blob: 6f2a6841c4f2be32603278a9597d776aafd55839 [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));
Naveen Rawat44f2f432016-12-01 12:58:57 -0800379 WMI_LOGA("%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;
1421 A_STATUS status = A_OK;
1422 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)
1434 return A_NO_MEMORY;
1435
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
1464 if (status != A_OK)
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
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301836 /*
1837 * Suppress authorization for all AUTH modes that need 4-way handshake
1838 * (during re-association).
1839 * Authorization will be done for these modes on key installation.
1840 */
1841 if (param->auth_flag)
1842 cmd->peer_flags |= WMI_PEER_AUTH;
1843 if (param->need_ptk_4_way)
1844 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1845 else
1846 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1847 if (param->need_gtk_2_way)
1848 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1849 /* safe mode bypass the 4-way handshake */
1850 if (param->safe_mode_enabled)
1851 cmd->peer_flags &=
1852 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1853 /* Disable AMSDU for station transmit, if user configures it */
1854 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1855 * it
1856 * if (param->amsdu_disable) Add after FW support
1857 **/
1858
1859 /* Target asserts if node is marked HT and all MCS is set to 0.
1860 * Mark the node as non-HT if all the mcs rates are disabled through
1861 * iwpriv
1862 **/
1863 if (param->peer_ht_rates.num_rates == 0)
1864 cmd->peer_flags &= ~WMI_PEER_HT;
1865}
1866#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301867
1868#ifdef CONFIG_MCL
1869static inline void copy_peer_mac_addr_tlv(
1870 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1871 struct peer_assoc_params *param)
1872{
1873 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1874 sizeof(param->peer_macaddr));
1875}
1876#else
1877static inline void copy_peer_mac_addr_tlv(
1878 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1879 struct peer_assoc_params *param)
1880{
1881 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1882}
1883#endif
1884
Govind Singh5eb51532016-03-09 11:34:12 +05301885/**
1886 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1887 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301888 * @param param : pointer to peer assoc parameter
1889 *
1890 * Return: 0 on success and -ve on failure.
1891 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301892static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301893 struct peer_assoc_params *param)
1894{
Govind Singhd3156eb2016-02-26 17:50:39 +05301895 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1896 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001897 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05301898 wmi_buf_t buf;
1899 int32_t len;
1900 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301901 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301902 uint32_t peer_legacy_rates_align;
1903 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001904 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05301905
1906
1907 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1908 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301909
1910 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001911 (peer_legacy_rates_align * sizeof(uint8_t)) +
1912 WMI_TLV_HDR_SIZE +
1913 (peer_ht_rates_align * sizeof(uint8_t)) +
1914 sizeof(wmi_vht_rate_set) +
1915 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
1916 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301917
1918 buf = wmi_buf_alloc(wmi_handle, len);
1919 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301920 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301921 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301922 }
1923
1924 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1925 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1926 WMITLV_SET_HDR(&cmd->tlv_header,
1927 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1928 WMITLV_GET_STRUCT_TLVLEN
1929 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301930
Govind Singhd3156eb2016-02-26 17:50:39 +05301931 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301932
Govind Singhd3156eb2016-02-26 17:50:39 +05301933 cmd->peer_new_assoc = param->peer_new_assoc;
1934 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301935
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301936 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301937 copy_peer_mac_addr_tlv(cmd, param);
1938
Govind Singhd3156eb2016-02-26 17:50:39 +05301939 cmd->peer_rate_caps = param->peer_rate_caps;
1940 cmd->peer_caps = param->peer_caps;
1941 cmd->peer_listen_intval = param->peer_listen_intval;
1942 cmd->peer_ht_caps = param->peer_ht_caps;
1943 cmd->peer_max_mpdu = param->peer_max_mpdu;
1944 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301945 cmd->peer_vht_caps = param->peer_vht_caps;
1946 cmd->peer_phymode = param->peer_phymode;
1947
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001948 /* Update 11ax capabilities */
1949 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1950 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001951 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1952 sizeof(param->peer_he_cap_phyinfo));
1953 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1954 sizeof(param->peer_ppet));
1955
Govind Singhd3156eb2016-02-26 17:50:39 +05301956 /* Update peer legacy rate information */
1957 buf_ptr += sizeof(*cmd);
1958 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301959 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301960 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301961 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301962 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301963 param->peer_legacy_rates.num_rates);
1964
1965 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001966 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301967 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301968 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301969 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301970 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301971 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301972 param->peer_ht_rates.num_rates);
1973
1974 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001975 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301976 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1977 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1978
1979 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05301980
1981 /* Update bandwidth-NSS mapping */
1982 cmd->peer_bw_rxnss_override = 0;
1983 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
1984
Govind Singhd3156eb2016-02-26 17:50:39 +05301985 mcs = (wmi_vht_rate_set *) buf_ptr;
1986 if (param->vht_capable) {
1987 mcs->rx_max_rate = param->rx_max_rate;
1988 mcs->rx_mcs_set = param->rx_mcs_set;
1989 mcs->tx_max_rate = param->tx_max_rate;
1990 mcs->tx_mcs_set = param->tx_mcs_set;
1991 }
1992
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001993 /* HE Rates */
1994 cmd->peer_he_mcs = param->peer_he_mcs_count;
1995 buf_ptr += sizeof(wmi_vht_rate_set);
1996 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
1997 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
1998 buf_ptr += WMI_TLV_HDR_SIZE;
1999
2000 /* Loop through the HE rate set */
2001 for (i = 0; i < param->peer_he_mcs_count; i++) {
2002 he_mcs = (wmi_he_rate_set *) buf_ptr;
2003 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2004 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2005
2006 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2007 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2008 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2009 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2010 buf_ptr += sizeof(wmi_he_rate_set);
2011 }
2012
2013
Govind Singhb53420c2016-03-09 14:32:57 +05302014 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302015 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2016 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002017 "cmd->peer_vht_caps %x "
2018 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302019 "HE phy %x %x %x "
2020 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302021 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2022 cmd->peer_rate_caps, cmd->peer_caps,
2023 cmd->peer_listen_intval, cmd->peer_ht_caps,
2024 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2025 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002026 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2027 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302028 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2029 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302030
2031 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2032 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302033 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302034 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302035 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302036 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302037 }
2038
2039 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302040}
2041
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302042/* copy_scan_notify_events() - Helper routine to copy scan notify events
2043 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302044static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302045 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302046 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302047{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302048
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302049 /* Scan events subscription */
2050 if (param->scan_ev_started)
2051 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2052 if (param->scan_ev_completed)
2053 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2054 if (param->scan_ev_bss_chan)
2055 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2056 if (param->scan_ev_foreign_chan)
2057 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2058 if (param->scan_ev_dequeued)
2059 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2060 if (param->scan_ev_preempted)
2061 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2062 if (param->scan_ev_start_failed)
2063 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2064 if (param->scan_ev_restarted)
2065 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2066 if (param->scan_ev_foreign_chn_exit)
2067 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2068 if (param->scan_ev_suspended)
2069 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2070 if (param->scan_ev_resumed)
2071 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302072
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302073 /** Set scan control flags */
2074 cmd->scan_ctrl_flags = 0;
2075 if (param->scan_f_passive)
2076 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2077 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302078 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302079 if (param->scan_f_promisc_mode)
2080 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2081 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302082 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302083 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302084 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302085 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302086 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302087 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302088 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302089 if (param->scan_f_ofdm_rates)
2090 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2091 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302092 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302093 if (param->scan_f_filter_prb_req)
2094 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2095 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302096 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302097 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302098 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302099 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302100 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302101 if (param->scan_f_force_active_dfs_chn)
2102 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2103 if (param->scan_f_add_tpc_ie_in_probe)
2104 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2105 if (param->scan_f_add_ds_ie_in_probe)
2106 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2107 if (param->scan_f_add_spoofed_mac_in_probe)
2108 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2109 if (param->scan_f_add_rand_seq_in_probe)
2110 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2111 if (param->scan_f_en_ie_whitelist_in_probe)
2112 cmd->scan_ctrl_flags |=
2113 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302114
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302115 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2116 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2117 param->adaptive_dwell_time_mode);
2118}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302119
2120/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302121static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302122 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302123{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302124 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302125}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302126
Anish Natarajdd855152017-03-20 12:49:08 +05302127/*
2128 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2129 * @param wmi_handle : Handle to WMI
2130 * @param vdev_id : vdev identifier
2131 *
2132 * Return : void *
2133 */
2134static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2135{
2136 struct wlan_objmgr_vdev *vdev = NULL;
2137 struct wlan_objmgr_pdev *pdev = NULL;
2138 uint8_t pdev_id = 0;
2139
2140 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2141 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2142 vdev_id, WLAN_SCAN_ID);
2143 if (vdev) {
2144 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2145 pdev = wlan_vdev_get_pdev(vdev);
2146 if (pdev)
2147 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2148 else {
2149 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2150 }
2151 } else {
2152 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2153 }
2154
2155 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2156}
2157
Govind Singh5eb51532016-03-09 11:34:12 +05302158/**
2159 * send_scan_start_cmd_tlv() - WMI scan start function
2160 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302161 * @param param : pointer to hold scan start cmd parameter
2162 *
2163 * Return: 0 on success and -ve on failure.
2164 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302165static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302166 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302167{
Govind Singhd3156eb2016-02-26 17:50:39 +05302168 int32_t ret = 0;
2169 int32_t i;
2170 wmi_buf_t wmi_buf;
2171 wmi_start_scan_cmd_fixed_param *cmd;
2172 uint8_t *buf_ptr;
2173 uint32_t *tmp_ptr;
2174 wmi_ssid *ssid = NULL;
2175 wmi_mac_addr *bssid;
2176 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302177 uint8_t extraie_len_with_pad = 0;
Govind Singhd3156eb2016-02-26 17:50:39 +05302178
2179 /* Length TLV placeholder for array of uint32_t */
2180 len += WMI_TLV_HDR_SIZE;
2181 /* calculate the length of buffer required */
2182 if (params->num_chan)
2183 len += params->num_chan * sizeof(uint32_t);
2184
2185 /* Length TLV placeholder for array of wmi_ssid structures */
2186 len += WMI_TLV_HDR_SIZE;
2187 if (params->num_ssids)
2188 len += params->num_ssids * sizeof(wmi_ssid);
2189
2190 /* Length TLV placeholder for array of wmi_mac_addr structures */
2191 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302192 if (params->num_bssid)
2193 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302194
2195 /* Length TLV placeholder for array of bytes */
2196 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302197 if (params->extraie.len)
2198 extraie_len_with_pad =
2199 roundup(params->extraie.len, sizeof(uint32_t));
2200 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302201
2202 /* Allocate the memory */
2203 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2204 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302205 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302206 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302207 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302208 }
2209 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2210 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2211 WMITLV_SET_HDR(&cmd->tlv_header,
2212 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2213 WMITLV_GET_STRUCT_TLVLEN
2214 (wmi_start_scan_cmd_fixed_param));
2215
2216 cmd->scan_id = params->scan_id;
2217 cmd->scan_req_id = params->scan_req_id;
2218 cmd->vdev_id = params->vdev_id;
2219 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302220
2221 copy_scan_event_cntrl_flags(cmd, params);
2222
Govind Singhd3156eb2016-02-26 17:50:39 +05302223 cmd->dwell_time_active = params->dwell_time_active;
2224 cmd->dwell_time_passive = params->dwell_time_passive;
2225 cmd->min_rest_time = params->min_rest_time;
2226 cmd->max_rest_time = params->max_rest_time;
2227 cmd->repeat_probe_time = params->repeat_probe_time;
2228 cmd->probe_spacing_time = params->probe_spacing_time;
2229 cmd->idle_time = params->idle_time;
2230 cmd->max_scan_time = params->max_scan_time;
2231 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302232 cmd->burst_duration = params->burst_duration;
2233 cmd->num_chan = params->num_chan;
2234 cmd->num_bssid = params->num_bssid;
2235 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302236 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302237 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302238 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2239
2240 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2241
Govind Singhd3156eb2016-02-26 17:50:39 +05302242 buf_ptr += sizeof(*cmd);
2243 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2244 for (i = 0; i < params->num_chan; ++i)
2245 tmp_ptr[i] = params->chan_list[i];
2246
2247 WMITLV_SET_HDR(buf_ptr,
2248 WMITLV_TAG_ARRAY_UINT32,
2249 (params->num_chan * sizeof(uint32_t)));
2250 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302251 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302252 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302253 goto error;
2254 }
2255
2256 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2257 (params->num_ssids * sizeof(wmi_ssid)));
2258
2259 if (params->num_ssids) {
2260 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2261 for (i = 0; i < params->num_ssids; ++i) {
2262 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302263 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302264 params->ssid[i].length);
2265 ssid++;
2266 }
2267 }
2268 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2269
2270 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2271 (params->num_bssid * sizeof(wmi_mac_addr)));
2272 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302273
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302274 if (params->num_bssid) {
2275 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302276 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2277 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302278 bssid++;
2279 }
2280 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302281
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302282 buf_ptr += WMI_TLV_HDR_SIZE +
2283 (params->num_bssid * sizeof(wmi_mac_addr));
2284
2285 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2286 if (params->extraie.len)
2287 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2288 params);
2289
2290 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302291
Anish Natarajdd855152017-03-20 12:49:08 +05302292 ret = wmi_unified_cmd_send(
2293 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302294 len, WMI_START_SCAN_CMDID);
2295 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302296 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302297 wmi_buf_free(wmi_buf);
2298 }
2299 return ret;
2300error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302301 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302302 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302303}
2304
2305/**
2306 * send_scan_stop_cmd_tlv() - WMI scan start function
2307 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302308 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302309 *
2310 * Return: 0 on success and -ve on failure.
2311 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302312static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302313 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302314{
Govind Singhd3156eb2016-02-26 17:50:39 +05302315 wmi_stop_scan_cmd_fixed_param *cmd;
2316 int ret;
2317 int len = sizeof(*cmd);
2318 wmi_buf_t wmi_buf;
2319
2320 /* Allocate the memory */
2321 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2322 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302323 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302324 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302325 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302326 goto error;
2327 }
2328
2329 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2330 WMITLV_SET_HDR(&cmd->tlv_header,
2331 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2332 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2333 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302334 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302335 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302336 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2337 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302338 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302339 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2340 /* Cancelling all scans */
2341 cmd->req_type = WMI_SCAN_STOP_ALL;
2342 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2343 /* Cancelling VAP scans */
2344 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2345 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2346 /* Cancelling specific scan */
2347 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302348 } else {
2349 WMI_LOGE("%s: Invalid Command : ", __func__);
2350 wmi_buf_free(wmi_buf);
2351 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302352 }
2353
Anish Natarajdd855152017-03-20 12:49:08 +05302354 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302355 len, WMI_STOP_SCAN_CMDID);
2356 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302357 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302358 wmi_buf_free(wmi_buf);
2359 }
2360
2361error:
2362 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302363}
2364
Govind Singh87542482016-06-08 19:40:11 +05302365#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302366/**
2367 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2368 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302369 * @param param : pointer to hold scan channel list parameter
2370 *
2371 * Return: 0 on success and -ve on failure.
2372 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302373static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302374 struct scan_chan_list_params *chan_list)
2375{
2376 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302377 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302378 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302379 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302380 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302381 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302382 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2383
2384 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2385 buf = wmi_buf_alloc(wmi_handle, len);
2386 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302387 WMI_LOGE("Failed to allocate memory");
2388 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302389 goto end;
2390 }
2391
2392 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2393 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2394 WMITLV_SET_HDR(&cmd->tlv_header,
2395 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2396 WMITLV_GET_STRUCT_TLVLEN
2397 (wmi_scan_chan_list_cmd_fixed_param));
2398
Govind Singhb53420c2016-03-09 14:32:57 +05302399 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302400
2401 cmd->num_scan_chans = chan_list->num_scan_chans;
2402 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2403 WMITLV_TAG_ARRAY_STRUC,
2404 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302405 chan_info = (wmi_channel_param *)
2406 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302407 tchan_info = chan_list->chan_info;
2408
2409 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2410 WMITLV_SET_HDR(&chan_info->tlv_header,
2411 WMITLV_TAG_STRUC_wmi_channel,
2412 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2413 chan_info->mhz = tchan_info->mhz;
2414 chan_info->band_center_freq1 =
2415 tchan_info->band_center_freq1;
2416 chan_info->band_center_freq2 =
2417 tchan_info->band_center_freq2;
2418 chan_info->info = tchan_info->info;
2419 chan_info->reg_info_1 = tchan_info->reg_info_1;
2420 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302421 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302422
2423 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2424 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2425 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2426 tchan_info++;
2427 chan_info++;
2428 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302429 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2430 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302431
Anish Natarajdd855152017-03-20 12:49:08 +05302432 qdf_status = wmi_unified_cmd_send(wmi_handle,
2433 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302434
Govind Singh67922e82016-04-01 16:48:57 +05302435 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302436 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302437 wmi_buf_free(buf);
2438 }
Govind Singh67922e82016-04-01 16:48:57 +05302439
Govind Singhd3156eb2016-02-26 17:50:39 +05302440end:
Govind Singhb53420c2016-03-09 14:32:57 +05302441 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302442}
Govind Singh87542482016-06-08 19:40:11 +05302443#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302444static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302445 struct scan_chan_list_params *chan_list)
2446{
2447 wmi_buf_t buf;
2448 QDF_STATUS qdf_status;
2449 wmi_scan_chan_list_cmd_fixed_param *cmd;
2450 int i;
2451 uint8_t *buf_ptr;
2452 wmi_channel *chan_info;
2453 struct channel_param *tchan_info;
2454 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302455
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302456 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302457 buf = wmi_buf_alloc(wmi_handle, len);
2458 if (!buf) {
2459 WMI_LOGE("Failed to allocate memory");
2460 qdf_status = QDF_STATUS_E_NOMEM;
2461 goto end;
2462 }
2463
2464 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2465 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2466 WMITLV_SET_HDR(&cmd->tlv_header,
2467 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2468 WMITLV_GET_STRUCT_TLVLEN
2469 (wmi_scan_chan_list_cmd_fixed_param));
2470
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302471 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302472
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302473 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2474 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302475 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302476 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2477 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302478 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302479 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2480 tchan_info = &(chan_list->ch_param[0]);
2481
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302482 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302483 WMITLV_SET_HDR(&chan_info->tlv_header,
2484 WMITLV_TAG_STRUC_wmi_channel,
2485 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2486 chan_info->mhz = tchan_info->mhz;
2487 chan_info->band_center_freq1 =
2488 tchan_info->cfreq1;
2489 chan_info->band_center_freq2 =
2490 tchan_info->cfreq2;
2491
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302492 if (tchan_info->is_chan_passive)
2493 WMI_SET_CHANNEL_FLAG(chan_info,
2494 WMI_CHAN_FLAG_PASSIVE);
2495
2496 if (tchan_info->allow_vht)
2497 WMI_SET_CHANNEL_FLAG(chan_info,
2498 WMI_CHAN_FLAG_ALLOW_VHT);
2499 else if (tchan_info->allow_ht)
2500 WMI_SET_CHANNEL_FLAG(chan_info,
2501 WMI_CHAN_FLAG_ALLOW_HT);
2502 WMI_SET_CHANNEL_MODE(chan_info,
2503 tchan_info->phy_mode);
2504
2505 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2506 * after FW support
2507 */
2508
2509 /* also fill in power information */
2510 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2511 tchan_info->minpower);
2512 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2513 tchan_info->maxpower);
2514 WMI_SET_CHANNEL_REG_POWER(chan_info,
2515 tchan_info->maxregpower);
2516 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2517 tchan_info->antennamax);
2518 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2519 tchan_info->reg_class_id);
2520
Govind Singh87542482016-06-08 19:40:11 +05302521 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2522
Govind Singh87542482016-06-08 19:40:11 +05302523 tchan_info++;
2524 chan_info++;
2525 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302526 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2527 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302528
Anish Natarajdd855152017-03-20 12:49:08 +05302529 qdf_status = wmi_unified_cmd_send(
2530 wmi_handle,
2531 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302532
2533 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2534 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2535 wmi_buf_free(buf);
2536 }
2537
2538end:
2539 return qdf_status;
2540}
2541#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302542/**
2543 * send_mgmt_cmd_tlv() - WMI scan start function
2544 * @wmi_handle : handle to WMI.
2545 * @param : pointer to hold mgmt cmd parameter
2546 *
2547 * Return: 0 on success and -ve on failure.
2548 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302549static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302550 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302551{
Govind Singh427ee5a2016-02-26 18:09:36 +05302552 wmi_buf_t buf;
2553 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2554 int32_t cmd_len;
2555 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302556 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302557 uint8_t *bufp;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302558 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302559 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2560 mgmt_tx_dl_frm_len;
2561
2562 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2563 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2564
2565 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2566 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302567 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2568 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302569 }
2570
2571 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2572 bufp = (uint8_t *) cmd;
2573 WMITLV_SET_HDR(&cmd->tlv_header,
2574 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2575 WMITLV_GET_STRUCT_TLVLEN
2576 (wmi_mgmt_tx_send_cmd_fixed_param));
2577
2578 cmd->vdev_id = param->vdev_id;
2579
Govind Singh224a7312016-06-21 14:33:26 +05302580 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302581 cmd->chanfreq = param->chanfreq;
2582 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2583 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2584 sizeof(uint32_t)));
2585 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302586 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302587
2588 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2589 QDF_DMA_TO_DEVICE);
2590 if (status != QDF_STATUS_SUCCESS) {
2591 WMI_LOGE("%s: wmi buf map failed", __func__);
2592 goto err1;
2593 }
2594
Govind Singhb53420c2016-03-09 14:32:57 +05302595 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302596 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002597#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302598 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2599#endif
2600 cmd->frame_len = param->frm_len;
2601 cmd->buf_len = bufp_len;
2602
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002603 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002604 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002605
Govind Singh427ee5a2016-02-26 18:09:36 +05302606 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2607 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302608 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302609 goto err1;
2610 }
Govind Singhb53420c2016-03-09 14:32:57 +05302611 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302612
2613err1:
2614 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302615 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302616}
2617
2618/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302619 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
2620 * @wmi_handle : handle to WMI.
2621 * @param : pointer to offchan data tx cmd parameter
2622 *
2623 * Return: QDF_STATUS_SUCCESS on success and error on failure.
2624 */
2625static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
2626 struct wmi_offchan_data_tx_params *param)
2627{
2628 wmi_buf_t buf;
2629 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
2630 int32_t cmd_len;
2631 uint64_t dma_addr;
2632 void *qdf_ctx = param->qdf_ctx;
2633 uint8_t *bufp;
2634 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
2635 param->frm_len : mgmt_tx_dl_frm_len;
2636
2637 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
2638 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2639
2640 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2641 if (!buf) {
2642 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2643 return QDF_STATUS_E_NOMEM;
2644 }
2645
2646 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
2647 bufp = (uint8_t *) cmd;
2648 WMITLV_SET_HDR(&cmd->tlv_header,
2649 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
2650 WMITLV_GET_STRUCT_TLVLEN
2651 (wmi_offchan_data_tx_send_cmd_fixed_param));
2652
2653 cmd->vdev_id = param->vdev_id;
2654
2655 cmd->desc_id = param->desc_id;
2656 cmd->chanfreq = param->chanfreq;
2657 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
2658 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2659 sizeof(uint32_t)));
2660 bufp += WMI_TLV_HDR_SIZE;
2661 qdf_mem_copy(bufp, param->pdata, bufp_len);
2662 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2663 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
2664 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2665#if defined(HTT_PADDR64)
2666 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2667#endif
2668 cmd->frame_len = param->frm_len;
2669 cmd->buf_len = bufp_len;
2670
2671 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
2672 bufp, cmd->vdev_id, cmd->chanfreq);
2673
2674 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2675 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
2676 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
2677 wmi_buf_free(buf);
2678 return QDF_STATUS_E_FAILURE;
2679 }
2680
2681 return QDF_STATUS_SUCCESS;
2682}
2683
2684/**
Govind Singh427ee5a2016-02-26 18:09:36 +05302685 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2686 * @wmi_handle: wmi handle
2687 * @param_value: parameter value
2688 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302689 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302690 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302691static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302692 uint32_t param_value)
2693{
Govind Singh67922e82016-04-01 16:48:57 +05302694 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302695 wmi_modem_power_state_cmd_param *cmd;
2696 wmi_buf_t buf;
2697 uint16_t len = sizeof(*cmd);
2698
2699 buf = wmi_buf_alloc(wmi_handle, len);
2700 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302701 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302702 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302703 }
2704 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2705 WMITLV_SET_HDR(&cmd->tlv_header,
2706 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2707 WMITLV_GET_STRUCT_TLVLEN
2708 (wmi_modem_power_state_cmd_param));
2709 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302710 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302711 param_value);
2712 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2713 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302714 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302715 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302716 wmi_buf_free(buf);
2717 }
Govind Singh67922e82016-04-01 16:48:57 +05302718
Govind Singh427ee5a2016-02-26 18:09:36 +05302719 return ret;
2720}
2721
2722/**
2723 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2724 * @wmi_handle: wmi handle
2725 * @vdev_id: vdev id
2726 * @val: value
2727 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302728 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302729 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302730static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302731 uint32_t vdev_id, uint8_t val)
2732{
2733 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2734 wmi_buf_t buf;
2735 int32_t len = sizeof(*cmd);
2736
Govind Singhb53420c2016-03-09 14:32:57 +05302737 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302738
2739 buf = wmi_buf_alloc(wmi_handle, len);
2740 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302741 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302742 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302743 }
2744 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2745 WMITLV_SET_HDR(&cmd->tlv_header,
2746 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2747 WMITLV_GET_STRUCT_TLVLEN
2748 (wmi_sta_powersave_mode_cmd_fixed_param));
2749 cmd->vdev_id = vdev_id;
2750 if (val)
2751 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2752 else
2753 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2754
2755 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2756 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302757 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302758 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302759 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302760 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302761 }
Govind Singh5eb51532016-03-09 11:34:12 +05302762 return 0;
2763}
2764
Govind Singh427ee5a2016-02-26 18:09:36 +05302765/**
2766 * send_set_mimops_cmd_tlv() - set MIMO powersave
2767 * @wmi_handle: wmi handle
2768 * @vdev_id: vdev id
2769 * @value: value
2770 *
Govind Singhb53420c2016-03-09 14:32:57 +05302771 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302772 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302773static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302774 uint8_t vdev_id, int value)
2775{
Govind Singh67922e82016-04-01 16:48:57 +05302776 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302777 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2778 wmi_buf_t buf;
2779 uint16_t len = sizeof(*cmd);
2780
2781 buf = wmi_buf_alloc(wmi_handle, len);
2782 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302783 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302784 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302785 }
2786 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2787 WMITLV_SET_HDR(&cmd->tlv_header,
2788 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2789 WMITLV_GET_STRUCT_TLVLEN
2790 (wmi_sta_smps_force_mode_cmd_fixed_param));
2791
2792 cmd->vdev_id = vdev_id;
2793
Houston Hoffmanb5168052016-04-14 02:18:01 -07002794 /* WMI_SMPS_FORCED_MODE values do not directly map
2795 * to SM power save values defined in the specification.
2796 * Make sure to send the right mapping.
2797 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302798 switch (value) {
2799 case 0:
2800 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2801 break;
2802 case 1:
2803 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2804 break;
2805 case 2:
2806 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2807 break;
2808 case 3:
2809 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2810 break;
2811 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302812 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2813 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302814 }
2815
Govind Singhb53420c2016-03-09 14:32:57 +05302816 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302817
2818 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2819 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302820 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302821 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302822 wmi_buf_free(buf);
2823 }
2824
2825 return ret;
2826}
2827
2828/**
2829 * send_set_smps_params_cmd_tlv() - set smps params
2830 * @wmi_handle: wmi handle
2831 * @vdev_id: vdev id
2832 * @value: value
2833 *
Govind Singhb53420c2016-03-09 14:32:57 +05302834 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302835 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302836static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302837 int value)
2838{
Govind Singh67922e82016-04-01 16:48:57 +05302839 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302840 wmi_sta_smps_param_cmd_fixed_param *cmd;
2841 wmi_buf_t buf;
2842 uint16_t len = sizeof(*cmd);
2843
2844 buf = wmi_buf_alloc(wmi_handle, len);
2845 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302846 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302847 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302848 }
2849 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2850 WMITLV_SET_HDR(&cmd->tlv_header,
2851 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2852 WMITLV_GET_STRUCT_TLVLEN
2853 (wmi_sta_smps_param_cmd_fixed_param));
2854
2855 cmd->vdev_id = vdev_id;
2856 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2857 cmd->param =
2858 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2859
Govind Singhb53420c2016-03-09 14:32:57 +05302860 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302861 cmd->param);
2862
2863 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2864 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302865 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302866 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302867 wmi_buf_free(buf);
2868 }
2869
2870 return ret;
2871}
2872
2873/**
2874 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2875 * @wmi_handle: wmi handle
2876 * @noa: p2p power save parameters
2877 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302878 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302879 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302880static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302881 struct p2p_ps_params *noa)
2882{
2883 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2884 wmi_p2p_noa_descriptor *noa_discriptor;
2885 wmi_buf_t buf;
2886 uint8_t *buf_ptr;
2887 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302888 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302889 uint32_t duration;
2890
Govind Singhb53420c2016-03-09 14:32:57 +05302891 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302892 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2893 buf = wmi_buf_alloc(wmi_handle, len);
2894 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302895 WMI_LOGE("Failed to allocate memory");
2896 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302897 goto end;
2898 }
2899
2900 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2901 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2902 WMITLV_SET_HDR(&cmd->tlv_header,
2903 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2904 WMITLV_GET_STRUCT_TLVLEN
2905 (wmi_p2p_set_noa_cmd_fixed_param));
2906 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2907 cmd->vdev_id = noa->session_id;
2908 cmd->enable = (duration) ? true : false;
2909 cmd->num_noa = 1;
2910
2911 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2912 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2913 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2914 sizeof
2915 (wmi_p2p_set_noa_cmd_fixed_param)
2916 + WMI_TLV_HDR_SIZE);
2917 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2918 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2919 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2920 noa_discriptor->type_count = noa->count;
2921 noa_discriptor->duration = duration;
2922 noa_discriptor->interval = noa->interval;
2923 noa_discriptor->start_time = 0;
2924
Govind Singhb53420c2016-03-09 14:32:57 +05302925 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302926 cmd->vdev_id, noa->count, noa_discriptor->duration,
2927 noa->interval);
2928 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2929 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302930 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302931 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302932 wmi_buf_free(buf);
2933 }
2934
2935end:
Govind Singhb53420c2016-03-09 14:32:57 +05302936 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302937 return status;
2938}
2939
2940
2941/**
2942 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2943 * @wmi_handle: wmi handle
2944 * @noa: p2p opp power save parameters
2945 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302946 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302947 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302948static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302949 struct p2p_ps_params *oppps)
2950{
2951 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2952 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302953 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302954
Govind Singhb53420c2016-03-09 14:32:57 +05302955 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302956 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2957 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302958 WMI_LOGE("Failed to allocate memory");
2959 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302960 goto end;
2961 }
2962
2963 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2964 WMITLV_SET_HDR(&cmd->tlv_header,
2965 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2966 WMITLV_GET_STRUCT_TLVLEN
2967 (wmi_p2p_set_oppps_cmd_fixed_param));
2968 cmd->vdev_id = oppps->session_id;
2969 if (oppps->ctwindow)
2970 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2971
2972 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302973 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302974 cmd->vdev_id, oppps->ctwindow);
2975 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2976 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302977 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302978 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302979 wmi_buf_free(buf);
2980 }
2981
2982end:
Govind Singhb53420c2016-03-09 14:32:57 +05302983 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302984 return status;
2985}
2986
Wu Gaocd3a8512017-03-13 20:17:34 +08002987#ifdef CONVERGED_P2P_ENABLE
2988/**
2989 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
2990 * @wmi_handle: wmi handle
2991 * @param: p2p listen offload start parameters
2992 *
2993 * Return: QDF status
2994 */
2995static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
2996 struct p2p_lo_start *param)
2997{
2998 wmi_buf_t buf;
2999 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3000 int32_t len = sizeof(*cmd);
3001 uint8_t *buf_ptr;
3002 QDF_STATUS status;
3003 int device_types_len_aligned;
3004 int probe_resp_len_aligned;
3005
3006 if (!param) {
3007 WMI_LOGE("lo start param is null");
3008 return QDF_STATUS_E_INVAL;
3009 }
3010
3011 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3012
3013 device_types_len_aligned =
3014 qdf_roundup(param->dev_types_len,
3015 sizeof(A_UINT32));
3016 probe_resp_len_aligned =
3017 qdf_roundup(param->probe_resp_len,
3018 sizeof(A_UINT32));
3019
3020 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3021 probe_resp_len_aligned;
3022
3023 buf = wmi_buf_alloc(wmi_handle, len);
3024 if (!buf) {
3025 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3026 __func__);
3027 return QDF_STATUS_E_NOMEM;
3028 }
3029
3030 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3031 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3032
3033 WMITLV_SET_HDR(&cmd->tlv_header,
3034 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3035 WMITLV_GET_STRUCT_TLVLEN(
3036 wmi_p2p_lo_start_cmd_fixed_param));
3037
3038 cmd->vdev_id = param->vdev_id;
3039 cmd->ctl_flags = param->ctl_flags;
3040 cmd->channel = param->freq;
3041 cmd->period = param->period;
3042 cmd->interval = param->interval;
3043 cmd->count = param->count;
3044 cmd->device_types_len = param->dev_types_len;
3045 cmd->prob_resp_len = param->probe_resp_len;
3046
3047 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3048 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3049 device_types_len_aligned);
3050 buf_ptr += WMI_TLV_HDR_SIZE;
3051 qdf_mem_copy(buf_ptr, param->device_types,
3052 param->dev_types_len);
3053
3054 buf_ptr += device_types_len_aligned;
3055 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3056 probe_resp_len_aligned);
3057 buf_ptr += WMI_TLV_HDR_SIZE;
3058 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3059 param->probe_resp_len);
3060
3061 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3062 cmd->channel, cmd->period, cmd->interval, cmd->count);
3063
3064 status = wmi_unified_cmd_send(wmi_handle,
3065 buf, len,
3066 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3067 if (status != QDF_STATUS_SUCCESS) {
3068 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3069 __func__, status);
3070 wmi_buf_free(buf);
3071 return status;
3072 }
3073
3074 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3075
3076 return QDF_STATUS_SUCCESS;
3077}
3078
3079/**
3080 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3081 * @wmi_handle: wmi handle
3082 * @param: p2p listen offload stop parameters
3083 *
3084 * Return: QDF status
3085 */
3086static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3087 uint8_t vdev_id)
3088{
3089 wmi_buf_t buf;
3090 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3091 int32_t len;
3092 QDF_STATUS status;
3093
3094 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3095
3096 len = sizeof(*cmd);
3097 buf = wmi_buf_alloc(wmi_handle, len);
3098 if (!buf) {
3099 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3100 __func__);
3101 return QDF_STATUS_E_NOMEM;
3102 }
3103 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3104
3105 WMITLV_SET_HDR(&cmd->tlv_header,
3106 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3107 WMITLV_GET_STRUCT_TLVLEN(
3108 wmi_p2p_lo_stop_cmd_fixed_param));
3109
3110 cmd->vdev_id = vdev_id;
3111
3112 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3113
3114 status = wmi_unified_cmd_send(wmi_handle,
3115 buf, len,
3116 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3117 if (status != QDF_STATUS_SUCCESS) {
3118 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3119 __func__, status);
3120 wmi_buf_free(buf);
3121 return status;
3122 }
3123
3124 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3125
3126 return QDF_STATUS_SUCCESS;
3127}
3128#endif /* End of CONVERGED_P2P_ENABLE */
3129
Govind Singh427ee5a2016-02-26 18:09:36 +05303130/**
3131 * send_get_temperature_cmd_tlv() - get pdev temperature req
3132 * @wmi_handle: wmi handle
3133 *
Govind Singhb53420c2016-03-09 14:32:57 +05303134 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303135 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303136static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303137{
3138 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3139 wmi_buf_t wmi_buf;
3140 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3141 uint8_t *buf_ptr;
3142
3143 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303144 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3145 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303146 }
3147
3148 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3149 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303150 WMI_LOGE(FL("wmi_buf_alloc failed"));
3151 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303152 }
3153
3154 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3155
3156 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3157 WMITLV_SET_HDR(&cmd->tlv_header,
3158 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3159 WMITLV_GET_STRUCT_TLVLEN
3160 (wmi_pdev_get_temperature_cmd_fixed_param));
3161
3162 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3163 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303164 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303165 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303166 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303167 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303168
Govind Singhb53420c2016-03-09 14:32:57 +05303169 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303170}
3171
3172/**
3173 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3174 * @wmi_handle: wmi handle
3175 * @vdevid: vdev id
3176 * @peer_addr: peer mac address
3177 * @auto_triggerparam: auto trigger parameters
3178 * @num_ac: number of access category
3179 *
3180 * This function sets the trigger
3181 * uapsd params such as service interval, delay interval
3182 * and suspend interval which will be used by the firmware
3183 * to send trigger frames periodically when there is no
3184 * traffic on the transmit side.
3185 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303186 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303187 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303188static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303189 struct sta_uapsd_trig_params *param)
3190{
3191 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303192 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303193 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3194 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3195 uint32_t i;
3196 wmi_buf_t buf;
3197 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003198 struct sta_uapsd_params *uapsd_param;
3199 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303200
3201 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3202 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303203 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303204 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303205 }
3206
3207 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3208 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3209 WMITLV_SET_HDR(&cmd->tlv_header,
3210 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3211 WMITLV_GET_STRUCT_TLVLEN
3212 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3213 cmd->vdev_id = param->vdevid;
3214 cmd->num_ac = param->num_ac;
3215 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3216
3217 /* TLV indicating array of structures to follow */
3218 buf_ptr += sizeof(*cmd);
3219 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3220
3221 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303222
3223 /*
3224 * Update tag and length for uapsd auto trigger params (this will take
3225 * care of updating tag and length if it is not pre-filled by caller).
3226 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003227 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3228 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303229 for (i = 0; i < param->num_ac; i++) {
3230 WMITLV_SET_HDR((buf_ptr +
3231 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3232 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3233 WMITLV_GET_STRUCT_TLVLEN
3234 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003235 trig_param->wmm_ac = uapsd_param->wmm_ac;
3236 trig_param->user_priority = uapsd_param->user_priority;
3237 trig_param->service_interval = uapsd_param->service_interval;
3238 trig_param->suspend_interval = uapsd_param->suspend_interval;
3239 trig_param->delay_interval = uapsd_param->delay_interval;
3240 trig_param++;
3241 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303242 }
3243
3244 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3245 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303246 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303247 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303248 wmi_buf_free(buf);
3249 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303250
Govind Singh427ee5a2016-02-26 18:09:36 +05303251 return ret;
3252}
3253
Govind Singh2edc80f2016-03-01 15:30:53 +05303254/**
3255 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3256 * @wmi_handle: pointer to the wmi handle
3257 * @utc: pointer to the UTC time struct
3258 *
3259 * Return: 0 on succes
3260 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303261static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303262 struct ocb_utc_param *utc)
3263{
Govind Singh67922e82016-04-01 16:48:57 +05303264 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303265 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3266 uint8_t *buf_ptr;
3267 uint32_t len, i;
3268 wmi_buf_t buf;
3269
3270 len = sizeof(*cmd);
3271 buf = wmi_buf_alloc(wmi_handle, len);
3272 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303273 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303274 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303275 }
3276
3277 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3278 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3279 WMITLV_SET_HDR(&cmd->tlv_header,
3280 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3281 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3282 cmd->vdev_id = utc->vdev_id;
3283
3284 for (i = 0; i < SIZE_UTC_TIME; i++)
3285 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3286
3287 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3288 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3289
3290 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3291 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303292 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303293 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303294 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303295 }
3296
Govind Singh67922e82016-04-01 16:48:57 +05303297 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303298}
3299
3300/**
3301 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3302 * frames on a channel
3303 * @wmi_handle: pointer to the wmi handle
3304 * @timing_advert: pointer to the timing advertisement struct
3305 *
3306 * Return: 0 on succes
3307 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303308static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303309 struct ocb_timing_advert_param *timing_advert)
3310{
Govind Singh67922e82016-04-01 16:48:57 +05303311 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303312 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3313 uint8_t *buf_ptr;
3314 uint32_t len, len_template;
3315 wmi_buf_t buf;
3316
3317 len = sizeof(*cmd) +
3318 WMI_TLV_HDR_SIZE;
3319
3320 len_template = timing_advert->template_length;
3321 /* Add padding to the template if needed */
3322 if (len_template % 4 != 0)
3323 len_template += 4 - (len_template % 4);
3324 len += len_template;
3325
3326 buf = wmi_buf_alloc(wmi_handle, len);
3327 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303328 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303329 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303330 }
3331
3332 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3333 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3334 WMITLV_SET_HDR(&cmd->tlv_header,
3335 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3336 WMITLV_GET_STRUCT_TLVLEN(
3337 wmi_ocb_start_timing_advert_cmd_fixed_param));
3338 cmd->vdev_id = timing_advert->vdev_id;
3339 cmd->repeat_rate = timing_advert->repeat_rate;
3340 cmd->channel_freq = timing_advert->chan_freq;
3341 cmd->timestamp_offset = timing_advert->timestamp_offset;
3342 cmd->time_value_offset = timing_advert->time_value_offset;
3343 cmd->timing_advert_template_length = timing_advert->template_length;
3344 buf_ptr += sizeof(*cmd);
3345
3346 /* Add the timing advert template */
3347 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3348 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303349 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303350 (uint8_t *)timing_advert->template_value,
3351 timing_advert->template_length);
3352
3353 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3354 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303355 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303356 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303357 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303358 }
3359
Govind Singh67922e82016-04-01 16:48:57 +05303360 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303361}
3362
3363/**
3364 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3365 * on a channel
3366 * @wmi_handle: pointer to the wmi handle
3367 * @timing_advert: pointer to the timing advertisement struct
3368 *
3369 * Return: 0 on succes
3370 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303371static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303372 struct ocb_timing_advert_param *timing_advert)
3373{
Govind Singh67922e82016-04-01 16:48:57 +05303374 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303375 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3376 uint8_t *buf_ptr;
3377 uint32_t len;
3378 wmi_buf_t buf;
3379
3380 len = sizeof(*cmd);
3381 buf = wmi_buf_alloc(wmi_handle, len);
3382 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303383 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303384 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303385 }
3386
3387 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3388 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3389 WMITLV_SET_HDR(&cmd->tlv_header,
3390 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3391 WMITLV_GET_STRUCT_TLVLEN(
3392 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3393 cmd->vdev_id = timing_advert->vdev_id;
3394 cmd->channel_freq = timing_advert->chan_freq;
3395
3396 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3397 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303398 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303399 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303400 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303401 }
3402
Govind Singh67922e82016-04-01 16:48:57 +05303403 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303404}
3405
3406/**
3407 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3408 * @wmi_handle: pointer to the wmi handle
3409 * @request: pointer to the request
3410 *
3411 * Return: 0 on succes
3412 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303413static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303414 uint8_t vdev_id)
3415{
Govind Singhb53420c2016-03-09 14:32:57 +05303416 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303417 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3418 uint8_t *buf_ptr;
3419 wmi_buf_t buf;
3420 int32_t len;
3421
3422 len = sizeof(*cmd);
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 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3429
3430 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303431 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303432 WMITLV_SET_HDR(&cmd->tlv_header,
3433 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3434 WMITLV_GET_STRUCT_TLVLEN(
3435 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3436 cmd->vdev_id = vdev_id;
3437
3438 /* Send the WMI command */
3439 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3440 WMI_OCB_GET_TSF_TIMER_CMDID);
3441 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303442 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303443 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303444 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303445 }
3446
Govind Singh67922e82016-04-01 16:48:57 +05303447 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303448}
3449
3450/**
3451 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3452 * @wmi_handle: pointer to the wmi handle
3453 * @get_stats_param: pointer to the dcc stats
3454 *
3455 * Return: 0 on succes
3456 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303457static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303458 struct dcc_get_stats_param *get_stats_param)
3459{
Govind Singh67922e82016-04-01 16:48:57 +05303460 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303461 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3462 wmi_dcc_channel_stats_request *channel_stats_array;
3463 wmi_buf_t buf;
3464 uint8_t *buf_ptr;
3465 uint32_t len;
3466 uint32_t i;
3467
3468 /* Validate the input */
3469 if (get_stats_param->request_array_len !=
3470 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303471 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303472 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303473 }
3474
3475 /* Allocate memory for the WMI command */
3476 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3477 get_stats_param->request_array_len;
3478
3479 buf = wmi_buf_alloc(wmi_handle, len);
3480 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303481 WMI_LOGE(FL("wmi_buf_alloc failed"));
3482 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303483 }
3484
3485 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303486 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303487
3488 /* Populate the WMI command */
3489 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3490 buf_ptr += sizeof(*cmd);
3491
3492 WMITLV_SET_HDR(&cmd->tlv_header,
3493 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3494 WMITLV_GET_STRUCT_TLVLEN(
3495 wmi_dcc_get_stats_cmd_fixed_param));
3496 cmd->vdev_id = get_stats_param->vdev_id;
3497 cmd->num_channels = get_stats_param->channel_count;
3498
3499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3500 get_stats_param->request_array_len);
3501 buf_ptr += WMI_TLV_HDR_SIZE;
3502
3503 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303504 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303505 get_stats_param->request_array_len);
3506 for (i = 0; i < cmd->num_channels; i++)
3507 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3508 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3509 WMITLV_GET_STRUCT_TLVLEN(
3510 wmi_dcc_channel_stats_request));
3511
3512 /* Send the WMI command */
3513 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3514 WMI_DCC_GET_STATS_CMDID);
3515
Govind Singh67922e82016-04-01 16:48:57 +05303516 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303517 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303518 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303519 }
3520
Govind Singh67922e82016-04-01 16:48:57 +05303521 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303522}
3523
3524/**
3525 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3526 * @wmi_handle: pointer to the wmi handle
3527 * @vdev_id: vdev id
3528 * @dcc_stats_bitmap: dcc status bitmap
3529 *
3530 * Return: 0 on succes
3531 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303532static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303533 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3534{
Govind Singh67922e82016-04-01 16:48:57 +05303535 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303536 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3537 wmi_buf_t buf;
3538 uint8_t *buf_ptr;
3539 uint32_t len;
3540
3541 /* Allocate memory for the WMI command */
3542 len = sizeof(*cmd);
3543
3544 buf = wmi_buf_alloc(wmi_handle, len);
3545 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303546 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303547 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303548 }
3549
3550 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303551 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303552
3553 /* Populate the WMI command */
3554 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3555
3556 WMITLV_SET_HDR(&cmd->tlv_header,
3557 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3558 WMITLV_GET_STRUCT_TLVLEN(
3559 wmi_dcc_clear_stats_cmd_fixed_param));
3560 cmd->vdev_id = vdev_id;
3561 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3562
3563 /* Send the WMI command */
3564 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3565 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303566 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303567 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303568 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303569 }
3570
Govind Singh67922e82016-04-01 16:48:57 +05303571 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303572}
3573
3574/**
3575 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3576 * @wmi_handle: pointer to the wmi handle
3577 * @update_ndl_param: pointer to the request parameters
3578 *
3579 * Return: 0 on success
3580 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303581static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303582 struct dcc_update_ndl_param *update_ndl_param)
3583{
Govind Singhb53420c2016-03-09 14:32:57 +05303584 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303585 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3586 wmi_dcc_ndl_chan *ndl_chan_array;
3587 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3588 uint32_t active_state_count;
3589 wmi_buf_t buf;
3590 uint8_t *buf_ptr;
3591 uint32_t len;
3592 uint32_t i;
3593
3594 /* validate the input */
3595 if (update_ndl_param->dcc_ndl_chan_list_len !=
3596 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303597 WMI_LOGE(FL("Invalid parameter"));
3598 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303599 }
3600 active_state_count = 0;
3601 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3602 for (i = 0; i < update_ndl_param->channel_count; i++)
3603 active_state_count +=
3604 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3605 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3606 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303607 WMI_LOGE(FL("Invalid parameter"));
3608 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303609 }
3610
3611 /* Allocate memory for the WMI command */
3612 len = sizeof(*cmd) +
3613 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3614 WMI_TLV_HDR_SIZE +
3615 update_ndl_param->dcc_ndl_active_state_list_len;
3616
3617 buf = wmi_buf_alloc(wmi_handle, len);
3618 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303619 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303620 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303621 }
3622
3623 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303624 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303625
3626 /* Populate the WMI command */
3627 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3628 buf_ptr += sizeof(*cmd);
3629
3630 WMITLV_SET_HDR(&cmd->tlv_header,
3631 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3632 WMITLV_GET_STRUCT_TLVLEN(
3633 wmi_dcc_update_ndl_cmd_fixed_param));
3634 cmd->vdev_id = update_ndl_param->vdev_id;
3635 cmd->num_channel = update_ndl_param->channel_count;
3636
3637 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3638 update_ndl_param->dcc_ndl_chan_list_len);
3639 buf_ptr += WMI_TLV_HDR_SIZE;
3640
3641 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303642 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303643 update_ndl_param->dcc_ndl_chan_list_len);
3644 for (i = 0; i < cmd->num_channel; i++)
3645 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3646 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3647 WMITLV_GET_STRUCT_TLVLEN(
3648 wmi_dcc_ndl_chan));
3649 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3650
3651 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3652 update_ndl_param->dcc_ndl_active_state_list_len);
3653 buf_ptr += WMI_TLV_HDR_SIZE;
3654
3655 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303656 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303657 update_ndl_param->dcc_ndl_active_state_list,
3658 update_ndl_param->dcc_ndl_active_state_list_len);
3659 for (i = 0; i < active_state_count; i++) {
3660 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3661 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3662 WMITLV_GET_STRUCT_TLVLEN(
3663 wmi_dcc_ndl_active_state_config));
3664 }
3665 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3666
3667 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303668 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303669 WMI_DCC_UPDATE_NDL_CMDID);
3670 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303671 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303672 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303673 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303674 }
3675
Govind Singh67922e82016-04-01 16:48:57 +05303676 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303677}
3678
3679/**
3680 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3681 * @wmi_handle: pointer to the wmi handle
3682 * @config: the OCB configuration
3683 *
3684 * Return: 0 on success
3685 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303686static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303687 struct ocb_config_param *config, uint32_t *ch_mhz)
3688{
Govind Singh67922e82016-04-01 16:48:57 +05303689 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303690 wmi_ocb_set_config_cmd_fixed_param *cmd;
3691 wmi_channel *chan;
3692 wmi_ocb_channel *ocb_chan;
3693 wmi_qos_parameter *qos_param;
3694 wmi_dcc_ndl_chan *ndl_chan;
3695 wmi_dcc_ndl_active_state_config *ndl_active_config;
3696 wmi_ocb_schedule_element *sched_elem;
3697 uint8_t *buf_ptr;
3698 wmi_buf_t buf;
3699 int32_t len;
3700 int32_t i, j, active_state_count;
3701
3702 /*
3703 * Validate the dcc_ndl_chan_list_len and count the number of active
3704 * states. Validate dcc_ndl_active_state_list_len.
3705 */
3706 active_state_count = 0;
3707 if (config->dcc_ndl_chan_list_len) {
3708 if (!config->dcc_ndl_chan_list ||
3709 config->dcc_ndl_chan_list_len !=
3710 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303711 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303712 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303713 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303714 }
3715
3716 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3717 i < config->channel_count; ++i, ++ndl_chan)
3718 active_state_count +=
3719 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3720
3721 if (active_state_count) {
3722 if (!config->dcc_ndl_active_state_list ||
3723 config->dcc_ndl_active_state_list_len !=
3724 active_state_count *
3725 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303726 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303727 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303728 }
3729 }
3730 }
3731
3732 len = sizeof(*cmd) +
3733 WMI_TLV_HDR_SIZE + config->channel_count *
3734 sizeof(wmi_channel) +
3735 WMI_TLV_HDR_SIZE + config->channel_count *
3736 sizeof(wmi_ocb_channel) +
3737 WMI_TLV_HDR_SIZE + config->channel_count *
3738 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3739 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3740 WMI_TLV_HDR_SIZE + active_state_count *
3741 sizeof(wmi_dcc_ndl_active_state_config) +
3742 WMI_TLV_HDR_SIZE + config->schedule_size *
3743 sizeof(wmi_ocb_schedule_element);
3744 buf = wmi_buf_alloc(wmi_handle, len);
3745 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303746 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303747 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303748 }
3749
3750 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3751 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3752 WMITLV_SET_HDR(&cmd->tlv_header,
3753 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3754 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3755 cmd->vdev_id = config->session_id;
3756 cmd->channel_count = config->channel_count;
3757 cmd->schedule_size = config->schedule_size;
3758 cmd->flags = config->flags;
3759 buf_ptr += sizeof(*cmd);
3760
3761 /* Add the wmi_channel info */
3762 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3763 config->channel_count*sizeof(wmi_channel));
3764 buf_ptr += WMI_TLV_HDR_SIZE;
3765 for (i = 0; i < config->channel_count; i++) {
3766 chan = (wmi_channel *)buf_ptr;
3767 WMITLV_SET_HDR(&chan->tlv_header,
3768 WMITLV_TAG_STRUC_wmi_channel,
3769 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3770 chan->mhz = config->channels[i].chan_freq;
3771 chan->band_center_freq1 = config->channels[i].chan_freq;
3772 chan->band_center_freq2 = 0;
3773 chan->info = 0;
3774
3775 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3776 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3777 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3778 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3779 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3780 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3781 config->channels[i].antenna_max);
3782
3783 if (config->channels[i].bandwidth < 10)
3784 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3785 else if (config->channels[i].bandwidth < 20)
3786 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3787 buf_ptr += sizeof(*chan);
3788 }
3789
3790 /* Add the wmi_ocb_channel info */
3791 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3792 config->channel_count*sizeof(wmi_ocb_channel));
3793 buf_ptr += WMI_TLV_HDR_SIZE;
3794 for (i = 0; i < config->channel_count; i++) {
3795 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3796 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3797 WMITLV_TAG_STRUC_wmi_ocb_channel,
3798 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3799 ocb_chan->bandwidth = config->channels[i].bandwidth;
3800 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3801 config->channels[i].mac_address.bytes,
3802 &ocb_chan->mac_address);
3803 buf_ptr += sizeof(*ocb_chan);
3804 }
3805
3806 /* Add the wmi_qos_parameter info */
3807 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3808 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3809 buf_ptr += WMI_TLV_HDR_SIZE;
3810 /* WMI_MAX_NUM_AC parameters for each channel */
3811 for (i = 0; i < config->channel_count; i++) {
3812 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3813 qos_param = (wmi_qos_parameter *)buf_ptr;
3814 WMITLV_SET_HDR(&qos_param->tlv_header,
3815 WMITLV_TAG_STRUC_wmi_qos_parameter,
3816 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3817 qos_param->aifsn =
3818 config->channels[i].qos_params[j].aifsn;
3819 qos_param->cwmin =
3820 config->channels[i].qos_params[j].cwmin;
3821 qos_param->cwmax =
3822 config->channels[i].qos_params[j].cwmax;
3823 buf_ptr += sizeof(*qos_param);
3824 }
3825 }
3826
3827 /* Add the wmi_dcc_ndl_chan (per channel) */
3828 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3829 config->dcc_ndl_chan_list_len);
3830 buf_ptr += WMI_TLV_HDR_SIZE;
3831 if (config->dcc_ndl_chan_list_len) {
3832 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303833 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303834 config->dcc_ndl_chan_list_len);
3835 for (i = 0; i < config->channel_count; i++)
3836 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3837 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3838 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3839 buf_ptr += config->dcc_ndl_chan_list_len;
3840 }
3841
3842 /* Add the wmi_dcc_ndl_active_state_config */
3843 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3844 sizeof(wmi_dcc_ndl_active_state_config));
3845 buf_ptr += WMI_TLV_HDR_SIZE;
3846 if (active_state_count) {
3847 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303848 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303849 config->dcc_ndl_active_state_list,
3850 active_state_count * sizeof(*ndl_active_config));
3851 for (i = 0; i < active_state_count; ++i)
3852 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3853 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3854 WMITLV_GET_STRUCT_TLVLEN(
3855 wmi_dcc_ndl_active_state_config));
3856 buf_ptr += active_state_count *
3857 sizeof(*ndl_active_config);
3858 }
3859
3860 /* Add the wmi_ocb_schedule_element info */
3861 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3862 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3863 buf_ptr += WMI_TLV_HDR_SIZE;
3864 for (i = 0; i < config->schedule_size; i++) {
3865 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3866 WMITLV_SET_HDR(&sched_elem->tlv_header,
3867 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3868 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3869 sched_elem->channel_freq = config->schedule[i].chan_freq;
3870 sched_elem->total_duration = config->schedule[i].total_duration;
3871 sched_elem->guard_interval = config->schedule[i].guard_interval;
3872 buf_ptr += sizeof(*sched_elem);
3873 }
3874
3875
3876 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3877 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303878 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303879 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303880 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303881 }
3882
Govind Singh67922e82016-04-01 16:48:57 +05303883 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303884}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303885
3886/**
3887 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3888 * @wmi_handle: wmi handle
3889 * @mcc_adaptive_scheduler: enable/disable
3890 *
3891 * This function enable/disable mcc adaptive scheduler in fw.
3892 *
Govind Singhb53420c2016-03-09 14:32:57 +05303893 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303894 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303895static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003896 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3897 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303898{
Govind Singh67922e82016-04-01 16:48:57 +05303899 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303900 wmi_buf_t buf = 0;
3901 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3902 uint16_t len =
3903 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3904
3905 buf = wmi_buf_alloc(wmi_handle, len);
3906 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303907 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3908 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303909 }
3910 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3911 wmi_buf_data(buf);
3912
3913 WMITLV_SET_HDR(&cmd->tlv_header,
3914 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3915 WMITLV_GET_STRUCT_TLVLEN
3916 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3917 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303918 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303919
3920 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3921 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303922 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303923 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303924 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303925 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303926 }
Govind Singh67922e82016-04-01 16:48:57 +05303927
3928 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303929}
3930
3931/**
3932 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3933 * @wmi: wmi handle
3934 * @mcc_channel: mcc channel
3935 * @mcc_channel_time_latency: MCC channel time latency.
3936 *
3937 * Currently used to set time latency for an MCC vdev/adapter using operating
3938 * channel of it and channel number. The info is provided run time using
3939 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3940 *
3941 * Return: CDF status
3942 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303943static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303944 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3945{
Govind Singh67922e82016-04-01 16:48:57 +05303946 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303947 wmi_buf_t buf = 0;
3948 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3949 uint16_t len = 0;
3950 uint8_t *buf_ptr = NULL;
3951 wmi_resmgr_chan_latency chan_latency;
3952 /* Note: we only support MCC time latency for a single channel */
3953 uint32_t num_channels = 1;
3954 uint32_t chan1_freq = mcc_channel_freq;
3955 uint32_t latency_chan1 = mcc_channel_time_latency;
3956
3957
3958 /* If 0ms latency is provided, then FW will set to a default.
3959 * Otherwise, latency must be at least 30ms.
3960 */
3961 if ((latency_chan1 > 0) &&
3962 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303963 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303964 "Minimum is 30ms (or 0 to use default value by "
3965 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303966 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303967 }
3968
3969 /* Set WMI CMD for channel time latency here */
3970 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3971 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3972 num_channels * sizeof(wmi_resmgr_chan_latency);
3973 buf = wmi_buf_alloc(wmi_handle, len);
3974 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303975 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3976 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303977 }
3978 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3979 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3980 wmi_buf_data(buf);
3981 WMITLV_SET_HDR(&cmdTL->tlv_header,
3982 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3983 WMITLV_GET_STRUCT_TLVLEN
3984 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3985 cmdTL->num_chans = num_channels;
3986 /* Update channel time latency information for home channel(s) */
3987 buf_ptr += sizeof(*cmdTL);
3988 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3989 num_channels * sizeof(wmi_resmgr_chan_latency));
3990 buf_ptr += WMI_TLV_HDR_SIZE;
3991 chan_latency.chan_mhz = chan1_freq;
3992 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303993 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303994 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3995 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303996 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303997 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303998 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303999 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304000 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304001 }
Govind Singh67922e82016-04-01 16:48:57 +05304002
4003 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304004}
4005
4006/**
4007 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4008 * @wmi: wmi handle
4009 * @adapter_1_chan_number: adapter 1 channel number
4010 * @adapter_1_quota: adapter 1 quota
4011 * @adapter_2_chan_number: adapter 2 channel number
4012 *
4013 * Return: CDF status
4014 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304015static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304016 uint32_t adapter_1_chan_freq,
4017 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4018{
Govind Singh67922e82016-04-01 16:48:57 +05304019 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304020 wmi_buf_t buf = 0;
4021 uint16_t len = 0;
4022 uint8_t *buf_ptr = NULL;
4023 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4024 wmi_resmgr_chan_time_quota chan_quota;
4025 uint32_t quota_chan1 = adapter_1_quota;
4026 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4027 uint32_t quota_chan2 = 100 - quota_chan1;
4028 /* Note: setting time quota for MCC requires info for 2 channels */
4029 uint32_t num_channels = 2;
4030 uint32_t chan1_freq = adapter_1_chan_freq;
4031 uint32_t chan2_freq = adapter_2_chan_freq;
4032
Govind Singhb53420c2016-03-09 14:32:57 +05304033 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304034 "freq2:%dMHz, Quota2:%dms", __func__,
4035 chan1_freq, quota_chan1, chan2_freq,
4036 quota_chan2);
4037
4038 /*
4039 * Perform sanity check on time quota values provided.
4040 */
4041 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4042 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304043 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304044 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304045 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304046 }
4047 /* Set WMI CMD for channel time quota here */
4048 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4049 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4050 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4051 buf = wmi_buf_alloc(wmi_handle, len);
4052 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304053 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4054 QDF_ASSERT(0);
4055 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304056 }
4057 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4058 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4059 wmi_buf_data(buf);
4060 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4061 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4062 WMITLV_GET_STRUCT_TLVLEN
4063 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4064 cmdTQ->num_chans = num_channels;
4065
4066 /* Update channel time quota information for home channel(s) */
4067 buf_ptr += sizeof(*cmdTQ);
4068 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4069 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4070 buf_ptr += WMI_TLV_HDR_SIZE;
4071 chan_quota.chan_mhz = chan1_freq;
4072 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304073 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304074 /* Construct channel and quota record for the 2nd MCC mode. */
4075 buf_ptr += sizeof(chan_quota);
4076 chan_quota.chan_mhz = chan2_freq;
4077 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304078 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304079
4080 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4081 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304082 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304083 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304084 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304085 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304086 }
Govind Singh67922e82016-04-01 16:48:57 +05304087
4088 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304089}
4090
4091/**
4092 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4093 * @wmi_handle: Pointer to wmi handle
4094 * @thermal_info: Thermal command information
4095 *
4096 * This function sends the thermal management command
4097 * to the firmware
4098 *
Govind Singhb53420c2016-03-09 14:32:57 +05304099 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304100 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304101static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304102 struct thermal_cmd_params *thermal_info)
4103{
4104 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4105 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304106 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304107 uint32_t len = 0;
4108
4109 len = sizeof(*cmd);
4110
4111 buf = wmi_buf_alloc(wmi_handle, len);
4112 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304113 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4114 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304115 }
4116
4117 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4118
4119 WMITLV_SET_HDR(&cmd->tlv_header,
4120 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4121 WMITLV_GET_STRUCT_TLVLEN
4122 (wmi_thermal_mgmt_cmd_fixed_param));
4123
4124 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4125 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4126 cmd->enable = thermal_info->thermal_enable;
4127
Govind Singhb53420c2016-03-09 14:32:57 +05304128 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304129 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4130
4131 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4132 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304133 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304134 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304135 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304136 }
4137
Govind Singh67922e82016-04-01 16:48:57 +05304138 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304139}
4140
4141
4142/**
4143 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304144 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304145 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4146 *
4147 * This function sends down the LRO configuration parameters to
4148 * the firmware to enable LRO, sets the TCP flags and sets the
4149 * seed values for the toeplitz hash generation
4150 *
Govind Singhb53420c2016-03-09 14:32:57 +05304151 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304152 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304153static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304154 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4155{
4156 wmi_lro_info_cmd_fixed_param *cmd;
4157 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304158 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304159
4160
4161 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304163 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4164 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304165 }
4166
4167 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4168
4169 WMITLV_SET_HDR(&cmd->tlv_header,
4170 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4171 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4172
4173 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4174 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4175 wmi_lro_cmd->tcp_flag);
4176 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4177 wmi_lro_cmd->tcp_flag_mask);
4178 cmd->toeplitz_hash_ipv4_0_3 =
4179 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4180 cmd->toeplitz_hash_ipv4_4_7 =
4181 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4182 cmd->toeplitz_hash_ipv4_8_11 =
4183 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4184 cmd->toeplitz_hash_ipv4_12_15 =
4185 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4186 cmd->toeplitz_hash_ipv4_16 =
4187 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4188
4189 cmd->toeplitz_hash_ipv6_0_3 =
4190 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4191 cmd->toeplitz_hash_ipv6_4_7 =
4192 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4193 cmd->toeplitz_hash_ipv6_8_11 =
4194 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4195 cmd->toeplitz_hash_ipv6_12_15 =
4196 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4197 cmd->toeplitz_hash_ipv6_16_19 =
4198 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4199 cmd->toeplitz_hash_ipv6_20_23 =
4200 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4201 cmd->toeplitz_hash_ipv6_24_27 =
4202 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4203 cmd->toeplitz_hash_ipv6_28_31 =
4204 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4205 cmd->toeplitz_hash_ipv6_32_35 =
4206 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4207 cmd->toeplitz_hash_ipv6_36_39 =
4208 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4209 cmd->toeplitz_hash_ipv6_40 =
4210 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4211
Govind Singhb53420c2016-03-09 14:32:57 +05304212 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304213 cmd->lro_enable, cmd->tcp_flag_u32);
4214
4215 status = wmi_unified_cmd_send(wmi_handle, buf,
4216 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304217 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304218 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304219 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304220 }
4221
Govind Singh67922e82016-04-01 16:48:57 +05304222 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304223}
4224
Govind Singh4eacd2b2016-03-07 14:24:22 +05304225/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304226 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4227 * @wmi_handle: Pointer to wmi handle
4228 * @rate_report_params: Pointer to peer rate report parameters
4229 *
4230 *
4231 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4232 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304233static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304234 struct wmi_peer_rate_report_params *rate_report_params)
4235{
4236 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4237 wmi_buf_t buf = NULL;
4238 QDF_STATUS status = 0;
4239 uint32_t len = 0;
4240 uint32_t i, j;
4241
4242 len = sizeof(*cmd);
4243
4244 buf = wmi_buf_alloc(wmi_handle, len);
4245 if (!buf) {
4246 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4247 return QDF_STATUS_E_FAILURE;
4248 }
4249
4250 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4251 wmi_buf_data(buf);
4252
4253 WMITLV_SET_HDR(
4254 &cmd->tlv_header,
4255 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4256 WMITLV_GET_STRUCT_TLVLEN(
4257 wmi_peer_set_rate_report_condition_fixed_param));
4258
4259 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4260 cmd->report_backoff_time = rate_report_params->backoff_time;
4261 cmd->report_timer_period = rate_report_params->timer_period;
4262 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4263 cmd->cond_per_phy[i].val_cond_flags =
4264 rate_report_params->report_per_phy[i].cond_flags;
4265 cmd->cond_per_phy[i].rate_delta.min_delta =
4266 rate_report_params->report_per_phy[i].delta.delta_min;
4267 cmd->cond_per_phy[i].rate_delta.percentage =
4268 rate_report_params->report_per_phy[i].delta.percent;
4269 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4270 cmd->cond_per_phy[i].rate_threshold[j] =
4271 rate_report_params->report_per_phy[i].
4272 report_rate_threshold[j];
4273 }
4274 }
4275
4276 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4277 cmd->enable_rate_report,
4278 cmd->report_backoff_time, cmd->report_timer_period);
4279
4280 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4281 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4282 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304283 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304284 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4285 __func__);
4286 }
4287 return status;
4288}
4289
4290/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304291 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4292 * @wmi_handle: wmi handle
4293 * @param: bcn ll cmd parameter
4294 *
Govind Singhb53420c2016-03-09 14:32:57 +05304295 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304296 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304297static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304298 wmi_bcn_send_from_host_cmd_fixed_param *param)
4299{
4300 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4301 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304302 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304303
4304 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4305 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304306 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4307 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304308 }
4309
4310 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4311 WMITLV_SET_HDR(&cmd->tlv_header,
4312 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4313 WMITLV_GET_STRUCT_TLVLEN
4314 (wmi_bcn_send_from_host_cmd_fixed_param));
4315 cmd->vdev_id = param->vdev_id;
4316 cmd->data_len = param->data_len;
4317 cmd->frame_ctrl = param->frame_ctrl;
4318 cmd->frag_ptr = param->frag_ptr;
4319 cmd->dtim_flag = param->dtim_flag;
4320
4321 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4322 WMI_PDEV_SEND_BCN_CMDID);
4323
Govind Singh67922e82016-04-01 16:48:57 +05304324 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304325 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304326 wmi_buf_free(wmi_buf);
4327 }
4328
4329 return ret;
4330}
4331
4332/**
4333 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4334 * @wmi_handle: wmi handle
4335 * @vdev_id: vdev id
4336 * @max_retries: max retries
4337 * @retry_interval: retry interval
4338 * This function sets sta query related parameters in fw.
4339 *
Govind Singhb53420c2016-03-09 14:32:57 +05304340 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304341 */
4342
Sathish Kumarfd347372017-02-13 12:29:09 +05304343static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304344 uint8_t vdev_id, uint32_t max_retries,
4345 uint32_t retry_interval)
4346{
4347 wmi_buf_t buf;
4348 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4349 int len;
4350
4351 len = sizeof(*cmd);
4352 buf = wmi_buf_alloc(wmi_handle, len);
4353 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304354 WMI_LOGE(FL("wmi_buf_alloc failed"));
4355 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304356 }
4357
4358 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4359 WMITLV_SET_HDR(&cmd->tlv_header,
4360 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4361 WMITLV_GET_STRUCT_TLVLEN
4362 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4363
4364
4365 cmd->vdev_id = vdev_id;
4366 cmd->sa_query_max_retry_count = max_retries;
4367 cmd->sa_query_retry_interval = retry_interval;
4368
Govind Singhb53420c2016-03-09 14:32:57 +05304369 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304370 vdev_id, retry_interval, max_retries);
4371
4372 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4373 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304374 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304375 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304376 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304377 }
4378
Govind Singhb53420c2016-03-09 14:32:57 +05304379 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304380 return 0;
4381}
4382
4383/**
4384 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4385 * @wmi_handle: wmi handle
4386 * @params: sta keep alive parameter
4387 *
4388 * This function sets keep alive related parameters in fw.
4389 *
4390 * Return: CDF status
4391 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304392static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304393 struct sta_params *params)
4394{
4395 wmi_buf_t buf;
4396 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4397 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4398 uint8_t *buf_ptr;
4399 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304400 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304401
Govind Singhb53420c2016-03-09 14:32:57 +05304402 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304403
Govind Singh4eacd2b2016-03-07 14:24:22 +05304404 len = sizeof(*cmd) + sizeof(*arp_rsp);
4405 buf = wmi_buf_alloc(wmi_handle, len);
4406 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304407 WMI_LOGE("wmi_buf_alloc failed");
4408 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304409 }
4410
4411 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4412 buf_ptr = (uint8_t *) cmd;
4413 WMITLV_SET_HDR(&cmd->tlv_header,
4414 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4415 WMITLV_GET_STRUCT_TLVLEN
4416 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4417 cmd->interval = params->timeperiod;
4418 cmd->enable = (params->timeperiod) ? 1 : 0;
4419 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304420 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304421 params->timeperiod, params->method);
4422 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4423 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4424 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4425 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4426
4427 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4428 if ((NULL == params->hostv4addr) ||
4429 (NULL == params->destv4addr) ||
4430 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304431 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304432 "destv4addr:%p destmac:%p ", __func__,
4433 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304434 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304435 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304436 }
4437 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304438 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304439 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304440 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304441 WMI_IPV4_ADDR_LEN);
4442 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4443 } else {
4444 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4445 }
4446
Govind Singh67922e82016-04-01 16:48:57 +05304447 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4448 WMI_STA_KEEPALIVE_CMDID);
4449 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304450 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304451 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304452 }
4453
Govind Singhb53420c2016-03-09 14:32:57 +05304454 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304455 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304456}
4457
4458/**
4459 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4460 * @wmi_handle: wmi handle
4461 * @if_id: vdev id
4462 * @gtx_info: GTX config params
4463 *
4464 * This function set GTX related params in firmware.
4465 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304466 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304467 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304468static 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 +05304469 struct wmi_gtx_config *gtx_info)
4470{
4471 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4472 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304473 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304474 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304475
Govind Singh4eacd2b2016-03-07 14:24:22 +05304476 buf = wmi_buf_alloc(wmi_handle, len);
4477 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304478 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304479 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304480 }
4481 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4482 WMITLV_SET_HDR(&cmd->tlv_header,
4483 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4484 WMITLV_GET_STRUCT_TLVLEN
4485 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4486 cmd->vdev_id = if_id;
4487
4488 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4489 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4490 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4491 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4492 cmd->gtxPERMargin = gtx_info->gtx_margin;
4493 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4494 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4495 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4496
Govind Singhb53420c2016-03-09 14:32:57 +05304497 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304498 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4499 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4500 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4501 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4502
Abhishek Singh716c46c2016-05-04 16:24:07 +05304503 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304504 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304505 if (QDF_IS_STATUS_ERROR(ret)) {
4506 WMI_LOGE("Failed to set GTX PARAMS");
4507 wmi_buf_free(buf);
4508 }
4509 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304510}
4511
4512/**
4513 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4514 * @wmi_handle: wmi handle
4515 * @edca_params: edca parameters
4516 *
4517 * This function updates EDCA parameters to the target
4518 *
4519 * Return: CDF Status
4520 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304521static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304522 uint8_t vdev_id,
4523 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4524{
4525 uint8_t *buf_ptr;
4526 wmi_buf_t buf;
4527 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4528 wmi_wmm_vparams *wmm_param, *twmm_param;
4529 int len = sizeof(*cmd);
4530 int ac;
4531
4532 buf = wmi_buf_alloc(wmi_handle, len);
4533
4534 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304535 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4536 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304537 }
4538
4539 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4540 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4541 WMITLV_SET_HDR(&cmd->tlv_header,
4542 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4543 WMITLV_GET_STRUCT_TLVLEN
4544 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4545 cmd->vdev_id = vdev_id;
4546
4547 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4548 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4549 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4550 WMITLV_SET_HDR(&wmm_param->tlv_header,
4551 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4552 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4553 wmm_param->cwmin = twmm_param->cwmin;
4554 wmm_param->cwmax = twmm_param->cwmax;
4555 wmm_param->aifs = twmm_param->aifs;
4556 wmm_param->txoplimit = twmm_param->txoplimit;
4557 wmm_param->acm = twmm_param->acm;
4558 wmm_param->no_ack = twmm_param->no_ack;
4559 }
4560
4561 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4562 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4563 goto fail;
4564
Govind Singhb53420c2016-03-09 14:32:57 +05304565 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304566
4567fail:
4568 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304569 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4570 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304571}
4572
4573/**
4574 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4575 * @wmi_handle: wmi handle
4576 * @vdev_id: vdev id
4577 * @probe_rsp_info: probe response info
4578 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304579 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304580 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304581static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304582 uint8_t vdev_id,
4583 struct wmi_probe_resp_params *probe_rsp_info,
4584 uint8_t *frm)
4585{
4586 wmi_prb_tmpl_cmd_fixed_param *cmd;
4587 wmi_bcn_prb_info *bcn_prb_info;
4588 wmi_buf_t wmi_buf;
4589 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4590 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304591 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304592
Govind Singhb53420c2016-03-09 14:32:57 +05304593 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304594
4595 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4596 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4597
4598 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4599 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4600 tmpl_len_aligned;
4601
4602 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304603 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304604 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304605 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304606 }
4607
4608 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4609 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304610 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304611 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304612 }
4613
4614 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4615
4616 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4617 WMITLV_SET_HDR(&cmd->tlv_header,
4618 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4619 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4620 cmd->vdev_id = vdev_id;
4621 cmd->buf_len = tmpl_len;
4622 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4623
4624 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4625 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4626 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4627 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4628 bcn_prb_info->caps = 0;
4629 bcn_prb_info->erp = 0;
4630 buf_ptr += sizeof(wmi_bcn_prb_info);
4631
4632 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4633 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304634 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304635
4636 ret = wmi_unified_cmd_send(wmi_handle,
4637 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304638 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304639 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304640 wmi_buf_free(wmi_buf);
4641 }
4642
4643 return ret;
4644}
4645
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304646#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304647#define WPI_IV_LEN 16
4648
4649/**
4650 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4651 *
4652 * @dest_tx: destination address of tsc key counter
4653 * @src_tx: source address of tsc key counter
4654 * @dest_rx: destination address of rsc key counter
4655 * @src_rx: source address of rsc key counter
4656 *
4657 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4658 *
4659 * Return: None
4660 *
4661 */
4662static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4663 uint8_t *dest_rx, uint8_t *src_rx)
4664{
4665 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4666 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4667}
4668#else
4669static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4670 uint8_t *dest_rx, uint8_t *src_rx)
4671{
4672 return;
4673}
4674#endif
4675
4676/**
4677 * send_setup_install_key_cmd_tlv() - set key parameters
4678 * @wmi_handle: wmi handle
4679 * @key_params: key parameters
4680 *
4681 * This function fills structure from information
4682 * passed in key_params.
4683 *
4684 * Return: QDF_STATUS_SUCCESS - success
4685 * QDF_STATUS_E_FAILURE - failure
4686 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4687 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304688static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304689 struct set_key_params *key_params)
4690{
4691 wmi_vdev_install_key_cmd_fixed_param *cmd;
4692 wmi_buf_t buf;
4693 uint8_t *buf_ptr;
4694 uint32_t len;
4695 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304696 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304697
4698 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4699 WMI_TLV_HDR_SIZE;
4700
4701 buf = wmi_buf_alloc(wmi_handle, len);
4702 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304703 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304704 return QDF_STATUS_E_NOMEM;
4705 }
4706
4707 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4708 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4709 WMITLV_SET_HDR(&cmd->tlv_header,
4710 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4711 WMITLV_GET_STRUCT_TLVLEN
4712 (wmi_vdev_install_key_cmd_fixed_param));
4713 cmd->vdev_id = key_params->vdev_id;
4714 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304715
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304716
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304717 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4718 cmd->key_flags |= key_params->key_flags;
4719 cmd->key_cipher = key_params->key_cipher;
4720 if ((key_params->key_txmic_len) &&
4721 (key_params->key_rxmic_len)) {
4722 cmd->key_txmic_len = key_params->key_txmic_len;
4723 cmd->key_rxmic_len = key_params->key_rxmic_len;
4724 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304725#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304726 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4727 key_params->tx_iv,
4728 cmd->wpi_key_rsc_counter,
4729 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304730#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304731 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4732 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4733 roundup(key_params->key_len, sizeof(uint32_t)));
4734 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4735 qdf_mem_copy((void *)key_data,
4736 (const void *)key_params->key_data, key_params->key_len);
4737 cmd->key_len = key_params->key_len;
4738
4739 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4740 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304741 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304742 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304743
Govind Singh67922e82016-04-01 16:48:57 +05304744 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304745}
4746
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304747/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004748 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4749 * @wmi_handle: wmi handle
4750 * @params: sar limit params
4751 *
4752 * Return: QDF_STATUS_SUCCESS for success or error code
4753 */
4754static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4755 struct sar_limit_cmd_params *sar_limit_params)
4756{
4757 wmi_buf_t buf;
4758 QDF_STATUS qdf_status;
4759 wmi_sar_limits_cmd_fixed_param *cmd;
4760 int i;
4761 uint8_t *buf_ptr;
4762 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4763 struct sar_limit_cmd_row *sar_rows_list;
4764 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4765
4766 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4767 buf = wmi_buf_alloc(wmi_handle, len);
4768 if (!buf) {
4769 WMI_LOGE("Failed to allocate memory");
4770 qdf_status = QDF_STATUS_E_NOMEM;
4771 goto end;
4772 }
4773
4774 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4775 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4776 WMITLV_SET_HDR(&cmd->tlv_header,
4777 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4778 WMITLV_GET_STRUCT_TLVLEN
4779 (wmi_sar_limits_cmd_fixed_param));
4780 cmd->sar_enable = sar_limit_params->sar_enable;
4781 cmd->commit_limits = sar_limit_params->commit_limits;
4782 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4783
4784 WMI_LOGD("no of sar rows = %d, len = %d",
4785 sar_limit_params->num_limit_rows, len);
4786 buf_ptr += sizeof(*cmd);
4787 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4788 sizeof(wmi_sar_limit_cmd_row) *
4789 sar_limit_params->num_limit_rows);
4790 if (cmd->num_limit_rows == 0)
4791 goto send_sar_limits;
4792
4793 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4794 (buf_ptr + WMI_TLV_HDR_SIZE);
4795 sar_rows_list = sar_limit_params->sar_limit_row_list;
4796
4797 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4798 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4799 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4800 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4801 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4802 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4803 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4804 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4805 wmi_sar_rows_list->validity_bitmap =
4806 sar_rows_list->validity_bitmap;
4807 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4808 i, wmi_sar_rows_list->band_id,
4809 wmi_sar_rows_list->chain_id,
4810 wmi_sar_rows_list->mod_id,
4811 wmi_sar_rows_list->limit_value,
4812 wmi_sar_rows_list->validity_bitmap);
4813 sar_rows_list++;
4814 wmi_sar_rows_list++;
4815 }
4816send_sar_limits:
4817 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4818 WMI_SAR_LIMITS_CMDID);
4819
4820 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4821 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4822 wmi_buf_free(buf);
4823 }
4824
4825end:
4826 return qdf_status;
4827}
4828
4829/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304830 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4831 * @wmi_handle: wmi handle
4832 * @params: encrypt/decrypt params
4833 *
4834 * Return: QDF_STATUS_SUCCESS for success or error code
4835 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004836static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304837QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4838 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4839{
4840 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4841 wmi_buf_t wmi_buf;
4842 uint8_t *buf_ptr;
4843 QDF_STATUS ret;
4844 uint32_t len;
4845
4846 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4847
4848 len = sizeof(*cmd) +
4849 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4850 WMI_TLV_HDR_SIZE;
4851 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4852 if (!wmi_buf) {
4853 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4854 __func__);
4855 return QDF_STATUS_E_NOMEM;
4856 }
4857
4858 buf_ptr = wmi_buf_data(wmi_buf);
4859 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4860
4861 WMITLV_SET_HDR(&cmd->tlv_header,
4862 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4863 WMITLV_GET_STRUCT_TLVLEN(
4864 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4865
4866 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4867 cmd->key_flag = encrypt_decrypt_params->key_flag;
4868 cmd->key_idx = encrypt_decrypt_params->key_idx;
4869 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4870 cmd->key_len = encrypt_decrypt_params->key_len;
4871 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4872 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4873
4874 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4875 encrypt_decrypt_params->key_len);
4876
4877 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4878 MAX_MAC_HEADER_LEN);
4879
4880 cmd->data_len = encrypt_decrypt_params->data_len;
4881
4882 if (cmd->data_len) {
4883 buf_ptr += sizeof(*cmd);
4884 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4885 roundup(encrypt_decrypt_params->data_len,
4886 sizeof(A_UINT32)));
4887 buf_ptr += WMI_TLV_HDR_SIZE;
4888 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4889 encrypt_decrypt_params->data_len);
4890 }
4891
4892 /* This conversion is to facilitate data to FW in little endian */
4893 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4894 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4895 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4896 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4897 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4898 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4899
4900 ret = wmi_unified_cmd_send(wmi_handle,
4901 wmi_buf, len,
4902 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4903 if (QDF_IS_STATUS_ERROR(ret)) {
4904 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4905 wmi_buf_free(wmi_buf);
4906 }
4907
4908 return ret;
4909}
4910
4911
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304912
Govind Singh4eacd2b2016-03-07 14:24:22 +05304913/**
4914 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4915 * @wmi_handle: wmi handle
4916 * @vdev_id: vdev id
4917 * @p2p_ie: p2p IE
4918 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304919 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304920 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304921static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304922 A_UINT32 vdev_id, uint8_t *p2p_ie)
4923{
Govind Singh67922e82016-04-01 16:48:57 +05304924 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304925 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4926 wmi_buf_t wmi_buf;
4927 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4928 uint8_t *buf_ptr;
4929
4930 ie_len = (uint32_t) (p2p_ie[1] + 2);
4931
4932 /* More than one P2P IE may be included in a single frame.
4933 If multiple P2P IEs are present, the complete P2P attribute
4934 data consists of the concatenation of the P2P Attribute
4935 fields of the P2P IEs. The P2P Attributes field of each
4936 P2P IE may be any length up to the maximum (251 octets).
4937 In this case host sends one P2P IE to firmware so the length
4938 should not exceed more than 251 bytes
4939 */
4940 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304941 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304942 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304943 }
4944
4945 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4946
4947 wmi_buf_len =
4948 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4949 WMI_TLV_HDR_SIZE;
4950
4951 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4952 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304953 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304954 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304955 }
4956
4957 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4958
4959 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4960 WMITLV_SET_HDR(&cmd->tlv_header,
4961 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4962 WMITLV_GET_STRUCT_TLVLEN
4963 (wmi_p2p_go_set_beacon_ie_fixed_param));
4964 cmd->vdev_id = vdev_id;
4965 cmd->ie_buf_len = ie_len;
4966
4967 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4968 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4969 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304970 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304971
Govind Singhb53420c2016-03-09 14:32:57 +05304972 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304973
4974 ret = wmi_unified_cmd_send(wmi_handle,
4975 wmi_buf, wmi_buf_len,
4976 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304977 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304978 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304979 wmi_buf_free(wmi_buf);
4980 }
4981
Govind Singhb53420c2016-03-09 14:32:57 +05304982 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304983 return ret;
4984}
4985
4986/**
4987 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4988 * @wmi_handle: wmi handle
4989 * @req: gateway parameter update request structure
4990 *
4991 * This function reads the incoming @req and fill in the destination
4992 * WMI structure and sends down the gateway configs down to the firmware
4993 *
Govind Singhb53420c2016-03-09 14:32:57 +05304994 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304995 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304996static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304997 struct gateway_update_req_param *req)
4998{
4999 wmi_roam_subnet_change_config_fixed_param *cmd;
5000 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305001 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305002 int len = sizeof(*cmd);
5003
5004 buf = wmi_buf_alloc(wmi_handle, len);
5005 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305006 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5007 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305008 }
5009
5010 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5011 WMITLV_SET_HDR(&cmd->tlv_header,
5012 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5013 WMITLV_GET_STRUCT_TLVLEN(
5014 wmi_roam_subnet_change_config_fixed_param));
5015
5016 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305017 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5018 QDF_IPV4_ADDR_SIZE);
5019 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5020 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305021 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5022 &cmd->inet_gw_mac_addr);
5023 cmd->max_retries = req->max_retries;
5024 cmd->timeout = req->timeout;
5025 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5026 cmd->flag = 0;
5027 if (req->ipv4_addr_type)
5028 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5029
5030 if (req->ipv6_addr_type)
5031 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5032
5033 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5034 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305035 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305036 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305037 ret);
5038 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305039 }
5040
Govind Singh67922e82016-04-01 16:48:57 +05305041 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305042}
5043
5044/**
5045 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5046 * @wmi_handle: wmi handle
5047 * @req: rssi monitoring request structure
5048 *
5049 * This function reads the incoming @req and fill in the destination
5050 * WMI structure and send down the rssi monitoring configs down to the firmware
5051 *
5052 * Return: 0 on success; error number otherwise
5053 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305054static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305055 struct rssi_monitor_param *req)
5056{
5057 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5058 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305059 QDF_STATUS ret;
5060 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305061
5062 buf = wmi_buf_alloc(wmi_handle, len);
5063 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305064 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5065 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305066 }
5067
5068 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5069 WMITLV_SET_HDR(&cmd->tlv_header,
5070 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5071 WMITLV_GET_STRUCT_TLVLEN(
5072 wmi_rssi_breach_monitor_config_fixed_param));
5073
5074 cmd->vdev_id = req->session_id;
5075 cmd->request_id = req->request_id;
5076 cmd->lo_rssi_reenable_hysteresis = 0;
5077 cmd->hi_rssi_reenable_histeresis = 0;
5078 cmd->min_report_interval = 0;
5079 cmd->max_num_report = 1;
5080 if (req->control) {
5081 /* enable one threshold for each min/max */
5082 cmd->enabled_bitmap = 0x09;
5083 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5084 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5085 } else {
5086 cmd->enabled_bitmap = 0;
5087 cmd->low_rssi_breach_threshold[0] = 0;
5088 cmd->hi_rssi_breach_threshold[0] = 0;
5089 }
5090
5091 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5092 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305093 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305094 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305095 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305096 }
5097
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005098 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5099
Govind Singh67922e82016-04-01 16:48:57 +05305100 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305101}
5102
5103/**
5104 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5105 * @wmi_handle: wmi handle
5106 * @psetoui: OUI parameters
5107 *
5108 * set scan probe OUI parameters in firmware
5109 *
5110 * Return: CDF status
5111 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305112static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305113 struct scan_mac_oui *psetoui)
5114{
5115 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5116 wmi_buf_t wmi_buf;
5117 uint32_t len;
5118 uint8_t *buf_ptr;
5119 uint32_t *oui_buf;
5120
5121 len = sizeof(*cmd);
5122 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5123 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305124 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5125 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305126 }
5127 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5128 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5129 WMITLV_SET_HDR(&cmd->tlv_header,
5130 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5131 WMITLV_GET_STRUCT_TLVLEN
5132 (wmi_scan_prob_req_oui_cmd_fixed_param));
5133
5134 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305135 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305136 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5137 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305138 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305139 cmd->prob_req_oui);
5140
5141 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5142 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305143 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305144 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305145 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305146 }
Govind Singhb53420c2016-03-09 14:32:57 +05305147 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305148}
5149
5150/**
5151 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5152 * @wmi_handle: wmi handle
5153 * @req: passpoint network request structure
5154 *
5155 * This function sends down WMI command with network id set to wildcard id.
5156 * firmware shall clear all the config entries
5157 *
Govind Singhb53420c2016-03-09 14:32:57 +05305158 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305159 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305160static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305161 struct wifi_passpoint_req_param *req)
5162{
5163 wmi_passpoint_config_cmd_fixed_param *cmd;
5164 wmi_buf_t buf;
5165 uint32_t len;
5166 int ret;
5167
5168 len = sizeof(*cmd);
5169 buf = wmi_buf_alloc(wmi_handle, len);
5170 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305171 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5172 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305173 }
5174
5175 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5176
5177 WMITLV_SET_HDR(&cmd->tlv_header,
5178 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5179 WMITLV_GET_STRUCT_TLVLEN(
5180 wmi_passpoint_config_cmd_fixed_param));
5181 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5182
5183 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5184 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5185 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305186 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305187 __func__);
5188 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305189 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305190 }
5191
Govind Singhb53420c2016-03-09 14:32:57 +05305192 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305193}
5194
5195/**
5196 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5197 * @wmi_handle: wmi handle
5198 * @req: passpoint network request structure
5199 *
5200 * This function reads the incoming @req and fill in the destination
5201 * WMI structure and send down the passpoint configs down to the firmware
5202 *
Govind Singhb53420c2016-03-09 14:32:57 +05305203 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305204 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305205static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305206 struct wifi_passpoint_req_param *req)
5207{
5208 wmi_passpoint_config_cmd_fixed_param *cmd;
5209 u_int8_t i, j, *bytes;
5210 wmi_buf_t buf;
5211 uint32_t len;
5212 int ret;
5213
5214 len = sizeof(*cmd);
5215 for (i = 0; i < req->num_networks; i++) {
5216 buf = wmi_buf_alloc(wmi_handle, len);
5217 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305218 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5219 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305220 }
5221
5222 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5223 wmi_buf_data(buf);
5224
5225 WMITLV_SET_HDR(&cmd->tlv_header,
5226 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5227 WMITLV_GET_STRUCT_TLVLEN(
5228 wmi_passpoint_config_cmd_fixed_param));
5229 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305230 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5231 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305232 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305233 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305234 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5235 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305236 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305237 j, bytes[0], bytes[1], bytes[2], bytes[3],
5238 bytes[4], bytes[5], bytes[6], bytes[7]);
5239
Govind Singhb53420c2016-03-09 14:32:57 +05305240 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305241 &req->networks[i].roaming_consortium_ids[j],
5242 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5243 }
Govind Singhb53420c2016-03-09 14:32:57 +05305244 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305245 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305246 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305247 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5248
5249 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5250 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5251 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305252 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305253 __func__);
5254 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305255 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305256 }
5257 }
5258
Govind Singhb53420c2016-03-09 14:32:57 +05305259 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305260}
5261
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305262/**
5263 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5264 * @wmi_handle: wmi handle
5265 * @scan_cmd_fp: start scan command ptr
5266 * @roam_req: roam request param
5267 *
5268 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5269 * of WMI_ROAM_SCAN_MODE.
5270 *
5271 * Return: QDF status
5272 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305273static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305274 wmi_start_scan_cmd_fixed_param *
5275 scan_cmd_fp,
5276 struct roam_offload_scan_params *roam_req)
5277{
5278 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305279 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305280 int len;
5281 uint8_t *buf_ptr;
5282 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305283
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305284#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5285 int auth_mode = roam_req->auth_mode;
5286 wmi_roam_offload_tlv_param *roam_offload_params;
5287 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5288 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5289 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305290 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305291#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5292 /* Need to create a buf with roam_scan command at
5293 * front and piggyback with scan command */
5294 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5295#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5296 (2 * WMI_TLV_HDR_SIZE) +
5297#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5298 sizeof(wmi_start_scan_cmd_fixed_param);
5299#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5300 if (roam_req->is_roam_req_valid &&
5301 roam_req->roam_offload_enabled) {
5302 len += sizeof(wmi_roam_offload_tlv_param);
5303 len += WMI_TLV_HDR_SIZE;
5304 if ((auth_mode != WMI_AUTH_NONE) &&
5305 ((auth_mode != WMI_AUTH_OPEN) ||
5306 (auth_mode == WMI_AUTH_OPEN &&
5307 roam_req->mdid.mdie_present) ||
5308 roam_req->is_ese_assoc)) {
5309 len += WMI_TLV_HDR_SIZE;
5310 if (roam_req->is_ese_assoc)
5311 len +=
5312 sizeof(wmi_roam_ese_offload_tlv_param);
5313 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5314 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5315 (auth_mode == WMI_AUTH_OPEN &&
5316 roam_req->mdid.mdie_present))
5317 len +=
5318 sizeof(wmi_roam_11r_offload_tlv_param);
5319 else
5320 len +=
5321 sizeof(wmi_roam_11i_offload_tlv_param);
5322 } else {
5323 len += WMI_TLV_HDR_SIZE;
5324 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305325
5326 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5327 + roundup(roam_req->assoc_ie_length,
5328 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305329 } else {
5330 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305331 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305332 __func__, roam_req->roam_offload_enabled);
5333 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305334 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305335 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305336 }
5337 if (roam_req->is_roam_req_valid &&
5338 roam_req->roam_offload_enabled) {
5339 roam_req->mode = roam_req->mode |
5340 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5341 }
5342#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5343
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305344 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5345 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5346 len = sizeof(wmi_roam_scan_mode_fixed_param);
5347
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305348 buf = wmi_buf_alloc(wmi_handle, len);
5349 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305350 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305351 return QDF_STATUS_E_NOMEM;
5352 }
5353
5354 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305355
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305356 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5357 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5358 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5359 WMITLV_GET_STRUCT_TLVLEN
5360 (wmi_roam_scan_mode_fixed_param));
5361
5362 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5363 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305364 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
5365 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
5366 roam_scan_mode_fp->flags |=
5367 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305368 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305369 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305370
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305371 /* Fill in scan parameters suitable for roaming scan */
5372 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305373
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305374 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5375 sizeof(wmi_start_scan_cmd_fixed_param));
5376 /* Ensure there is no additional IEs */
5377 scan_cmd_fp->ie_len = 0;
5378 WMITLV_SET_HDR(buf_ptr,
5379 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5380 WMITLV_GET_STRUCT_TLVLEN
5381 (wmi_start_scan_cmd_fixed_param));
5382#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5383 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5384 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5385 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5386 sizeof(wmi_roam_offload_tlv_param));
5387 buf_ptr += WMI_TLV_HDR_SIZE;
5388 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5389 WMITLV_SET_HDR(buf_ptr,
5390 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5391 WMITLV_GET_STRUCT_TLVLEN
5392 (wmi_roam_offload_tlv_param));
5393 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5394 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5395 roam_offload_params->select_5g_margin =
5396 roam_req->select_5ghz_margin;
5397 roam_offload_params->reassoc_failure_timeout =
5398 roam_req->reassoc_failure_timeout;
5399
5400 /* Fill the capabilities */
5401 roam_offload_params->capability =
5402 roam_req->roam_offload_params.capability;
5403 roam_offload_params->ht_caps_info =
5404 roam_req->roam_offload_params.ht_caps_info;
5405 roam_offload_params->ampdu_param =
5406 roam_req->roam_offload_params.ampdu_param;
5407 roam_offload_params->ht_ext_cap =
5408 roam_req->roam_offload_params.ht_ext_cap;
5409 roam_offload_params->ht_txbf =
5410 roam_req->roam_offload_params.ht_txbf;
5411 roam_offload_params->asel_cap =
5412 roam_req->roam_offload_params.asel_cap;
5413 roam_offload_params->qos_caps =
5414 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005415 roam_offload_params->qos_enabled =
5416 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305417 roam_offload_params->wmm_caps =
5418 roam_req->roam_offload_params.wmm_caps;
5419 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5420 (uint8_t *)roam_req->roam_offload_params.mcsset,
5421 ROAM_OFFLOAD_NUM_MCS_SET);
5422
5423 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5424 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5425 * they are filled in the same order.Depending on the
5426 * authentication type, the other mode TLV's are nullified
5427 * and only headers are filled.*/
5428 if ((auth_mode != WMI_AUTH_NONE) &&
5429 ((auth_mode != WMI_AUTH_OPEN) ||
5430 (auth_mode == WMI_AUTH_OPEN
5431 && roam_req->mdid.mdie_present) ||
5432 roam_req->is_ese_assoc)) {
5433 if (roam_req->is_ese_assoc) {
5434 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5435 WMITLV_GET_STRUCT_TLVLEN(0));
5436 buf_ptr += WMI_TLV_HDR_SIZE;
5437 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5438 WMITLV_GET_STRUCT_TLVLEN(0));
5439 buf_ptr += WMI_TLV_HDR_SIZE;
5440 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5441 sizeof(wmi_roam_ese_offload_tlv_param));
5442 buf_ptr += WMI_TLV_HDR_SIZE;
5443 roam_offload_ese =
5444 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5445 qdf_mem_copy(roam_offload_ese->krk,
5446 roam_req->krk,
5447 sizeof(roam_req->krk));
5448 qdf_mem_copy(roam_offload_ese->btk,
5449 roam_req->btk,
5450 sizeof(roam_req->btk));
5451 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5452 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5453 WMITLV_GET_STRUCT_TLVLEN
5454 (wmi_roam_ese_offload_tlv_param));
5455 buf_ptr +=
5456 sizeof(wmi_roam_ese_offload_tlv_param);
5457 } else if (auth_mode == WMI_AUTH_FT_RSNA
5458 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5459 || (auth_mode == WMI_AUTH_OPEN
5460 && roam_req->mdid.mdie_present)) {
5461 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5462 0);
5463 buf_ptr += WMI_TLV_HDR_SIZE;
5464 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5465 sizeof(wmi_roam_11r_offload_tlv_param));
5466 buf_ptr += WMI_TLV_HDR_SIZE;
5467 roam_offload_11r =
5468 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5469 roam_offload_11r->r0kh_id_len =
5470 roam_req->rokh_id_length;
5471 qdf_mem_copy(roam_offload_11r->r0kh_id,
5472 roam_req->rokh_id,
5473 roam_offload_11r->r0kh_id_len);
5474 qdf_mem_copy(roam_offload_11r->psk_msk,
5475 roam_req->psk_pmk,
5476 sizeof(roam_req->psk_pmk));
5477 roam_offload_11r->psk_msk_len =
5478 roam_req->pmk_len;
5479 roam_offload_11r->mdie_present =
5480 roam_req->mdid.mdie_present;
5481 roam_offload_11r->mdid =
5482 roam_req->mdid.mobility_domain;
5483 if (auth_mode == WMI_AUTH_OPEN) {
5484 /* If FT-Open ensure pmk length
5485 and r0khid len are zero */
5486 roam_offload_11r->r0kh_id_len = 0;
5487 roam_offload_11r->psk_msk_len = 0;
5488 }
5489 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5490 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5491 WMITLV_GET_STRUCT_TLVLEN
5492 (wmi_roam_11r_offload_tlv_param));
5493 buf_ptr +=
5494 sizeof(wmi_roam_11r_offload_tlv_param);
5495 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5496 WMITLV_GET_STRUCT_TLVLEN(0));
5497 buf_ptr += WMI_TLV_HDR_SIZE;
5498 } else {
5499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5500 sizeof(wmi_roam_11i_offload_tlv_param));
5501 buf_ptr += WMI_TLV_HDR_SIZE;
5502 roam_offload_11i =
5503 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005504
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005505 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005506 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305507 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5508 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005509 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305510 } else {
5511 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5512 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005513 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005514 }
5515 if (roam_req->roam_key_mgmt_offload_enabled &&
5516 roam_req->fw_pmksa_cache) {
5517 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
5518 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005519 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005520 } else {
5521 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
5522 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005523 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305524 }
5525
5526 qdf_mem_copy(roam_offload_11i->pmk,
5527 roam_req->psk_pmk,
5528 sizeof(roam_req->psk_pmk));
5529 roam_offload_11i->pmk_len = roam_req->pmk_len;
5530 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5531 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5532 WMITLV_GET_STRUCT_TLVLEN
5533 (wmi_roam_11i_offload_tlv_param));
5534 buf_ptr +=
5535 sizeof(wmi_roam_11i_offload_tlv_param);
5536 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5537 0);
5538 buf_ptr += WMI_TLV_HDR_SIZE;
5539 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5540 0);
5541 buf_ptr += WMI_TLV_HDR_SIZE;
5542 }
5543 } else {
5544 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5545 WMITLV_GET_STRUCT_TLVLEN(0));
5546 buf_ptr += WMI_TLV_HDR_SIZE;
5547 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5548 WMITLV_GET_STRUCT_TLVLEN(0));
5549 buf_ptr += WMI_TLV_HDR_SIZE;
5550 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5551 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305552 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305553 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305554
5555 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5556 sizeof(*assoc_ies));
5557 buf_ptr += WMI_TLV_HDR_SIZE;
5558
5559 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5560 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5561 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5562 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5563 assoc_ies->buf_len = roam_req->assoc_ie_length;
5564
5565 buf_ptr += sizeof(*assoc_ies);
5566
5567 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5568 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5569 buf_ptr += WMI_TLV_HDR_SIZE;
5570
5571 if (assoc_ies->buf_len != 0) {
5572 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5573 assoc_ies->buf_len);
5574 }
5575
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305576 } else {
5577 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5578 WMITLV_GET_STRUCT_TLVLEN(0));
5579 buf_ptr += WMI_TLV_HDR_SIZE;
5580 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5581 WMITLV_GET_STRUCT_TLVLEN(0));
5582 buf_ptr += WMI_TLV_HDR_SIZE;
5583 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5584 WMITLV_GET_STRUCT_TLVLEN(0));
5585 buf_ptr += WMI_TLV_HDR_SIZE;
5586 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5587 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305588 buf_ptr += WMI_TLV_HDR_SIZE;
5589 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5590 WMITLV_GET_STRUCT_TLVLEN(0));
5591 buf_ptr += WMI_TLV_HDR_SIZE;
5592 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5593 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305594 }
5595#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305596
5597send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305598 status = wmi_unified_cmd_send(wmi_handle, buf,
5599 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305600 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305601 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305602 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5603 status);
5604 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305605 }
5606
Govind Singh67922e82016-04-01 16:48:57 +05305607 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305608}
5609
5610
5611/**
5612 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5613 * rssi threashold
5614 * @wmi_handle: wmi handle
5615 * @roam_req: Roaming request buffer
5616 *
5617 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5618 *
5619 * Return: QDF status
5620 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305621static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305622 struct roam_offload_scan_rssi_params *roam_req)
5623{
5624 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305625 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305626 int len;
5627 uint8_t *buf_ptr;
5628 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5629 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5630 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305631 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305632
5633 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5634 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5635 len += sizeof(wmi_roam_scan_extended_threshold_param);
5636 len += WMI_TLV_HDR_SIZE;
5637 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305638 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5639 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305640 buf = wmi_buf_alloc(wmi_handle, len);
5641 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305642 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305643 return QDF_STATUS_E_NOMEM;
5644 }
5645
5646 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5647 rssi_threshold_fp =
5648 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5649 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5650 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5651 WMITLV_GET_STRUCT_TLVLEN
5652 (wmi_roam_scan_rssi_threshold_fixed_param));
5653 /* fill in threshold values */
5654 rssi_threshold_fp->vdev_id = roam_req->session_id;
5655 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5656 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5657 rssi_threshold_fp->hirssi_scan_max_count =
5658 roam_req->hi_rssi_scan_max_count;
5659 rssi_threshold_fp->hirssi_scan_delta =
5660 roam_req->hi_rssi_scan_rssi_delta;
5661 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5662
5663 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5664 WMITLV_SET_HDR(buf_ptr,
5665 WMITLV_TAG_ARRAY_STRUC,
5666 sizeof(wmi_roam_scan_extended_threshold_param));
5667 buf_ptr += WMI_TLV_HDR_SIZE;
5668 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5669
5670 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5671 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5672 ext_thresholds->boost_threshold_5g =
5673 roam_req->boost_threshold_5g;
5674
5675 ext_thresholds->boost_algorithm_5g =
5676 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5677 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5678 ext_thresholds->penalty_algorithm_5g =
5679 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5680 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5681 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5682 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5683 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5684
5685 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5686 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5687 WMITLV_GET_STRUCT_TLVLEN
5688 (wmi_roam_scan_extended_threshold_param));
5689 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5690 WMITLV_SET_HDR(buf_ptr,
5691 WMITLV_TAG_ARRAY_STRUC,
5692 sizeof(wmi_roam_earlystop_rssi_thres_param));
5693 buf_ptr += WMI_TLV_HDR_SIZE;
5694 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5695 early_stop_thresholds->roam_earlystop_thres_min =
5696 roam_req->roam_earlystop_thres_min;
5697 early_stop_thresholds->roam_earlystop_thres_max =
5698 roam_req->roam_earlystop_thres_max;
5699 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5700 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5701 WMITLV_GET_STRUCT_TLVLEN
5702 (wmi_roam_earlystop_rssi_thres_param));
5703
Gupta, Kapil7e652922016-04-12 15:02:00 +05305704 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5705 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5706 sizeof(wmi_roam_dense_thres_param));
5707 buf_ptr += WMI_TLV_HDR_SIZE;
5708 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5709 dense_thresholds->roam_dense_rssi_thres_offset =
5710 roam_req->dense_rssi_thresh_offset;
5711 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5712 dense_thresholds->roam_dense_traffic_thres =
5713 roam_req->traffic_threshold;
5714 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5715 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5716 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5717 WMITLV_GET_STRUCT_TLVLEN
5718 (wmi_roam_dense_thres_param));
5719
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305720 status = wmi_unified_cmd_send(wmi_handle, buf,
5721 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305722 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305723 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305724 status);
5725 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305726 }
5727
Govind Singh67922e82016-04-01 16:48:57 +05305728 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305729}
5730
5731/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305732 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5733 * configuration params
5734 * @wma_handle: wma handler
5735 * @dwelltime_params: pointer to dwelltime_params
5736 *
5737 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5738 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005739static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305740QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5741 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5742{
5743 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5744 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5745 wmi_buf_t buf;
5746 uint8_t *buf_ptr;
5747 int32_t err;
5748 int len;
5749
5750 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5751 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5752 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5753 buf = wmi_buf_alloc(wmi_handle, len);
5754 if (!buf) {
5755 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5756 __func__);
5757 return QDF_STATUS_E_NOMEM;
5758 }
5759 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5760 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5761 WMITLV_SET_HDR(&dwell_param->tlv_header,
5762 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5763 WMITLV_GET_STRUCT_TLVLEN
5764 (wmi_scan_adaptive_dwell_config_fixed_param));
5765
5766 dwell_param->enable = dwelltime_params->is_enabled;
5767 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5768 WMITLV_SET_HDR(buf_ptr,
5769 WMITLV_TAG_ARRAY_STRUC,
5770 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5771 buf_ptr += WMI_TLV_HDR_SIZE;
5772
5773 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5774 WMITLV_SET_HDR(&cmd->tlv_header,
5775 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5776 WMITLV_GET_STRUCT_TLVLEN(
5777 wmi_scan_adaptive_dwell_parameters_tlv));
5778
5779 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5780 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5781 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5782 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5783 err = wmi_unified_cmd_send(wmi_handle, buf,
5784 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5785 if (err) {
5786 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5787 wmi_buf_free(buf);
5788 return QDF_STATUS_E_FAILURE;
5789 }
5790
5791 return QDF_STATUS_SUCCESS;
5792}
5793
Nitesh Shah52323d02017-05-22 15:49:00 +05305794/**
5795 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
5796 * configuration params
5797 * @wmi_handle: wmi handler
5798 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
5799 *
5800 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5801 */
5802static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
5803 struct wmi_dbs_scan_sel_params *dbs_scan_params)
5804{
5805 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
5806 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
5807 wmi_buf_t buf;
5808 uint8_t *buf_ptr;
5809 QDF_STATUS err;
5810 uint32_t i;
5811 int len;
5812
5813 len = sizeof(*dbs_scan_param);
5814 len += WMI_TLV_HDR_SIZE;
5815 len += dbs_scan_params->num_clients * sizeof(*cmd);
5816
5817 buf = wmi_buf_alloc(wmi_handle, len);
5818 if (!buf) {
5819 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
5820 return QDF_STATUS_E_NOMEM;
5821 }
5822
5823 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5824 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
5825 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
5826 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
5827 WMITLV_GET_STRUCT_TLVLEN
5828 (wmi_scan_dbs_duty_cycle_fixed_param));
5829
5830 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
5831 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
5832 buf_ptr += sizeof(*dbs_scan_param);
5833 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5834 (sizeof(*cmd) * dbs_scan_params->num_clients));
5835 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
5836
5837 for (i = 0; i < dbs_scan_params->num_clients; i++) {
5838 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
5839 WMITLV_SET_HDR(&cmd->tlv_header,
5840 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
5841 WMITLV_GET_STRUCT_TLVLEN(
5842 wmi_scan_dbs_duty_cycle_tlv_param));
5843 cmd->module_id = dbs_scan_params->module_id[i];
5844 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
5845 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
5846 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
5847 }
5848
5849 err = wmi_unified_cmd_send(wmi_handle, buf,
5850 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
5851 if (QDF_IS_STATUS_ERROR(err)) {
5852 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
5853 wmi_buf_free(buf);
5854 return QDF_STATUS_E_FAILURE;
5855 }
5856
5857 return QDF_STATUS_SUCCESS;
5858}
Gupta, Kapil2e685982016-04-25 19:14:19 +05305859
5860/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305861 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5862 * @wmi_handle: wmi handle
5863 * @roam_req: Request which contains the filters
5864 *
5865 * There are filters such as whitelist, blacklist and preferred
5866 * list that need to be applied to the scan results to form the
5867 * probable candidates for roaming.
5868 *
5869 * Return: Return success upon succesfully passing the
5870 * parameters to the firmware, otherwise failure.
5871 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305872static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305873 struct roam_scan_filter_params *roam_req)
5874{
5875 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305876 QDF_STATUS status;
5877 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305878 uint32_t len;
5879 uint8_t *buf_ptr;
5880 wmi_roam_filter_fixed_param *roam_filter;
5881 uint8_t *bssid_src_ptr = NULL;
5882 wmi_mac_addr *bssid_dst_ptr = NULL;
5883 wmi_ssid *ssid_ptr = NULL;
5884 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05305885 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305886
5887 len = sizeof(wmi_roam_filter_fixed_param);
5888 len += WMI_TLV_HDR_SIZE;
5889 len += roam_req->len;
5890
5891 buf = wmi_buf_alloc(wmi_handle, len);
5892 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305893 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305894 return QDF_STATUS_E_NOMEM;
5895 }
5896
5897 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5898 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5899 WMITLV_SET_HDR(&roam_filter->tlv_header,
5900 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5901 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5902 /* fill in fixed values */
5903 roam_filter->vdev_id = roam_req->session_id;
5904 roam_filter->flags = 0;
5905 roam_filter->op_bitmap = roam_req->op_bitmap;
5906 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5907 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5908 roam_filter->num_bssid_preferred_list =
5909 roam_req->num_bssid_preferred_list;
5910 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5911
5912 WMITLV_SET_HDR((buf_ptr),
5913 WMITLV_TAG_ARRAY_FIXED_STRUC,
5914 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5915 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5916 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5917 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5918 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5919 bssid_src_ptr += ATH_MAC_LEN;
5920 bssid_dst_ptr++;
5921 }
5922 buf_ptr += WMI_TLV_HDR_SIZE +
5923 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5924 WMITLV_SET_HDR((buf_ptr),
5925 WMITLV_TAG_ARRAY_FIXED_STRUC,
5926 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5927 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5928 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5929 qdf_mem_copy(&ssid_ptr->ssid,
5930 &roam_req->ssid_allowed_list[i].mac_ssid,
5931 roam_req->ssid_allowed_list[i].length);
5932 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5933 ssid_ptr++;
5934 }
5935 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5936 sizeof(wmi_ssid));
5937 WMITLV_SET_HDR((buf_ptr),
5938 WMITLV_TAG_ARRAY_FIXED_STRUC,
5939 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5940 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5941 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5942 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5943 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5944 (wmi_mac_addr *)bssid_dst_ptr);
5945 bssid_src_ptr += ATH_MAC_LEN;
5946 bssid_dst_ptr++;
5947 }
5948 buf_ptr += WMI_TLV_HDR_SIZE +
5949 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5950 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5951 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5952 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5953 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5954 *bssid_preferred_factor_ptr =
5955 roam_req->bssid_favored_factor[i];
5956 bssid_preferred_factor_ptr++;
5957 }
5958 buf_ptr += WMI_TLV_HDR_SIZE +
5959 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5960
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05305961 if (roam_req->lca_disallow_config_present) {
5962 WMITLV_SET_HDR(buf_ptr,
5963 WMITLV_TAG_ARRAY_STRUC,
5964 sizeof(wmi_roam_lca_disallow_config_tlv_param));
5965 buf_ptr += WMI_TLV_HDR_SIZE;
5966 blist_param =
5967 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
5968 WMITLV_SET_HDR(&blist_param->tlv_header,
5969 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
5970 WMITLV_GET_STRUCT_TLVLEN(
5971 wmi_roam_lca_disallow_config_tlv_param));
5972
5973 blist_param->disallow_duration = roam_req->disallow_duration;
5974 blist_param->rssi_channel_penalization =
5975 roam_req->rssi_channel_penalization;
5976 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
5977 blist_param->disallow_lca_enable_source_bitmap = 0x1;
5978 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
5979 }
5980
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305981 status = wmi_unified_cmd_send(wmi_handle, buf,
5982 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305983 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305984 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305985 status);
5986 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305987 }
Govind Singh67922e82016-04-01 16:48:57 +05305988
5989 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305990}
5991
Govind Singh4eacd2b2016-03-07 14:24:22 +05305992/** send_set_epno_network_list_cmd_tlv() - set epno network list
5993 * @wmi_handle: wmi handle
5994 * @req: epno config params request structure
5995 *
5996 * This function reads the incoming epno config request structure
5997 * and constructs the WMI message to the firmware.
5998 *
5999 * Returns: 0 on success, error number otherwise
6000 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306001static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306002 struct wifi_enhanched_pno_params *req)
6003{
6004 wmi_nlo_config_cmd_fixed_param *cmd;
6005 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306006 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306007 u_int8_t i, *buf_ptr;
6008 wmi_buf_t buf;
6009 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05306010 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306011
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306012 /* Fixed Params */
6013 len = sizeof(*cmd);
6014 if (req->num_networks) {
6015 /* TLV place holder for array of structures
6016 * then each nlo_configured_parameters(nlo_list) TLV.
6017 */
6018 len += WMI_TLV_HDR_SIZE;
6019 len += (sizeof(nlo_configured_parameters)
6020 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
6021 /* TLV for array of uint32 channel_list */
6022 len += WMI_TLV_HDR_SIZE;
6023 /* TLV for nlo_channel_prediction_cfg */
6024 len += WMI_TLV_HDR_SIZE;
6025 /* TLV for candidate score params */
6026 len += sizeof(enlo_candidate_score_params);
6027 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05306028
6029 buf = wmi_buf_alloc(wmi_handle, len);
6030 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306031 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6032 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306033 }
6034
6035 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6036
6037 buf_ptr = (u_int8_t *) cmd;
6038 WMITLV_SET_HDR(&cmd->tlv_header,
6039 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6040 WMITLV_GET_STRUCT_TLVLEN(
6041 wmi_nlo_config_cmd_fixed_param));
6042 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306043
6044 /* set flag to reset if num of networks are 0 */
6045 cmd->flags = (req->num_networks == 0 ?
6046 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306047
6048 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6049
Govind Singhb53420c2016-03-09 14:32:57 +05306050 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306051 WMI_LOGD("SSID count: %d flags: %d",
6052 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306053
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306054 /* Fill nlo_config only when num_networks are non zero */
6055 if (cmd->no_of_ssids) {
6056 /* Fill networks */
6057 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6058 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6059 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306060
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306061 nlo_list = (nlo_configured_parameters *) buf_ptr;
6062 for (i = 0; i < cmd->no_of_ssids; i++) {
6063 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6064 WMITLV_TAG_ARRAY_BYTE,
6065 WMITLV_GET_STRUCT_TLVLEN(
6066 nlo_configured_parameters));
6067 /* Copy ssid and it's length */
6068 nlo_list[i].ssid.valid = true;
6069 nlo_list[i].ssid.ssid.ssid_len =
6070 req->networks[i].ssid.length;
6071 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
6072 req->networks[i].ssid.mac_ssid,
6073 nlo_list[i].ssid.ssid.ssid_len);
6074 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
6075 nlo_list[i].ssid.ssid.ssid_len,
6076 (char *) nlo_list[i].ssid.ssid.ssid,
6077 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306078
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306079 /* Copy pno flags */
6080 nlo_list[i].bcast_nw_type.valid = true;
6081 nlo_list[i].bcast_nw_type.bcast_nw_type =
6082 req->networks[i].flags;
6083 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306084 nlo_list[i].bcast_nw_type.bcast_nw_type);
6085
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306086 /* Copy auth bit field */
6087 nlo_list[i].auth_type.valid = true;
6088 nlo_list[i].auth_type.auth_type =
6089 req->networks[i].auth_bit_field;
6090 WMI_LOGD("Auth bit field (%u)",
6091 nlo_list[i].auth_type.auth_type);
6092 }
6093
6094 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6095 /* Fill the channel list */
6096 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6097 buf_ptr += WMI_TLV_HDR_SIZE;
6098
6099 /* Fill prediction_param */
6100 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6101 buf_ptr += WMI_TLV_HDR_SIZE;
6102
6103 /* Fill epno candidate score params */
6104 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
6105 WMITLV_SET_HDR(buf_ptr,
6106 WMITLV_TAG_STRUC_enlo_candidate_score_param,
6107 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
6108 cand_score_params->min5GHz_rssi =
6109 req->min_5ghz_rssi;
6110 cand_score_params->min24GHz_rssi =
6111 req->min_24ghz_rssi;
6112 cand_score_params->initial_score_max =
6113 req->initial_score_max;
6114 cand_score_params->current_connection_bonus =
6115 req->current_connection_bonus;
6116 cand_score_params->same_network_bonus =
6117 req->same_network_bonus;
6118 cand_score_params->secure_bonus =
6119 req->secure_bonus;
6120 cand_score_params->band5GHz_bonus =
6121 req->band_5ghz_bonus;
6122 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306123 }
6124
Govind Singh4eacd2b2016-03-07 14:24:22 +05306125 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306126 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306127 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306128 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306129 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306130 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306131 }
6132
Govind Singhb53420c2016-03-09 14:32:57 +05306133 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306134 req->session_id);
6135
Govind Singh67922e82016-04-01 16:48:57 +05306136 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306137}
6138
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306139
Govind Singh4eacd2b2016-03-07 14:24:22 +05306140/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
6141 * @wmi_handle: wmi handle
6142 * @ipa_offload: ipa offload control parameter
6143 *
6144 * Returns: 0 on success, error number otherwise
6145 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306146static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306147 struct ipa_offload_control_params *ipa_offload)
6148{
6149 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
6150 wmi_buf_t wmi_buf;
6151 uint32_t len;
6152 u_int8_t *buf_ptr;
6153
6154 len = sizeof(*cmd);
6155 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6156 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306157 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
6158 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306159 }
6160
Govind Singhb53420c2016-03-09 14:32:57 +05306161 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306162 ipa_offload->offload_type, ipa_offload->enable);
6163
6164 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
6165
6166 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
6167 WMITLV_SET_HDR(&cmd->tlv_header,
6168 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
6169 WMITLV_GET_STRUCT_TLVLEN(
6170 wmi_ipa_offload_enable_disable_cmd_fixed_param));
6171
6172 cmd->offload_type = ipa_offload->offload_type;
6173 cmd->vdev_id = ipa_offload->vdev_id;
6174 cmd->enable = ipa_offload->enable;
6175
6176 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6177 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306178 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306179 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306180 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306181 }
6182
Govind Singhb53420c2016-03-09 14:32:57 +05306183 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306184}
6185
6186/**
6187 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
6188 * @wmi_handle: wmi handle
6189 * @pgetcapab: get capabilities params
6190 *
6191 * This function send request to fw to get extscan capabilities.
6192 *
6193 * Return: CDF status
6194 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306195static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306196 struct extscan_capabilities_params *pgetcapab)
6197{
6198 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
6199 wmi_buf_t wmi_buf;
6200 uint32_t len;
6201 uint8_t *buf_ptr;
6202
6203 len = sizeof(*cmd);
6204 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6205 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306206 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6207 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306208 }
6209 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6210
6211 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
6212 WMITLV_SET_HDR(&cmd->tlv_header,
6213 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
6214 WMITLV_GET_STRUCT_TLVLEN
6215 (wmi_extscan_get_capabilities_cmd_fixed_param));
6216
6217 cmd->request_id = pgetcapab->request_id;
6218
6219 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6220 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306221 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306222 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306223 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306224 }
Govind Singhb53420c2016-03-09 14:32:57 +05306225 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306226}
6227
6228/**
6229 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
6230 * @wmi_handle: wmi handle
6231 * @pcached_results: cached results parameters
6232 *
6233 * This function send request to fw to get cached results.
6234 *
6235 * Return: CDF status
6236 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306237static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306238 struct extscan_cached_result_params *pcached_results)
6239{
6240 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
6241 wmi_buf_t wmi_buf;
6242 uint32_t len;
6243 uint8_t *buf_ptr;
6244
6245 len = sizeof(*cmd);
6246 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6247 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306248 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6249 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306250 }
6251 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6252
6253 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6254 WMITLV_SET_HDR(&cmd->tlv_header,
6255 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6256 WMITLV_GET_STRUCT_TLVLEN
6257 (wmi_extscan_get_cached_results_cmd_fixed_param));
6258
6259 cmd->request_id = pcached_results->request_id;
6260 cmd->vdev_id = pcached_results->session_id;
6261 cmd->control_flags = pcached_results->flush;
6262
6263 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6264 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306265 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306266 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306267 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306268 }
Govind Singhb53420c2016-03-09 14:32:57 +05306269 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306270}
6271
6272/**
6273 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6274 * @wmi_handle: wmi handle
6275 * @reset_req: Reset change request params
6276 *
6277 * This function sends stop change monitor request to fw.
6278 *
6279 * Return: CDF status
6280 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306281static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306282 struct extscan_capabilities_reset_params *reset_req)
6283{
6284 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6285 wmi_buf_t wmi_buf;
6286 uint32_t len;
6287 uint8_t *buf_ptr;
6288 int change_list = 0;
6289
6290 len = sizeof(*cmd);
6291
6292 /* reset significant change tlv is set to 0 */
6293 len += WMI_TLV_HDR_SIZE;
6294 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6295 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6296 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306297 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6298 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306299 }
6300 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6301
6302 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6303 buf_ptr;
6304 WMITLV_SET_HDR(&cmd->tlv_header,
6305 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6306 WMITLV_GET_STRUCT_TLVLEN
6307 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6308
6309 cmd->request_id = reset_req->request_id;
6310 cmd->vdev_id = reset_req->session_id;
6311 cmd->mode = 0;
6312
6313 buf_ptr += sizeof(*cmd);
6314 WMITLV_SET_HDR(buf_ptr,
6315 WMITLV_TAG_ARRAY_STRUC,
6316 change_list *
6317 sizeof(wmi_extscan_wlan_change_bssid_param));
6318 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6319 sizeof
6320 (wmi_extscan_wlan_change_bssid_param));
6321
6322 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6323 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306324 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306325 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306326 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306327 }
Govind Singhb53420c2016-03-09 14:32:57 +05306328 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306329}
6330
6331/**
6332 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6333 * @wmi_handle: wmi handle
6334 * @psigchange: change monitor request params
6335 * @buf: wmi buffer
6336 * @buf_len: buffer length
6337 *
6338 * This function fills elements of change monitor request buffer.
6339 *
6340 * Return: CDF status
6341 */
Govind Singhb53420c2016-03-09 14:32:57 +05306342static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306343 struct extscan_set_sig_changereq_params
6344 *psigchange, wmi_buf_t *buf, int *buf_len)
6345{
6346 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6347 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6348 uint8_t *buf_ptr;
6349 int j;
6350 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006351 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306352 struct ap_threshold_params *src_ap = psigchange->ap;
6353
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006354 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306355 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6356 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306357 }
6358 len += WMI_TLV_HDR_SIZE;
6359 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6360
6361 *buf = wmi_buf_alloc(wmi_handle, len);
6362 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306363 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306364 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306365 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306366 }
6367 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6368 cmd =
6369 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6370 buf_ptr;
6371 WMITLV_SET_HDR(&cmd->tlv_header,
6372 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6373 WMITLV_GET_STRUCT_TLVLEN
6374 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6375
6376 cmd->request_id = psigchange->request_id;
6377 cmd->vdev_id = psigchange->session_id;
6378 cmd->total_entries = numap;
6379 cmd->mode = 1;
6380 cmd->num_entries_in_page = numap;
6381 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6382 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6383 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6384 cmd->max_out_of_range_count = psigchange->min_breaching;
6385
6386 buf_ptr += sizeof(*cmd);
6387 WMITLV_SET_HDR(buf_ptr,
6388 WMITLV_TAG_ARRAY_STRUC,
6389 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6390 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6391 (buf_ptr + WMI_TLV_HDR_SIZE);
6392
6393 for (j = 0; j < numap; j++) {
6394 WMITLV_SET_HDR(dest_chglist,
6395 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6396 WMITLV_GET_STRUCT_TLVLEN
6397 (wmi_extscan_wlan_change_bssid_param));
6398
6399 dest_chglist->lower_rssi_limit = src_ap->low;
6400 dest_chglist->upper_rssi_limit = src_ap->high;
6401 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6402 &dest_chglist->bssid);
6403
Govind Singhb53420c2016-03-09 14:32:57 +05306404 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306405 dest_chglist->lower_rssi_limit);
6406 dest_chglist++;
6407 src_ap++;
6408 }
6409 buf_ptr += WMI_TLV_HDR_SIZE +
6410 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6411 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306412 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306413}
6414
6415/**
6416 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6417 * @wmi_handle: wmi handle
6418 * @psigchange: change monitor request params
6419 *
6420 * This function sends start change monitor request to fw.
6421 *
6422 * Return: CDF status
6423 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306424static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306425 struct extscan_set_sig_changereq_params *
6426 psigchange)
6427{
Govind Singhb53420c2016-03-09 14:32:57 +05306428 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306429 wmi_buf_t buf;
6430 int len;
6431
6432
Govind Singhb53420c2016-03-09 14:32:57 +05306433 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306434 psigchange, &buf,
6435 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306436 if (qdf_status != QDF_STATUS_SUCCESS) {
6437 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306438 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306439 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306440 }
6441 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306442 WMI_LOGE("%s: Failed to get buffer", __func__);
6443 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306444 }
6445 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6446 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306447 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306448 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306449 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306450 }
Govind Singhb53420c2016-03-09 14:32:57 +05306451 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306452}
6453
6454/**
6455 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6456 * @wmi_handle: wmi handle
6457 * @photlist_reset: hotlist reset params
6458 *
6459 * This function configures hotlist monitor to stop in fw.
6460 *
6461 * Return: CDF status
6462 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306463static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306464 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6465{
6466 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6467 wmi_buf_t wmi_buf;
6468 uint32_t len;
6469 uint8_t *buf_ptr;
6470 int hotlist_entries = 0;
6471
6472 len = sizeof(*cmd);
6473
6474 /* reset bssid hotlist with tlv set to 0 */
6475 len += WMI_TLV_HDR_SIZE;
6476 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6477
6478 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6479 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306480 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6481 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306482 }
6483
6484 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6485 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6486 buf_ptr;
6487 WMITLV_SET_HDR(&cmd->tlv_header,
6488 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6489 WMITLV_GET_STRUCT_TLVLEN
6490 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6491
6492 cmd->request_id = photlist_reset->request_id;
6493 cmd->vdev_id = photlist_reset->session_id;
6494 cmd->mode = 0;
6495
6496 buf_ptr += sizeof(*cmd);
6497 WMITLV_SET_HDR(buf_ptr,
6498 WMITLV_TAG_ARRAY_STRUC,
6499 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6500 buf_ptr += WMI_TLV_HDR_SIZE +
6501 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6502
6503 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6504 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306505 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306506 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306507 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306508 }
Govind Singhb53420c2016-03-09 14:32:57 +05306509 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306510}
6511
6512/**
6513 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6514 * @wmi_handle: wmi handle
6515 * @pstopcmd: stop scan command request params
6516 *
6517 * This function sends stop extscan request to fw.
6518 *
6519 * Return: CDF Status.
6520 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306521static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306522 struct extscan_stop_req_params *pstopcmd)
6523{
6524 wmi_extscan_stop_cmd_fixed_param *cmd;
6525 wmi_buf_t wmi_buf;
6526 uint32_t len;
6527 uint8_t *buf_ptr;
6528
6529 len = sizeof(*cmd);
6530 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6531 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306532 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6533 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306534 }
6535 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6536 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6537 WMITLV_SET_HDR(&cmd->tlv_header,
6538 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6539 WMITLV_GET_STRUCT_TLVLEN
6540 (wmi_extscan_stop_cmd_fixed_param));
6541
6542 cmd->request_id = pstopcmd->request_id;
6543 cmd->vdev_id = pstopcmd->session_id;
6544
6545 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6546 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306547 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306548 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306549 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306550 }
6551
Govind Singhb53420c2016-03-09 14:32:57 +05306552 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306553}
6554
6555/**
6556 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6557 * @wmi_handle: wmi handle
6558 * @pstart: scan command request params
6559 * @buf: event buffer
6560 * @buf_len: length of buffer
6561 *
6562 * This function fills individual elements of extscan request and
6563 * TLV for buckets, channel list.
6564 *
6565 * Return: CDF Status.
6566 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006567static
Govind Singhb53420c2016-03-09 14:32:57 +05306568QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306569 struct wifi_scan_cmd_req_params *pstart,
6570 wmi_buf_t *buf, int *buf_len)
6571{
6572 wmi_extscan_start_cmd_fixed_param *cmd;
6573 wmi_extscan_bucket *dest_blist;
6574 wmi_extscan_bucket_channel *dest_clist;
6575 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6576 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6577 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6578
6579 uint8_t *buf_ptr;
6580 int i, k, count = 0;
6581 int len = sizeof(*cmd);
6582 int nbuckets = pstart->numBuckets;
6583 int nchannels = 0;
6584
6585 /* These TLV's are are NULL by default */
6586 uint32_t ie_len_with_pad = 0;
6587 int num_ssid = 0;
6588 int num_bssid = 0;
6589 int ie_len = 0;
6590
6591 uint32_t base_period = pstart->basePeriod;
6592
6593 /* TLV placeholder for ssid_list (NULL) */
6594 len += WMI_TLV_HDR_SIZE;
6595 len += num_ssid * sizeof(wmi_ssid);
6596
6597 /* TLV placeholder for bssid_list (NULL) */
6598 len += WMI_TLV_HDR_SIZE;
6599 len += num_bssid * sizeof(wmi_mac_addr);
6600
6601 /* TLV placeholder for ie_data (NULL) */
6602 len += WMI_TLV_HDR_SIZE;
6603 len += ie_len * sizeof(uint32_t);
6604
6605 /* TLV placeholder for bucket */
6606 len += WMI_TLV_HDR_SIZE;
6607 len += nbuckets * sizeof(wmi_extscan_bucket);
6608
6609 /* TLV channel placeholder */
6610 len += WMI_TLV_HDR_SIZE;
6611 for (i = 0; i < nbuckets; i++) {
6612 nchannels += src_bucket->numChannels;
6613 src_bucket++;
6614 }
6615
Govind Singhb53420c2016-03-09 14:32:57 +05306616 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306617 __func__, nbuckets, nchannels);
6618 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6619 /* Allocate the memory */
6620 *buf = wmi_buf_alloc(wmi_handle, len);
6621 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306622 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306623 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306624 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306625 }
6626 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6627 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6628 WMITLV_SET_HDR(&cmd->tlv_header,
6629 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6630 WMITLV_GET_STRUCT_TLVLEN
6631 (wmi_extscan_start_cmd_fixed_param));
6632
6633 cmd->request_id = pstart->requestId;
6634 cmd->vdev_id = pstart->sessionId;
6635 cmd->base_period = pstart->basePeriod;
6636 cmd->num_buckets = nbuckets;
6637 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306638 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306639 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306640 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306641 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306642#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306643 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6644 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306645 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6646 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6647#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306648 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6649
6650 /* The max dwell time is retrieved from the first channel
6651 * of the first bucket and kept common for all channels.
6652 */
6653 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6654 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6655 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6656 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6657 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6658 cmd->max_table_usage = pstart->report_threshold_percent;
6659 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6660
6661 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306662 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306663 cmd->probe_delay = 0;
6664 cmd->probe_spacing_time = 0;
6665 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306666 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6667 WMI_SCAN_ADD_CCK_RATES |
6668 WMI_SCAN_ADD_OFDM_RATES |
6669 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6670 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306671 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6672 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306673 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306674 cmd->num_ssids = 0;
6675 cmd->num_bssid = 0;
6676 cmd->ie_len = 0;
6677 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6678 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6679
6680 buf_ptr += sizeof(*cmd);
6681 WMITLV_SET_HDR(buf_ptr,
6682 WMITLV_TAG_ARRAY_FIXED_STRUC,
6683 num_ssid * sizeof(wmi_ssid));
6684 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6685
6686 WMITLV_SET_HDR(buf_ptr,
6687 WMITLV_TAG_ARRAY_FIXED_STRUC,
6688 num_bssid * sizeof(wmi_mac_addr));
6689 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6690
6691 ie_len_with_pad = 0;
6692 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6693 ie_len_with_pad);
6694 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6695
6696 WMITLV_SET_HDR(buf_ptr,
6697 WMITLV_TAG_ARRAY_STRUC,
6698 nbuckets * sizeof(wmi_extscan_bucket));
6699 dest_blist = (wmi_extscan_bucket *)
6700 (buf_ptr + WMI_TLV_HDR_SIZE);
6701 src_bucket = pstart->buckets;
6702
6703 /* Retrieve scanning information from each bucket and
6704 * channels and send it to the target
6705 */
6706 for (i = 0; i < nbuckets; i++) {
6707 WMITLV_SET_HDR(dest_blist,
6708 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6709 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6710
6711 dest_blist->bucket_id = src_bucket->bucket;
6712 dest_blist->base_period_multiplier =
6713 src_bucket->period / base_period;
6714 dest_blist->min_period = src_bucket->period;
6715 dest_blist->max_period = src_bucket->max_period;
6716 dest_blist->exp_backoff = src_bucket->exponent;
6717 dest_blist->exp_max_step_count = src_bucket->step_count;
6718 dest_blist->channel_band = src_bucket->band;
6719 dest_blist->num_channels = src_bucket->numChannels;
6720 dest_blist->notify_extscan_events = 0;
6721
6722 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6723 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006724 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6725 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306726
6727 if (src_bucket->reportEvents &
6728 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6729 dest_blist->forwarding_flags =
6730 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6731 dest_blist->notify_extscan_events |=
6732 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6733 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6734 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6735 } else {
6736 dest_blist->forwarding_flags =
6737 WMI_EXTSCAN_NO_FORWARDING;
6738 }
6739
6740 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6741 dest_blist->configuration_flags = 0;
6742 else
6743 dest_blist->configuration_flags =
6744 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6745
Govind Singhb53420c2016-03-09 14:32:57 +05306746 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306747 __func__, dest_blist->notify_extscan_events,
6748 dest_blist->configuration_flags,
6749 dest_blist->forwarding_flags);
6750
6751 dest_blist->min_dwell_time_active =
6752 src_bucket->min_dwell_time_active;
6753 dest_blist->max_dwell_time_active =
6754 src_bucket->max_dwell_time_active;
6755 dest_blist->min_dwell_time_passive =
6756 src_bucket->min_dwell_time_passive;
6757 dest_blist->max_dwell_time_passive =
6758 src_bucket->max_dwell_time_passive;
6759 src_channel = src_bucket->channels;
6760
6761 /* save the channel info to later populate
6762 * the channel TLV
6763 */
6764 for (k = 0; k < src_bucket->numChannels; k++) {
6765 save_channel[count++].channel = src_channel->channel;
6766 src_channel++;
6767 }
6768 dest_blist++;
6769 src_bucket++;
6770 }
6771 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6772 WMITLV_SET_HDR(buf_ptr,
6773 WMITLV_TAG_ARRAY_STRUC,
6774 nchannels * sizeof(wmi_extscan_bucket_channel));
6775 dest_clist = (wmi_extscan_bucket_channel *)
6776 (buf_ptr + WMI_TLV_HDR_SIZE);
6777
6778 /* Active or passive scan is based on the bucket dwell time
6779 * and channel specific active,passive scans are not
6780 * supported yet
6781 */
6782 for (i = 0; i < nchannels; i++) {
6783 WMITLV_SET_HDR(dest_clist,
6784 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6785 WMITLV_GET_STRUCT_TLVLEN
6786 (wmi_extscan_bucket_channel));
6787 dest_clist->channel = save_channel[i].channel;
6788 dest_clist++;
6789 }
6790 buf_ptr += WMI_TLV_HDR_SIZE +
6791 (nchannels * sizeof(wmi_extscan_bucket_channel));
6792 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306793 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306794}
6795
6796/**
6797 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6798 * @wmi_handle: wmi handle
6799 * @pstart: scan command request params
6800 *
6801 * This function sends start extscan request to fw.
6802 *
6803 * Return: CDF Status.
6804 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306805static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306806 struct wifi_scan_cmd_req_params *pstart)
6807{
Govind Singhb53420c2016-03-09 14:32:57 +05306808 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306809 wmi_buf_t buf;
6810 int len;
6811
6812 /* Fill individual elements of extscan request and
6813 * TLV for buckets, channel list.
6814 */
Govind Singhb53420c2016-03-09 14:32:57 +05306815 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306816 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306817 if (qdf_status != QDF_STATUS_SUCCESS) {
6818 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6819 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306820 }
6821 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306822 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306823 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306824 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306825 }
6826 if (wmi_unified_cmd_send(wmi_handle, buf,
6827 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306828 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306829 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306830 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306831 }
6832
Govind Singhb53420c2016-03-09 14:32:57 +05306833 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306834}
6835
6836/**
6837 * send_plm_stop_cmd_tlv() - plm stop request
6838 * @wmi_handle: wmi handle
6839 * @plm: plm request parameters
6840 *
6841 * This function request FW to stop PLM.
6842 *
6843 * Return: CDF status
6844 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306845static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306846 const struct plm_req_params *plm)
6847{
6848 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6849 int32_t len;
6850 wmi_buf_t buf;
6851 uint8_t *buf_ptr;
6852 int ret;
6853
6854 len = sizeof(*cmd);
6855 buf = wmi_buf_alloc(wmi_handle, len);
6856 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306857 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6858 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306859 }
6860
6861 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6862
6863 buf_ptr = (uint8_t *) cmd;
6864
6865 WMITLV_SET_HDR(&cmd->tlv_header,
6866 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6867 WMITLV_GET_STRUCT_TLVLEN
6868 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6869
6870 cmd->vdev_id = plm->session_id;
6871
6872 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306873 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306874
6875 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6876 WMI_VDEV_PLMREQ_STOP_CMDID);
6877 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306878 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306879 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306880 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306881 }
6882
Govind Singhb53420c2016-03-09 14:32:57 +05306883 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306884}
6885
6886/**
6887 * send_plm_start_cmd_tlv() - plm start request
6888 * @wmi_handle: wmi handle
6889 * @plm: plm request parameters
6890 *
6891 * This function request FW to start PLM.
6892 *
6893 * Return: CDF status
6894 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306895static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306896 const struct plm_req_params *plm,
6897 uint32_t *gchannel_list)
6898{
6899 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6900 uint32_t *channel_list;
6901 int32_t len;
6902 wmi_buf_t buf;
6903 uint8_t *buf_ptr;
6904 uint8_t count;
6905 int ret;
6906
6907 /* TLV place holder for channel_list */
6908 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6909 len += sizeof(uint32_t) * plm->plm_num_ch;
6910
6911 buf = wmi_buf_alloc(wmi_handle, len);
6912 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306913 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6914 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306915 }
6916 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6917
6918 buf_ptr = (uint8_t *) cmd;
6919
6920 WMITLV_SET_HDR(&cmd->tlv_header,
6921 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6922 WMITLV_GET_STRUCT_TLVLEN
6923 (wmi_vdev_plmreq_start_cmd_fixed_param));
6924
6925 cmd->vdev_id = plm->session_id;
6926
6927 cmd->meas_token = plm->meas_token;
6928 cmd->dialog_token = plm->diag_token;
6929 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306930 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306931 cmd->off_duration = plm->meas_duration;
6932 cmd->burst_cycle = plm->burst_len;
6933 cmd->tx_power = plm->desired_tx_pwr;
6934 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6935 cmd->num_chans = plm->plm_num_ch;
6936
6937 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6938
Govind Singhb53420c2016-03-09 14:32:57 +05306939 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6940 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6941 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6942 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6943 WMI_LOGD("off_duration: %d", cmd->off_duration);
6944 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6945 WMI_LOGD("tx_power: %d", cmd->tx_power);
6946 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306947
6948 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6949 (cmd->num_chans * sizeof(uint32_t)));
6950
6951 buf_ptr += WMI_TLV_HDR_SIZE;
6952 if (cmd->num_chans) {
6953 channel_list = (uint32_t *) buf_ptr;
6954 for (count = 0; count < cmd->num_chans; count++) {
6955 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306956 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306957 channel_list[count] =
6958 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306959 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306960 }
6961 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6962 }
6963
6964 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6965 WMI_VDEV_PLMREQ_START_CMDID);
6966 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306967 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306968 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306969 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306970 }
6971
Govind Singhb53420c2016-03-09 14:32:57 +05306972 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306973}
6974
6975/**
6976 * send_pno_stop_cmd_tlv() - PNO stop request
6977 * @wmi_handle: wmi handle
6978 * @vdev_id: vdev id
6979 *
6980 * This function request FW to stop ongoing PNO operation.
6981 *
6982 * Return: CDF status
6983 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306984static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306985{
6986 wmi_nlo_config_cmd_fixed_param *cmd;
6987 int32_t len = sizeof(*cmd);
6988 wmi_buf_t buf;
6989 uint8_t *buf_ptr;
6990 int ret;
6991
6992 /*
6993 * TLV place holder for array of structures nlo_configured_parameters
6994 * TLV place holder for array of uint32_t channel_list
6995 * TLV place holder for chnl prediction cfg
6996 */
6997 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6998 buf = wmi_buf_alloc(wmi_handle, len);
6999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307000 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7001 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307002 }
7003
7004 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7005 buf_ptr = (uint8_t *) cmd;
7006
7007 WMITLV_SET_HDR(&cmd->tlv_header,
7008 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7009 WMITLV_GET_STRUCT_TLVLEN
7010 (wmi_nlo_config_cmd_fixed_param));
7011
7012 cmd->vdev_id = vdev_id;
7013 cmd->flags = WMI_NLO_CONFIG_STOP;
7014 buf_ptr += sizeof(*cmd);
7015
7016 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7017 buf_ptr += WMI_TLV_HDR_SIZE;
7018
7019 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7020 buf_ptr += WMI_TLV_HDR_SIZE;
7021
7022 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7023 buf_ptr += WMI_TLV_HDR_SIZE;
7024
7025
7026 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7027 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7028 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307029 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307030 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307031 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307032 }
7033
Govind Singhb53420c2016-03-09 14:32:57 +05307034 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307035}
7036
7037/**
Govind Singhccb0c272016-04-01 16:30:08 +05307038 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7039 * @buf_ptr: Buffer passed by upper layers
7040 * @pno: Buffer to be sent to the firmware
7041 *
7042 * Copy the PNO Channel prediction configuration parameters
7043 * passed by the upper layers to a WMI format TLV and send it
7044 * down to the firmware.
7045 *
7046 * Return: None
7047 */
7048static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7049 struct pno_scan_req_params *pno)
7050{
7051 nlo_channel_prediction_cfg *channel_prediction_cfg =
7052 (nlo_channel_prediction_cfg *) buf_ptr;
7053 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7054 WMITLV_TAG_ARRAY_BYTE,
7055 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307056#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307057 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7058 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7059 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7060 channel_prediction_cfg->full_scan_period_ms =
7061 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307062#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307063 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7064 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7065 channel_prediction_cfg->enable,
7066 channel_prediction_cfg->top_k_num,
7067 channel_prediction_cfg->stationary_threshold,
7068 channel_prediction_cfg->full_scan_period_ms);
7069}
7070
7071/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307072 * send_pno_start_cmd_tlv() - PNO start request
7073 * @wmi_handle: wmi handle
7074 * @pno: PNO request
7075 *
7076 * This function request FW to start PNO request.
7077 * Request: CDF status
7078 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307079static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307080 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307081{
7082 wmi_nlo_config_cmd_fixed_param *cmd;
7083 nlo_configured_parameters *nlo_list;
7084 uint32_t *channel_list;
7085 int32_t len;
7086 wmi_buf_t buf;
7087 uint8_t *buf_ptr;
7088 uint8_t i;
7089 int ret;
7090
7091 /*
7092 * TLV place holder for array nlo_configured_parameters(nlo_list)
7093 * TLV place holder for array of uint32_t channel_list
7094 * TLV place holder for chnnl prediction cfg
7095 */
7096 len = sizeof(*cmd) +
7097 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7098
Abhishek Singh5987b632017-03-03 22:09:07 +05307099 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307100 WMI_NLO_MAX_CHAN);
7101 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307102 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307103 len += sizeof(nlo_channel_prediction_cfg);
7104
7105 buf = wmi_buf_alloc(wmi_handle, len);
7106 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307107 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7108 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307109 }
7110
7111 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7112
7113 buf_ptr = (uint8_t *) cmd;
7114 WMITLV_SET_HDR(&cmd->tlv_header,
7115 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7116 WMITLV_GET_STRUCT_TLVLEN
7117 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307118 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307119 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7120
Govind Singh87542482016-06-08 19:40:11 +05307121#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307122 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307123 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307124#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307125 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307126 cmd->active_dwell_time = pno->active_dwell_time;
7127 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307128
7129 /* Copy scan interval */
7130 cmd->fast_scan_period = pno->fast_scan_period;
7131 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007132 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307133 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007134 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307135 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307136 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307137 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307138
7139 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7140
Abhishek Singh5987b632017-03-03 22:09:07 +05307141 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307142 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307143 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7144 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7145 buf_ptr += WMI_TLV_HDR_SIZE;
7146
7147 nlo_list = (nlo_configured_parameters *) buf_ptr;
7148 for (i = 0; i < cmd->no_of_ssids; i++) {
7149 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7150 WMITLV_TAG_ARRAY_BYTE,
7151 WMITLV_GET_STRUCT_TLVLEN
7152 (nlo_configured_parameters));
7153 /* Copy ssid and it's length */
7154 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307155 nlo_list[i].ssid.ssid.ssid_len =
7156 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307157 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307158 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307159 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307160 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307161 nlo_list[i].ssid.ssid.ssid_len,
7162 (char *)nlo_list[i].ssid.ssid.ssid,
7163 nlo_list[i].ssid.ssid.ssid_len);
7164
7165 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307166 if (pno->networks_list[i].rssi_thresh &&
7167 pno->networks_list[i].rssi_thresh >
7168 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307169 nlo_list[i].rssi_cond.valid = true;
7170 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307171 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307172 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307173 nlo_list[i].rssi_cond.rssi);
7174 }
7175 nlo_list[i].bcast_nw_type.valid = true;
7176 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307177 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007178 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307179 nlo_list[i].bcast_nw_type.bcast_nw_type);
7180 }
7181 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7182
7183 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307184 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307185 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307186 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307187 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7188 (cmd->num_of_channels * sizeof(uint32_t)));
7189 buf_ptr += WMI_TLV_HDR_SIZE;
7190
7191 channel_list = (uint32_t *) buf_ptr;
7192 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307193 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307194
7195 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307196 channel_list[i] =
7197 wlan_chan_to_freq(pno->
7198 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307199
Govind Singhb53420c2016-03-09 14:32:57 +05307200 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307201 }
7202 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7203 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7204 sizeof(nlo_channel_prediction_cfg));
7205 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307206 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307207 buf_ptr += WMI_TLV_HDR_SIZE;
7208 /** TODO: Discrete firmware doesn't have command/option to configure
7209 * App IE which comes from wpa_supplicant as of part PNO start request.
7210 */
7211 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7212 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7213 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307214 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307215 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307216 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307217 }
7218
Govind Singhb53420c2016-03-09 14:32:57 +05307219 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307220}
7221
7222/* send_set_ric_req_cmd_tlv() - set ric request element
7223 * @wmi_handle: wmi handle
7224 * @msg: message
7225 * @is_add_ts: is addts required
7226 *
7227 * This function sets ric request element for 11r roaming.
7228 *
7229 * Return: CDF status
7230 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307231static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307232 void *msg, uint8_t is_add_ts)
7233{
7234 wmi_ric_request_fixed_param *cmd;
7235 wmi_ric_tspec *tspec_param;
7236 wmi_buf_t buf;
7237 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307238 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307239 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7240 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7241
7242 buf = wmi_buf_alloc(wmi_handle, len);
7243 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307244 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7245 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307246 }
7247
7248 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7249
7250 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7251 WMITLV_SET_HDR(&cmd->tlv_header,
7252 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7253 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7254 if (is_add_ts)
7255 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
7256 else
7257 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7258 cmd->num_ric_request = 1;
7259 cmd->is_add_ric = is_add_ts;
7260
7261 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7262 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7263
7264 buf_ptr += WMI_TLV_HDR_SIZE;
7265 tspec_param = (wmi_ric_tspec *) buf_ptr;
7266 WMITLV_SET_HDR(&tspec_param->tlv_header,
7267 WMITLV_TAG_STRUC_wmi_ric_tspec,
7268 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7269
7270 if (is_add_ts)
7271 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307272#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307273 else
7274 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307275#endif
7276 if (ptspecIE) {
7277 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307278#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307279 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7280 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307281#else
Govind Singh87542482016-06-08 19:40:11 +05307282 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7283 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307284#endif /* ANI_LITTLE_BIT_ENDIAN */
7285
Govind Singh87542482016-06-08 19:40:11 +05307286 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7287 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7288 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7289 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7290 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7291 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7292 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7293 tspec_param->min_data_rate = ptspecIE->minDataRate;
7294 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7295 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7296 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7297 tspec_param->delay_bound = ptspecIE->delayBound;
7298 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7299 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7300 tspec_param->medium_time = 0;
7301 }
Govind Singhb53420c2016-03-09 14:32:57 +05307302 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307303
7304 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7305 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307306 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307307 __func__);
7308 if (is_add_ts)
7309 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307310 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307311 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307312 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307313 }
7314
Govind Singhb53420c2016-03-09 14:32:57 +05307315 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307316}
7317
7318/**
7319 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7320 * @wmi_handle: wmi handle
7321 * @clear_req: ll stats clear request command params
7322 *
Govind Singhb53420c2016-03-09 14:32:57 +05307323 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307324 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307325static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307326 const struct ll_stats_clear_params *clear_req,
7327 uint8_t addr[IEEE80211_ADDR_LEN])
7328{
7329 wmi_clear_link_stats_cmd_fixed_param *cmd;
7330 int32_t len;
7331 wmi_buf_t buf;
7332 uint8_t *buf_ptr;
7333 int ret;
7334
7335 len = sizeof(*cmd);
7336 buf = wmi_buf_alloc(wmi_handle, len);
7337
7338 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307339 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7340 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307341 }
7342
7343 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307344 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307345 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7346
7347 WMITLV_SET_HDR(&cmd->tlv_header,
7348 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7349 WMITLV_GET_STRUCT_TLVLEN
7350 (wmi_clear_link_stats_cmd_fixed_param));
7351
7352 cmd->stop_stats_collection_req = clear_req->stop_req;
7353 cmd->vdev_id = clear_req->sta_id;
7354 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7355
7356 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7357 &cmd->peer_macaddr);
7358
Govind Singhb53420c2016-03-09 14:32:57 +05307359 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7360 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7361 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7362 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7363 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307364 cmd->peer_macaddr); */
7365
7366 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7367 WMI_CLEAR_LINK_STATS_CMDID);
7368 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307369 WMI_LOGE("%s: Failed to send clear link stats req", __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 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7375 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307376}
7377
7378/**
7379 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7380 * @wmi_handle: wmi handle
7381 * @setReq: ll stats set request command params
7382 *
Govind Singhb53420c2016-03-09 14:32:57 +05307383 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307384 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307385static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307386 const struct ll_stats_set_params *set_req)
7387{
7388 wmi_start_link_stats_cmd_fixed_param *cmd;
7389 int32_t len;
7390 wmi_buf_t buf;
7391 uint8_t *buf_ptr;
7392 int ret;
7393
7394 len = sizeof(*cmd);
7395 buf = wmi_buf_alloc(wmi_handle, len);
7396
7397 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307398 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7399 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307400 }
7401
7402 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307403 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307404 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7405
7406 WMITLV_SET_HDR(&cmd->tlv_header,
7407 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7408 WMITLV_GET_STRUCT_TLVLEN
7409 (wmi_start_link_stats_cmd_fixed_param));
7410
7411 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7412 cmd->aggressive_statistics_gathering =
7413 set_req->aggressive_statistics_gathering;
7414
Govind Singhb53420c2016-03-09 14:32:57 +05307415 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7416 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7417 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307418
7419 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7420 WMI_START_LINK_STATS_CMDID);
7421 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307422 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307423 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307424 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307425 }
7426
Govind Singhb53420c2016-03-09 14:32:57 +05307427 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307428}
7429
7430/**
7431 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7432 * @wmi_handle:wmi handle
7433 * @get_req:ll stats get request command params
7434 * @addr: mac address
7435 *
Govind Singhb53420c2016-03-09 14:32:57 +05307436 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307437 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307438static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307439 const struct ll_stats_get_params *get_req,
7440 uint8_t addr[IEEE80211_ADDR_LEN])
7441{
7442 wmi_request_link_stats_cmd_fixed_param *cmd;
7443 int32_t len;
7444 wmi_buf_t buf;
7445 uint8_t *buf_ptr;
7446 int ret;
7447
7448 len = sizeof(*cmd);
7449 buf = wmi_buf_alloc(wmi_handle, len);
7450
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307451 if (!buf) {
7452 WMI_LOGE("%s: buf allocation failed", __func__);
7453 return QDF_STATUS_E_NOMEM;
7454 }
7455
Govind Singh4eacd2b2016-03-07 14:24:22 +05307456 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307457 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307458 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7459
7460 WMITLV_SET_HDR(&cmd->tlv_header,
7461 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7462 WMITLV_GET_STRUCT_TLVLEN
7463 (wmi_request_link_stats_cmd_fixed_param));
7464
7465 cmd->request_id = get_req->req_id;
7466 cmd->stats_type = get_req->param_id_mask;
7467 cmd->vdev_id = get_req->sta_id;
7468
7469 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7470 &cmd->peer_macaddr);
7471
Govind Singhb53420c2016-03-09 14:32:57 +05307472 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007473 WMI_LOGD("Request ID : %u", cmd->request_id);
7474 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307475 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7476 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307477
7478 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7479 WMI_REQUEST_LINK_STATS_CMDID);
7480 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307481 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307482 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307483 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307484 }
7485
Govind Singhb53420c2016-03-09 14:32:57 +05307486 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307487}
7488
7489/**
7490 * send_get_stats_cmd_tlv() - get stats request
7491 * @wmi_handle: wmi handle
7492 * @get_stats_param: stats params
7493 * @addr: mac address
7494 *
7495 * Return: CDF status
7496 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307497static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307498 struct pe_stats_req *get_stats_param,
7499 uint8_t addr[IEEE80211_ADDR_LEN])
7500{
7501 wmi_buf_t buf;
7502 wmi_request_stats_cmd_fixed_param *cmd;
7503 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7504
7505 buf = wmi_buf_alloc(wmi_handle, len);
7506 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307507 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7508 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307509 }
7510
7511
7512 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7513 WMITLV_SET_HDR(&cmd->tlv_header,
7514 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7515 WMITLV_GET_STRUCT_TLVLEN
7516 (wmi_request_stats_cmd_fixed_param));
7517 cmd->stats_id =
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05307518 WMI_REQUEST_PDEV_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307519 cmd->vdev_id = get_stats_param->session_id;
7520 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307521 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307522 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7523 WMI_REQUEST_STATS_CMDID)) {
7524
Govind Singhb53420c2016-03-09 14:32:57 +05307525 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307526 __func__);
7527 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307528 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307529 }
7530
Govind Singhb53420c2016-03-09 14:32:57 +05307531 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307532
7533}
7534
Govind Singh20c5dac2016-03-07 15:33:31 +05307535/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05307536 * send_congestion_cmd_tlv() - send request to fw to get CCA
7537 * @wmi_handle: wmi handle
7538 * @vdev_id: vdev id
7539 *
7540 * Return: CDF status
7541 */
7542static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
7543 A_UINT8 vdev_id)
7544{
7545 wmi_buf_t buf;
7546 wmi_request_stats_cmd_fixed_param *cmd;
7547 uint8_t len;
7548 uint8_t *buf_ptr;
7549
7550 len = sizeof(*cmd);
7551 buf = wmi_buf_alloc(wmi_handle, len);
7552 if (!buf) {
7553 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7554 return QDF_STATUS_E_FAILURE;
7555 }
7556
7557 buf_ptr = wmi_buf_data(buf);
7558 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
7559 WMITLV_SET_HDR(&cmd->tlv_header,
7560 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7561 WMITLV_GET_STRUCT_TLVLEN
7562 (wmi_request_stats_cmd_fixed_param));
7563
7564 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
7565 cmd->vdev_id = vdev_id;
7566 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
7567 cmd->vdev_id, cmd->stats_id);
7568
7569 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7570 WMI_REQUEST_STATS_CMDID)) {
7571 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
7572 __func__);
7573 wmi_buf_free(buf);
7574 return QDF_STATUS_E_FAILURE;
7575 }
7576
7577 return QDF_STATUS_SUCCESS;
7578}
7579
7580/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307581 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7582 * @wmi_handle: wmi handle
7583 * @rssi_req: get RSSI request
7584 *
7585 * Return: CDF status
7586 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307587static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307588{
7589 wmi_buf_t buf;
7590 wmi_request_stats_cmd_fixed_param *cmd;
7591 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7592
7593 buf = wmi_buf_alloc(wmi_handle, len);
7594 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307595 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7596 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307597 }
7598
7599 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7600 WMITLV_SET_HDR(&cmd->tlv_header,
7601 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7602 WMITLV_GET_STRUCT_TLVLEN
7603 (wmi_request_stats_cmd_fixed_param));
7604 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7605 if (wmi_unified_cmd_send
7606 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307607 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307608 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307609 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307610 }
7611
Govind Singhb53420c2016-03-09 14:32:57 +05307612 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307613}
7614
7615/**
7616 * send_snr_cmd_tlv() - get RSSI from fw
7617 * @wmi_handle: wmi handle
7618 * @vdev_id: vdev id
7619 *
7620 * Return: CDF status
7621 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307622static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307623{
7624 wmi_buf_t buf;
7625 wmi_request_stats_cmd_fixed_param *cmd;
7626 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7627
7628 buf = wmi_buf_alloc(wmi_handle, len);
7629 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307630 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7631 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307632 }
7633
7634 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7635 cmd->vdev_id = vdev_id;
7636
7637 WMITLV_SET_HDR(&cmd->tlv_header,
7638 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7639 WMITLV_GET_STRUCT_TLVLEN
7640 (wmi_request_stats_cmd_fixed_param));
7641 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7642 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7643 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307644 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307645 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307646 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307647 }
7648
Govind Singhb53420c2016-03-09 14:32:57 +05307649 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307650}
7651
7652/**
7653 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7654 * @wmi_handle: wmi handle
7655 * @link_status: get link params
7656 *
7657 * Return: CDF status
7658 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307659static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307660 struct link_status_params *link_status)
7661{
7662 wmi_buf_t buf;
7663 wmi_request_stats_cmd_fixed_param *cmd;
7664 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7665
7666 buf = wmi_buf_alloc(wmi_handle, len);
7667 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307668 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7669 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307670 }
7671
7672 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7673 WMITLV_SET_HDR(&cmd->tlv_header,
7674 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7675 WMITLV_GET_STRUCT_TLVLEN
7676 (wmi_request_stats_cmd_fixed_param));
7677 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7678 cmd->vdev_id = link_status->session_id;
7679 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7680 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307681 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307682 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307683 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307684 }
7685
Govind Singhb53420c2016-03-09 14:32:57 +05307686 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307687}
7688
Govind Singh20c5dac2016-03-07 15:33:31 +05307689/**
7690 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7691 * @wmi_handle: wmi handle
7692 * @ta_dhcp_ind: DHCP indication parameter
7693 *
7694 * Return: CDF Status
7695 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307696static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307697 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7698{
Govind Singh67922e82016-04-01 16:48:57 +05307699 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307700 wmi_buf_t buf = NULL;
7701 uint8_t *buf_ptr;
7702 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7703 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7704
7705
7706 buf = wmi_buf_alloc(wmi_handle, len);
7707 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307708 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7709 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307710 }
7711
7712 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7713 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7714 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7715 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7716 WMITLV_GET_STRUCT_TLVLEN
7717 (wmi_peer_set_param_cmd_fixed_param));
7718
7719 /* fill in values */
7720 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7721 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7722 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307723 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307724 &ta_dhcp_ind->peer_macaddr,
7725 sizeof(ta_dhcp_ind->peer_macaddr));
7726
7727 status = wmi_unified_cmd_send(wmi_handle, buf,
7728 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307729 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307730 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307731 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307732 wmi_buf_free(buf);
7733 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307734
Govind Singh67922e82016-04-01 16:48:57 +05307735 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307736}
7737
7738/**
7739 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7740 * @wmi_handle: wmi handle
7741 * @pLinkSpeed: link speed info
7742 *
7743 * Return: CDF status
7744 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307745static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307746 wmi_mac_addr peer_macaddr)
7747{
7748 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7749 wmi_buf_t wmi_buf;
7750 uint32_t len;
7751 uint8_t *buf_ptr;
7752
7753 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7754 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7755 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307756 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7757 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307758 }
7759 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7760
7761 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7762 WMITLV_SET_HDR(&cmd->tlv_header,
7763 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7764 WMITLV_GET_STRUCT_TLVLEN
7765 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7766
7767 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307768 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307769 &peer_macaddr,
7770 sizeof(peer_macaddr));
7771
7772
7773 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7774 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307775 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307776 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307777 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307778 }
Govind Singhb53420c2016-03-09 14:32:57 +05307779 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307780}
7781
7782/**
7783 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7784 * @wmi_handle: wmi handler
7785 * @egap_params: pointer to egap_params
7786 *
7787 * Return: 0 for success, otherwise appropriate error code
7788 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307789static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307790 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7791{
7792 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7793 wmi_buf_t buf;
7794 int32_t err;
7795
7796 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7797 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307798 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7799 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307800 }
7801 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7802 WMITLV_SET_HDR(&cmd->tlv_header,
7803 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7804 WMITLV_GET_STRUCT_TLVLEN(
7805 wmi_ap_ps_egap_param_cmd_fixed_param));
7806
7807 cmd->enable = egap_params->enable;
7808 cmd->inactivity_time = egap_params->inactivity_time;
7809 cmd->wait_time = egap_params->wait_time;
7810 cmd->flags = egap_params->flags;
7811 err = wmi_unified_cmd_send(wmi_handle, buf,
7812 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7813 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307814 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307815 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307816 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307817 }
7818
Govind Singhb53420c2016-03-09 14:32:57 +05307819 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307820}
7821
7822/**
7823 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7824 * @wmi_handl: wmi handle
7825 * @cmd: Profiling command index
7826 * @value1: parameter1 value
7827 * @value2: parameter2 value
7828 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307829 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307830 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307831static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307832 uint32_t cmd, uint32_t value1, uint32_t value2)
7833{
7834 wmi_buf_t buf;
7835 int32_t len = 0;
7836 int ret;
7837 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7838 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7839 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7840 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7841
7842 switch (cmd) {
7843 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7844 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7845 buf = wmi_buf_alloc(wmi_handle, len);
7846 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307847 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307848 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307849 }
7850 prof_trig_cmd =
7851 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7852 wmi_buf_data(buf);
7853 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7854 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7855 WMITLV_GET_STRUCT_TLVLEN
7856 (wmi_wlan_profile_trigger_cmd_fixed_param));
7857 prof_trig_cmd->enable = value1;
7858 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7859 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7860 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307861 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307862 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307863 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307864 return ret;
7865 }
7866 break;
7867
7868 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7869 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7870 buf = wmi_buf_alloc(wmi_handle, len);
7871 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307872 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307873 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307874 }
7875 profile_getdata_cmd =
7876 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7877 wmi_buf_data(buf);
7878 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7879 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7880 WMITLV_GET_STRUCT_TLVLEN
7881 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7882 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7883 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7884 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307885 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307886 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307887 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307888 return ret;
7889 }
7890 break;
7891
7892 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7893 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7894 buf = wmi_buf_alloc(wmi_handle, len);
7895 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307896 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307897 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307898 }
7899 hist_intvl_cmd =
7900 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7901 wmi_buf_data(buf);
7902 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7903 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7904 WMITLV_GET_STRUCT_TLVLEN
7905 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7906 hist_intvl_cmd->profile_id = value1;
7907 hist_intvl_cmd->value = value2;
7908 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7909 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7910 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307911 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307912 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307913 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307914 return ret;
7915 }
7916 break;
7917
7918 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7919 len =
7920 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7921 buf = wmi_buf_alloc(wmi_handle, len);
7922 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307923 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307924 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307925 }
7926 profile_enable_cmd =
7927 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7928 wmi_buf_data(buf);
7929 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7930 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7931 WMITLV_GET_STRUCT_TLVLEN
7932 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7933 profile_enable_cmd->profile_id = value1;
7934 profile_enable_cmd->enable = value2;
7935 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7936 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7937 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307938 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307939 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307940 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307941 return ret;
7942 }
7943 break;
7944
7945 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307946 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307947 break;
7948 }
7949
7950 return 0;
7951}
7952
Govind Singh20c5dac2016-03-07 15:33:31 +05307953/**
7954 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7955 * @wmi_handle: wmi handle
7956 * @vdev_id: vdev id
7957 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307958 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307959 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307960static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307961{
7962 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7963 wmi_buf_t buf;
7964 int32_t len = sizeof(*cmd);
7965
Govind Singhb53420c2016-03-09 14:32:57 +05307966 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307967 buf = wmi_buf_alloc(wmi_handle, len);
7968 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307969 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307970 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307971 }
7972 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7973 wmi_buf_data(buf);
7974 WMITLV_SET_HDR(&cmd->tlv_header,
7975 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7976 WMITLV_GET_STRUCT_TLVLEN
7977 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7978 cmd->vdev_id = vdev_id;
7979 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7980 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7981 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307982 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307983 __func__);
7984 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307985 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307986 }
7987
7988 return 0;
7989}
7990
7991/**
7992 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7993 * @wmi_handle: wmi handle
7994 * @vdev_id: vdev id
7995 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307996 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307997 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307998static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307999 uint8_t vdev_id)
8000{
8001 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8002 wmi_buf_t buf;
8003 int32_t len = sizeof(*cmd);
8004
Govind Singhb53420c2016-03-09 14:32:57 +05308005 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308006 buf = wmi_buf_alloc(wmi_handle, len);
8007 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308008 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308009 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308010 }
8011 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8012 WMITLV_SET_HDR(&cmd->tlv_header,
8013 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8014 WMITLV_GET_STRUCT_TLVLEN
8015 (wmi_csa_offload_enable_cmd_fixed_param));
8016 cmd->vdev_id = vdev_id;
8017 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8018 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8019 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308020 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308021 __func__);
8022 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308023 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308024 }
8025
8026 return 0;
8027}
8028
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008029#ifdef WLAN_FEATURE_CIF_CFR
8030/**
8031 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8032 * @wmi_handle: wmi handle
8033 * @data_len: len of dma cfg req
8034 * @data: dma cfg req
8035 *
8036 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8037 */
8038static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8039 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8040{
8041 wmi_buf_t buf;
8042 uint8_t *cmd;
8043 QDF_STATUS ret;
8044
8045 WMITLV_SET_HDR(cfg,
8046 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8047 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8048
8049 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8050 if (!buf) {
8051 WMI_LOGE(FL("wmi_buf_alloc failed"));
8052 return QDF_STATUS_E_FAILURE;
8053 }
8054
8055 cmd = (uint8_t *) wmi_buf_data(buf);
8056 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8057 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8058 sizeof(*cfg));
8059 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8060 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8061 if (QDF_IS_STATUS_ERROR(ret)) {
8062 WMI_LOGE(FL(":wmi cmd send failed"));
8063 wmi_buf_free(buf);
8064 }
8065
8066 return ret;
8067}
8068#endif
8069
Govind Singh20c5dac2016-03-07 15:33:31 +05308070/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008071 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8072 * @wmi_handle: wmi handle
8073 * @start_11d_scan: 11d scan start request parameters
8074 *
8075 * This function request FW to start 11d scan.
8076 *
8077 * Return: QDF status
8078 */
8079static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8080 struct reg_start_11d_scan_req *start_11d_scan)
8081{
8082 wmi_11d_scan_start_cmd_fixed_param *cmd;
8083 int32_t len;
8084 wmi_buf_t buf;
8085 int ret;
8086
8087 len = sizeof(*cmd);
8088 buf = wmi_buf_alloc(wmi_handle, len);
8089 if (!buf) {
8090 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8091 return QDF_STATUS_E_NOMEM;
8092 }
8093
8094 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8095
8096 WMITLV_SET_HDR(&cmd->tlv_header,
8097 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8098 WMITLV_GET_STRUCT_TLVLEN
8099 (wmi_11d_scan_start_cmd_fixed_param));
8100
8101 cmd->vdev_id = start_11d_scan->vdev_id;
8102 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8103 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8104
8105 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8106
8107 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8108 WMI_11D_SCAN_START_CMDID);
8109 if (ret) {
8110 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8111 wmi_buf_free(buf);
8112 return QDF_STATUS_E_FAILURE;
8113 }
8114
8115 return QDF_STATUS_SUCCESS;
8116}
8117
8118/**
8119 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8120 * @wmi_handle: wmi handle
8121 * @start_11d_scan: 11d scan stop request parameters
8122 *
8123 * This function request FW to stop 11d scan.
8124 *
8125 * Return: QDF status
8126 */
8127static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8128 struct reg_stop_11d_scan_req *stop_11d_scan)
8129{
8130 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8131 int32_t len;
8132 wmi_buf_t buf;
8133 int ret;
8134
8135 len = sizeof(*cmd);
8136 buf = wmi_buf_alloc(wmi_handle, len);
8137 if (!buf) {
8138 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8139 return QDF_STATUS_E_NOMEM;
8140 }
8141
8142 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8143
8144 WMITLV_SET_HDR(&cmd->tlv_header,
8145 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8146 WMITLV_GET_STRUCT_TLVLEN
8147 (wmi_11d_scan_stop_cmd_fixed_param));
8148
8149 cmd->vdev_id = stop_11d_scan->vdev_id;
8150
8151 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8152
8153 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8154 WMI_11D_SCAN_STOP_CMDID);
8155 if (ret) {
8156 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8157 wmi_buf_free(buf);
8158 return QDF_STATUS_E_FAILURE;
8159 }
8160
8161 return QDF_STATUS_SUCCESS;
8162}
8163
8164/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308165 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8166 * @wmi_handle: wmi handle
8167 * @startOemDataReq: start request params
8168 *
8169 * Return: CDF status
8170 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308171static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008172 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308173 uint8_t *data)
8174{
8175 wmi_buf_t buf;
8176 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308177 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308178
8179 buf = wmi_buf_alloc(wmi_handle,
8180 (data_len + WMI_TLV_HDR_SIZE));
8181 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308182 WMI_LOGE(FL("wmi_buf_alloc failed"));
8183 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308184 }
8185
8186 cmd = (uint8_t *) wmi_buf_data(buf);
8187
8188 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8189 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308190 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308191 data_len);
8192
Govind Singhb53420c2016-03-09 14:32:57 +05308193 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308194 data_len);
8195
8196 ret = wmi_unified_cmd_send(wmi_handle, buf,
8197 (data_len +
8198 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8199
Govind Singh67922e82016-04-01 16:48:57 +05308200 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308201 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308202 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308203 }
8204
Govind Singh67922e82016-04-01 16:48:57 +05308205 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308206}
8207
8208/**
8209 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8210 * @wmi_handle: wmi handle
8211 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8212 *
8213 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8214 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8215 * to firmware based on phyerr filtering
8216 * offload status.
8217 *
8218 * Return: 1 success, 0 failure
8219 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308220static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308221send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8222 bool dfs_phyerr_filter_offload)
8223{
8224 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8225 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8226 wmi_buf_t buf;
8227 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308228 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308229
8230
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008231 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308232 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308233 __func__);
8234 len = sizeof(*disable_phyerr_offload_cmd);
8235 buf = wmi_buf_alloc(wmi_handle, len);
8236 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308237 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308238 return 0;
8239 }
8240 disable_phyerr_offload_cmd =
8241 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8242 wmi_buf_data(buf);
8243
8244 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8245 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8246 WMITLV_GET_STRUCT_TLVLEN
8247 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8248
8249 /*
8250 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8251 * to the firmware to disable the phyerror
8252 * filtering offload.
8253 */
8254 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8255 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308256 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308257 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308258 __func__, ret);
8259 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308260 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308261 }
Govind Singhb53420c2016-03-09 14:32:57 +05308262 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308263 __func__);
8264 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308265 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308266 __func__);
8267
8268 len = sizeof(*enable_phyerr_offload_cmd);
8269 buf = wmi_buf_alloc(wmi_handle, len);
8270 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308271 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8272 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308273 }
8274
8275 enable_phyerr_offload_cmd =
8276 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8277 wmi_buf_data(buf);
8278
8279 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8280 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8281 WMITLV_GET_STRUCT_TLVLEN
8282 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8283
8284 /*
8285 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8286 * to the firmware to enable the phyerror
8287 * filtering offload.
8288 */
8289 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8290 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8291
Govind Singh67922e82016-04-01 16:48:57 +05308292 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308293 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308294 __func__, ret);
8295 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308296 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308297 }
Govind Singhb53420c2016-03-09 14:32:57 +05308298 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308299 __func__);
8300 }
8301
Govind Singhb53420c2016-03-09 14:32:57 +05308302 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308303}
8304
8305#if !defined(REMOVE_PKT_LOG)
8306/**
8307 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8308 * @wmi_handle: wmi handle
8309 * @pktlog_event: pktlog event
8310 * @cmd_id: pktlog cmd id
8311 *
8312 * Return: CDF status
8313 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308314static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308315 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308316 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308317{
8318 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8319 WMI_CMD_ID CMD_ID;
8320 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8321 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8322 int len = 0;
8323 wmi_buf_t buf;
8324
8325 PKTLOG_EVENT = pktlog_event;
8326 CMD_ID = cmd_id;
8327
8328 switch (CMD_ID) {
8329 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8330 len = sizeof(*cmd);
8331 buf = wmi_buf_alloc(wmi_handle, len);
8332 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308333 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8334 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308335 }
8336 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
8337 wmi_buf_data(buf);
8338 WMITLV_SET_HDR(&cmd->tlv_header,
8339 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
8340 WMITLV_GET_STRUCT_TLVLEN
8341 (wmi_pdev_pktlog_enable_cmd_fixed_param));
8342 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05308343 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
8344 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308345 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8346 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308347 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8348 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308349 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308350 goto wmi_send_failed;
8351 }
8352 break;
8353 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
8354 len = sizeof(*disable_cmd);
8355 buf = wmi_buf_alloc(wmi_handle, len);
8356 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308357 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8358 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308359 }
8360 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
8361 wmi_buf_data(buf);
8362 WMITLV_SET_HDR(&disable_cmd->tlv_header,
8363 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
8364 WMITLV_GET_STRUCT_TLVLEN
8365 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308366 disable_cmd->pdev_id =
8367 wmi_handle->ops->convert_pdev_id_host_to_target(
8368 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308369 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8370 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308371 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308372 goto wmi_send_failed;
8373 }
8374 break;
8375 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308376 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308377 break;
8378 }
8379
Govind Singhb53420c2016-03-09 14:32:57 +05308380 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308381
8382wmi_send_failed:
8383 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308384 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308385}
8386#endif /* REMOVE_PKT_LOG */
8387
8388/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308389 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8390 * @wmi_handle: wmi handle
8391 * @ptrn_id: pattern id
8392 * @vdev_id: vdev id
8393 *
8394 * Return: CDF status
8395 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05308396static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8397 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308398{
8399 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8400 wmi_buf_t buf;
8401 int32_t len;
8402 int ret;
8403
8404 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8405
8406
8407 buf = wmi_buf_alloc(wmi_handle, len);
8408 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308409 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8410 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308411 }
8412
8413 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8414
8415 WMITLV_SET_HDR(&cmd->tlv_header,
8416 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8417 WMITLV_GET_STRUCT_TLVLEN(
8418 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8419 cmd->vdev_id = vdev_id;
8420 cmd->pattern_id = ptrn_id;
8421 cmd->pattern_type = WOW_BITMAP_PATTERN;
8422
Govind Singhb53420c2016-03-09 14:32:57 +05308423 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308424 cmd->pattern_id, vdev_id);
8425
8426 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8427 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8428 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308429 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308430 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308431 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308432 }
8433
Govind Singhb53420c2016-03-09 14:32:57 +05308434 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308435}
8436
8437/**
8438 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8439 * @wmi_handle: wmi handle
8440 *
8441 * Sends host wakeup indication to FW. On receiving this indication,
8442 * FW will come out of WOW.
8443 *
8444 * Return: CDF status
8445 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308446static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308447{
8448 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8449 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308450 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308451 int32_t len;
8452 int ret;
8453
8454 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8455
8456 buf = wmi_buf_alloc(wmi_handle, len);
8457 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308458 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8459 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308460 }
8461
8462 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8463 wmi_buf_data(buf);
8464 WMITLV_SET_HDR(&cmd->tlv_header,
8465 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8466 WMITLV_GET_STRUCT_TLVLEN
8467 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8468
8469
8470 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8471 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8472 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308473 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308474 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308475 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308476 }
8477
Govind Singhb53420c2016-03-09 14:32:57 +05308478 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308479}
8480
8481/**
8482 * send_del_ts_cmd_tlv() - send DELTS request to fw
8483 * @wmi_handle: wmi handle
8484 * @msg: delts params
8485 *
8486 * Return: CDF status
8487 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308488static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308489 uint8_t ac)
8490{
8491 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8492 wmi_buf_t buf;
8493 int32_t len = sizeof(*cmd);
8494
8495 buf = wmi_buf_alloc(wmi_handle, len);
8496 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308497 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8498 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308499 }
8500 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8501 WMITLV_SET_HDR(&cmd->tlv_header,
8502 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8503 WMITLV_GET_STRUCT_TLVLEN
8504 (wmi_vdev_wmm_delts_cmd_fixed_param));
8505 cmd->vdev_id = vdev_id;
8506 cmd->ac = ac;
8507
Govind Singhb53420c2016-03-09 14:32:57 +05308508 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308509 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8510 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8511 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308512 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308513 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308514 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308515 }
8516
Govind Singhb53420c2016-03-09 14:32:57 +05308517 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308518}
8519
8520/**
8521 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8522 * @wmi_handle: handle to wmi
8523 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8524 *
Govind Singhb53420c2016-03-09 14:32:57 +05308525 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308526 * ADD_TS requestes to firmware in loop for all the ACs with
8527 * active flow.
8528 *
8529 * Return: CDF status
8530 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308531static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308532 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8533{
8534 int i = 0;
8535 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8536 wmi_buf_t buf;
8537 int32_t len = sizeof(*cmd);
8538
8539 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8540 /* if flow in this AC is active */
8541 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8542 /*
8543 * as per implementation of wma_add_ts_req() we
8544 * are not waiting any response from firmware so
8545 * apart from sending ADDTS to firmware just send
8546 * success to upper layers
8547 */
Govind Singhb53420c2016-03-09 14:32:57 +05308548 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308549
8550 buf = wmi_buf_alloc(wmi_handle, len);
8551 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308552 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8553 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308554 }
8555 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8556 wmi_buf_data(buf);
8557 WMITLV_SET_HDR(&cmd->tlv_header,
8558 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8559 WMITLV_GET_STRUCT_TLVLEN
8560 (wmi_vdev_wmm_addts_cmd_fixed_param));
8561 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8562 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308563 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308564 traffic.userPrio);
8565 cmd->medium_time_us =
8566 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8567 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308568 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308569 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8570 cmd->medium_time_us, cmd->downgrade_type);
8571 if (wmi_unified_cmd_send
8572 (wmi_handle, buf, len,
8573 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308574 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308575 __func__);
8576 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308577 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308578 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308579 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308580 }
8581 }
8582 }
8583
Govind Singhb53420c2016-03-09 14:32:57 +05308584 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308585}
8586
8587/**
8588 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8589 * @wmi_handle: wmi handle
8590 * @msg: ADDTS params
8591 *
8592 * Return: CDF status
8593 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308594static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308595 struct add_ts_param *msg)
8596{
8597 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8598 wmi_buf_t buf;
8599 int32_t len = sizeof(*cmd);
8600
Govind Singhb53420c2016-03-09 14:32:57 +05308601 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308602
8603 buf = wmi_buf_alloc(wmi_handle, len);
8604 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308605 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8606 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308607 }
8608 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8609 WMITLV_SET_HDR(&cmd->tlv_header,
8610 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8611 WMITLV_GET_STRUCT_TLVLEN
8612 (wmi_vdev_wmm_addts_cmd_fixed_param));
8613 cmd->vdev_id = msg->sme_session_id;
8614 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8615 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8616 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308617 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308618 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8619 cmd->downgrade_type, __func__, __LINE__);
8620 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8621 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308622 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8623 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308624 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308625 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308626 }
8627
Govind Singhb53420c2016-03-09 14:32:57 +05308628 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308629}
8630
8631/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308632 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8633 * @wmi_handle: wmi handle
8634 * @pAddPeriodicTxPtrnParams: tx ptrn params
8635 *
8636 * Retrun: CDF status
8637 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308638static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308639 struct periodic_tx_pattern *
8640 pAddPeriodicTxPtrnParams,
8641 uint8_t vdev_id)
8642{
8643 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8644 wmi_buf_t wmi_buf;
8645 uint32_t len;
8646 uint8_t *buf_ptr;
8647 uint32_t ptrn_len, ptrn_len_aligned;
8648 int j;
8649
8650 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8651 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8652 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8653 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8654
8655 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8656 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308657 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8658 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308659 }
8660
8661 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8662
8663 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8664 WMITLV_SET_HDR(&cmd->tlv_header,
8665 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8666 WMITLV_GET_STRUCT_TLVLEN
8667 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8668
8669 /* Pass the pattern id to delete for the corresponding vdev id */
8670 cmd->vdev_id = vdev_id;
8671 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8672 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8673 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8674
8675 /* Pattern info */
8676 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8677 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8678 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308679 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308680 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308681 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308682
Govind Singhb53420c2016-03-09 14:32:57 +05308683 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308684 __func__, cmd->pattern_id, cmd->vdev_id);
8685
8686 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8687 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308688 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308689 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308690 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308691 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308692 }
Govind Singhb53420c2016-03-09 14:32:57 +05308693 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308694}
8695
8696/**
8697 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8698 * @wmi_handle: wmi handle
8699 * @vdev_id: vdev id
8700 * @pattern_id: pattern id
8701 *
8702 * Retrun: CDF status
8703 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308704static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308705 uint8_t vdev_id,
8706 uint8_t pattern_id)
8707{
8708 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8709 wmi_buf_t wmi_buf;
8710 uint32_t len =
8711 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8712
8713 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8714 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308715 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8716 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308717 }
8718
8719 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8720 wmi_buf_data(wmi_buf);
8721 WMITLV_SET_HDR(&cmd->tlv_header,
8722 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8723 WMITLV_GET_STRUCT_TLVLEN
8724 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8725
8726 /* Pass the pattern id to delete for the corresponding vdev id */
8727 cmd->vdev_id = vdev_id;
8728 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308729 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308730 __func__, cmd->pattern_id, cmd->vdev_id);
8731
8732 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8733 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308734 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308735 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308736 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308737 }
Govind Singhb53420c2016-03-09 14:32:57 +05308738 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308739}
8740
8741/**
8742 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8743 * @wmi_handle: wmi handle
8744 * @preq: stats ext params
8745 *
8746 * Return: CDF status
8747 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308748static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308749 struct stats_ext_params *preq)
8750{
Govind Singh67922e82016-04-01 16:48:57 +05308751 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308752 wmi_req_stats_ext_cmd_fixed_param *cmd;
8753 wmi_buf_t buf;
8754 uint16_t len;
8755 uint8_t *buf_ptr;
8756
8757 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8758
8759 buf = wmi_buf_alloc(wmi_handle, len);
8760 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308761 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308762 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308763 }
8764
8765 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8766 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8767
8768 WMITLV_SET_HDR(&cmd->tlv_header,
8769 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8770 WMITLV_GET_STRUCT_TLVLEN
8771 (wmi_req_stats_ext_cmd_fixed_param));
8772 cmd->vdev_id = preq->vdev_id;
8773 cmd->data_len = preq->request_data_len;
8774
Govind Singhb53420c2016-03-09 14:32:57 +05308775 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308776 __func__, preq->request_data_len, preq->vdev_id);
8777
8778 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8780
8781 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308782 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308783
8784 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8785 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308786 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308787 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308788 ret);
8789 wmi_buf_free(buf);
8790 }
8791
8792 return ret;
8793}
8794
8795/**
8796 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8797 * @wmi_handle: wmi handle
8798 * @params: ext wow params
8799 *
8800 * Return:0 for success or error code
8801 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308802static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308803 struct ext_wow_params *params)
8804{
8805 wmi_extwow_enable_cmd_fixed_param *cmd;
8806 wmi_buf_t buf;
8807 int32_t len;
8808 int ret;
8809
8810 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8811 buf = wmi_buf_alloc(wmi_handle, len);
8812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308813 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8814 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308815 }
8816
8817 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8818
8819 WMITLV_SET_HDR(&cmd->tlv_header,
8820 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8821 WMITLV_GET_STRUCT_TLVLEN
8822 (wmi_extwow_enable_cmd_fixed_param));
8823
8824 cmd->vdev_id = params->vdev_id;
8825 cmd->type = params->type;
8826 cmd->wakeup_pin_num = params->wakeup_pin_num;
8827
Govind Singhb53420c2016-03-09 14:32:57 +05308828 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308829 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8830
8831 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8832 WMI_EXTWOW_ENABLE_CMDID);
8833 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308834 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308835 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308836 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308837 }
8838
Govind Singhb53420c2016-03-09 14:32:57 +05308839 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308840
8841}
8842
8843/**
8844 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8845 * @wmi_handle: wmi handle
8846 * @app_type1_params: app type1 params
8847 *
8848 * Return: CDF status
8849 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308850static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308851 struct app_type1_params *app_type1_params)
8852{
8853 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8854 wmi_buf_t buf;
8855 int32_t len;
8856 int ret;
8857
8858 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8859 buf = wmi_buf_alloc(wmi_handle, len);
8860 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308861 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8862 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308863 }
8864
8865 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8866 wmi_buf_data(buf);
8867
8868 WMITLV_SET_HDR(&cmd->tlv_header,
8869 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8870 WMITLV_GET_STRUCT_TLVLEN
8871 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8872
8873 cmd->vdev_id = app_type1_params->vdev_id;
8874 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8875 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308876 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308877 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308878 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308879 cmd->passwd_len = app_type1_params->pass_length;
8880
Govind Singhb53420c2016-03-09 14:32:57 +05308881 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308882 "identification_id %.8s id_length %u "
8883 "password %.16s pass_length %u",
8884 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8885 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8886
8887 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8888 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8889 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308890 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308891 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308892 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308893 }
8894
Govind Singhb53420c2016-03-09 14:32:57 +05308895 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308896}
8897
8898/**
8899 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8900 * @wmi_handle: wmi handle
8901 * @appType2Params: app type2 params
8902 *
8903 * Return: CDF status
8904 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308905static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308906 struct app_type2_params *appType2Params)
8907{
8908 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8909 wmi_buf_t buf;
8910 int32_t len;
8911 int ret;
8912
8913 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8914 buf = wmi_buf_alloc(wmi_handle, len);
8915 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308916 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8917 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308918 }
8919
8920 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8921 wmi_buf_data(buf);
8922
8923 WMITLV_SET_HDR(&cmd->tlv_header,
8924 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8925 WMITLV_GET_STRUCT_TLVLEN
8926 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8927
8928 cmd->vdev_id = appType2Params->vdev_id;
8929
Govind Singhb53420c2016-03-09 14:32:57 +05308930 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308931 cmd->rc4_key_len = appType2Params->rc4_key_len;
8932
8933 cmd->ip_id = appType2Params->ip_id;
8934 cmd->ip_device_ip = appType2Params->ip_device_ip;
8935 cmd->ip_server_ip = appType2Params->ip_server_ip;
8936
8937 cmd->tcp_src_port = appType2Params->tcp_src_port;
8938 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8939 cmd->tcp_seq = appType2Params->tcp_seq;
8940 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8941
8942 cmd->keepalive_init = appType2Params->keepalive_init;
8943 cmd->keepalive_min = appType2Params->keepalive_min;
8944 cmd->keepalive_max = appType2Params->keepalive_max;
8945 cmd->keepalive_inc = appType2Params->keepalive_inc;
8946
8947 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8948 &cmd->gateway_mac);
8949 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8950 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8951
Govind Singhb53420c2016-03-09 14:32:57 +05308952 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308953 "rc4_key %.16s rc4_key_len %u "
8954 "ip_id %x ip_device_ip %x ip_server_ip %x "
8955 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8956 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8957 "keepalive_max %u keepalive_inc %u "
8958 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8959 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8960 cmd->rc4_key, cmd->rc4_key_len,
8961 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8962 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8963 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8964 cmd->keepalive_max, cmd->keepalive_inc,
8965 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8966
8967 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8968 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8969 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308970 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308971 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308972 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308973 }
8974
Govind Singhb53420c2016-03-09 14:32:57 +05308975 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308976
8977}
8978
8979/**
8980 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8981 * @wmi_handle: wmi handle
8982 * @timer_val: auto shutdown timer value
8983 *
8984 * Return: CDF status
8985 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308986static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308987 uint32_t timer_val)
8988{
Govind Singh67922e82016-04-01 16:48:57 +05308989 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308990 wmi_buf_t buf = NULL;
8991 uint8_t *buf_ptr;
8992 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8993 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8994
Govind Singhb53420c2016-03-09 14:32:57 +05308995 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308996 __func__, timer_val);
8997
8998 buf = wmi_buf_alloc(wmi_handle, len);
8999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309000 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9001 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309002 }
9003
9004 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9005 wmi_auto_sh_cmd =
9006 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9007 wmi_auto_sh_cmd->timer_value = timer_val;
9008
9009 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9010 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9011 WMITLV_GET_STRUCT_TLVLEN
9012 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9013
9014 status = wmi_unified_cmd_send(wmi_handle, buf,
9015 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309016 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309017 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309018 __func__, status);
9019 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309020 }
9021
Govind Singh67922e82016-04-01 16:48:57 +05309022 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309023}
9024
9025/**
9026 * send_nan_req_cmd_tlv() - to send nan request to target
9027 * @wmi_handle: wmi handle
9028 * @nan_req: request data which will be non-null
9029 *
9030 * Return: CDF status
9031 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309032static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309033 struct nan_req_params *nan_req)
9034{
Govind Singh67922e82016-04-01 16:48:57 +05309035 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309036 wmi_nan_cmd_param *cmd;
9037 wmi_buf_t buf;
9038 uint16_t len = sizeof(*cmd);
9039 uint16_t nan_data_len, nan_data_len_aligned;
9040 uint8_t *buf_ptr;
9041
9042 /*
9043 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9044 * +------------+----------+-----------------------+--------------+
9045 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9046 * +------------+----------+-----------------------+--------------+
9047 */
9048 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309049 WMI_LOGE("%s:nan req is not valid", __func__);
9050 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309051 }
9052 nan_data_len = nan_req->request_data_len;
9053 nan_data_len_aligned = roundup(nan_req->request_data_len,
9054 sizeof(uint32_t));
9055 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9056 buf = wmi_buf_alloc(wmi_handle, len);
9057 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309058 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9059 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309060 }
9061 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9062 cmd = (wmi_nan_cmd_param *) buf_ptr;
9063 WMITLV_SET_HDR(&cmd->tlv_header,
9064 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9065 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9066 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309067 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309068 __func__, nan_req->request_data_len);
9069 buf_ptr += sizeof(wmi_nan_cmd_param);
9070 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9071 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309072 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309073
9074 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9075 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309076 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309077 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309078 __func__, ret);
9079 wmi_buf_free(buf);
9080 }
9081
9082 return ret;
9083}
9084
9085/**
9086 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9087 * @wmi_handle: wmi handle
9088 * @pDhcpSrvOffloadInfo: DHCP server offload info
9089 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309090 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309091 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309092static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309093 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
9094{
9095 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9096 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309097 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309098
9099 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9100 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309101 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309102 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309103 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309104 }
9105
9106 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309107 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05309108
9109 WMITLV_SET_HDR(&cmd->tlv_header,
9110 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9111 WMITLV_GET_STRUCT_TLVLEN
9112 (wmi_set_dhcp_server_offload_cmd_fixed_param));
9113 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
9114 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
9115 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
9116 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
9117 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309118 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309119 sizeof(*cmd),
9120 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309121 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309122 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309123 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309124 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309125 }
Govind Singhb53420c2016-03-09 14:32:57 +05309126 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309127 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309128
9129 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309130}
9131
9132/**
9133 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9134 * @wmi_handle: wmi handle
9135 * @flashing: flashing request
9136 *
9137 * Return: CDF status
9138 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309139static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309140 struct flashing_req_params *flashing)
9141{
9142 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309143 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309144 wmi_buf_t buf;
9145 uint8_t *buf_ptr;
9146 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9147
9148 buf = wmi_buf_alloc(wmi_handle, len);
9149 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309150 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309151 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309152 }
9153 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9154 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9155 WMITLV_SET_HDR(&cmd->tlv_header,
9156 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9157 WMITLV_GET_STRUCT_TLVLEN
9158 (wmi_set_led_flashing_cmd_fixed_param));
9159 cmd->pattern_id = flashing->pattern_id;
9160 cmd->led_x0 = flashing->led_x0;
9161 cmd->led_x1 = flashing->led_x1;
9162
9163 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9164 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309165 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309166 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309167 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309168 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309169 }
Govind Singh67922e82016-04-01 16:48:57 +05309170
9171 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309172}
9173
9174/**
9175 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9176 * @wmi_handle: wmi handle
9177 * @ch_avoid_update_req: channel avoid update params
9178 *
9179 * Return: CDF status
9180 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309181static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309182{
Govind Singh67922e82016-04-01 16:48:57 +05309183 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309184 wmi_buf_t buf = NULL;
9185 uint8_t *buf_ptr;
9186 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9187 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9188
9189
9190 buf = wmi_buf_alloc(wmi_handle, len);
9191 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309192 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9193 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309194 }
9195
9196 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9197 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9198 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9199 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9200 WMITLV_GET_STRUCT_TLVLEN
9201 (wmi_chan_avoid_update_cmd_param));
9202
9203 status = wmi_unified_cmd_send(wmi_handle, buf,
9204 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309205 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309206 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309207 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9208 " returned Error %d", status);
9209 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309210 }
9211
Govind Singh67922e82016-04-01 16:48:57 +05309212 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309213}
9214
9215/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309216 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9217 * @wmi_handle: wmi handle
9218 * @param: pointer to pdev regdomain params
9219 *
9220 * Return: 0 for success or error code
9221 */
9222static QDF_STATUS
9223send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9224 struct pdev_set_regdomain_params *param)
9225{
9226 wmi_buf_t buf;
9227 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9228 int32_t len = sizeof(*cmd);
9229
9230
9231 buf = wmi_buf_alloc(wmi_handle, len);
9232 if (!buf) {
9233 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9234 return QDF_STATUS_E_NOMEM;
9235 }
9236 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9237 WMITLV_SET_HDR(&cmd->tlv_header,
9238 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9239 WMITLV_GET_STRUCT_TLVLEN
9240 (wmi_pdev_set_regdomain_cmd_fixed_param));
9241
9242 cmd->reg_domain = param->currentRDinuse;
9243 cmd->reg_domain_2G = param->currentRD2G;
9244 cmd->reg_domain_5G = param->currentRD5G;
9245 cmd->conformance_test_limit_2G = param->ctl_2G;
9246 cmd->conformance_test_limit_5G = param->ctl_5G;
9247 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309248 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9249 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309250
9251 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9252 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9253 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9254 __func__);
9255 wmi_buf_free(buf);
9256 return QDF_STATUS_E_FAILURE;
9257 }
9258
9259 return QDF_STATUS_SUCCESS;
9260}
9261
9262/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309263 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9264 * @wmi_handle: wmi handle
9265 * @reg_dmn: reg domain
9266 * @regdmn2G: 2G reg domain
9267 * @regdmn5G: 5G reg domain
9268 * @ctl2G: 2G test limit
9269 * @ctl5G: 5G test limit
9270 *
9271 * Return: none
9272 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309273static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309274 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309275 uint16_t regdmn5G, uint8_t ctl2G,
9276 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309277{
9278 wmi_buf_t buf;
9279 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9280 int32_t len = sizeof(*cmd);
9281
9282
9283 buf = wmi_buf_alloc(wmi_handle, len);
9284 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309285 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9286 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309287 }
9288 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9289 WMITLV_SET_HDR(&cmd->tlv_header,
9290 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9291 WMITLV_GET_STRUCT_TLVLEN
9292 (wmi_pdev_set_regdomain_cmd_fixed_param));
9293 cmd->reg_domain = reg_dmn;
9294 cmd->reg_domain_2G = regdmn2G;
9295 cmd->reg_domain_5G = regdmn5G;
9296 cmd->conformance_test_limit_2G = ctl2G;
9297 cmd->conformance_test_limit_5G = ctl5G;
9298
9299 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9300 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309301 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309302 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309303 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309304 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309305 }
9306
Govind Singhb53420c2016-03-09 14:32:57 +05309307 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309308}
9309
9310
9311/**
9312 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9313 * @wmi_handle: wmi handle
9314 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9315 *
9316 * This function sets tdls off channel mode
9317 *
9318 * Return: 0 on success; Negative errno otherwise
9319 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309320static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309321 struct tdls_channel_switch_params *chan_switch_params)
9322{
9323 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9324 wmi_buf_t wmi_buf;
9325 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9326
9327 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9328 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309329 WMI_LOGE(FL("wmi_buf_alloc failed"));
9330 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309331 }
9332 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9333 wmi_buf_data(wmi_buf);
9334 WMITLV_SET_HDR(&cmd->tlv_header,
9335 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9336 WMITLV_GET_STRUCT_TLVLEN(
9337 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9338
9339 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9340 &cmd->peer_macaddr);
9341 cmd->vdev_id = chan_switch_params->vdev_id;
9342 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9343 cmd->is_peer_responder = chan_switch_params->is_responder;
9344 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9345 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9346 cmd->offchan_oper_class = chan_switch_params->oper_class;
9347
Govind Singhb53420c2016-03-09 14:32:57 +05309348 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309349 cmd->peer_macaddr.mac_addr31to0,
9350 cmd->peer_macaddr.mac_addr47to32);
9351
Govind Singhb53420c2016-03-09 14:32:57 +05309352 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309353 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9354 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9355 ),
9356 cmd->vdev_id,
9357 cmd->offchan_mode,
9358 cmd->offchan_num,
9359 cmd->offchan_bw_bitmap,
9360 cmd->is_peer_responder,
9361 cmd->offchan_oper_class);
9362
9363 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9364 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309365 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309366 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309367 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309368 }
9369
9370
Govind Singhb53420c2016-03-09 14:32:57 +05309371 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309372}
9373
9374/**
9375 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9376 * @wmi_handle: wmi handle
9377 * @pwmaTdlsparams: TDLS params
9378 *
9379 * Return: 0 for sucess or error code
9380 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309381static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309382 void *tdls_param, uint8_t tdls_state)
9383{
9384 wmi_tdls_set_state_cmd_fixed_param *cmd;
9385 wmi_buf_t wmi_buf;
9386
9387 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9388 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9389
9390 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9391 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309392 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9393 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309394 }
9395 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9396 WMITLV_SET_HDR(&cmd->tlv_header,
9397 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9398 WMITLV_GET_STRUCT_TLVLEN
9399 (wmi_tdls_set_state_cmd_fixed_param));
9400 cmd->vdev_id = wmi_tdls->vdev_id;
9401 cmd->state = tdls_state;
9402 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9403 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9404 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9405 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9406 cmd->rssi_delta = wmi_tdls->rssi_delta;
9407 cmd->tdls_options = wmi_tdls->tdls_options;
9408 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9409 cmd->tdls_peer_traffic_response_timeout_ms =
9410 wmi_tdls->peer_traffic_response_timeout;
9411 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9412 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9413 cmd->tdls_puapsd_rx_frame_threshold =
9414 wmi_tdls->puapsd_rx_frame_threshold;
9415 cmd->teardown_notification_ms =
9416 wmi_tdls->teardown_notification_ms;
9417 cmd->tdls_peer_kickout_threshold =
9418 wmi_tdls->tdls_peer_kickout_threshold;
9419
Govind Singhb53420c2016-03-09 14:32:57 +05309420 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309421 "notification_interval_ms: %d, "
9422 "tx_discovery_threshold: %d, "
9423 "tx_teardown_threshold: %d, "
9424 "rssi_teardown_threshold: %d, "
9425 "rssi_delta: %d, "
9426 "tdls_options: 0x%x, "
9427 "tdls_peer_traffic_ind_window: %d, "
9428 "tdls_peer_traffic_response_timeout: %d, "
9429 "tdls_puapsd_mask: 0x%x, "
9430 "tdls_puapsd_inactivity_time: %d, "
9431 "tdls_puapsd_rx_frame_threshold: %d, "
9432 "teardown_notification_ms: %d, "
9433 "tdls_peer_kickout_threshold: %d",
9434 __func__, tdls_state, cmd->state,
9435 cmd->notification_interval_ms,
9436 cmd->tx_discovery_threshold,
9437 cmd->tx_teardown_threshold,
9438 cmd->rssi_teardown_threshold,
9439 cmd->rssi_delta,
9440 cmd->tdls_options,
9441 cmd->tdls_peer_traffic_ind_window,
9442 cmd->tdls_peer_traffic_response_timeout_ms,
9443 cmd->tdls_puapsd_mask,
9444 cmd->tdls_puapsd_inactivity_time_ms,
9445 cmd->tdls_puapsd_rx_frame_threshold,
9446 cmd->teardown_notification_ms,
9447 cmd->tdls_peer_kickout_threshold);
9448
9449 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9450 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309451 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309452 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309453 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309454 }
Govind Singhb53420c2016-03-09 14:32:57 +05309455 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309456
Govind Singhb53420c2016-03-09 14:32:57 +05309457 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309458}
9459
9460/**
9461 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9462 * @wmi_handle: wmi handle
9463 * @peerStateParams: TDLS peer state params
9464 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309465 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309466 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309467static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309468 struct tdls_peer_state_params *peerStateParams,
9469 uint32_t *ch_mhz)
9470{
9471 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9472 wmi_tdls_peer_capabilities *peer_cap;
9473 wmi_channel *chan_info;
9474 wmi_buf_t wmi_buf;
9475 uint8_t *buf_ptr;
9476 uint32_t i;
9477 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9478 sizeof(wmi_tdls_peer_capabilities);
9479
9480
9481 len += WMI_TLV_HDR_SIZE +
9482 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9483
9484 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9485 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309486 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9487 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309488 }
9489
9490 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9491 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9492 WMITLV_SET_HDR(&cmd->tlv_header,
9493 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9494 WMITLV_GET_STRUCT_TLVLEN
9495 (wmi_tdls_peer_update_cmd_fixed_param));
9496
9497 cmd->vdev_id = peerStateParams->vdevId;
9498 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9499 &cmd->peer_macaddr);
9500
9501
9502 cmd->peer_state = peerStateParams->peerState;
9503
Govind Singhb53420c2016-03-09 14:32:57 +05309504 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309505 "peer_macaddr.mac_addr31to0: 0x%x, "
9506 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9507 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9508 cmd->peer_macaddr.mac_addr31to0,
9509 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9510
9511 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9512 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9513 WMITLV_SET_HDR(&peer_cap->tlv_header,
9514 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9515 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9516
9517 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9518 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9519 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9520 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9521 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9522 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9523 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9524 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9525
9526 /* Ack and More Data Ack are sent as 0, so no need to set
9527 * but fill SP
9528 */
9529 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9530 peerStateParams->peerCap.peerMaxSp);
9531
9532 peer_cap->buff_sta_support =
9533 peerStateParams->peerCap.peerBuffStaSupport;
9534 peer_cap->off_chan_support =
9535 peerStateParams->peerCap.peerOffChanSupport;
9536 peer_cap->peer_curr_operclass =
9537 peerStateParams->peerCap.peerCurrOperClass;
9538 /* self curr operclass is not being used and so pass op class for
9539 * preferred off chan in it.
9540 */
9541 peer_cap->self_curr_operclass =
9542 peerStateParams->peerCap.opClassForPrefOffChan;
9543 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9544 peer_cap->peer_operclass_len =
9545 peerStateParams->peerCap.peerOperClassLen;
9546
Govind Singhb53420c2016-03-09 14:32:57 +05309547 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309548 __func__, peer_cap->peer_operclass_len);
9549 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9550 peer_cap->peer_operclass[i] =
9551 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309552 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309553 __func__, i, peer_cap->peer_operclass[i]);
9554 }
9555
9556 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9557 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9558 peer_cap->pref_offchan_bw =
9559 peerStateParams->peerCap.prefOffChanBandwidth;
9560
Govind Singhb53420c2016-03-09 14:32:57 +05309561 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309562 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9563 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9564 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9565 " %d, pref_offchan_bw: %d",
9566 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9567 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9568 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9569 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9570 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9571
9572 /* next fill variable size array of peer chan info */
9573 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9574 WMITLV_SET_HDR(buf_ptr,
9575 WMITLV_TAG_ARRAY_STRUC,
9576 sizeof(wmi_channel) *
9577 peerStateParams->peerCap.peerChanLen);
9578 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9579
9580 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9581 WMITLV_SET_HDR(&chan_info->tlv_header,
9582 WMITLV_TAG_STRUC_wmi_channel,
9583 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9584 chan_info->mhz = ch_mhz[i];
9585 chan_info->band_center_freq1 = chan_info->mhz;
9586 chan_info->band_center_freq2 = 0;
9587
Govind Singhb53420c2016-03-09 14:32:57 +05309588 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309589
9590 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9591 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309592 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309593 peerStateParams->peerCap.peerChan[i].chanId,
9594 peerStateParams->peerCap.peerChan[i].dfsSet);
9595 }
9596
9597 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9598 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9599 else
9600 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9601
9602 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9603 peerStateParams->peerCap.
9604 peerChan[i].pwr);
9605
9606 WMI_SET_CHANNEL_REG_POWER(chan_info,
9607 peerStateParams->peerCap.peerChan[i].
9608 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309609 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309610 peerStateParams->peerCap.peerChan[i].pwr);
9611
9612 chan_info++;
9613 }
9614
9615 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9616 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309617 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309618 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309619 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309620 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309621 }
9622
9623
Govind Singhb53420c2016-03-09 14:32:57 +05309624 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309625}
9626
9627/*
9628 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9629 * firmware
9630 * @wmi_handle: Pointer to wmi handle
9631 * @mem_dump_req: Pointer for mem_dump_req
9632 *
9633 * This function sends memory dump request to firmware
9634 *
Govind Singhb53420c2016-03-09 14:32:57 +05309635 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309636 *
9637 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309638static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309639 struct fw_dump_req_param *mem_dump_req)
9640{
9641 wmi_get_fw_mem_dump_fixed_param *cmd;
9642 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309643 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309644 int32_t len;
9645 wmi_buf_t buf;
9646 u_int8_t *buf_ptr;
9647 int ret, loop;
9648
9649 /*
9650 * len = sizeof(fixed param) that includes tlv header +
9651 * tlv header for array of struc +
9652 * sizeof (each struct)
9653 */
9654 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9655 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9656 buf = wmi_buf_alloc(wmi_handle, len);
9657
9658 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309659 WMI_LOGE(FL("Failed allocate wmi buffer"));
9660 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309661 }
9662
9663 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309664 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309665 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9666
9667 WMITLV_SET_HDR(&cmd->tlv_header,
9668 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9669 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9670
9671 cmd->request_id = mem_dump_req->request_id;
9672 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9673
9674 /* TLV indicating array of structures to follow */
9675 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9676 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9677 sizeof(wmi_fw_mem_dump) *
9678 cmd->num_fw_mem_dump_segs);
9679
9680 buf_ptr += WMI_TLV_HDR_SIZE;
9681 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9682
Govind Singhb53420c2016-03-09 14:32:57 +05309683 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309684 mem_dump_req->request_id, mem_dump_req->num_seg);
9685 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309686 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309687 ((uint8_t *)(mem_dump_req->segment) +
9688 loop * sizeof(*seg_req));
9689 WMITLV_SET_HDR(&dump_params->tlv_header,
9690 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9691 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9692 dump_params->seg_id = seg_req->seg_id;
9693 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9694 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9695 dump_params->seg_length = seg_req->seg_length;
9696 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9697 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309698 WMI_LOGI(FL("seg_number:%d"), loop);
9699 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309700 dump_params->seg_id, dump_params->seg_start_addr_lo,
9701 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309702 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309703 dump_params->seg_length, dump_params->dest_addr_lo,
9704 dump_params->dest_addr_hi);
9705 dump_params++;
9706 }
9707
9708 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9709 WMI_GET_FW_MEM_DUMP_CMDID);
9710 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309711 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309712 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309713 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309714 }
9715
Govind Singhb53420c2016-03-09 14:32:57 +05309716 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9717 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309718}
9719
9720/*
9721 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9722 * @wmi_handle: Pointer to WMi handle
9723 * @ie_data: Pointer for ie data
9724 *
9725 * This function sends IE information to firmware
9726 *
Govind Singhb53420c2016-03-09 14:32:57 +05309727 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309728 *
9729 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309730static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309731 struct vdev_ie_info_param *ie_info)
9732{
9733 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9734 wmi_buf_t buf;
9735 uint8_t *buf_ptr;
9736 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309737 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309738
9739
9740 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9741 /* Allocate memory for the WMI command */
9742 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9743
9744 buf = wmi_buf_alloc(wmi_handle, len);
9745 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309746 WMI_LOGE(FL("wmi_buf_alloc failed"));
9747 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309748 }
9749
9750 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309751 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309752
9753 /* Populate the WMI command */
9754 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9755
9756 WMITLV_SET_HDR(&cmd->tlv_header,
9757 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9758 WMITLV_GET_STRUCT_TLVLEN(
9759 wmi_vdev_set_ie_cmd_fixed_param));
9760 cmd->vdev_id = ie_info->vdev_id;
9761 cmd->ie_id = ie_info->ie_id;
9762 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009763 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309764
Govind Singhb53420c2016-03-09 14:32:57 +05309765 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309766 ie_info->length, ie_info->vdev_id);
9767
9768 buf_ptr += sizeof(*cmd);
9769 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9770 buf_ptr += WMI_TLV_HDR_SIZE;
9771
Govind Singhb53420c2016-03-09 14:32:57 +05309772 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309773
9774 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9775 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309776 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309777 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309778 wmi_buf_free(buf);
9779 }
9780
9781 return ret;
9782}
9783
Sathish Kumar497bef42017-03-01 14:02:36 +05309784/**
9785 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9786 *
9787 * @param wmi_handle : handle to WMI.
9788 * @param param : pointer to antenna param
9789 *
9790 * This function sends smart antenna enable command to FW
9791 *
9792 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9793 */
9794static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9795 struct smart_ant_enable_params *param)
9796{
9797 /* Send WMI COMMAND to Enable */
9798 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9799 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9800 wmi_buf_t buf;
9801 uint8_t *buf_ptr;
9802 int len = 0;
9803 QDF_STATUS ret;
9804 int loop = 0;
9805
9806 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9807 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9808 buf = wmi_buf_alloc(wmi_handle, len);
9809
9810 if (!buf) {
9811 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9812 return QDF_STATUS_E_NOMEM;
9813 }
9814
9815 buf_ptr = wmi_buf_data(buf);
9816 qdf_mem_zero(buf_ptr, len);
9817 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9818
9819 WMITLV_SET_HDR(&cmd->tlv_header,
9820 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9821 WMITLV_GET_STRUCT_TLVLEN(
9822 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9823
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309824 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9825 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309826 cmd->enable = param->enable;
9827 cmd->mode = param->mode;
9828 cmd->rx_antenna = param->rx_antenna;
9829 cmd->tx_default_antenna = param->rx_antenna;
9830
9831 /* TLV indicating array of structures to follow */
9832 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9833 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9834 WMI_HAL_MAX_SANTENNA *
9835 sizeof(wmi_pdev_smart_ant_gpio_handle));
9836
9837 buf_ptr += WMI_TLV_HDR_SIZE;
9838 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9839
9840 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9841 WMITLV_SET_HDR(&gpio_param->tlv_header,
9842 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9843 WMITLV_GET_STRUCT_TLVLEN(
9844 wmi_pdev_smart_ant_gpio_handle));
9845 if (param->mode == SMART_ANT_MODE_SERIAL) {
9846 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
9847 gpio_param->gpio_pin = param->gpio_pin[loop];
9848 gpio_param->gpio_func = param->gpio_func[loop];
9849 } else {
9850 gpio_param->gpio_pin = 0;
9851 gpio_param->gpio_func = 0;
9852 }
9853 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
9854 gpio_param->gpio_pin = param->gpio_pin[loop];
9855 gpio_param->gpio_func = param->gpio_func[loop];
9856 }
9857 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309858 gpio_param->pdev_id =
9859 wmi_handle->ops->convert_pdev_id_host_to_target(
9860 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309861 gpio_param++;
9862 }
9863
9864 ret = wmi_unified_cmd_send(wmi_handle,
9865 buf,
9866 len,
9867 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
9868
9869 if (ret != 0) {
9870 WMI_LOGE(" %s :WMI Failed\n", __func__);
9871 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
9872 cmd->enable,
9873 cmd->mode,
9874 cmd->rx_antenna,
9875 param->gpio_pin[0], param->gpio_pin[1],
9876 param->gpio_pin[2], param->gpio_pin[3],
9877 param->gpio_func[0], param->gpio_func[1],
9878 param->gpio_func[2], param->gpio_func[3],
9879 ret);
9880 wmi_buf_free(buf);
9881 }
9882
9883 return ret;
9884}
9885
9886/**
9887 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
9888 *
9889 * @param wmi_handle : handle to WMI.
9890 * @param param : pointer to rx antenna param
9891 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9892 */
9893static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9894 struct smart_ant_rx_ant_params *param)
9895{
9896 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
9897 wmi_buf_t buf;
9898 uint8_t *buf_ptr;
9899 uint32_t len;
9900 QDF_STATUS ret;
9901
9902 len = sizeof(*cmd);
9903 buf = wmi_buf_alloc(wmi_handle, len);
9904 WMI_LOGD("%s:\n", __func__);
9905 if (!buf) {
9906 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9907 return QDF_STATUS_E_NOMEM;
9908 }
9909
9910 buf_ptr = wmi_buf_data(buf);
9911 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
9912 WMITLV_SET_HDR(&cmd->tlv_header,
9913 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
9914 WMITLV_GET_STRUCT_TLVLEN(
9915 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
9916 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309917 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9918 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309919
9920 ret = wmi_unified_cmd_send(wmi_handle,
9921 buf,
9922 len,
9923 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
9924
9925 if (ret != 0) {
9926 WMI_LOGE(" %s :WMI Failed\n", __func__);
9927 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
9928 __func__,
9929 cmd->rx_antenna,
9930 ret);
9931 wmi_buf_free(buf);
9932 }
9933
9934 return ret;
9935}
9936
9937/**
9938 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
9939 * @wmi_handle: wmi handle
9940 * @param: pointer to hold ctl table param
9941 *
9942 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9943 */
9944static QDF_STATUS
9945send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
9946 struct ctl_table_params *param)
9947{
9948 uint16_t len, ctl_tlv_len;
9949 uint8_t *buf_ptr;
9950 wmi_buf_t buf;
9951 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
9952 uint32_t *ctl_array;
9953
9954 if (!param->ctl_array)
9955 return QDF_STATUS_E_FAILURE;
9956
9957 if (param->ctl_cmd_len !=
9958 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
9959 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
9960 qdf_print("CTL array len not correct\n");
9961 return QDF_STATUS_E_FAILURE;
9962 }
9963
9964 ctl_tlv_len = WMI_TLV_HDR_SIZE +
9965 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
9966 len = sizeof(*cmd) + ctl_tlv_len;
9967
9968 buf = wmi_buf_alloc(wmi_handle, len);
9969 if (!buf) {
9970 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9971 return QDF_STATUS_E_FAILURE;
9972 }
9973
9974 buf_ptr = wmi_buf_data(buf);
9975 qdf_mem_zero(buf_ptr, len);
9976
9977 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
9978
9979 WMITLV_SET_HDR(&cmd->tlv_header,
9980 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
9981 WMITLV_GET_STRUCT_TLVLEN(
9982 wmi_pdev_set_ctl_table_cmd_fixed_param));
9983 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309984 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9985 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309986
9987 buf_ptr += sizeof(*cmd);
9988 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9989 (cmd->ctl_len));
9990 buf_ptr += WMI_TLV_HDR_SIZE;
9991 ctl_array = (uint32_t *)buf_ptr;
9992
9993 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
9994 sizeof(param->ctl_band));
9995 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
9996 param->ctl_cmd_len -
9997 sizeof(param->ctl_band));
9998
9999 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10000 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10001 WMI_LOGE("%s:Failed to send command\n", __func__);
10002 wmi_buf_free(buf);
10003 return QDF_STATUS_E_FAILURE;
10004 }
10005
10006 return QDF_STATUS_SUCCESS;
10007}
10008
10009/**
10010 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10011 * @wmi_handle: wmi handle
10012 * @param: pointer to hold mimogain table param
10013 *
10014 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10015 */
10016static QDF_STATUS
10017send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10018 struct mimogain_table_params *param)
10019{
10020 uint16_t len, table_tlv_len;
10021 wmi_buf_t buf;
10022 uint8_t *buf_ptr;
10023 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10024 uint32_t *gain_table;
10025
10026 if (!param->array_gain)
10027 return QDF_STATUS_E_FAILURE;
10028
10029 /* len must be multiple of a single array gain table */
10030 if (param->tbl_len %
10031 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10032 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10033 WMI_LOGE("Array gain table len not correct\n");
10034 return QDF_STATUS_E_FAILURE;
10035 }
10036
10037 table_tlv_len = WMI_TLV_HDR_SIZE +
10038 roundup(param->tbl_len, sizeof(uint32_t));
10039 len = sizeof(*cmd) + table_tlv_len;
10040
10041 buf = wmi_buf_alloc(wmi_handle, len);
10042 if (!buf) {
10043 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10044 return QDF_STATUS_E_FAILURE;
10045 }
10046
10047 buf_ptr = wmi_buf_data(buf);
10048 qdf_mem_zero(buf_ptr, len);
10049
10050 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10051
10052 WMITLV_SET_HDR(&cmd->tlv_header,
10053 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10054 WMITLV_GET_STRUCT_TLVLEN(
10055 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10056
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010057 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10058 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010059 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10060 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10061 param->multichain_gain_bypass);
10062
10063 buf_ptr += sizeof(*cmd);
10064 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10065 (param->tbl_len));
10066 buf_ptr += WMI_TLV_HDR_SIZE;
10067 gain_table = (uint32_t *)buf_ptr;
10068
10069 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10070 param->array_gain,
10071 param->tbl_len);
10072
10073 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10074 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10075 return QDF_STATUS_E_FAILURE;
10076 }
10077
10078 return QDF_STATUS_SUCCESS;
10079}
10080
10081/**
10082 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10083 * info to fw
10084 * @wmi_handle: wmi handle
10085 * @param: pointer to hold packet power info param
10086 *
10087 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10088 */
10089static QDF_STATUS
10090send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10091 struct packet_power_info_params *param)
10092{
10093 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10094 wmi_buf_t wmibuf;
10095 uint8_t *buf_ptr;
10096 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10097
10098 wmibuf = wmi_buf_alloc(wmi_handle, len);
10099 if (wmibuf == NULL)
10100 return QDF_STATUS_E_NOMEM;
10101
10102 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10103
10104 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10105 WMITLV_SET_HDR(&cmd->tlv_header,
10106 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10107 WMITLV_GET_STRUCT_TLVLEN(
10108 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010109 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10110 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010111 cmd->rate_flags = param->rate_flags;
10112 cmd->nss = param->nss;
10113 cmd->preamble = param->preamble;
10114 cmd->hw_rate = param->hw_rate;
10115 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
10116 __func__,
10117 __LINE__,
10118 WMI_PDEV_GET_TPC_CMDID,
10119 *((u_int32_t *)cmd));
10120 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10121 WMI_PDEV_GET_TPC_CMDID)) {
10122 WMI_LOGE(FL("Failed to get tpc command\n"));
10123 wmi_buf_free(wmibuf);
10124 return QDF_STATUS_E_FAILURE;
10125 }
10126
10127 return QDF_STATUS_SUCCESS;
10128}
10129
10130/**
10131 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10132 * @wmi_handle: wmi handle
10133 * @param: pointer to hold config ratemask params
10134 *
10135 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10136 */
10137static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10138 struct config_ratemask_params *param)
10139{
10140 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10141 wmi_buf_t buf;
10142 int32_t len = sizeof(*cmd);
10143
10144 buf = wmi_buf_alloc(wmi_handle, len);
10145 if (!buf) {
10146 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10147 return QDF_STATUS_E_FAILURE;
10148 }
10149 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10150 WMITLV_SET_HDR(&cmd->tlv_header,
10151 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10152 WMITLV_GET_STRUCT_TLVLEN(
10153 wmi_vdev_config_ratemask_cmd_fixed_param));
10154 cmd->vdev_id = param->vdev_id;
10155 cmd->type = param->type;
10156 cmd->mask_lower32 = param->lower32;
10157 cmd->mask_higher32 = param->higher32;
10158 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
10159 param->vdev_id, param->type, param->lower32, param->higher32);
10160
10161 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10162 WMI_VDEV_RATEMASK_CMDID)) {
10163 WMI_LOGE("Seting vdev ratemask failed\n");
10164 wmi_buf_free(buf);
10165 return QDF_STATUS_E_FAILURE;
10166 }
10167
10168 return QDF_STATUS_SUCCESS;
10169}
10170
10171/**
10172 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
10173 * @wmi_handle: wmi handle
10174 * @param: pointer to hold vap dscp tid map param
10175 *
10176 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10177 */
10178static QDF_STATUS
10179send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
10180 struct vap_dscp_tid_map_params *param)
10181{
10182 wmi_buf_t buf;
10183 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
10184 int32_t len = sizeof(*cmd);
10185
10186 buf = wmi_buf_alloc(wmi_handle, len);
10187 if (!buf) {
10188 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10189 return QDF_STATUS_E_FAILURE;
10190 }
10191
10192 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
10193 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
10194 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
10195
10196 cmd->vdev_id = param->vdev_id;
10197 cmd->enable_override = 0;
10198
10199 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
10200 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10201 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
10202 WMI_LOGE("Failed to set dscp cmd\n");
10203 wmi_buf_free(buf);
10204 return QDF_STATUS_E_FAILURE;
10205 }
10206
10207 return QDF_STATUS_SUCCESS;
10208}
10209
10210/**
10211 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
10212 * @wmi_handle: wmi handle
10213 * @macaddr: vdev mac address
10214 * @param: pointer to hold neigbour rx param
10215 *
10216 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10217 */
10218static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
10219 uint8_t macaddr[IEEE80211_ADDR_LEN],
10220 struct set_neighbour_rx_params *param)
10221{
10222 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
10223 wmi_buf_t buf;
10224 int32_t len = sizeof(*cmd);
10225
10226 buf = wmi_buf_alloc(wmi_handle, len);
10227 if (!buf) {
10228 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10229 return QDF_STATUS_E_FAILURE;
10230 }
10231 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
10232 WMITLV_SET_HDR(&cmd->tlv_header,
10233 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
10234 WMITLV_GET_STRUCT_TLVLEN(
10235 wmi_vdev_filter_nrp_config_cmd_fixed_param));
10236 cmd->vdev_id = param->vdev_id;
10237 cmd->bssid_idx = param->idx;
10238 cmd->action = param->action;
10239 cmd->type = param->type;
10240 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
10241 cmd->flag = 0;
10242
10243 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10244 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
10245 WMI_LOGE("Failed to set neighbour rx param\n");
10246 wmi_buf_free(buf);
10247 return QDF_STATUS_E_FAILURE;
10248 }
10249
10250 return QDF_STATUS_SUCCESS;
10251}
10252
10253/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010254 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053010255 * @param wmi_handle : handle to WMI.
10256 * @param macaddr : vdev mac address
10257 * @param param : pointer to tx antenna param
10258 *
10259 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10260 */
10261static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10262 uint8_t macaddr[IEEE80211_ADDR_LEN],
10263 struct smart_ant_tx_ant_params *param)
10264{
10265 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
10266 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
10267 wmi_buf_t buf;
10268 int32_t len = 0;
10269 int i;
10270 uint8_t *buf_ptr;
10271 QDF_STATUS ret;
10272
10273 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10274 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10275 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
10276 buf = wmi_buf_alloc(wmi_handle, len);
10277
10278 if (!buf) {
10279 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10280 return QDF_STATUS_E_NOMEM;
10281 }
10282
10283 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10284 qdf_mem_zero(buf_ptr, len);
10285 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
10286
10287 WMITLV_SET_HDR(&cmd->tlv_header,
10288 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
10289 WMITLV_GET_STRUCT_TLVLEN(
10290 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
10291
10292 cmd->vdev_id = param->vdev_id;
10293 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10294
10295 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
10296 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10297 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
10298 buf_ptr += WMI_TLV_HDR_SIZE;
10299 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
10300
10301 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
10302 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
10303 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
10304 WMITLV_GET_STRUCT_TLVLEN(
10305 wmi_peer_smart_ant_set_tx_antenna_series));
10306 ant_tx_series->antenna_series = param->antenna_array[i];
10307 ant_tx_series++;
10308 }
10309
10310 ret = wmi_unified_cmd_send(wmi_handle,
10311 buf,
10312 len,
10313 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
10314
10315 if (ret != 0) {
10316 WMI_LOGE(" %s :WMI Failed\n", __func__);
10317 wmi_buf_free(buf);
10318 }
10319
10320 return ret;
10321}
10322
Sathish Kumar02c3b542017-02-22 17:24:45 +053010323/**
10324 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
10325 * @wmi_handle: wmi handle
10326 * @param: pointer to hold ant switch tbl param
10327 *
10328 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10329 */
10330static QDF_STATUS
10331send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
10332 struct ant_switch_tbl_params *param)
10333{
10334 uint8_t len;
10335 wmi_buf_t buf;
10336 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
10337 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
10338 uint8_t *buf_ptr;
10339
10340 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10341 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
10342 buf = wmi_buf_alloc(wmi_handle, len);
10343
10344 if (!buf) {
10345 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10346 return QDF_STATUS_E_NOMEM;
10347 }
10348
10349 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10350 qdf_mem_zero(buf_ptr, len);
10351 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
10352
10353 WMITLV_SET_HDR(&cmd->tlv_header,
10354 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
10355 WMITLV_GET_STRUCT_TLVLEN(
10356 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
10357
10358 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
10359 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010360 cmd->mac_id =
10361 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010362
10363 /* TLV indicating array of structures to follow */
10364 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
10365 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10366 sizeof(wmi_pdev_set_ant_ctrl_chain));
10367 buf_ptr += WMI_TLV_HDR_SIZE;
10368 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
10369
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010370 ctrl_chain->pdev_id =
10371 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010372 ctrl_chain->antCtrlChain = param->antCtrlChain;
10373
10374 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10375 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
10376 wmi_buf_free(buf);
10377 return QDF_STATUS_E_FAILURE;
10378 }
10379
10380 return QDF_STATUS_SUCCESS;
10381}
10382
10383/**
10384 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
10385 * training information function
10386 * @param wmi_handle : handle to WMI.
10387 * @macaddr : vdev mac address
10388 * @param param : pointer to tx antenna param
10389 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10390 */
10391static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
10392 wmi_unified_t wmi_handle,
10393 uint8_t macaddr[IEEE80211_ADDR_LEN],
10394 struct smart_ant_training_info_params *param)
10395{
10396 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
10397 wmi_peer_smart_ant_set_train_antenna_param *train_param;
10398 wmi_buf_t buf;
10399 uint8_t *buf_ptr;
10400 int32_t len = 0;
10401 QDF_STATUS ret;
10402 int loop;
10403
10404 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10405 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10406 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
10407 buf = wmi_buf_alloc(wmi_handle, len);
10408
10409 if (!buf) {
10410 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10411 return QDF_STATUS_E_NOMEM;
10412 }
10413
10414 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10415 qdf_mem_zero(buf_ptr, len);
10416 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10417
10418 WMITLV_SET_HDR(&cmd->tlv_header,
10419 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10420 WMITLV_GET_STRUCT_TLVLEN(
10421 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10422
10423 cmd->vdev_id = param->vdev_id;
10424 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10425 cmd->num_pkts = param->numpkts;
10426
10427 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10428 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10429 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10430 WMI_SMART_ANT_MAX_RATE_SERIES);
10431
10432 buf_ptr += WMI_TLV_HDR_SIZE;
10433 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10434
10435 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10436 WMITLV_SET_HDR(&train_param->tlv_header,
10437 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10438 WMITLV_GET_STRUCT_TLVLEN(
10439 wmi_peer_smart_ant_set_train_antenna_param));
10440 train_param->train_rate_series = param->rate_array[loop];
10441 train_param->train_antenna_series = param->antenna_array[loop];
10442 train_param->rc_flags = 0;
10443 WMI_LOGI(FL("Series number:%d\n"), loop);
10444 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10445 train_param->train_rate_series,
10446 train_param->train_antenna_series);
10447 train_param++;
10448 }
10449
10450 ret = wmi_unified_cmd_send(wmi_handle,
10451 buf,
10452 len,
10453 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10454
10455 if (ret != 0) {
10456 WMI_LOGE(" %s :WMI Failed\n", __func__);
10457 wmi_buf_free(buf);
10458 return QDF_STATUS_E_FAILURE;
10459 }
10460
10461 return ret;
10462}
10463
10464/**
10465 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10466 * configuration function
10467 * @param wmi_handle : handle to WMI.
10468 * @macaddr : vdev mad address
10469 * @param param : pointer to tx antenna param
10470 *
10471 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10472 */
10473static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10474 wmi_unified_t wmi_handle,
10475 uint8_t macaddr[IEEE80211_ADDR_LEN],
10476 struct smart_ant_node_config_params *param)
10477{
10478 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10479 wmi_buf_t buf;
10480 uint8_t *buf_ptr;
10481 int32_t len = 0, args_tlv_len;
10482 int ret;
10483 int i = 0;
10484 A_UINT32 *node_config_args;
10485
10486 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10487 len = sizeof(*cmd) + args_tlv_len;
10488
10489 if ((param->args_count == 0)) {
10490 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10491 __func__, param->args_count);
10492 return QDF_STATUS_E_FAILURE;
10493 }
10494
10495 buf = wmi_buf_alloc(wmi_handle, len);
10496 if (!buf) {
10497 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10498 return QDF_STATUS_E_NOMEM;
10499 }
10500
10501 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10502 wmi_buf_data(buf);
10503 buf_ptr = (uint8_t *)cmd;
10504 WMITLV_SET_HDR(&cmd->tlv_header,
10505 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10506 WMITLV_GET_STRUCT_TLVLEN(
10507 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10508 cmd->vdev_id = param->vdev_id;
10509 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10510 cmd->cmd_id = param->cmd_id;
10511 cmd->args_count = param->args_count;
10512 buf_ptr += sizeof(
10513 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10514 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10515 (cmd->args_count * sizeof(A_UINT32)));
10516 buf_ptr += WMI_TLV_HDR_SIZE;
10517 node_config_args = (A_UINT32 *)buf_ptr;
10518
10519 for (i = 0; i < param->args_count; i++) {
10520 node_config_args[i] = param->args_arr[i];
10521 WMI_LOGI("%d", param->args_arr[i]);
10522 }
10523
10524 ret = wmi_unified_cmd_send(wmi_handle,
10525 buf,
10526 len,
10527 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10528
10529 if (ret != 0) {
10530 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10531 __func__, param->cmd_id, macaddr[0],
10532 macaddr[1], macaddr[2], macaddr[3],
10533 macaddr[4], macaddr[5], ret);
10534 wmi_buf_free(buf);
10535 }
10536
10537 return ret;
10538}
10539
10540/**
10541 * send_set_atf_cmd_tlv() - send set atf command to fw
10542 * @wmi_handle: wmi handle
10543 * @param: pointer to set atf param
10544 *
10545 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10546 */
10547static QDF_STATUS
10548send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10549 struct set_atf_params *param)
10550{
10551 wmi_atf_peer_info *peer_info;
10552 wmi_peer_atf_request_fixed_param *cmd;
10553 wmi_buf_t buf;
10554 uint8_t *buf_ptr;
10555 int i;
10556 int32_t len = 0;
10557 QDF_STATUS retval;
10558
10559 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10560 len += param->num_peers * sizeof(wmi_atf_peer_info);
10561 buf = wmi_buf_alloc(wmi_handle, len);
10562 if (!buf) {
10563 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10564 return QDF_STATUS_E_FAILURE;
10565 }
10566 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10567 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10568 WMITLV_SET_HDR(&cmd->tlv_header,
10569 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10570 WMITLV_GET_STRUCT_TLVLEN(
10571 wmi_peer_atf_request_fixed_param));
10572 cmd->num_peers = param->num_peers;
10573
10574 buf_ptr += sizeof(*cmd);
10575 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10576 sizeof(wmi_atf_peer_info) *
10577 cmd->num_peers);
10578 buf_ptr += WMI_TLV_HDR_SIZE;
10579 peer_info = (wmi_atf_peer_info *)buf_ptr;
10580
10581 for (i = 0; i < cmd->num_peers; i++) {
10582 WMITLV_SET_HDR(&peer_info->tlv_header,
10583 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10584 WMITLV_GET_STRUCT_TLVLEN(
10585 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010586 qdf_mem_copy(&(peer_info->peer_macaddr),
10587 &(param->peer_info[i].peer_macaddr),
10588 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053010589 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010590 peer_info->vdev_id = param->peer_info[i].vdev_id;
10591 peer_info->pdev_id =
10592 wmi_handle->ops->convert_pdev_id_host_to_target(
10593 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010594 /*
10595 * TLV definition for peer atf request fixed param combines
10596 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
10597 * stats and atf extension stats as two different
10598 * implementations.
10599 * Need to discuss with FW on this.
10600 *
10601 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
10602 * peer_info->atf_units_reserved =
10603 * param->peer_ext_info[i].atf_index_reserved;
10604 */
10605 peer_info++;
10606 }
10607
10608 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10609 WMI_PEER_ATF_REQUEST_CMDID);
10610
10611 if (retval != QDF_STATUS_SUCCESS) {
10612 WMI_LOGE("%s : WMI Failed\n", __func__);
10613 wmi_buf_free(buf);
10614 }
10615
10616 return retval;
10617}
10618
10619/**
10620 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
10621 * @wmi_handle: wmi handle
10622 * @param: pointer to hold fwtest param
10623 *
10624 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10625 */
10626static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
10627 struct set_fwtest_params *param)
10628{
10629 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10630 wmi_buf_t buf;
10631 int32_t len = sizeof(*cmd);
10632
10633 buf = wmi_buf_alloc(wmi_handle, len);
10634
10635 if (!buf) {
10636 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10637 return QDF_STATUS_E_FAILURE;
10638 }
10639
10640 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
10641 WMITLV_SET_HDR(&cmd->tlv_header,
10642 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10643 WMITLV_GET_STRUCT_TLVLEN(
10644 wmi_fwtest_set_param_cmd_fixed_param));
10645 cmd->param_id = param->arg;
10646 cmd->param_value = param->value;
10647
10648 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
10649 WMI_LOGE("Setting FW test param failed\n");
10650 wmi_buf_free(buf);
10651 return QDF_STATUS_E_FAILURE;
10652 }
10653
10654 return QDF_STATUS_SUCCESS;
10655}
10656
10657/**
10658 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
10659 * @wmi_handle: wmi handle
10660 * @param: pointer to qboost params
10661 * @macaddr: vdev mac address
10662 *
10663 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10664 */
10665static QDF_STATUS
10666send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
10667 uint8_t macaddr[IEEE80211_ADDR_LEN],
10668 struct set_qboost_params *param)
10669{
10670 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
10671 wmi_buf_t buf;
10672 int32_t len;
10673 QDF_STATUS ret;
10674
10675 len = sizeof(*cmd);
10676
10677 buf = wmi_buf_alloc(wmi_handle, len);
10678 if (!buf) {
10679 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10680 return QDF_STATUS_E_FAILURE;
10681 }
10682
10683 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
10684 WMITLV_SET_HDR(&cmd->tlv_header,
10685 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
10686 WMITLV_GET_STRUCT_TLVLEN(
10687 WMI_QBOOST_CFG_CMD_fixed_param));
10688 cmd->vdev_id = param->vdev_id;
10689 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10690 cmd->qb_enable = param->value;
10691
10692 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10693 WMI_QBOOST_CFG_CMDID);
10694
10695 if (ret != 0) {
10696 WMI_LOGE("Setting qboost cmd failed\n");
10697 wmi_buf_free(buf);
10698 }
10699
10700 return ret;
10701}
10702
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010703/**
10704 * send_gpio_config_cmd_tlv() - send gpio config to fw
10705 * @wmi_handle: wmi handle
10706 * @param: pointer to hold gpio config param
10707 *
10708 * Return: 0 for success or error code
10709 */
10710static QDF_STATUS
10711send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
10712 struct gpio_config_params *param)
10713{
10714 wmi_gpio_config_cmd_fixed_param *cmd;
10715 wmi_buf_t buf;
10716 int32_t len;
10717 QDF_STATUS ret;
10718
10719 len = sizeof(*cmd);
10720
10721 /* Sanity Checks */
10722 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
10723 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
10724 return QDF_STATUS_E_FAILURE;
10725 }
10726
10727 buf = wmi_buf_alloc(wmi_handle, len);
10728 if (!buf) {
10729 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10730 return QDF_STATUS_E_FAILURE;
10731 }
10732
10733 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
10734 WMITLV_SET_HDR(&cmd->tlv_header,
10735 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
10736 WMITLV_GET_STRUCT_TLVLEN(
10737 wmi_gpio_config_cmd_fixed_param));
10738 cmd->gpio_num = param->gpio_num;
10739 cmd->input = param->input;
10740 cmd->pull_type = param->pull_type;
10741 cmd->intr_mode = param->intr_mode;
10742
10743 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10744 WMI_GPIO_CONFIG_CMDID);
10745
10746 if (ret != 0) {
10747 WMI_LOGE("Sending GPIO config cmd failed\n");
10748 wmi_buf_free(buf);
10749 }
10750
10751 return ret;
10752}
10753
10754/**
10755 * send_gpio_output_cmd_tlv() - send gpio output to fw
10756 * @wmi_handle: wmi handle
10757 * @param: pointer to hold gpio output param
10758 *
10759 * Return: 0 for success or error code
10760 */
10761static QDF_STATUS
10762send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
10763 struct gpio_output_params *param)
10764{
10765 wmi_gpio_output_cmd_fixed_param *cmd;
10766 wmi_buf_t buf;
10767 int32_t len;
10768 QDF_STATUS ret;
10769
10770 len = sizeof(*cmd);
10771
10772 buf = wmi_buf_alloc(wmi_handle, len);
10773 if (!buf) {
10774 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10775 return QDF_STATUS_E_FAILURE;
10776 }
10777
10778 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
10779 WMITLV_SET_HDR(&cmd->tlv_header,
10780 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
10781 WMITLV_GET_STRUCT_TLVLEN(
10782 wmi_gpio_output_cmd_fixed_param));
10783 cmd->gpio_num = param->gpio_num;
10784 cmd->set = param->set;
10785
10786 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10787 WMI_GPIO_OUTPUT_CMDID);
10788
10789 if (ret != 0) {
10790 WMI_LOGE("Sending GPIO output cmd failed\n");
10791 wmi_buf_free(buf);
10792 }
10793
10794 return ret;
10795
10796}
10797
10798/**
10799 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
10800 *
10801 * @param wmi_handle : handle to WMI.
10802 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10803 */
10804static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
10805{
10806 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
10807 wmi_buf_t buf;
10808 QDF_STATUS ret;
10809 int32_t len;
10810
10811 len = sizeof(*cmd);
10812
10813 buf = wmi_buf_alloc(wmi_handle, len);
10814 if (!buf) {
10815 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10816 return QDF_STATUS_E_FAILURE;
10817 }
10818
10819 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
10820 WMITLV_SET_HDR(&cmd->tlv_header,
10821 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
10822 WMITLV_GET_STRUCT_TLVLEN(
10823 wmi_pdev_dfs_disable_cmd_fixed_param));
10824 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010825 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10826 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010827
10828 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10829 WMI_PDEV_DFS_DISABLE_CMDID);
10830
10831 if (ret != 0) {
10832 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
10833 wmi_buf_free(buf);
10834 }
10835
10836 return ret;
10837}
10838
10839/**
10840 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
10841 *
10842 * @param wmi_handle : handle to WMI.
10843 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10844 */
10845static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
10846{
10847 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
10848 wmi_buf_t buf;
10849 QDF_STATUS ret;
10850 int32_t len;
10851
10852 len = sizeof(*cmd);
10853
10854 buf = wmi_buf_alloc(wmi_handle, len);
10855 if (!buf) {
10856 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10857 return QDF_STATUS_E_FAILURE;
10858 }
10859
10860 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
10861 WMITLV_SET_HDR(&cmd->tlv_header,
10862 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
10863 WMITLV_GET_STRUCT_TLVLEN(
10864 wmi_pdev_dfs_enable_cmd_fixed_param));
10865 /* Reserved for future use */
10866 cmd->reserved0 = 0;
10867
10868 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10869 WMI_PDEV_DFS_ENABLE_CMDID);
10870
10871 if (ret != 0) {
10872 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
10873 wmi_buf_free(buf);
10874 }
10875
10876 return ret;
10877}
10878
10879/**
10880 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
10881 * @wmi_handle: wmi handle
10882 *
10883 * Return: 0 for success or error code
10884 */
10885static QDF_STATUS
10886send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
10887{
10888 wmi_buf_t buf;
10889 QDF_STATUS ret;
10890
10891 buf = wmi_buf_alloc(wmi_handle, 0);
10892 if (buf == NULL)
10893 return QDF_STATUS_E_NOMEM;
10894
10895 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
10896 WMI_PDEV_GET_NFCAL_POWER_CMDID);
10897 if (ret != 0) {
10898 WMI_LOGE("Sending get nfcal power cmd failed\n");
10899 wmi_buf_free(buf);
10900 }
10901
10902 return ret;
10903}
10904
10905/**
10906 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
10907 * @wmi_handle: wmi handle
10908 * @param: pointer to ht ie param
10909 *
10910 * Return: 0 for success or error code
10911 */
10912static QDF_STATUS
10913send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10914 struct ht_ie_params *param)
10915{
10916 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
10917 wmi_buf_t buf;
10918 QDF_STATUS ret;
10919 int32_t len;
10920 uint8_t *buf_ptr;
10921
10922 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10923 roundup(param->ie_len, sizeof(uint32_t));
10924
10925 buf = wmi_buf_alloc(wmi_handle, len);
10926 if (!buf) {
10927 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10928 return QDF_STATUS_E_FAILURE;
10929 }
10930
10931 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10932 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
10933 WMITLV_SET_HDR(&cmd->tlv_header,
10934 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
10935 WMITLV_GET_STRUCT_TLVLEN(
10936 wmi_pdev_set_ht_ie_cmd_fixed_param));
10937 cmd->reserved0 = 0;
10938 cmd->ie_len = param->ie_len;
10939 cmd->tx_streams = param->tx_streams;
10940 cmd->rx_streams = param->rx_streams;
10941
10942 buf_ptr += sizeof(*cmd);
10943 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10944 buf_ptr += WMI_TLV_HDR_SIZE;
10945 if (param->ie_len)
10946 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10947 cmd->ie_len);
10948
10949 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10950 WMI_PDEV_SET_HT_CAP_IE_CMDID);
10951
10952 if (ret != 0) {
10953 WMI_LOGE("Sending set ht ie cmd failed\n");
10954 wmi_buf_free(buf);
10955 }
10956
10957 return ret;
10958}
10959
10960/**
10961 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
10962 * @wmi_handle: wmi handle
10963 * @param: pointer to vht ie param
10964 *
10965 * Return: 0 for success or error code
10966 */
10967static QDF_STATUS
10968send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10969 struct vht_ie_params *param)
10970{
10971 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
10972 wmi_buf_t buf;
10973 QDF_STATUS ret;
10974 int32_t len;
10975 uint8_t *buf_ptr;
10976
10977 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10978 roundup(param->ie_len, sizeof(uint32_t));
10979
10980 buf = wmi_buf_alloc(wmi_handle, len);
10981 if (!buf) {
10982 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10983 return QDF_STATUS_E_FAILURE;
10984 }
10985
10986 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10987 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
10988 WMITLV_SET_HDR(&cmd->tlv_header,
10989 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
10990 WMITLV_GET_STRUCT_TLVLEN(
10991 wmi_pdev_set_vht_ie_cmd_fixed_param));
10992 cmd->reserved0 = 0;
10993 cmd->ie_len = param->ie_len;
10994 cmd->tx_streams = param->tx_streams;
10995 cmd->rx_streams = param->rx_streams;
10996
10997 buf_ptr += sizeof(*cmd);
10998 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10999 buf_ptr += WMI_TLV_HDR_SIZE;
11000 if (param->ie_len)
11001 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11002 cmd->ie_len);
11003
11004 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11005 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11006
11007 if (ret != 0) {
11008 WMI_LOGE("Sending set vht ie cmd failed\n");
11009 wmi_buf_free(buf);
11010 }
11011
11012 return ret;
11013}
11014
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011015/**
11016 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11017 * @wmi_handle: wmi handle
11018 * @param: pointer to quiet mode params
11019 *
11020 * Return: 0 for success or error code
11021 */
11022static QDF_STATUS
11023send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11024 struct set_quiet_mode_params *param)
11025{
11026 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11027 wmi_buf_t buf;
11028 QDF_STATUS ret;
11029 int32_t len;
11030
11031 len = sizeof(*quiet_cmd);
11032 buf = wmi_buf_alloc(wmi_handle, len);
11033 if (!buf) {
11034 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11035 return QDF_STATUS_E_FAILURE;
11036 }
11037
11038 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11039 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11040 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11041 WMITLV_GET_STRUCT_TLVLEN(
11042 wmi_pdev_set_quiet_cmd_fixed_param));
11043 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11044 quiet_cmd->enabled = param->enabled;
11045 quiet_cmd->period = (param->period)*(param->intval);
11046 quiet_cmd->duration = param->duration;
11047 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011048 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11049 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011050
11051 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11052 WMI_PDEV_SET_QUIET_MODE_CMDID);
11053
11054 if (ret != 0) {
11055 WMI_LOGE("Sending set quiet cmd failed\n");
11056 wmi_buf_free(buf);
11057 }
11058
11059 return ret;
11060}
11061
11062/**
11063 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11064 * @wmi_handle: wmi handle
11065 * @param: pointer to set bwf param
11066 *
11067 * Return: 0 for success or error code
11068 */
11069static QDF_STATUS
11070send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
11071 struct set_bwf_params *param)
11072{
11073 wmi_bwf_peer_info *peer_info;
11074 wmi_peer_bwf_request_fixed_param *cmd;
11075 wmi_buf_t buf;
11076 QDF_STATUS retval;
11077 int32_t len;
11078 uint8_t *buf_ptr;
11079 int i;
11080
11081 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11082 len += param->num_peers * sizeof(wmi_bwf_peer_info);
11083 buf = wmi_buf_alloc(wmi_handle, len);
11084 if (!buf) {
11085 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11086 return QDF_STATUS_E_FAILURE;
11087 }
11088 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11089 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
11090 WMITLV_SET_HDR(&cmd->tlv_header,
11091 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
11092 WMITLV_GET_STRUCT_TLVLEN(
11093 wmi_peer_bwf_request_fixed_param));
11094 cmd->num_peers = param->num_peers;
11095
11096 buf_ptr += sizeof(*cmd);
11097 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11098 sizeof(wmi_bwf_peer_info) *
11099 cmd->num_peers);
11100 buf_ptr += WMI_TLV_HDR_SIZE;
11101 peer_info = (wmi_bwf_peer_info *)buf_ptr;
11102
11103 for (i = 0; i < cmd->num_peers; i++) {
11104 WMITLV_SET_HDR(&peer_info->tlv_header,
11105 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
11106 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
11107 peer_info->bwf_guaranteed_bandwidth =
11108 param->peer_info[i].throughput;
11109 peer_info->bwf_max_airtime =
11110 param->peer_info[i].max_airtime;
11111 peer_info->bwf_peer_priority =
11112 param->peer_info[i].priority;
11113 qdf_mem_copy(&peer_info->peer_macaddr,
11114 &param->peer_info[i].peer_macaddr,
11115 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011116 peer_info->vdev_id =
11117 param->peer_info[i].vdev_id;
11118 peer_info->pdev_id =
11119 wmi_handle->ops->convert_pdev_id_host_to_target(
11120 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011121 peer_info++;
11122 }
11123
11124 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11125 WMI_PEER_BWF_REQUEST_CMDID);
11126
11127 if (retval != QDF_STATUS_SUCCESS) {
11128 WMI_LOGE("%s : WMI Failed\n", __func__);
11129 wmi_buf_free(buf);
11130 }
11131
11132 return retval;
11133}
11134
11135/**
11136 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
11137 * @wmi_handle: wmi handle
11138 * @param: pointer to hold mcast update param
11139 *
11140 * Return: 0 for success or error code
11141 */
11142static QDF_STATUS
11143send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
11144 struct mcast_group_update_params *param)
11145{
11146 wmi_peer_mcast_group_cmd_fixed_param *cmd;
11147 wmi_buf_t buf;
11148 QDF_STATUS ret;
11149 int32_t len;
11150 int offset = 0;
11151 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
11152
11153 len = sizeof(*cmd);
11154 buf = wmi_buf_alloc(wmi_handle, len);
11155 if (!buf) {
11156 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11157 return QDF_STATUS_E_FAILURE;
11158 }
11159 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
11160 WMITLV_SET_HDR(&cmd->tlv_header,
11161 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
11162 WMITLV_GET_STRUCT_TLVLEN(
11163 wmi_peer_mcast_group_cmd_fixed_param));
11164 /* confirm the buffer is 4-byte aligned */
11165 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
11166 qdf_mem_zero(cmd, sizeof(*cmd));
11167
11168 cmd->vdev_id = param->vap_id;
11169 /* construct the message assuming our endianness matches the target */
11170 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
11171 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
11172 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
11173 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
11174 if (param->is_action_delete)
11175 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
11176
11177 if (param->is_mcast_addr_len)
11178 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
11179
11180 if (param->is_filter_mode_snoop)
11181 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
11182
11183 /* unicast address spec only applies for non-wildcard cases */
11184 if (!param->wildcard && param->ucast_mac_addr) {
11185 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
11186 &cmd->ucast_mac_addr);
11187 }
11188 if (param->mcast_ip_addr) {
11189 QDF_ASSERT(param->mcast_ip_addr_bytes <=
11190 sizeof(cmd->mcast_ip_addr));
11191 offset = sizeof(cmd->mcast_ip_addr) -
11192 param->mcast_ip_addr_bytes;
11193 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
11194 param->mcast_ip_addr,
11195 param->mcast_ip_addr_bytes);
11196 }
11197 if (!param->mask)
11198 param->mask = &dummymask[0];
11199
11200 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
11201 param->mask,
11202 param->mcast_ip_addr_bytes);
11203
11204 if (param->srcs && param->nsrcs) {
11205 cmd->num_filter_addr = param->nsrcs;
11206 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
11207 sizeof(cmd->filter_addr));
11208
11209 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
11210 param->nsrcs * param->mcast_ip_addr_bytes);
11211 }
11212
11213 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11214 WMI_PEER_MCAST_GROUP_CMDID);
11215
11216 if (ret != QDF_STATUS_SUCCESS) {
11217 WMI_LOGE("%s : WMI Failed\n", __func__);
11218 wmi_buf_free(buf);
11219 }
11220
11221 return ret;
11222}
11223
11224/**
11225 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
11226 * command to fw
11227 * @wmi_handle: wmi handle
11228 * @param: pointer to hold spectral config parameter
11229 *
11230 * Return: 0 for success or error code
11231 */
11232static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
11233 struct vdev_spectral_configure_params *param)
11234{
11235 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
11236 wmi_buf_t buf;
11237 QDF_STATUS ret;
11238 int32_t len;
11239
11240 len = sizeof(*cmd);
11241 buf = wmi_buf_alloc(wmi_handle, len);
11242 if (!buf) {
11243 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11244 return QDF_STATUS_E_FAILURE;
11245 }
11246
11247 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
11248 WMITLV_SET_HDR(&cmd->tlv_header,
11249 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
11250 WMITLV_GET_STRUCT_TLVLEN(
11251 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param));
11252
11253 cmd->vdev_id = param->vdev_id;
11254 cmd->spectral_scan_count = param->count;
11255 cmd->spectral_scan_period = param->period;
11256 cmd->spectral_scan_priority = param->spectral_pri;
11257 cmd->spectral_scan_fft_size = param->fft_size;
11258 cmd->spectral_scan_gc_ena = param->gc_enable;
11259 cmd->spectral_scan_restart_ena = param->restart_enable;
11260 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
11261 cmd->spectral_scan_init_delay = param->init_delay;
11262 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
11263 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
11264 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
11265 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
11266 cmd->spectral_scan_rssi_thr = param->rssi_thr;
11267 cmd->spectral_scan_pwr_format = param->pwr_format;
11268 cmd->spectral_scan_rpt_mode = param->rpt_mode;
11269 cmd->spectral_scan_bin_scale = param->bin_scale;
11270 cmd->spectral_scan_dBm_adj = param->dBm_adj;
11271 cmd->spectral_scan_chn_mask = param->chn_mask;
11272
11273 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11274 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
11275
11276 if (ret != 0) {
11277 WMI_LOGE("Sending set quiet cmd failed\n");
11278 wmi_buf_free(buf);
11279 }
11280
11281 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
11282 __func__);
11283
11284 WMI_LOGI("vdev_id = %u\n"
11285 "spectral_scan_count = %u\n"
11286 "spectral_scan_period = %u\n"
11287 "spectral_scan_priority = %u\n"
11288 "spectral_scan_fft_size = %u\n"
11289 "spectral_scan_gc_ena = %u\n"
11290 "spectral_scan_restart_ena = %u\n"
11291 "spectral_scan_noise_floor_ref = %u\n"
11292 "spectral_scan_init_delay = %u\n"
11293 "spectral_scan_nb_tone_thr = %u\n"
11294 "spectral_scan_str_bin_thr = %u\n"
11295 "spectral_scan_wb_rpt_mode = %u\n"
11296 "spectral_scan_rssi_rpt_mode = %u\n"
11297 "spectral_scan_rssi_thr = %u\n"
11298 "spectral_scan_pwr_format = %u\n"
11299 "spectral_scan_rpt_mode = %u\n"
11300 "spectral_scan_bin_scale = %u\n"
11301 "spectral_scan_dBm_adj = %u\n"
11302 "spectral_scan_chn_mask = %u\n",
11303 param->vdev_id,
11304 param->count,
11305 param->period,
11306 param->spectral_pri,
11307 param->fft_size,
11308 param->gc_enable,
11309 param->restart_enable,
11310 param->noise_floor_ref,
11311 param->init_delay,
11312 param->nb_tone_thr,
11313 param->str_bin_thr,
11314 param->wb_rpt_mode,
11315 param->rssi_rpt_mode,
11316 param->rssi_thr,
11317 param->pwr_format,
11318 param->rpt_mode,
11319 param->bin_scale,
11320 param->dBm_adj,
11321 param->chn_mask);
11322 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11323
11324 return ret;
11325}
11326
11327/**
11328 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
11329 * command to fw
11330 * @wmi_handle: wmi handle
11331 * @param: pointer to hold spectral enable parameter
11332 *
11333 * Return: 0 for success or error code
11334 */
11335static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
11336 struct vdev_spectral_enable_params *param)
11337{
11338 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
11339 wmi_buf_t buf;
11340 QDF_STATUS ret;
11341 int32_t len;
11342
11343 len = sizeof(*cmd);
11344 buf = wmi_buf_alloc(wmi_handle, len);
11345 if (!buf) {
11346 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11347 return QDF_STATUS_E_FAILURE;
11348 }
11349
11350 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
11351 WMITLV_SET_HDR(&cmd->tlv_header,
11352 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
11353 WMITLV_GET_STRUCT_TLVLEN(
11354 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param));
11355
11356 cmd->vdev_id = param->vdev_id;
11357
11358 if (param->active_valid) {
11359 cmd->trigger_cmd = param->active ? 1 : 2;
11360 /* 1: Trigger, 2: Clear Trigger */
11361 } else {
11362 cmd->trigger_cmd = 0; /* 0: Ignore */
11363 }
11364
11365 if (param->enabled_valid) {
11366 cmd->enable_cmd = param->enabled ? 1 : 2;
11367 /* 1: Enable 2: Disable */
11368 } else {
11369 cmd->enable_cmd = 0; /* 0: Ignore */
11370 }
11371
11372 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11373 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
11374
11375 if (ret != 0) {
11376 WMI_LOGE("Sending scan enable CMD failed\n");
11377 wmi_buf_free(buf);
11378 }
11379
11380 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
11381
11382 WMI_LOGI("vdev_id = %u\n"
11383 "trigger_cmd = %u\n"
11384 "enable_cmd = %u\n",
11385 cmd->vdev_id,
11386 cmd->trigger_cmd,
11387 cmd->enable_cmd);
11388
11389 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11390
11391 return ret;
11392}
11393
11394/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011395 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
11396 * @param wmi_handle : handle to WMI.
11397 * @param param : pointer to hold thermal mitigation param
11398 *
11399 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11400 */
11401static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
11402 wmi_unified_t wmi_handle,
11403 struct thermal_mitigation_params *param)
11404{
11405 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
11406 wmi_therm_throt_level_config_info *lvl_conf = NULL;
11407 wmi_buf_t buf = NULL;
11408 uint8_t *buf_ptr = NULL;
11409 int error;
11410 int32_t len;
11411 int i;
11412
11413 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
11414 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
11415
11416 buf = wmi_buf_alloc(wmi_handle, len);
11417 if (!buf) {
11418 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11419 return QDF_STATUS_E_NOMEM;
11420 }
11421 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
11422
11423 /* init fixed params */
11424 WMITLV_SET_HDR(tt_conf,
11425 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
11426 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
11427
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011428 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11429 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011430 tt_conf->enable = param->enable;
11431 tt_conf->dc = param->dc;
11432 tt_conf->dc_per_event = param->dc_per_event;
11433 tt_conf->therm_throt_levels = THERMAL_LEVELS;
11434
11435 buf_ptr = (uint8_t *) ++tt_conf;
11436 /* init TLV params */
11437 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11438 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
11439
11440 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
11441 for (i = 0; i < THERMAL_LEVELS; i++) {
11442 WMITLV_SET_HDR(&lvl_conf->tlv_header,
11443 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
11444 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
11445 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
11446 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
11447 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
11448 lvl_conf->prio = param->levelconf[i].priority;
11449 lvl_conf++;
11450 }
11451
11452 error = wmi_unified_cmd_send(wmi_handle, buf, len,
11453 WMI_THERM_THROT_SET_CONF_CMDID);
11454 if (QDF_IS_STATUS_ERROR(error)) {
11455 wmi_buf_free(buf);
11456 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
11457 }
11458
11459 return error;
11460}
11461
11462/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011463 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
11464 * @wmi_handle: wmi handle
11465 * @param: pointer to pdev_qvit_params
11466 *
11467 * Return: 0 for success or error code
11468 */
11469static QDF_STATUS
11470send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
11471 struct pdev_qvit_params *param)
11472{
11473 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011474 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011475 uint8_t *cmd;
11476 static uint8_t msgref = 1;
11477 uint8_t segnumber = 0, seginfo, numsegments;
11478 uint16_t chunk_len, total_bytes;
11479 uint8_t *bufpos;
11480 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
11481
11482 bufpos = param->utf_payload;
11483 total_bytes = param->len;
11484 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
11485 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
11486 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
11487
11488 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
11489 numsegments++;
11490
11491 while (param->len) {
11492 if (param->len > MAX_WMI_QVIT_LEN)
11493 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
11494 else
11495 chunk_len = param->len;
11496
11497 buf = wmi_buf_alloc(wmi_handle,
11498 (chunk_len + sizeof(seghdrinfo) +
11499 WMI_TLV_HDR_SIZE));
11500 if (!buf) {
11501 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11502 return QDF_STATUS_E_NOMEM;
11503 }
11504
11505 cmd = (uint8_t *) wmi_buf_data(buf);
11506
11507 seghdrinfo.len = total_bytes;
11508 seghdrinfo.msgref = msgref;
11509 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
11510 seghdrinfo.segmentInfo = seginfo;
11511
11512 segnumber++;
11513
11514 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
11515 (chunk_len + sizeof(seghdrinfo)));
11516 cmd += WMI_TLV_HDR_SIZE;
11517 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
11518 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
11519
11520 ret = wmi_unified_cmd_send(wmi_handle, buf,
11521 (chunk_len + sizeof(seghdrinfo) +
11522 WMI_TLV_HDR_SIZE),
11523 WMI_PDEV_QVIT_CMDID);
11524
11525 if (ret != 0) {
11526 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
11527 wmi_buf_free(buf);
11528 break;
11529 }
11530
11531 param->len -= chunk_len;
11532 bufpos += chunk_len;
11533 }
11534 msgref++;
11535
11536 return ret;
11537}
11538
11539/**
11540 * send_wmm_update_cmd_tlv() - send wmm update command to fw
11541 * @wmi_handle: wmi handle
11542 * @param: pointer to wmm update param
11543 *
11544 * Return: 0 for success or error code
11545 */
11546static QDF_STATUS
11547send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
11548 struct wmm_update_params *param)
11549{
11550 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
11551 wmi_wmm_params *wmm_param;
11552 wmi_buf_t buf;
11553 QDF_STATUS ret;
11554 int32_t len;
11555 int ac = 0;
11556 struct wmi_host_wmeParams *wmep;
11557 uint8_t *buf_ptr;
11558
11559 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
11560 buf = wmi_buf_alloc(wmi_handle, len);
11561 if (!buf) {
11562 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11563 return QDF_STATUS_E_FAILURE;
11564 }
11565
11566 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11567 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
11568 WMITLV_SET_HDR(&cmd->tlv_header,
11569 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
11570 WMITLV_GET_STRUCT_TLVLEN
11571 (wmi_pdev_set_wmm_params_cmd_fixed_param));
11572
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011573 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011574
11575 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
11576
11577 for (ac = 0; ac < WME_NUM_AC; ac++) {
11578 wmep = &param->wmep_array[ac];
11579 wmm_param = (wmi_wmm_params *)buf_ptr;
11580 WMITLV_SET_HDR(&wmm_param->tlv_header,
11581 WMITLV_TAG_STRUC_wmi_wmm_params,
11582 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
11583 wmm_param->aifs = wmep->wmep_aifsn;
11584 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
11585 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
11586 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
11587 wmm_param->acm = wmep->wmep_acm;
11588 wmm_param->no_ack = wmep->wmep_noackPolicy;
11589 buf_ptr += sizeof(wmi_wmm_params);
11590 }
11591 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11592 WMI_PDEV_SET_WMM_PARAMS_CMDID);
11593
11594 if (ret != 0) {
11595 WMI_LOGE("Sending WMM update CMD failed\n");
11596 wmi_buf_free(buf);
11597 }
11598
11599 return ret;
11600}
11601
Sathish Kumar80f4f382017-04-24 11:36:00 +053011602/**
11603 * send_coex_config_cmd_tlv() - send coex config command to fw
11604 * @wmi_handle: wmi handle
11605 * @param: pointer to coex config param
11606 *
11607 * Return: 0 for success or error code
11608 */
11609static QDF_STATUS
11610send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
11611 struct coex_config_params *param)
11612{
11613 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
11614 wmi_buf_t buf;
11615 QDF_STATUS ret;
11616 int32_t len;
11617
11618 len = sizeof(*cmd);
11619 buf = wmi_buf_alloc(wmi_handle, len);
11620 if (!buf) {
11621 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11622 return QDF_STATUS_E_FAILURE;
11623 }
11624
11625 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
11626 WMITLV_SET_HDR(&cmd->tlv_header,
11627 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
11628 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053011629 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053011630
11631 cmd->vdev_id = param->vdev_id;
11632 cmd->config_type = param->config_type;
11633 cmd->config_arg1 = param->config_arg1;
11634 cmd->config_arg2 = param->config_arg2;
11635 cmd->config_arg3 = param->config_arg3;
11636 cmd->config_arg4 = param->config_arg4;
11637 cmd->config_arg5 = param->config_arg5;
11638 cmd->config_arg6 = param->config_arg6;
11639
11640 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11641 WMI_COEX_CONFIG_CMDID);
11642
11643 if (ret != 0) {
11644 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
11645 wmi_buf_free(buf);
11646 }
11647
11648 return ret;
11649}
11650
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011651static
Govind Singh9ddd5162016-03-07 16:30:32 +053011652void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053011653 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053011654{
Govind Singhe7f2f342016-05-23 12:12:52 +053011655 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053011656 resource_cfg->num_peers = tgt_res_cfg->num_peers;
11657 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
11658 resource_cfg->num_offload_reorder_buffs =
11659 tgt_res_cfg->num_offload_reorder_buffs;
11660 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
11661 resource_cfg->num_tids = tgt_res_cfg->num_tids;
11662 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
11663 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
11664 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
11665 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
11666 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
11667 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
11668 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
11669 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
11670 resource_cfg->scan_max_pending_req =
11671 tgt_res_cfg->scan_max_pending_req;
11672 resource_cfg->bmiss_offload_max_vdev =
11673 tgt_res_cfg->bmiss_offload_max_vdev;
11674 resource_cfg->roam_offload_max_vdev =
11675 tgt_res_cfg->roam_offload_max_vdev;
11676 resource_cfg->roam_offload_max_ap_profiles =
11677 tgt_res_cfg->roam_offload_max_ap_profiles;
11678 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
11679 resource_cfg->num_mcast_table_elems =
11680 tgt_res_cfg->num_mcast_table_elems;
11681 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
11682 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
11683 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
11684 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
11685 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
11686 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
11687 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
11688 resource_cfg->vow_config = tgt_res_cfg->vow_config;
11689 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
11690 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
11691 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
11692 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
11693 resource_cfg->num_tdls_conn_table_entries =
11694 tgt_res_cfg->num_tdls_conn_table_entries;
11695 resource_cfg->beacon_tx_offload_max_vdev =
11696 tgt_res_cfg->beacon_tx_offload_max_vdev;
11697 resource_cfg->num_multicast_filter_entries =
11698 tgt_res_cfg->num_multicast_filter_entries;
11699 resource_cfg->num_wow_filters =
11700 tgt_res_cfg->num_wow_filters;
11701 resource_cfg->num_keep_alive_pattern =
11702 tgt_res_cfg->num_keep_alive_pattern;
11703 resource_cfg->keep_alive_pattern_size =
11704 tgt_res_cfg->keep_alive_pattern_size;
11705 resource_cfg->max_tdls_concurrent_sleep_sta =
11706 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
11707 resource_cfg->max_tdls_concurrent_buffer_sta =
11708 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
11709 resource_cfg->wmi_send_separate =
11710 tgt_res_cfg->wmi_send_separate;
11711 resource_cfg->num_ocb_vdevs =
11712 tgt_res_cfg->num_ocb_vdevs;
11713 resource_cfg->num_ocb_channels =
11714 tgt_res_cfg->num_ocb_channels;
11715 resource_cfg->num_ocb_schedules =
11716 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053011717 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
11718 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
11719 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011720
11721 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1,
11722 tgt_res_cfg->atf_config);
Govind Singh9ddd5162016-03-07 16:30:32 +053011723}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011724#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011725/**
11726 * send_init_cmd_tlv() - wmi init command
11727 * @wmi_handle: pointer to wmi handle
11728 * @res_cfg: resource config
11729 * @num_mem_chunks: no of mem chunck
11730 * @mem_chunk: pointer to mem chunck structure
11731 *
11732 * This function sends IE information to firmware
11733 *
Govind Singhb53420c2016-03-09 14:32:57 +053011734 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011735 *
11736 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011737static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011738 wmi_resource_config *tgt_res_cfg,
11739 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
11740 bool action)
11741{
11742 wmi_buf_t buf;
11743 wmi_init_cmd_fixed_param *cmd;
11744 wmi_abi_version my_vers;
11745 int num_whitelist;
11746 uint8_t *buf_ptr;
11747 wmi_resource_config *resource_cfg;
11748 wlan_host_memory_chunk *host_mem_chunks;
11749 uint32_t mem_chunk_len = 0;
11750 uint16_t idx;
11751 int len;
11752 int ret;
11753
11754 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11755 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11756 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11757 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011758 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
11759 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011760 }
11761
11762 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11763 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11764 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11765
11766 host_mem_chunks = (wlan_host_memory_chunk *)
11767 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11768 + WMI_TLV_HDR_SIZE);
11769
11770 WMITLV_SET_HDR(&cmd->tlv_header,
11771 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11772 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11773
Govind Singhb53420c2016-03-09 14:32:57 +053011774 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053011775 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11776 WMITLV_TAG_STRUC_wmi_resource_config,
11777 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11778
11779 for (idx = 0; idx < num_mem_chunks; ++idx) {
11780 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11781 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11782 WMITLV_GET_STRUCT_TLVLEN
11783 (wlan_host_memory_chunk));
11784 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11785 host_mem_chunks[idx].size = mem_chunks[idx].len;
11786 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053011787 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053011788 idx, host_mem_chunks[idx].size,
11789 host_mem_chunks[idx].ptr);
11790 }
11791 cmd->num_host_mem_chunks = num_mem_chunks;
11792 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11793 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11794 WMITLV_TAG_ARRAY_STRUC,
11795 (sizeof(wlan_host_memory_chunk) *
11796 num_mem_chunks));
11797
11798 num_whitelist = sizeof(version_whitelist) /
11799 sizeof(wmi_whitelist_version_info);
11800 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11801 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11802 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11803 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11804 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11805 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053011806#ifdef CONFIG_MCL
11807 /* This needs to be enabled for WIN Lithium after removing dependency
11808 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053011809 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11810 &my_vers,
11811 &wmi_handle->fw_abi_version,
11812 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011813#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011814 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053011815 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11816 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11817 cmd->host_abi_vers.abi_version_ns_0,
11818 cmd->host_abi_vers.abi_version_ns_1,
11819 cmd->host_abi_vers.abi_version_ns_2,
11820 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053011821#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011822 /* Save version sent from host -
11823 * Will be used to check ready event
11824 */
Govind Singhb53420c2016-03-09 14:32:57 +053011825 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011826 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011827#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011828 if (action) {
11829 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11830 WMI_INIT_CMDID);
11831 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053011832 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053011833 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011834 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011835 }
11836 } else {
11837 wmi_handle->saved_wmi_init_cmd.buf = buf;
11838 wmi_handle->saved_wmi_init_cmd.buf_len = len;
11839 }
11840
Govind Singhb53420c2016-03-09 14:32:57 +053011841 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011842
11843}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011844#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011845/**
11846 * send_saved_init_cmd_tlv() - wmi init command
11847 * @wmi_handle: pointer to wmi handle
11848 *
11849 * This function sends IE information to firmware
11850 *
Govind Singhb53420c2016-03-09 14:32:57 +053011851 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011852 *
11853 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011854static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053011855{
11856 int status;
11857
11858 if (!wmi_handle->saved_wmi_init_cmd.buf ||
11859 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053011860 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
11861 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011862 }
11863 status = wmi_unified_cmd_send(wmi_handle,
11864 wmi_handle->saved_wmi_init_cmd.buf,
11865 wmi_handle->saved_wmi_init_cmd.buf_len,
11866 WMI_INIT_CMDID);
11867 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053011868 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053011869 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011870 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011871 }
11872 wmi_handle->saved_wmi_init_cmd.buf = NULL;
11873 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
11874
Govind Singhb53420c2016-03-09 14:32:57 +053011875 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011876}
11877
Sathish Kumarfd347372017-02-13 12:29:09 +053011878static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053011879{
11880 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11881 wmi_service_ready_event_fixed_param *ev;
11882
11883
11884 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11885
11886 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11887 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053011888 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011889
Govind Singh87542482016-06-08 19:40:11 +053011890#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011891 /*Save fw version from service ready message */
11892 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053011893 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011894 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011895#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011896 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011897}
11898
11899/**
11900 * wmi_unified_save_fw_version_cmd() - save fw version
11901 * @wmi_handle: pointer to wmi handle
11902 * @res_cfg: resource config
11903 * @num_mem_chunks: no of mem chunck
11904 * @mem_chunk: pointer to mem chunck structure
11905 *
11906 * This function sends IE information to firmware
11907 *
Govind Singhb53420c2016-03-09 14:32:57 +053011908 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011909 *
11910 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011911static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011912 void *evt_buf)
11913{
11914 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11915 wmi_ready_event_fixed_param *ev = NULL;
11916
11917 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11918 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053011919#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011920 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
11921 &ev->fw_abi_vers)) {
11922 /*
11923 * Error: Our host version and the given firmware version
11924 * are incompatible.
11925 **/
Govind Singhb53420c2016-03-09 14:32:57 +053011926 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053011927 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
11928 __func__,
11929 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
11930 abi_version_0),
11931 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
11932 abi_version_0),
11933 wmi_handle->final_abi_vers.abi_version_ns_0,
11934 wmi_handle->final_abi_vers.abi_version_ns_1,
11935 wmi_handle->final_abi_vers.abi_version_ns_2,
11936 wmi_handle->final_abi_vers.abi_version_ns_3,
11937 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
11938 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
11939 ev->fw_abi_vers.abi_version_ns_0,
11940 ev->fw_abi_vers.abi_version_ns_1,
11941 ev->fw_abi_vers.abi_version_ns_2,
11942 ev->fw_abi_vers.abi_version_ns_3);
11943
Govind Singhb53420c2016-03-09 14:32:57 +053011944 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011945 }
Govind Singhb53420c2016-03-09 14:32:57 +053011946 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011947 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053011948 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011949 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011950#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011951
Govind Singhb53420c2016-03-09 14:32:57 +053011952 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011953}
Govind Singha4836fd2016-03-07 16:45:38 +053011954
11955/**
11956 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
11957 * @wmi_handle: wmi handle
11958 * @custom_addr: base mac address
11959 *
Govind Singhe7f2f342016-05-23 12:12:52 +053011960 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053011961 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011962static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011963 uint8_t *custom_addr)
11964{
11965 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
11966 wmi_buf_t buf;
11967 int err;
11968
11969 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11970 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011971 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053011972 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011973 }
11974
11975 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011976 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053011977
11978 WMITLV_SET_HDR(&cmd->tlv_header,
11979 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
11980 WMITLV_GET_STRUCT_TLVLEN
11981 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
11982 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011983 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11984 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053011985 err = wmi_unified_cmd_send(wmi_handle, buf,
11986 sizeof(*cmd),
11987 WMI_PDEV_SET_BASE_MACADDR_CMDID);
11988 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053011989 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053011990 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011991 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011992 }
11993
11994 return 0;
11995}
11996
11997/**
11998 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
11999 * @handle: wmi handle
12000 * @event: Event received from FW
12001 * @len: Length of the event
12002 *
12003 * Enables the low frequency events and disables the high frequency
12004 * events. Bit 17 indicates if the event if low/high frequency.
12005 * 1 - high frequency, 0 - low frequency
12006 *
12007 * Return: 0 on successfully enabling/disabling the events
12008 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012009static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012010 uint8_t *event,
12011 uint32_t len)
12012{
12013 uint32_t num_of_diag_events_logs;
12014 wmi_diag_event_log_config_fixed_param *cmd;
12015 wmi_buf_t buf;
12016 uint8_t *buf_ptr;
12017 uint32_t *cmd_args, *evt_args;
12018 uint32_t buf_len, i;
12019
12020 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12021 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12022
Govind Singhb53420c2016-03-09 14:32:57 +053012023 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012024
12025 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12026 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012027 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012028 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012029 }
12030 wmi_event = param_buf->fixed_param;
12031 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
12032 evt_args = param_buf->diag_events_logs_list;
12033 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012034 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012035 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012036 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012037 }
12038
Govind Singhb53420c2016-03-09 14:32:57 +053012039 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012040 __func__, num_of_diag_events_logs);
12041
12042 /* Free any previous allocation */
12043 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012044 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012045
12046 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012047 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012048 sizeof(uint32_t));
12049 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012050 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012051 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012052 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012053 }
12054 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12055
12056 /* Prepare the send buffer */
12057 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12058 (num_of_diag_events_logs * sizeof(uint32_t));
12059
12060 buf = wmi_buf_alloc(wmi_handle, buf_len);
12061 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012062 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12063 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012064 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012065 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012066 }
12067
12068 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12069 buf_ptr = (uint8_t *) cmd;
12070
12071 WMITLV_SET_HDR(&cmd->tlv_header,
12072 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12073 WMITLV_GET_STRUCT_TLVLEN(
12074 wmi_diag_event_log_config_fixed_param));
12075
12076 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
12077
12078 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12079
12080 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12081 (num_of_diag_events_logs * sizeof(uint32_t)));
12082
12083 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12084
12085 /* Populate the events */
12086 for (i = 0; i < num_of_diag_events_logs; i++) {
12087 /* Low freq (0) - Enable (1) the event
12088 * High freq (1) - Disable (0) the event
12089 */
12090 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
12091 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
12092 /* Set the event ID */
12093 WMI_DIAG_ID_SET(cmd_args[i],
12094 WMI_DIAG_ID_GET(evt_args[i]));
12095 /* Set the type */
12096 WMI_DIAG_TYPE_SET(cmd_args[i],
12097 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053012098 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053012099 wmi_handle->events_logs_list[i] = evt_args[i];
12100 }
12101
12102 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
12103 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012104 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012105 __func__);
12106 wmi_buf_free(buf);
12107 /* Not clearing events_logs_list, though wmi cmd failed.
12108 * Host can still have this list
12109 */
Govind Singh67922e82016-04-01 16:48:57 +053012110 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012111 }
12112
12113 return 0;
12114}
12115
12116/**
12117 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
12118 * @wmi_handle: wmi handle
12119 * @start_log: Start logging related parameters
12120 *
12121 * Send the command to the FW based on which specific logging of diag
12122 * event/log id can be started/stopped
12123 *
12124 * Return: None
12125 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012126static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012127 struct wmi_wifi_start_log *start_log)
12128{
12129 wmi_diag_event_log_config_fixed_param *cmd;
12130 wmi_buf_t buf;
12131 uint8_t *buf_ptr;
12132 uint32_t len, count, log_level, i;
12133 uint32_t *cmd_args;
12134 uint32_t total_len;
12135 count = 0;
12136
12137 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012138 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053012139 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012140 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012141 }
12142 /* total_len stores the number of events where BITS 17 and 18 are set.
12143 * i.e., events of high frequency (17) and for extended debugging (18)
12144 */
12145 total_len = 0;
12146 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12147 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
12148 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
12149 total_len++;
12150 }
12151
12152 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12153 (total_len * sizeof(uint32_t));
12154
12155 buf = wmi_buf_alloc(wmi_handle, len);
12156 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012157 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012158 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012159 }
12160 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12161 buf_ptr = (uint8_t *) cmd;
12162
12163 WMITLV_SET_HDR(&cmd->tlv_header,
12164 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12165 WMITLV_GET_STRUCT_TLVLEN(
12166 wmi_diag_event_log_config_fixed_param));
12167
12168 cmd->num_of_diag_events_logs = total_len;
12169
12170 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12171
12172 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12173 (total_len * sizeof(uint32_t)));
12174
12175 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12176
Govind Singh224a7312016-06-21 14:33:26 +053012177 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053012178 log_level = 1;
12179 else
12180 log_level = 0;
12181
Govind Singhb53420c2016-03-09 14:32:57 +053012182 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053012183 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12184 uint32_t val = wmi_handle->events_logs_list[i];
12185 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
12186 (WMI_DIAG_EXT_FEATURE_GET(val))) {
12187
12188 WMI_DIAG_ID_SET(cmd_args[count],
12189 WMI_DIAG_ID_GET(val));
12190 WMI_DIAG_TYPE_SET(cmd_args[count],
12191 WMI_DIAG_TYPE_GET(val));
12192 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
12193 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053012194 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053012195 count++;
12196 }
12197 }
12198
12199 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12200 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012201 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012202 __func__);
12203 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012204 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012205 }
12206
Govind Singhb53420c2016-03-09 14:32:57 +053012207 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012208}
12209
12210/**
12211 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
12212 * @wmi_handle: WMI handle
12213 *
12214 * This function is used to send the flush command to the FW,
12215 * that will flush the fw logs that are residue in the FW
12216 *
12217 * Return: None
12218 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012219static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053012220{
12221 wmi_debug_mesg_flush_fixed_param *cmd;
12222 wmi_buf_t buf;
12223 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053012224 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012225
12226 buf = wmi_buf_alloc(wmi_handle, len);
12227 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012228 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012229 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012230 }
12231
12232 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
12233 WMITLV_SET_HDR(&cmd->tlv_header,
12234 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
12235 WMITLV_GET_STRUCT_TLVLEN(
12236 wmi_debug_mesg_flush_fixed_param));
12237 cmd->reserved0 = 0;
12238
12239 ret = wmi_unified_cmd_send(wmi_handle,
12240 buf,
12241 len,
12242 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053012243 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012244 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053012245 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012246 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012247 }
Govind Singhb53420c2016-03-09 14:32:57 +053012248 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053012249
Govind Singh67922e82016-04-01 16:48:57 +053012250 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012251}
12252
12253/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012254 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012255 * @wmi_handle: wmi handle
12256 * @msg: PCL structure containing the PCL and the number of channels
12257 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012258 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053012259 * firmware. The DBS Manager is the consumer of this information in the WLAN
12260 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
12261 * to migrate to a new channel without host driver involvement. An example of
12262 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
12263 * manage the channel selection without firmware involvement.
12264 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012265 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
12266 * channel list. The weights corresponds to the channels sent in
12267 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
12268 * weightage compared to the non PCL channels.
12269 *
Govind Singha4836fd2016-03-07 16:45:38 +053012270 * Return: Success if the cmd is sent successfully to the firmware
12271 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012272static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012273 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053012274{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012275 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012276 wmi_buf_t buf;
12277 uint8_t *buf_ptr;
12278 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012279 uint32_t chan_len;
12280
12281 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053012282
12283 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012284 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012285
12286 buf = wmi_buf_alloc(wmi_handle, len);
12287 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012288 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12289 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012290 }
12291
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012292 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012293 buf_ptr = (uint8_t *) cmd;
12294 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012295 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
12296 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053012297
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012298 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12299 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012300 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053012301 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012302
12303 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053012304 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012305 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053012306 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012307 for (i = 0; i < chan_len ; i++) {
12308 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053012309 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012310 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012311 }
12312 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012313 WMI_PDEV_SET_PCL_CMDID)) {
12314 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012315 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012316 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012317 }
Govind Singhb53420c2016-03-09 14:32:57 +053012318 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012319}
12320
12321/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012322 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012323 * @wmi_handle: wmi handle
12324 * @msg: Structure containing the following parameters
12325 *
12326 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
12327 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
12328 *
12329 * Provides notification to the WLAN firmware that host driver is requesting a
12330 * HardWare (HW) Mode change. This command is needed to support iHelium in the
12331 * configurations that include the Dual Band Simultaneous (DBS) feature.
12332 *
12333 * Return: Success if the cmd is sent successfully to the firmware
12334 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012335static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012336 uint32_t hw_mode_index)
12337{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012338 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012339 wmi_buf_t buf;
12340 uint32_t len;
12341
12342 len = sizeof(*cmd);
12343
12344 buf = wmi_buf_alloc(wmi_handle, len);
12345 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012346 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12347 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012348 }
12349
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012350 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012351 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012352 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12353 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
12354
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012355 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12356 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012357 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053012358 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053012359
12360 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012361 WMI_PDEV_SET_HW_MODE_CMDID)) {
12362 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012363 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012364 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012365 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012366 }
12367
Govind Singhb53420c2016-03-09 14:32:57 +053012368 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012369}
12370
12371/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012372 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012373 * @wmi_handle: wmi handle
12374 * @msg: Dual MAC config parameters
12375 *
12376 * Configures WLAN firmware with the dual MAC features
12377 *
Govind Singhb53420c2016-03-09 14:32:57 +053012378 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053012379 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012380static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012381QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012382 struct wmi_dual_mac_config *msg)
12383{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012384 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012385 wmi_buf_t buf;
12386 uint32_t len;
12387
12388 len = sizeof(*cmd);
12389
12390 buf = wmi_buf_alloc(wmi_handle, len);
12391 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012392 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12393 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012394 }
12395
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012396 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012397 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012398 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053012399 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012400 wmi_pdev_set_mac_config_cmd_fixed_param));
12401
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012402 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12403 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012404 cmd->concurrent_scan_config_bits = msg->scan_config;
12405 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053012406 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053012407 __func__, msg->scan_config, msg->fw_mode_config);
12408
12409 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012410 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
12411 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012412 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012413 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012414 }
Govind Singhb53420c2016-03-09 14:32:57 +053012415 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012416}
12417
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012418#ifdef BIG_ENDIAN_HOST
12419/**
12420* fips_conv_data_be() - LE to BE conversion of FIPS ev data
12421* @param data_len - data length
12422* @param data - pointer to data
12423*
12424* Return: QDF_STATUS - success or error status
12425*/
12426static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12427 struct fips_params *param)
12428{
12429 unsigned char *key_unaligned, *data_unaligned;
12430 int c;
12431 u_int8_t *key_aligned = NULL;
12432 u_int8_t *data_aligned = NULL;
12433
12434 /* Assigning unaligned space to copy the key */
12435 key_unaligned = qdf_mem_malloc(
12436 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
12437 data_unaligned = qdf_mem_malloc(
12438 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
12439
12440 /* Checking if kmalloc is succesful to allocate space */
12441 if (key_unaligned == NULL)
12442 return QDF_STATUS_SUCCESS;
12443 /* Checking if space is aligned */
12444 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
12445 /* align to 4 */
12446 key_aligned =
12447 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
12448 FIPS_ALIGN);
12449 } else {
12450 key_aligned = (u_int8_t *)key_unaligned;
12451 }
12452
12453 /* memset and copy content from key to key aligned */
12454 OS_MEMSET(key_aligned, 0, param->key_len);
12455 OS_MEMCPY(key_aligned, param->key, param->key_len);
12456
12457 /* print a hexdump for host debug */
12458 print_hex_dump(KERN_DEBUG,
12459 "\t Aligned and Copied Key:@@@@ ",
12460 DUMP_PREFIX_NONE,
12461 16, 1, key_aligned, param->key_len, true);
12462
12463 /* Checking if kmalloc is succesful to allocate space */
12464 if (data_unaligned == NULL)
12465 return QDF_STATUS_SUCCESS;
12466 /* Checking of space is aligned */
12467 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
12468 /* align to 4 */
12469 data_aligned =
12470 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
12471 FIPS_ALIGN);
12472 } else {
12473 data_aligned = (u_int8_t *)data_unaligned;
12474 }
12475
12476 /* memset and copy content from data to data aligned */
12477 OS_MEMSET(data_aligned, 0, param->data_len);
12478 OS_MEMCPY(data_aligned, param->data, param->data_len);
12479
12480 /* print a hexdump for host debug */
12481 print_hex_dump(KERN_DEBUG,
12482 "\t Properly Aligned and Copied Data:@@@@ ",
12483 DUMP_PREFIX_NONE,
12484 16, 1, data_aligned, param->data_len, true);
12485
12486 /* converting to little Endian both key_aligned and
12487 * data_aligned*/
12488 for (c = 0; c < param->key_len/4; c++) {
12489 *((u_int32_t *)key_aligned+c) =
12490 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
12491 }
12492 for (c = 0; c < param->data_len/4; c++) {
12493 *((u_int32_t *)data_aligned+c) =
12494 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
12495 }
12496
12497 /* update endian data to key and data vectors */
12498 OS_MEMCPY(param->key, key_aligned, param->key_len);
12499 OS_MEMCPY(param->data, data_aligned, param->data_len);
12500
12501 /* clean up allocated spaces */
12502 qdf_mem_free(key_unaligned);
12503 key_unaligned = NULL;
12504 key_aligned = NULL;
12505
12506 qdf_mem_free(data_unaligned);
12507 data_unaligned = NULL;
12508 data_aligned = NULL;
12509
12510 return QDF_STATUS_SUCCESS;
12511}
12512#else
12513/**
12514* fips_align_data_be() - DUMMY for LE platform
12515*
12516* Return: QDF_STATUS - success
12517*/
12518static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12519 struct fips_params *param)
12520{
12521 return QDF_STATUS_SUCCESS;
12522}
12523#endif
12524
12525
12526/**
12527 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
12528 * @wmi_handle: wmi handle
12529 * @param: pointer to hold pdev fips param
12530 *
12531 * Return: 0 for success or error code
12532 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012533static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012534send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
12535 struct fips_params *param)
12536{
12537 wmi_pdev_fips_cmd_fixed_param *cmd;
12538 wmi_buf_t buf;
12539 uint8_t *buf_ptr;
12540 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
12541 QDF_STATUS retval = QDF_STATUS_SUCCESS;
12542
12543 /* Length TLV placeholder for array of bytes */
12544 len += WMI_TLV_HDR_SIZE;
12545 if (param->data_len)
12546 len += (param->data_len*sizeof(uint8_t));
12547
12548 /*
12549 * Data length must be multiples of 16 bytes - checked against 0xF -
12550 * and must be less than WMI_SVC_MSG_SIZE - static size of
12551 * wmi_pdev_fips_cmd structure
12552 */
12553
12554 /* do sanity on the input */
12555 if (!(((param->data_len & 0xF) == 0) &&
12556 ((param->data_len > 0) &&
12557 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
12558 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
12559 return QDF_STATUS_E_INVAL;
12560 }
12561
12562 buf = wmi_buf_alloc(wmi_handle, len);
12563 if (!buf) {
12564 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
12565 return QDF_STATUS_E_FAILURE;
12566 }
12567
12568 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12569 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
12570 WMITLV_SET_HDR(&cmd->tlv_header,
12571 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
12572 WMITLV_GET_STRUCT_TLVLEN
12573 (wmi_pdev_fips_cmd_fixed_param));
12574
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012575 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12576 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012577 if (param->key != NULL && param->data != NULL) {
12578 cmd->key_len = param->key_len;
12579 cmd->data_len = param->data_len;
12580 cmd->fips_cmd = !!(param->op);
12581
12582 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
12583 return QDF_STATUS_E_FAILURE;
12584
12585 qdf_mem_copy(cmd->key, param->key, param->key_len);
12586
12587 if (param->mode == FIPS_ENGINE_AES_CTR ||
12588 param->mode == FIPS_ENGINE_AES_MIC) {
12589 cmd->mode = param->mode;
12590 } else {
12591 cmd->mode = FIPS_ENGINE_AES_CTR;
12592 }
12593 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
12594 cmd->key_len, cmd->data_len);
12595
12596 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
12597 cmd->key, cmd->key_len, true);
12598 buf_ptr += sizeof(*cmd);
12599
12600 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
12601
12602 buf_ptr += WMI_TLV_HDR_SIZE;
12603 if (param->data_len)
12604 qdf_mem_copy(buf_ptr,
12605 (uint8_t *) param->data, param->data_len);
12606
12607 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
12608 16, 1, buf_ptr, cmd->data_len, true);
12609
12610 buf_ptr += param->data_len;
12611
12612 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12613 WMI_PDEV_FIPS_CMDID);
12614 qdf_print("%s return value %d\n", __func__, retval);
12615 } else {
12616 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
12617 wmi_buf_free(buf);
12618 retval = -QDF_STATUS_E_BADMSG;
12619 }
12620
12621 return retval;
12622}
12623
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012624#ifdef WLAN_PMO_ENABLE
12625/**
12626 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
12627 * @wmi_handle: wmi handle
12628 * @vdev_id: vdev id
12629 * @bitmap: Event bitmap
12630 * @enable: enable/disable
12631 *
12632 * Return: CDF status
12633 */
12634static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
12635 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053012636 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012637 bool enable)
12638{
12639 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
12640 uint16_t len;
12641 wmi_buf_t buf;
12642 int ret;
12643
12644 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
12645 buf = wmi_buf_alloc(wmi_handle, len);
12646 if (!buf) {
12647 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12648 return QDF_STATUS_E_NOMEM;
12649 }
12650 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
12651 WMITLV_SET_HDR(&cmd->tlv_header,
12652 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
12653 WMITLV_GET_STRUCT_TLVLEN
12654 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
12655 cmd->vdev_id = vdev_id;
12656 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053012657 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
12658 WMI_WOW_MAX_EVENT_BM_LEN);
12659
12660 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
12661 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
12662 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012663
12664 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12665 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
12666 if (ret) {
12667 WMI_LOGE("Failed to config wow wakeup event");
12668 wmi_buf_free(buf);
12669 return QDF_STATUS_E_FAILURE;
12670 }
12671
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012672 return QDF_STATUS_SUCCESS;
12673}
12674
12675/**
12676 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
12677 * @wmi_handle: wmi handle
12678 * @vdev_id: vdev id
12679 * @ptrn_id: pattern id
12680 * @ptrn: pattern
12681 * @ptrn_len: pattern length
12682 * @ptrn_offset: pattern offset
12683 * @mask: mask
12684 * @mask_len: mask length
12685 * @user: true for user configured pattern and false for default pattern
12686 * @default_patterns: default patterns
12687 *
12688 * Return: CDF status
12689 */
12690static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
12691 uint8_t vdev_id, uint8_t ptrn_id,
12692 const uint8_t *ptrn, uint8_t ptrn_len,
12693 uint8_t ptrn_offset, const uint8_t *mask,
12694 uint8_t mask_len, bool user,
12695 uint8_t default_patterns)
12696{
12697 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12698 WOW_BITMAP_PATTERN_T *bitmap_pattern;
12699 wmi_buf_t buf;
12700 uint8_t *buf_ptr;
12701 int32_t len;
12702 int ret;
12703
12704 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12705 WMI_TLV_HDR_SIZE +
12706 1 * sizeof(WOW_BITMAP_PATTERN_T) +
12707 WMI_TLV_HDR_SIZE +
12708 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12709 WMI_TLV_HDR_SIZE +
12710 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12711 WMI_TLV_HDR_SIZE +
12712 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12713 WMI_TLV_HDR_SIZE +
12714 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12715
12716 buf = wmi_buf_alloc(wmi_handle, len);
12717 if (!buf) {
12718 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12719 return QDF_STATUS_E_NOMEM;
12720 }
12721
12722 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12723 buf_ptr = (uint8_t *) cmd;
12724
12725 WMITLV_SET_HDR(&cmd->tlv_header,
12726 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12727 WMITLV_GET_STRUCT_TLVLEN
12728 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12729 cmd->vdev_id = vdev_id;
12730 cmd->pattern_id = ptrn_id;
12731
12732 cmd->pattern_type = WOW_BITMAP_PATTERN;
12733 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12734
12735 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12736 sizeof(WOW_BITMAP_PATTERN_T));
12737 buf_ptr += WMI_TLV_HDR_SIZE;
12738 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
12739
12740 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
12741 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
12742 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
12743
12744 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
12745 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
12746
12747 bitmap_pattern->pattern_offset = ptrn_offset;
12748 bitmap_pattern->pattern_len = ptrn_len;
12749
12750 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
12751 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
12752
12753 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
12754 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
12755
12756 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
12757 bitmap_pattern->pattern_id = ptrn_id;
12758
12759 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
12760 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
12761 bitmap_pattern->pattern_offset, user);
12762 WMI_LOGI("Pattern : ");
12763 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12764 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
12765
12766 WMI_LOGI("Mask : ");
12767 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12768 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
12769
12770 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
12771
12772 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12773 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12774 buf_ptr += WMI_TLV_HDR_SIZE;
12775
12776 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12777 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12778 buf_ptr += WMI_TLV_HDR_SIZE;
12779
12780 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12781 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12782 buf_ptr += WMI_TLV_HDR_SIZE;
12783
12784 /* Fill TLV for pattern_info_timeout but no data. */
12785 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12786 buf_ptr += WMI_TLV_HDR_SIZE;
12787
12788 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
12789 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
12790 buf_ptr += WMI_TLV_HDR_SIZE;
12791 *(A_UINT32 *) buf_ptr = 0;
12792
12793 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12794 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12795 if (ret) {
12796 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
12797 wmi_buf_free(buf);
12798 return QDF_STATUS_E_FAILURE;
12799 }
12800
12801 return QDF_STATUS_SUCCESS;
12802}
12803
Govind Singha4836fd2016-03-07 16:45:38 +053012804/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012805 * fill_arp_offload_params_tlv() - Fill ARP offload data
12806 * @wmi_handle: wmi handle
12807 * @offload_req: offload request
12808 * @buf_ptr: buffer pointer
12809 *
12810 * To fill ARP offload data to firmware
12811 * when target goes to wow mode.
12812 *
12813 * Return: None
12814 */
12815static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012816 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012817{
12818
12819 int i;
12820 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012821 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012822
12823 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12824 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
12825 *buf_ptr += WMI_TLV_HDR_SIZE;
12826 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
12827 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
12828 WMITLV_SET_HDR(&arp_tuple->tlv_header,
12829 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
12830 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
12831
12832 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012833 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012834 /* Copy the target ip addr and flags */
12835 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
12836 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012837 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012838 WMI_IPV4_ADDR_LEN);
12839 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012840 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012841 }
12842 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
12843 }
12844}
12845
12846#ifdef WLAN_NS_OFFLOAD
12847/**
12848 * fill_ns_offload_params_tlv() - Fill NS offload data
12849 * @wmi|_handle: wmi handle
12850 * @offload_req: offload request
12851 * @buf_ptr: buffer pointer
12852 *
12853 * To fill NS offload data to firmware
12854 * when target goes to wow mode.
12855 *
12856 * Return: None
12857 */
12858static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012859 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012860{
12861
12862 int i;
12863 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012864
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012865 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12866 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12867 *buf_ptr += WMI_TLV_HDR_SIZE;
12868 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
12869 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12870 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12871 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12872 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
12873
12874 /*
12875 * Fill data only for NS offload in the first ARP tuple for LA
12876 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012877 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012878 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12879 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012880 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012881 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012882 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012883 sizeof(WMI_IPV6_ADDR));
12884 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012885 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012886 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012887 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012888 ns_tuple->flags |=
12889 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12890 }
12891 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012892 i, &ns_req->self_ipv6_addr[i],
12893 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012894
12895 /* target MAC is optional, check if it is valid,
12896 * if this is not valid, the target will use the known
12897 * local MAC address rather than the tuple
12898 */
12899 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012900 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012901 &ns_tuple->target_mac);
12902 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12903 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12904 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12905 }
12906 }
12907 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12908 }
12909}
12910
12911
12912/**
12913 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
12914 * @wmi: wmi handle
12915 * @offload_req: offload request
12916 * @buf_ptr: buffer pointer
12917 *
12918 * To fill extended NS offload extended data to firmware
12919 * when target goes to wow mode.
12920 *
12921 * Return: None
12922 */
12923static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012924 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012925{
12926 int i;
12927 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
12928 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012929
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012930 count = ns_req->num_ns_offload_count;
12931 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012932 WMI_MAX_NS_OFFLOADS;
12933
12934 /* Populate extended NS offload tuples */
12935 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12936 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12937 *buf_ptr += WMI_TLV_HDR_SIZE;
12938 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
12939 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12940 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12941 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12942 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
12943
12944 /*
12945 * Fill data only for NS offload in the first ARP tuple for LA
12946 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012947 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012948 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12949 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012950 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012951 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012952 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012953 sizeof(WMI_IPV6_ADDR));
12954 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012955 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012956 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012957 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012958 ns_tuple->flags |=
12959 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12960 }
12961 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012962 i, &ns_req->self_ipv6_addr[i],
12963 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012964
12965 /* target MAC is optional, check if it is valid,
12966 * if this is not valid, the target will use the
12967 * known local MAC address rather than the tuple
12968 */
12969 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012970 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012971 &ns_tuple->target_mac);
12972 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12973 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12974 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12975 }
12976 }
12977 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12978 }
12979}
12980#else
12981static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012982 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012983{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012984}
12985
12986static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012987 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012988{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012989}
12990#endif
12991
12992/**
Govind Singha4836fd2016-03-07 16:45:38 +053012993 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
12994 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012995 * @arp_offload_req: arp offload request
12996 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053012997 * @arp_only: flag
12998 *
12999 * To configure ARP NS off load data to firmware
13000 * when target goes to wow mode.
13001 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013002 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013003 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013004static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013005 struct pmo_arp_offload_params *arp_offload_req,
13006 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013007 uint8_t vdev_id)
13008{
Govind Singha4836fd2016-03-07 16:45:38 +053013009 int32_t res;
13010 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013011 A_UINT8 *buf_ptr;
13012 wmi_buf_t buf;
13013 int32_t len;
13014 uint32_t count = 0, num_ns_ext_tuples = 0;
13015
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013016 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013017
Govind Singha4836fd2016-03-07 16:45:38 +053013018 /*
13019 * TLV place holder size for array of NS tuples
13020 * TLV place holder size for array of ARP tuples
13021 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013022 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13023 WMI_TLV_HDR_SIZE +
13024 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13025 WMI_TLV_HDR_SIZE +
13026 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013027
13028 /*
13029 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13030 * extra length for extended NS offload tuples which follows ARP offload
13031 * tuples. Host needs to fill this structure in following format:
13032 * 2 NS ofload tuples
13033 * 2 ARP offload tuples
13034 * N numbers of extended NS offload tuples if HDD has given more than
13035 * 2 NS offload addresses
13036 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013037 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013038 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013039 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13040 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013041 }
13042
13043 buf = wmi_buf_alloc(wmi_handle, len);
13044 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013045 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013046 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013047 }
13048
13049 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
13050 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13051 WMITLV_SET_HDR(&cmd->tlv_header,
13052 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13053 WMITLV_GET_STRUCT_TLVLEN
13054 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13055 cmd->flags = 0;
13056 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013057 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013058
Govind Singhb53420c2016-03-09 14:32:57 +053013059 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013060
Govind Singha4836fd2016-03-07 16:45:38 +053013061 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013062 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13063 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13064 if (num_ns_ext_tuples)
13065 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013066
13067 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13068 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13069 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013070 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013071 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013072 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013073 }
13074
Govind Singhb53420c2016-03-09 14:32:57 +053013075 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013076}
13077
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013078/**
13079 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
13080 * @wmi_handle: wmi handle
13081 * @vdev_id: vdev id
13082 * @action: true for enable else false
13083 *
13084 * To enable enhance multicast offload to firmware
13085 * when target goes to wow mode.
13086 *
13087 * Return: QDF Status
13088 */
13089
13090static
13091QDF_STATUS send_enable_enhance_multicast_offload_tlv(
13092 wmi_unified_t wmi_handle,
13093 uint8_t vdev_id, bool action)
13094{
13095 QDF_STATUS status;
13096 wmi_buf_t buf;
13097 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
13098
13099 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13100 if (!buf) {
13101 WMI_LOGE("Failed to allocate buffer to send set key cmd");
13102 return QDF_STATUS_E_NOMEM;
13103 }
13104
13105 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
13106 wmi_buf_data(buf);
13107
13108 WMITLV_SET_HDR(&cmd->tlv_header,
13109 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
13110 WMITLV_GET_STRUCT_TLVLEN(
13111 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
13112
13113 cmd->vdev_id = vdev_id;
13114 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
13115 ENHANCED_MCAST_FILTER_ENABLED);
13116 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
13117 __func__, action, vdev_id);
13118 status = wmi_unified_cmd_send(wmi_handle, buf,
13119 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
13120 if (status != QDF_STATUS_SUCCESS) {
13121 qdf_nbuf_free(buf);
13122 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
13123 __func__);
13124 }
13125
13126 return status;
13127}
13128
13129/**
13130 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
13131 * @wmi_handle: wmi handle
13132 * @param evt_buf: pointer to event buffer
13133 * @param hdr: Pointer to hold header
13134 * @param bufp: Pointer to hold pointer to rx param buffer
13135 *
13136 * Return: QDF_STATUS_SUCCESS for success or error code
13137 */
13138static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
13139 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
13140{
13141 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
13142 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
13143
13144 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
13145 if (!param_buf) {
13146 WMI_LOGE("gtk param_buf is NULL");
13147 return QDF_STATUS_E_INVAL;
13148 }
13149
13150 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
13151 WMI_LOGE("Invalid length for GTK status");
13152 return QDF_STATUS_E_INVAL;
13153 }
13154
13155 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
13156 param_buf->fixed_param;
13157 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
13158 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
13159 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
13160 qdf_mem_copy(&gtk_rsp_param->replay_counter,
13161 &fixed_param->replay_counter,
13162 GTK_REPLAY_COUNTER_BYTES);
13163
13164 return QDF_STATUS_SUCCESS;
13165
13166}
13167
13168#ifdef FEATURE_WLAN_RA_FILTERING
13169/**
13170 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
13171 * @wmi_handle: wmi handle
13172 * @vdev_id: vdev id
13173 *
13174 * Return: CDF status
13175 */
13176static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
13177 uint8_t vdev_id, uint8_t default_pattern,
13178 uint16_t rate_limit_interval)
13179{
13180
13181 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13182 wmi_buf_t buf;
13183 uint8_t *buf_ptr;
13184 int32_t len;
13185 int ret;
13186
13187 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13188 WMI_TLV_HDR_SIZE +
13189 0 * sizeof(WOW_BITMAP_PATTERN_T) +
13190 WMI_TLV_HDR_SIZE +
13191 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13192 WMI_TLV_HDR_SIZE +
13193 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13194 WMI_TLV_HDR_SIZE +
13195 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13196 WMI_TLV_HDR_SIZE +
13197 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
13198
13199 buf = wmi_buf_alloc(wmi_handle, len);
13200 if (!buf) {
13201 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13202 return QDF_STATUS_E_NOMEM;
13203 }
13204
13205 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13206 buf_ptr = (uint8_t *) cmd;
13207
13208 WMITLV_SET_HDR(&cmd->tlv_header,
13209 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13210 WMITLV_GET_STRUCT_TLVLEN
13211 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13212 cmd->vdev_id = vdev_id;
13213 cmd->pattern_id = default_pattern,
13214 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
13215 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13216
13217 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
13218 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13219 buf_ptr += WMI_TLV_HDR_SIZE;
13220
13221 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13222 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13223 buf_ptr += WMI_TLV_HDR_SIZE;
13224
13225 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13226 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13227 buf_ptr += WMI_TLV_HDR_SIZE;
13228
13229 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13230 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13231 buf_ptr += WMI_TLV_HDR_SIZE;
13232
13233 /* Fill TLV for pattern_info_timeout but no data. */
13234 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13235 buf_ptr += WMI_TLV_HDR_SIZE;
13236
13237 /* Fill TLV for ra_ratelimit_interval. */
13238 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
13239 buf_ptr += WMI_TLV_HDR_SIZE;
13240
13241 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
13242
13243 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
13244 rate_limit_interval, vdev_id);
13245
13246 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13247 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13248 if (ret) {
13249 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
13250 wmi_buf_free(buf);
13251 return QDF_STATUS_E_FAILURE;
13252 }
13253
13254 return QDF_STATUS_SUCCESS;
13255
13256}
13257#endif /* FEATURE_WLAN_RA_FILTERING */
13258
13259/**
13260 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
13261 * @wmi_handle: wmi handle
13262 * @vdev_id: vdev id
13263 * @multicastAddr: mcast address
13264 * @clearList: clear list flag
13265 *
13266 * Return: QDF_STATUS_SUCCESS for success or error code
13267 */
13268static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
13269 uint8_t vdev_id,
13270 struct qdf_mac_addr multicast_addr,
13271 bool clearList)
13272{
13273 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
13274 wmi_buf_t buf;
13275 int err;
13276
13277 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13278 if (!buf) {
13279 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13280 return QDF_STATUS_E_NOMEM;
13281 }
13282
13283 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
13284 qdf_mem_zero(cmd, sizeof(*cmd));
13285
13286 WMITLV_SET_HDR(&cmd->tlv_header,
13287 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
13288 WMITLV_GET_STRUCT_TLVLEN
13289 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
13290 cmd->action =
13291 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
13292 cmd->vdev_id = vdev_id;
13293 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
13294
13295 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
13296 cmd->action, vdev_id, clearList, multicast_addr.bytes);
13297
13298 err = wmi_unified_cmd_send(wmi_handle, buf,
13299 sizeof(*cmd),
13300 WMI_SET_MCASTBCAST_FILTER_CMDID);
13301 if (err) {
13302 WMI_LOGE("Failed to send set_param cmd");
13303 wmi_buf_free(buf);
13304 return QDF_STATUS_E_FAILURE;
13305 }
13306
13307 return QDF_STATUS_SUCCESS;
13308}
13309
13310/**
13311 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
13312 * @wmi_handle: wmi handle
13313 * @vdev_id: vdev id
13314 * @params: GTK offload parameters
13315 *
13316 * Return: CDF status
13317 */
13318static
13319QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
13320 struct pmo_gtk_req *params,
13321 bool enable_offload,
13322 uint32_t gtk_offload_opcode)
13323{
13324 int len;
13325 wmi_buf_t buf;
13326 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13327 QDF_STATUS status = QDF_STATUS_SUCCESS;
13328
13329 WMI_LOGD("%s Enter", __func__);
13330
13331 len = sizeof(*cmd);
13332
13333 /* alloc wmi buffer */
13334 buf = wmi_buf_alloc(wmi_handle, len);
13335 if (!buf) {
13336 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13337 status = QDF_STATUS_E_NOMEM;
13338 goto out;
13339 }
13340
13341 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13342 WMITLV_SET_HDR(&cmd->tlv_header,
13343 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13344 WMITLV_GET_STRUCT_TLVLEN
13345 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13346
13347 cmd->vdev_id = vdev_id;
13348
13349 /* Request target to enable GTK offload */
13350 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
13351 cmd->flags = gtk_offload_opcode;
13352
13353 /* Copy the keys and replay counter */
13354 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
13355 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
13356 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
13357 GTK_REPLAY_COUNTER_BYTES);
13358 } else {
13359 cmd->flags = gtk_offload_opcode;
13360 }
13361
13362 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
13363
13364 /* send the wmi command */
13365 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13366 WMI_GTK_OFFLOAD_CMDID)) {
13367 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
13368 wmi_buf_free(buf);
13369 status = QDF_STATUS_E_FAILURE;
13370 }
13371
13372out:
13373 WMI_LOGD("%s Exit", __func__);
13374 return status;
13375}
13376
13377/**
13378 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
13379 * @wmi_handle: wmi handle
13380 * @params: GTK offload params
13381 *
13382 * Return: CDF status
13383 */
13384static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
13385 wmi_unified_t wmi_handle,
13386 uint8_t vdev_id,
13387 uint64_t offload_req_opcode)
13388{
13389 int len;
13390 wmi_buf_t buf;
13391 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13392 QDF_STATUS status = QDF_STATUS_SUCCESS;
13393
13394 len = sizeof(*cmd);
13395
13396 /* alloc wmi buffer */
13397 buf = wmi_buf_alloc(wmi_handle, len);
13398 if (!buf) {
13399 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13400 status = QDF_STATUS_E_NOMEM;
13401 goto out;
13402 }
13403
13404 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13405 WMITLV_SET_HDR(&cmd->tlv_header,
13406 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13407 WMITLV_GET_STRUCT_TLVLEN
13408 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13409
13410 /* Request for GTK offload status */
13411 cmd->flags = offload_req_opcode;
13412 cmd->vdev_id = vdev_id;
13413
13414 /* send the wmi command */
13415 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13416 WMI_GTK_OFFLOAD_CMDID)) {
13417 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
13418 wmi_buf_free(buf);
13419 status = QDF_STATUS_E_FAILURE;
13420 }
13421
13422out:
13423 return status;
13424}
13425
13426/**
13427 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
13428 * @wmi_handle: wmi handler
13429 * @action_params: pointer to action_params
13430 *
13431 * Return: 0 for success, otherwise appropriate error code
13432 */
13433static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
13434 struct pmo_action_wakeup_set_params *action_params)
13435{
13436 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
13437 wmi_buf_t buf;
13438 int i;
13439 int32_t err;
13440
13441 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13442 if (!buf) {
13443 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
13444 return QDF_STATUS_E_NOMEM;
13445 }
13446 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
13447 WMITLV_SET_HDR(&cmd->tlv_header,
13448 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
13449 WMITLV_GET_STRUCT_TLVLEN(
13450 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
13451
13452 cmd->vdev_id = action_params->vdev_id;
13453 cmd->operation = action_params->operation;
13454
13455 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
13456 cmd->action_category_map[i] =
13457 action_params->action_category_map[i];
13458
13459 err = wmi_unified_cmd_send(wmi_handle, buf,
13460 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
13461 if (err) {
13462 WMI_LOGE("Failed to send ap_ps_egap cmd");
13463 wmi_buf_free(buf);
13464 return QDF_STATUS_E_FAILURE;
13465 }
13466
13467 return QDF_STATUS_SUCCESS;
13468}
13469
13470#ifdef FEATURE_WLAN_LPHB
13471
13472/**
13473 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
13474 * @wmi_handle: wmi handle
13475 * @lphb_conf_req: configuration info
13476 *
13477 * Return: CDF status
13478 */
13479static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
13480 wmi_hb_set_enable_cmd_fixed_param *params)
13481{
13482 QDF_STATUS status;
13483 wmi_buf_t buf = NULL;
13484 uint8_t *buf_ptr;
13485 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
13486 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
13487
13488
13489 buf = wmi_buf_alloc(wmi_handle, len);
13490 if (!buf) {
13491 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13492 return QDF_STATUS_E_NOMEM;
13493 }
13494
13495 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13496 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
13497 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
13498 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
13499 WMITLV_GET_STRUCT_TLVLEN
13500 (wmi_hb_set_enable_cmd_fixed_param));
13501
13502 /* fill in values */
13503 hb_enable_fp->vdev_id = params->session;
13504 hb_enable_fp->enable = params->enable;
13505 hb_enable_fp->item = params->item;
13506 hb_enable_fp->session = params->session;
13507
13508 status = wmi_unified_cmd_send(wmi_handle, buf,
13509 len, WMI_HB_SET_ENABLE_CMDID);
13510 if (QDF_IS_STATUS_ERROR(status)) {
13511 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
13512 status);
13513 wmi_buf_free(buf);
13514 }
13515
13516 return status;
13517}
13518
13519/**
13520 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
13521 * @wmi_handle: wmi handle
13522 * @lphb_conf_req: lphb config request
13523 *
13524 * Return: CDF status
13525 */
13526static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
13527 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
13528{
13529 QDF_STATUS status;
13530 wmi_buf_t buf = NULL;
13531 uint8_t *buf_ptr;
13532 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
13533 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
13534
13535 buf = wmi_buf_alloc(wmi_handle, len);
13536 if (!buf) {
13537 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13538 return QDF_STATUS_E_NOMEM;
13539 }
13540
13541 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13542 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
13543 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
13544 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
13545 WMITLV_GET_STRUCT_TLVLEN
13546 (wmi_hb_set_tcp_params_cmd_fixed_param));
13547
13548 /* fill in values */
13549 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13550 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13551 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13552 hb_tcp_params_fp->seq = lphb_conf_req->seq;
13553 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
13554 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
13555 hb_tcp_params_fp->interval = lphb_conf_req->interval;
13556 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
13557 hb_tcp_params_fp->session = lphb_conf_req->session;
13558 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
13559 &lphb_conf_req->gateway_mac,
13560 sizeof(hb_tcp_params_fp->gateway_mac));
13561
13562 status = wmi_unified_cmd_send(wmi_handle, buf,
13563 len, WMI_HB_SET_TCP_PARAMS_CMDID);
13564 if (QDF_IS_STATUS_ERROR(status)) {
13565 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
13566 status);
13567 wmi_buf_free(buf);
13568 }
13569
13570 return status;
13571}
13572
13573/**
13574 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
13575 * @wmi_handle: wmi handle
13576 * @lphb_conf_req: lphb config request
13577 *
13578 * Return: CDF status
13579 */
13580static
13581QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13582 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
13583{
13584 QDF_STATUS status;
13585 wmi_buf_t buf = NULL;
13586 uint8_t *buf_ptr;
13587 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
13588 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
13589
13590 buf = wmi_buf_alloc(wmi_handle, len);
13591 if (!buf) {
13592 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13593 return QDF_STATUS_E_NOMEM;
13594 }
13595
13596 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13597 hb_tcp_filter_fp =
13598 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
13599 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
13600 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
13601 WMITLV_GET_STRUCT_TLVLEN
13602 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
13603
13604 /* fill in values */
13605 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
13606 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
13607 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
13608 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
13609 memcpy((void *)&hb_tcp_filter_fp->filter,
13610 (void *)&g_hb_tcp_filter_fp->filter,
13611 WMI_WLAN_HB_MAX_FILTER_SIZE);
13612
13613 status = wmi_unified_cmd_send(wmi_handle, buf,
13614 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
13615 if (QDF_IS_STATUS_ERROR(status)) {
13616 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
13617 status);
13618 wmi_buf_free(buf);
13619 }
13620
13621 return status;
13622}
13623
13624/**
13625 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
13626 * @wmi_handle: wmi handle
13627 * @lphb_conf_req: lphb config request
13628 *
13629 * Return: CDF status
13630 */
13631static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
13632 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
13633{
13634 QDF_STATUS status;
13635 wmi_buf_t buf = NULL;
13636 uint8_t *buf_ptr;
13637 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
13638 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
13639
13640 buf = wmi_buf_alloc(wmi_handle, len);
13641 if (!buf) {
13642 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13643 return QDF_STATUS_E_NOMEM;
13644 }
13645
13646 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13647 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
13648 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
13649 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
13650 WMITLV_GET_STRUCT_TLVLEN
13651 (wmi_hb_set_udp_params_cmd_fixed_param));
13652
13653 /* fill in values */
13654 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13655 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13656 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13657 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
13658 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
13659 hb_udp_params_fp->interval = lphb_conf_req->interval;
13660 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
13661 hb_udp_params_fp->session = lphb_conf_req->session;
13662 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
13663 &lphb_conf_req->gateway_mac,
13664 sizeof(lphb_conf_req->gateway_mac));
13665
13666 status = wmi_unified_cmd_send(wmi_handle, buf,
13667 len, WMI_HB_SET_UDP_PARAMS_CMDID);
13668 if (QDF_IS_STATUS_ERROR(status)) {
13669 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
13670 status);
13671 wmi_buf_free(buf);
13672 }
13673
13674 return status;
13675}
13676
13677/**
13678 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
13679 * @wmi_handle: wmi handle
13680 * @lphb_conf_req: lphb config request
13681 *
13682 * Return: CDF status
13683 */
13684static
13685QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13686 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
13687{
13688 QDF_STATUS status;
13689 wmi_buf_t buf = NULL;
13690 uint8_t *buf_ptr;
13691 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
13692 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
13693
13694 buf = wmi_buf_alloc(wmi_handle, len);
13695 if (!buf) {
13696 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13697 return QDF_STATUS_E_NOMEM;
13698 }
13699
13700 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13701 hb_udp_filter_fp =
13702 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
13703 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
13704 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
13705 WMITLV_GET_STRUCT_TLVLEN
13706 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
13707
13708 /* fill in values */
13709 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
13710 hb_udp_filter_fp->length = lphb_conf_req->length;
13711 hb_udp_filter_fp->offset = lphb_conf_req->offset;
13712 hb_udp_filter_fp->session = lphb_conf_req->session;
13713 memcpy((void *)&hb_udp_filter_fp->filter,
13714 (void *)&lphb_conf_req->filter,
13715 WMI_WLAN_HB_MAX_FILTER_SIZE);
13716
13717 status = wmi_unified_cmd_send(wmi_handle, buf,
13718 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
13719 if (QDF_IS_STATUS_ERROR(status)) {
13720 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
13721 status);
13722 wmi_buf_free(buf);
13723 }
13724
13725 return status;
13726}
13727#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013728
Dustin Brownf31f88b2017-05-12 14:01:44 -070013729static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
13730 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013731{
Dustin Brownf31f88b2017-05-12 14:01:44 -070013732 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013733 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070013734 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013735
Dustin Brownf31f88b2017-05-12 14:01:44 -070013736 if (!req) {
13737 WMI_LOGE("req is null");
13738 return QDF_STATUS_E_INVAL;
13739 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013740
Dustin Brownf31f88b2017-05-12 14:01:44 -070013741 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
13742 if (!wmi_buf) {
13743 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013744 return QDF_STATUS_E_NOMEM;
13745 }
13746
Dustin Brownf31f88b2017-05-12 14:01:44 -070013747 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013748 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070013749 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
13750 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
13751 cmd->vdev_id = req->vdev_id;
13752 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
13753 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013754
Dustin Brownf31f88b2017-05-12 14:01:44 -070013755 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
13756 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013757
Dustin Brownf31f88b2017-05-12 14:01:44 -070013758 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
13759 WMI_HW_DATA_FILTER_CMDID);
13760 if (QDF_IS_STATUS_ERROR(status)) {
13761 WMI_LOGE("Failed to configure hw filter");
13762 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013763 }
13764
Dustin Brownf31f88b2017-05-12 14:01:44 -070013765 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013766}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053013767
13768/**
13769 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
13770 * @wmi_handle: wmi handle
13771 * @vdev_id: vdev id
13772 * @enable: Flag to enable/disable packet filter
13773 *
13774 * Return: QDF_STATUS_SUCCESS for success or error code
13775 */
13776static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
13777 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
13778{
13779 int32_t len;
13780 int ret = 0;
13781 wmi_buf_t buf;
13782 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
13783
13784 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
13785
13786 buf = wmi_buf_alloc(wmi_handle, len);
13787 if (!buf) {
13788 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13789 return QDF_STATUS_E_NOMEM;
13790 }
13791
13792 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
13793 WMITLV_SET_HDR(&cmd->tlv_header,
13794 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
13795 WMITLV_GET_STRUCT_TLVLEN(
13796 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
13797
13798 cmd->vdev_id = vdev_id;
13799 if (enable)
13800 cmd->enable = PACKET_FILTER_SET_ENABLE;
13801 else
13802 cmd->enable = PACKET_FILTER_SET_DISABLE;
13803
13804 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
13805 __func__, cmd->enable, vdev_id);
13806
13807 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13808 WMI_PACKET_FILTER_ENABLE_CMDID);
13809 if (ret) {
13810 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
13811 wmi_buf_free(buf);
13812 }
13813
13814 return ret;
13815}
13816
13817/**
13818 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
13819 * @wmi_handle: wmi handle
13820 * @vdev_id: vdev id
13821 * @rcv_filter_param: Packet filter parameters
13822 * @filter_id: Filter id
13823 * @enable: Flag to add/delete packet filter configuration
13824 *
13825 * Return: QDF_STATUS_SUCCESS for success or error code
13826 */
13827static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
13828 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
13829 uint8_t filter_id, bool enable)
13830{
13831 int len, i;
13832 int err = 0;
13833 wmi_buf_t buf;
13834 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
13835
13836
13837 /* allocate the memory */
13838 len = sizeof(*cmd);
13839 buf = wmi_buf_alloc(wmi_handle, len);
13840 if (!buf) {
13841 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13842 return QDF_STATUS_E_NOMEM;
13843 }
13844
13845 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13846 WMITLV_SET_HDR(&cmd->tlv_header,
13847 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
13848 WMITLV_GET_STRUCT_TLVLEN
13849 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
13850
13851 cmd->vdev_id = vdev_id;
13852 cmd->filter_id = filter_id;
13853 if (enable)
13854 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
13855 else
13856 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
13857
13858 if (enable) {
13859 cmd->num_params = QDF_MIN(
13860 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
13861 rcv_filter_param->num_params);
13862 cmd->filter_type = rcv_filter_param->filter_type;
13863 cmd->coalesce_time = rcv_filter_param->coalesce_time;
13864
13865 for (i = 0; i < cmd->num_params; i++) {
13866 cmd->paramsData[i].proto_type =
13867 rcv_filter_param->params_data[i].protocol_layer;
13868 cmd->paramsData[i].cmp_type =
13869 rcv_filter_param->params_data[i].compare_flag;
13870 cmd->paramsData[i].data_length =
13871 rcv_filter_param->params_data[i].data_length;
13872 cmd->paramsData[i].data_offset =
13873 rcv_filter_param->params_data[i].data_offset;
13874 memcpy(&cmd->paramsData[i].compareData,
13875 rcv_filter_param->params_data[i].compare_data,
13876 sizeof(cmd->paramsData[i].compareData));
13877 memcpy(&cmd->paramsData[i].dataMask,
13878 rcv_filter_param->params_data[i].data_mask,
13879 sizeof(cmd->paramsData[i].dataMask));
13880 }
13881 }
13882
13883 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
13884 cmd->filter_action, cmd->filter_id, cmd->num_params);
13885 /* send the command along with data */
13886 err = wmi_unified_cmd_send(wmi_handle, buf, len,
13887 WMI_PACKET_FILTER_CONFIG_CMDID);
13888 if (err) {
13889 WMI_LOGE("Failed to send pkt_filter cmd");
13890 wmi_buf_free(buf);
13891 return QDF_STATUS_E_FAILURE;
13892 }
13893
13894 return QDF_STATUS_SUCCESS;
13895}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053013896#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013897
Govind Singha4836fd2016-03-07 16:45:38 +053013898/**
13899 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
13900 * @wmi_handle: wmi handle
13901 * @request: SSID hotlist set request
13902 *
Govind Singhb53420c2016-03-09 14:32:57 +053013903 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053013904 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013905static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053013906send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
13907 struct ssid_hotlist_request_params *request)
13908{
13909 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
13910 wmi_buf_t wmi_buf;
13911 uint32_t len;
13912 uint32_t array_size;
13913 uint8_t *buf_ptr;
13914
13915 /* length of fixed portion */
13916 len = sizeof(*cmd);
13917
13918 /* length of variable portion */
13919 array_size =
13920 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
13921 len += WMI_TLV_HDR_SIZE + array_size;
13922
13923 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13924 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013925 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13926 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013927 }
13928
13929 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
13930 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
13931 buf_ptr;
13932 WMITLV_SET_HDR
13933 (&cmd->tlv_header,
13934 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
13935 WMITLV_GET_STRUCT_TLVLEN
13936 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
13937
13938 cmd->request_id = request->request_id;
13939 cmd->requestor_id = 0;
13940 cmd->vdev_id = request->session_id;
13941 cmd->table_id = 0;
13942 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
13943 cmd->total_entries = request->ssid_count;
13944 cmd->num_entries_in_page = request->ssid_count;
13945 cmd->first_entry_index = 0;
13946
13947 buf_ptr += sizeof(*cmd);
13948 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
13949
13950 if (request->ssid_count) {
13951 wmi_extscan_hotlist_ssid_entry *entry;
13952 int i;
13953
13954 buf_ptr += WMI_TLV_HDR_SIZE;
13955 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
13956 for (i = 0; i < request->ssid_count; i++) {
13957 WMITLV_SET_HDR
13958 (entry,
13959 WMITLV_TAG_ARRAY_STRUC,
13960 WMITLV_GET_STRUCT_TLVLEN
13961 (wmi_extscan_hotlist_ssid_entry));
13962 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053013963 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053013964 request->ssids[i].ssid.mac_ssid,
13965 request->ssids[i].ssid.length);
13966 entry->band = request->ssids[i].band;
13967 entry->min_rssi = request->ssids[i].rssi_low;
13968 entry->max_rssi = request->ssids[i].rssi_high;
13969 entry++;
13970 }
13971 cmd->mode = WMI_EXTSCAN_MODE_START;
13972 } else {
13973 cmd->mode = WMI_EXTSCAN_MODE_STOP;
13974 }
13975
13976 if (wmi_unified_cmd_send
13977 (wmi_handle, wmi_buf, len,
13978 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013979 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053013980 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013981 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013982 }
13983
Govind Singhb53420c2016-03-09 14:32:57 +053013984 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013985}
13986
13987/**
13988 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
13989 * @wmi_handle: wmi handle
13990 * @vdev_id: vdev id
13991 *
13992 * This function sends roam synch complete event to fw.
13993 *
13994 * Return: CDF STATUS
13995 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013996static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013997 uint8_t vdev_id)
13998{
13999 wmi_roam_synch_complete_fixed_param *cmd;
14000 wmi_buf_t wmi_buf;
14001 uint8_t *buf_ptr;
14002 uint16_t len;
14003 len = sizeof(wmi_roam_synch_complete_fixed_param);
14004
14005 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14006 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014007 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14008 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014009 }
14010 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
14011 buf_ptr = (uint8_t *) cmd;
14012 WMITLV_SET_HDR(&cmd->tlv_header,
14013 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
14014 WMITLV_GET_STRUCT_TLVLEN
14015 (wmi_roam_synch_complete_fixed_param));
14016 cmd->vdev_id = vdev_id;
14017 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14018 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014019 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053014020 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014021 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014022 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014023 }
14024
Govind Singhb53420c2016-03-09 14:32:57 +053014025 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014026}
14027
14028/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053014029 * send_fw_test_cmd_tlv() - send fw test command to fw.
14030 * @wmi_handle: wmi handle
14031 * @wmi_fwtest: fw test command
14032 *
14033 * This function sends fw test command to fw.
14034 *
14035 * Return: CDF STATUS
14036 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014037static
Anurag Chouhan459e0152016-07-22 20:19:54 +053014038QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
14039 struct set_fwtest_params *wmi_fwtest)
14040{
14041 wmi_fwtest_set_param_cmd_fixed_param *cmd;
14042 wmi_buf_t wmi_buf;
14043 uint16_t len;
14044
14045 len = sizeof(*cmd);
14046
14047 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14048 if (!wmi_buf) {
14049 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14050 return QDF_STATUS_E_NOMEM;
14051 }
14052
14053 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14054 WMITLV_SET_HDR(&cmd->tlv_header,
14055 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
14056 WMITLV_GET_STRUCT_TLVLEN(
14057 wmi_fwtest_set_param_cmd_fixed_param));
14058 cmd->param_id = wmi_fwtest->arg;
14059 cmd->param_value = wmi_fwtest->value;
14060
14061 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14062 WMI_FWTEST_CMDID)) {
14063 WMI_LOGP("%s: failed to send fw test command", __func__);
14064 qdf_nbuf_free(wmi_buf);
14065 return QDF_STATUS_E_FAILURE;
14066 }
14067
14068 return QDF_STATUS_SUCCESS;
14069}
14070
14071/**
Govind Singha4836fd2016-03-07 16:45:38 +053014072 * send_unit_test_cmd_tlv() - send unit test command to fw.
14073 * @wmi_handle: wmi handle
14074 * @wmi_utest: unit test command
14075 *
14076 * This function send unit test command to fw.
14077 *
14078 * Return: CDF STATUS
14079 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014080static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014081 struct wmi_unit_test_cmd *wmi_utest)
14082{
14083 wmi_unit_test_cmd_fixed_param *cmd;
14084 wmi_buf_t wmi_buf;
14085 uint8_t *buf_ptr;
14086 int i;
14087 uint16_t len, args_tlv_len;
14088 A_UINT32 *unit_test_cmd_args;
14089
14090 args_tlv_len =
14091 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
14092 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
14093
14094 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14095 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014096 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14097 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014098 }
14099
14100 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14101 buf_ptr = (uint8_t *) cmd;
14102 WMITLV_SET_HDR(&cmd->tlv_header,
14103 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
14104 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
14105 cmd->vdev_id = wmi_utest->vdev_id;
14106 cmd->module_id = wmi_utest->module_id;
14107 cmd->num_args = wmi_utest->num_args;
14108 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
14109 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14110 (wmi_utest->num_args * sizeof(uint32_t)));
14111 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053014112 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053014113 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14114 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014115 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014116 }
14117 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14118 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014119 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014120 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014121 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014122 }
14123
Govind Singhb53420c2016-03-09 14:32:57 +053014124 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014125}
14126
14127/**
14128 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
14129 * @wmi_handle: wma handle
14130 * @roaminvoke: roam invoke command
14131 *
14132 * Send roam invoke command to fw for fastreassoc.
14133 *
14134 * Return: CDF STATUS
14135 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014136static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014137 struct wmi_roam_invoke_cmd *roaminvoke,
14138 uint32_t ch_hz)
14139{
14140 wmi_roam_invoke_cmd_fixed_param *cmd;
14141 wmi_buf_t wmi_buf;
14142 u_int8_t *buf_ptr;
14143 u_int16_t len, args_tlv_len;
14144 A_UINT32 *channel_list;
14145 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080014146 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053014147
14148 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080014149 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
14150 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
14151 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053014152 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
14153 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14154 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014155 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14156 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014157 }
14158
14159 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
14160 buf_ptr = (u_int8_t *) cmd;
14161 WMITLV_SET_HDR(&cmd->tlv_header,
14162 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
14163 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
14164 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080014165 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Naveen Rawat77797922017-01-20 17:00:07 -080014166
14167 if (roaminvoke->frame_len)
14168 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
14169 else
14170 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
14171
Govind Singha4836fd2016-03-07 16:45:38 +053014172 cmd->roam_ap_sel_mode = 0;
14173 cmd->roam_delay = 0;
14174 cmd->num_chan = 1;
14175 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080014176 /* packing 1 beacon/probe_rsp frame with WMI cmd */
14177 cmd->num_buf = 1;
14178
Govind Singha4836fd2016-03-07 16:45:38 +053014179 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
14180 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14181 (sizeof(u_int32_t)));
14182 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
14183 *channel_list = ch_hz;
14184 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
14185 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14186 (sizeof(wmi_mac_addr)));
14187 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
14188 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080014189
14190 /* move to next tlv i.e. bcn_prb_buf_list */
14191 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
14192
14193 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14194 sizeof(wmi_tlv_buf_len_param));
14195
14196 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
14197 buf_len_tlv->buf_len = roaminvoke->frame_len;
14198
14199 /* move to next tlv i.e. bcn_prb_frm */
14200 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
14201 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
14202 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
14203
14204 /* copy frame after the header */
14205 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
14206 roaminvoke->frame_buf,
14207 roaminvoke->frame_len);
14208
14209 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
14210 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
14211 buf_ptr + WMI_TLV_HDR_SIZE,
14212 roaminvoke->frame_len);
Varun Reddy Yeturu1ad240c2017-03-21 10:44:28 -070014213 WMI_LOGD(FL("flags:%d, scan_mode:%d"), cmd->flags, cmd->roam_scan_mode);
Naveen Rawat77797922017-01-20 17:00:07 -080014214
Govind Singha4836fd2016-03-07 16:45:38 +053014215 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14216 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014217 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014218 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014219 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014220 }
14221
Govind Singhb53420c2016-03-09 14:32:57 +053014222 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014223}
14224
14225/**
14226 * send_roam_scan_offload_cmd_tlv() - set roam offload command
14227 * @wmi_handle: wmi handle
14228 * @command: command
14229 * @vdev_id: vdev id
14230 *
14231 * This function set roam offload command to fw.
14232 *
14233 * Return: CDF status
14234 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014235static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014236 uint32_t command, uint32_t vdev_id)
14237{
Govind Singh67922e82016-04-01 16:48:57 +053014238 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014239 wmi_roam_scan_cmd_fixed_param *cmd_fp;
14240 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014241 int len;
14242 uint8_t *buf_ptr;
14243
14244 len = sizeof(wmi_roam_scan_cmd_fixed_param);
14245 buf = wmi_buf_alloc(wmi_handle, len);
14246 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014247 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14248 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014249 }
14250
14251 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14252
14253 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
14254 WMITLV_SET_HDR(&cmd_fp->tlv_header,
14255 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
14256 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
14257 cmd_fp->vdev_id = vdev_id;
14258 cmd_fp->command_arg = command;
14259
14260 status = wmi_unified_cmd_send(wmi_handle, buf,
14261 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053014262 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014263 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014264 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014265 goto error;
14266 }
14267
Govind Singhb53420c2016-03-09 14:32:57 +053014268 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
14269 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014270
14271error:
14272 wmi_buf_free(buf);
14273
Govind Singh67922e82016-04-01 16:48:57 +053014274 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014275}
14276
14277/**
14278 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
14279 * @wmi_handle: wmi handle
14280 * @ap_profile_p: ap profile
14281 * @vdev_id: vdev id
14282 *
14283 * Send WMI_ROAM_AP_PROFILE to firmware
14284 *
14285 * Return: CDF status
14286 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014287static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014288 wmi_ap_profile *ap_profile_p,
14289 uint32_t vdev_id)
14290{
Govind Singha4836fd2016-03-07 16:45:38 +053014291 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014292 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014293 int len;
14294 uint8_t *buf_ptr;
14295 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
14296
14297 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
14298
14299 buf = wmi_buf_alloc(wmi_handle, len);
14300 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014301 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14302 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014303 }
14304
14305 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14306 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
14307 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
14308 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
14309 WMITLV_GET_STRUCT_TLVLEN
14310 (wmi_roam_ap_profile_fixed_param));
14311 /* fill in threshold values */
14312 roam_ap_profile_fp->vdev_id = vdev_id;
14313 roam_ap_profile_fp->id = 0;
14314 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
14315
Govind Singhb53420c2016-03-09 14:32:57 +053014316 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053014317 WMITLV_SET_HDR(buf_ptr,
14318 WMITLV_TAG_STRUC_wmi_ap_profile,
14319 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
14320 status = wmi_unified_cmd_send(wmi_handle, buf,
14321 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053014322 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014323 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014324 status);
Govind Singh67922e82016-04-01 16:48:57 +053014325 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014326 }
14327
Govind Singhb53420c2016-03-09 14:32:57 +053014328 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053014329
Govind Singh67922e82016-04-01 16:48:57 +053014330 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014331}
14332
14333/**
14334 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
14335 * @wmi_handle: wmi handle
14336 * @scan_period: scan period
14337 * @scan_age: scan age
14338 * @vdev_id: vdev id
14339 *
14340 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
14341 *
14342 * Return: CDF status
14343 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014344static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014345 uint32_t scan_period,
14346 uint32_t scan_age,
14347 uint32_t vdev_id)
14348{
Govind Singh67922e82016-04-01 16:48:57 +053014349 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014350 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014351 int len;
14352 uint8_t *buf_ptr;
14353 wmi_roam_scan_period_fixed_param *scan_period_fp;
14354
14355 /* Send scan period values */
14356 len = sizeof(wmi_roam_scan_period_fixed_param);
14357 buf = wmi_buf_alloc(wmi_handle, len);
14358 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014359 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14360 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014361 }
14362
14363 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14364 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
14365 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
14366 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
14367 WMITLV_GET_STRUCT_TLVLEN
14368 (wmi_roam_scan_period_fixed_param));
14369 /* fill in scan period values */
14370 scan_period_fp->vdev_id = vdev_id;
14371 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
14372 scan_period_fp->roam_scan_age = scan_age;
14373
14374 status = wmi_unified_cmd_send(wmi_handle, buf,
14375 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053014376 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014377 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014378 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014379 goto error;
14380 }
14381
Govind Singhb53420c2016-03-09 14:32:57 +053014382 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053014383 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053014384 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014385error:
14386 wmi_buf_free(buf);
14387
Govind Singh67922e82016-04-01 16:48:57 +053014388 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014389}
14390
14391/**
14392 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
14393 * @wmi_handle: wmi handle
14394 * @chan_count: channel count
14395 * @chan_list: channel list
14396 * @list_type: list type
14397 * @vdev_id: vdev id
14398 *
14399 * Set roam offload channel list.
14400 *
14401 * Return: CDF status
14402 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014403static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014404 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070014405 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053014406 uint8_t list_type, uint32_t vdev_id)
14407{
Govind Singha4836fd2016-03-07 16:45:38 +053014408 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014409 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014410 int len, list_tlv_len;
14411 int i;
14412 uint8_t *buf_ptr;
14413 wmi_roam_chan_list_fixed_param *chan_list_fp;
14414 A_UINT32 *roam_chan_list_array;
14415
14416 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053014417 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053014418 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053014419 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053014420 }
14421 /* Channel list is a table of 2 TLV's */
14422 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
14423 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
14424 buf = wmi_buf_alloc(wmi_handle, len);
14425 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014426 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14427 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014428 }
14429
14430 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14431 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
14432 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
14433 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
14434 WMITLV_GET_STRUCT_TLVLEN
14435 (wmi_roam_chan_list_fixed_param));
14436 chan_list_fp->vdev_id = vdev_id;
14437 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053014438 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053014439 /* external app is controlling channel list */
14440 chan_list_fp->chan_list_type =
14441 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
14442 } else {
14443 /* umac supplied occupied channel list in LFR */
14444 chan_list_fp->chan_list_type =
14445 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
14446 }
14447
14448 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
14449 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14450 (chan_list_fp->num_chan * sizeof(uint32_t)));
14451 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053014452 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053014453 for (i = 0; ((i < chan_list_fp->num_chan) &&
14454 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
14455 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014456 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014457 }
14458
14459 status = wmi_unified_cmd_send(wmi_handle, buf,
14460 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053014461 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014462 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014463 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014464 goto error;
14465 }
14466
Govind Singhb53420c2016-03-09 14:32:57 +053014467 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
14468 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014469error:
14470 wmi_buf_free(buf);
14471
Govind Singh67922e82016-04-01 16:48:57 +053014472 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014473}
14474
14475/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014476 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
14477 * @wmi_handle: wmi handle
14478 * @req_buf: per roam config buffer
14479 *
14480 * Return: QDF status
14481 */
14482static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
14483 struct wmi_per_roam_config_req *req_buf)
14484{
14485 wmi_buf_t buf = NULL;
14486 QDF_STATUS status;
14487 int len;
14488 uint8_t *buf_ptr;
14489 wmi_roam_per_config_fixed_param *wmi_per_config;
14490
14491 len = sizeof(wmi_roam_per_config_fixed_param);
14492 buf = wmi_buf_alloc(wmi_handle, len);
14493 if (!buf) {
14494 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14495 return QDF_STATUS_E_NOMEM;
14496 }
14497
14498 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14499 wmi_per_config =
14500 (wmi_roam_per_config_fixed_param *) buf_ptr;
14501 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
14502 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
14503 WMITLV_GET_STRUCT_TLVLEN
14504 (wmi_roam_per_config_fixed_param));
14505
14506 /* fill in per roam config values */
14507 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014508
14509 wmi_per_config->enable = req_buf->per_config.enable;
14510 wmi_per_config->high_rate_thresh =
14511 (req_buf->per_config.tx_high_rate_thresh << 16) |
14512 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
14513 wmi_per_config->low_rate_thresh =
14514 (req_buf->per_config.tx_low_rate_thresh << 16) |
14515 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
14516 wmi_per_config->pkt_err_rate_thresh_pct =
14517 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
14518 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
14519 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053014520 wmi_per_config->pkt_err_rate_mon_time =
14521 (req_buf->per_config.tx_per_mon_time << 16) |
14522 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053014523 wmi_per_config->min_candidate_rssi =
14524 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014525
14526 /* Send per roam config parameters */
14527 status = wmi_unified_cmd_send(wmi_handle, buf,
14528 len, WMI_ROAM_PER_CONFIG_CMDID);
14529 if (QDF_IS_STATUS_ERROR(status)) {
14530 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
14531 status);
14532 wmi_buf_free(buf);
14533 return status;
14534 }
14535
14536 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
14537 req_buf->per_config.enable, req_buf->vdev_id);
14538 return QDF_STATUS_SUCCESS;
14539}
14540
14541/**
Govind Singha4836fd2016-03-07 16:45:38 +053014542 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
14543 * @wmi_handle: wmi handle
14544 * @rssi_change_thresh: RSSI Change threshold
14545 * @bcn_rssi_weight: beacon RSSI weight
14546 * @vdev_id: vdev id
14547 *
14548 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
14549 *
14550 * Return: CDF status
14551 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014552static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014553 uint32_t vdev_id,
14554 int32_t rssi_change_thresh,
14555 uint32_t bcn_rssi_weight,
14556 uint32_t hirssi_delay_btw_scans)
14557{
Govind Singha4836fd2016-03-07 16:45:38 +053014558 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014559 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014560 int len;
14561 uint8_t *buf_ptr;
14562 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
14563
14564 /* Send rssi change parameters */
14565 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
14566 buf = wmi_buf_alloc(wmi_handle, len);
14567 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014568 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14569 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014570 }
14571
14572 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14573 rssi_change_fp =
14574 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
14575 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
14576 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
14577 WMITLV_GET_STRUCT_TLVLEN
14578 (wmi_roam_scan_rssi_change_threshold_fixed_param));
14579 /* fill in rssi change threshold (hysteresis) values */
14580 rssi_change_fp->vdev_id = vdev_id;
14581 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
14582 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
14583 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
14584
14585 status = wmi_unified_cmd_send(wmi_handle, buf,
14586 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053014587 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014588 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014589 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014590 goto error;
14591 }
14592
Govind Singhb53420c2016-03-09 14:32:57 +053014593 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053014594 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053014595 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
14596 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014597error:
14598 wmi_buf_free(buf);
14599
Govind Singh67922e82016-04-01 16:48:57 +053014600 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014601}
14602
14603/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
14604 * @wmi_handle: wmi handle.
14605 * @cmd: size of command structure.
14606 * @per_entry_size: per entry size.
14607 *
14608 * This utility function calculates how many hotlist entries can
14609 * fit in one page.
14610 *
14611 * Return: number of entries
14612 */
14613static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
14614 size_t cmd_size,
14615 size_t per_entry_size)
14616{
14617 uint32_t avail_space = 0;
14618 int num_entries = 0;
14619 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
14620
14621 /* Calculate number of hotlist entries that can
14622 * be passed in wma message request.
14623 */
14624 avail_space = max_msg_len - cmd_size;
14625 num_entries = avail_space / per_entry_size;
14626 return num_entries;
14627}
14628
14629/**
14630 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
14631 * @wmi_handle: wmi handle
14632 * @photlist: hotlist command params
14633 * @buf_len: buffer length
14634 *
14635 * This function fills individual elements for hotlist request and
14636 * TLV for bssid entries
14637 *
14638 * Return: CDF Status.
14639 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014640static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014641 struct ext_scan_setbssi_hotlist_params *
14642 photlist, int *buf_len)
14643{
14644 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
14645 wmi_extscan_hotlist_entry *dest_hotlist;
14646 struct ap_threshold_params *src_ap = photlist->ap;
14647 wmi_buf_t buf;
14648 uint8_t *buf_ptr;
14649
14650 int j, index = 0;
14651 int cmd_len = 0;
14652 int num_entries;
14653 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014654 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053014655 int len = sizeof(*cmd);
14656
14657 len += WMI_TLV_HDR_SIZE;
14658 cmd_len = len;
14659
14660 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
14661 cmd_len,
14662 sizeof(*dest_hotlist));
14663 /* setbssid hotlist expects the bssid list
14664 * to be non zero value
14665 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014666 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080014667 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053014668 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053014669 }
14670
14671 /* Split the hot list entry pages and send multiple command
14672 * requests if the buffer reaches the maximum request size
14673 */
14674 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053014675 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053014676 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
14677 buf = wmi_buf_alloc(wmi_handle, len);
14678 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014679 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
14680 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014681 }
14682 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14683 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
14684 buf_ptr;
14685 WMITLV_SET_HDR(&cmd->tlv_header,
14686 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
14687 WMITLV_GET_STRUCT_TLVLEN
14688 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
14689
14690 /* Multiple requests are sent until the num_entries_in_page
14691 * matches the total_entries
14692 */
14693 cmd->request_id = photlist->requestId;
14694 cmd->vdev_id = photlist->sessionId;
14695 cmd->total_entries = numap;
14696 cmd->mode = 1;
14697 cmd->num_entries_in_page = min_entries;
14698 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
14699 cmd->first_entry_index = index;
14700
Govind Singhb53420c2016-03-09 14:32:57 +053014701 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014702 __func__, cmd->vdev_id, cmd->total_entries,
14703 cmd->num_entries_in_page,
14704 cmd->lost_ap_scan_count);
14705
14706 buf_ptr += sizeof(*cmd);
14707 WMITLV_SET_HDR(buf_ptr,
14708 WMITLV_TAG_ARRAY_STRUC,
14709 min_entries * sizeof(wmi_extscan_hotlist_entry));
14710 dest_hotlist = (wmi_extscan_hotlist_entry *)
14711 (buf_ptr + WMI_TLV_HDR_SIZE);
14712
14713 /* Populate bssid, channel info and rssi
14714 * for the bssid's that are sent as hotlists.
14715 */
14716 for (j = 0; j < min_entries; j++) {
14717 WMITLV_SET_HDR(dest_hotlist,
14718 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
14719 WMITLV_GET_STRUCT_TLVLEN
14720 (wmi_extscan_hotlist_entry));
14721
14722 dest_hotlist->min_rssi = src_ap->low;
14723 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
14724 &dest_hotlist->bssid);
14725
Govind Singhb53420c2016-03-09 14:32:57 +053014726 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014727 __func__, dest_hotlist->channel,
14728 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053014729 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053014730 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
14731 __func__, dest_hotlist->bssid.mac_addr31to0,
14732 dest_hotlist->bssid.mac_addr47to32);
14733 dest_hotlist++;
14734 src_ap++;
14735 }
14736 buf_ptr += WMI_TLV_HDR_SIZE +
14737 (min_entries * sizeof(wmi_extscan_hotlist_entry));
14738
14739 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14740 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014741 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014742 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014743 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014744 }
14745 index = index + min_entries;
14746 num_entries = numap - min_entries;
14747 len = cmd_len;
14748 }
Govind Singhb53420c2016-03-09 14:32:57 +053014749 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014750}
14751
Govind Singhbca3b1b2016-05-02 17:59:24 +053014752/**
Dustin Brown4423f632017-01-13 15:24:07 -080014753 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
14754 * @wmi_handle: the WMI handle
14755 * @vdev_id: the Id of the vdev to apply the configuration to
14756 * @ucast_mode: the active BPF mode to configure for unicast packets
14757 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
14758 * packets
14759 *
14760 * Return: QDF status
14761 */
14762static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
14763 uint8_t vdev_id,
14764 enum wmi_host_active_bpf_mode ucast_mode,
14765 enum wmi_host_active_bpf_mode mcast_bcast_mode)
14766{
14767 const WMITLV_TAG_ID tag_id =
14768 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
14769 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
14770 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
14771 QDF_STATUS status;
14772 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
14773 wmi_buf_t buf;
14774
14775 WMI_LOGI("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
14776 vdev_id, ucast_mode, mcast_bcast_mode);
14777
14778 /* allocate command buffer */
14779 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14780 if (!buf) {
14781 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14782 return QDF_STATUS_E_NOMEM;
14783 }
14784
14785 /* set TLV header */
14786 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
14787 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
14788
14789 /* populate data */
14790 cmd->vdev_id = vdev_id;
14791 cmd->uc_mode = ucast_mode;
14792 cmd->mcbc_mode = mcast_bcast_mode;
14793
14794 /* send to FW */
14795 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
14796 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
14797 if (QDF_IS_STATUS_ERROR(status)) {
14798 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
14799 status);
14800 wmi_buf_free(buf);
14801 return status;
14802 }
14803
14804 WMI_LOGI("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
14805
14806 return QDF_STATUS_SUCCESS;
14807}
14808
14809/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053014810 * send_power_dbg_cmd_tlv() - send power debug commands
14811 * @wmi_handle: wmi handle
14812 * @param: wmi power debug parameter
14813 *
14814 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
14815 *
14816 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14817 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014818static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
14819 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053014820{
14821 wmi_buf_t buf = NULL;
14822 QDF_STATUS status;
14823 int len, args_tlv_len;
14824 uint8_t *buf_ptr;
14825 uint8_t i;
14826 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
14827 uint32_t *cmd_args;
14828
14829 /* Prepare and send power debug cmd parameters */
14830 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
14831 len = sizeof(*cmd) + args_tlv_len;
14832 buf = wmi_buf_alloc(wmi_handle, len);
14833 if (!buf) {
14834 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14835 return QDF_STATUS_E_NOMEM;
14836 }
14837
14838 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14839 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
14840 WMITLV_SET_HDR(&cmd->tlv_header,
14841 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
14842 WMITLV_GET_STRUCT_TLVLEN
14843 (wmi_pdev_wal_power_debug_cmd_fixed_param));
14844
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014845 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14846 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053014847 cmd->module_id = param->module_id;
14848 cmd->num_args = param->num_args;
14849 buf_ptr += sizeof(*cmd);
14850 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14851 (param->num_args * sizeof(uint32_t)));
14852 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
14853 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
14854 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14855 cmd_args[i] = param->args[i];
14856 WMI_LOGI("%d,", param->args[i]);
14857 }
14858
14859 status = wmi_unified_cmd_send(wmi_handle, buf,
14860 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
14861 if (QDF_IS_STATUS_ERROR(status)) {
14862 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
14863 status);
14864 goto error;
14865 }
14866
14867 return QDF_STATUS_SUCCESS;
14868error:
14869 wmi_buf_free(buf);
14870
14871 return status;
14872}
14873
Kiran Venkatappa26117052016-12-23 19:58:54 +053014874/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014875 * @wmi_handle: pointer to wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053014876 * @buf_ptr: pointer to current position in init command buffer
14877 * @len: pointer to length. This will be updated with current lenght of cmd
14878 * @param: point host parameters for init command
14879 *
14880 * Return: Updated pointer of buf_ptr.
14881 */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014882static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
14883 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
Kiran Venkatappa26117052016-12-23 19:58:54 +053014884{
14885 uint16_t idx;
14886
14887 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
14888 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
14889 wmi_pdev_band_to_mac *band_to_mac;
14890
14891 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
14892 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
14893 sizeof(wmi_resource_config) +
14894 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
14895 sizeof(wlan_host_memory_chunk)));
14896
14897 WMITLV_SET_HDR(&hw_mode->tlv_header,
14898 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
14899 (WMITLV_GET_STRUCT_TLVLEN
14900 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
14901
14902 hw_mode->hw_mode_index = param->hw_mode_id;
14903 hw_mode->num_band_to_mac = param->num_band_to_mac;
14904
14905 buf_ptr = (uint8_t *) (hw_mode + 1);
14906 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
14907 WMI_TLV_HDR_SIZE);
14908 for (idx = 0; idx < param->num_band_to_mac; idx++) {
14909 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
14910 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
14911 WMITLV_GET_STRUCT_TLVLEN
14912 (wmi_pdev_band_to_mac));
14913 band_to_mac[idx].pdev_id =
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014914 wmi_handle->ops->convert_pdev_id_host_to_target(
14915 param->band_to_mac[idx].pdev_id);
Kiran Venkatappa26117052016-12-23 19:58:54 +053014916 band_to_mac[idx].start_freq =
14917 param->band_to_mac[idx].start_freq;
14918 band_to_mac[idx].end_freq =
14919 param->band_to_mac[idx].end_freq;
14920 }
14921 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
14922 (param->num_band_to_mac *
14923 sizeof(wmi_pdev_band_to_mac)) +
14924 WMI_TLV_HDR_SIZE;
14925
14926 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14927 (param->num_band_to_mac *
14928 sizeof(wmi_pdev_band_to_mac)));
14929 }
14930
14931 return buf_ptr;
14932}
14933
Govind Singhe7f2f342016-05-23 12:12:52 +053014934/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053014935 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
14936 * @wmi_handle: wmi handle
14937 * @param: wmi multiple vdev restart req param
14938 *
14939 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
14940 *
14941 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14942 */
14943static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
14944 wmi_unified_t wmi_handle,
14945 struct multiple_vdev_restart_params *param)
14946{
14947 wmi_buf_t buf;
14948 QDF_STATUS qdf_status;
14949 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
14950 int i;
14951 uint8_t *buf_ptr;
14952 uint32_t *vdev_ids;
14953 wmi_channel *chan_info;
14954 struct channel_param *tchan_info;
14955 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
14956
14957 len += sizeof(wmi_channel);
14958 if (param->num_vdevs)
14959 len += sizeof(uint32_t) * param->num_vdevs;
14960
14961 buf = wmi_buf_alloc(wmi_handle, len);
14962 if (!buf) {
14963 WMI_LOGE("Failed to allocate memory\n");
14964 qdf_status = QDF_STATUS_E_NOMEM;
14965 goto end;
14966 }
14967
14968 buf_ptr = (uint8_t *)wmi_buf_data(buf);
14969 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
14970 buf_ptr;
14971
14972 WMITLV_SET_HDR(&cmd->tlv_header,
14973 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
14974 WMITLV_GET_STRUCT_TLVLEN
14975 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014976 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14977 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053014978 cmd->requestor_id = param->requestor_id;
14979 cmd->disable_hw_ack = param->disable_hw_ack;
14980 cmd->cac_duration_ms = param->cac_duration_ms;
14981 cmd->num_vdevs = param->num_vdevs;
14982
14983 buf_ptr += sizeof(*cmd);
14984
14985 WMITLV_SET_HDR(buf_ptr,
14986 WMITLV_TAG_ARRAY_UINT32,
14987 sizeof(A_UINT32) * param->num_vdevs);
14988 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
14989 for (i = 0; i < param->num_vdevs; i++) {
14990 vdev_ids[i] = param->vdev_ids[i];
14991 }
14992
14993 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
14994
14995 WMITLV_SET_HDR(buf_ptr,
14996 WMITLV_TAG_STRUC_wmi_channel,
14997 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053014998 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053014999 tchan_info = &(param->ch_param);
15000 chan_info->mhz = tchan_info->mhz;
15001 chan_info->band_center_freq1 = tchan_info->cfreq1;
15002 chan_info->band_center_freq2 = tchan_info->cfreq2;
15003 if (tchan_info->is_chan_passive)
15004 WMI_SET_CHANNEL_FLAG(chan_info,
15005 WMI_CHAN_FLAG_PASSIVE);
15006 if (tchan_info->allow_vht)
15007 WMI_SET_CHANNEL_FLAG(chan_info,
15008 WMI_CHAN_FLAG_ALLOW_VHT);
15009 else if (tchan_info->allow_ht)
15010 WMI_SET_CHANNEL_FLAG(chan_info,
15011 WMI_CHAN_FLAG_ALLOW_HT);
15012 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15013 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15014 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15015 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15016 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15017 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
15018
15019 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15020 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15021
15022 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15023 WMI_LOGE("%s: Failed to send\n", __func__);
15024 wmi_buf_free(buf);
15025 }
15026
15027end:
15028 return qdf_status;
15029}
15030
15031/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015032 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15033 * @wmi_handle: wmi handle
15034 * @pdev_id: pdev id
15035 *
15036 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15037 *
15038 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15039 */
15040static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15041 uint32_t pdev_id)
15042{
15043 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15044 wmi_buf_t buf;
15045 uint16_t len;
15046 QDF_STATUS ret;
15047
15048 len = sizeof(*cmd);
15049 buf = wmi_buf_alloc(wmi_handle, len);
15050
15051 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15052
15053 if (!buf) {
15054 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15055 return QDF_STATUS_E_NOMEM;
15056 }
15057
15058 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
15059 wmi_buf_data(buf);
15060
15061 WMITLV_SET_HDR(&cmd->tlv_header,
15062 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
15063 WMITLV_GET_STRUCT_TLVLEN(
15064 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
15065
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015066 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015067 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15068 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
15069 if (QDF_IS_STATUS_ERROR(ret)) {
15070 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15071 __func__, ret, pdev_id);
15072 wmi_buf_free(buf);
15073 return QDF_STATUS_E_FAILURE;
15074 }
15075
15076 return QDF_STATUS_SUCCESS;
15077}
15078
15079/**
15080 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
15081 * @wmi_handle: wmi handle
15082 * @pdev_id: pdev id
15083 *
15084 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
15085 *
15086 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15087 */
15088static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
15089 uint32_t pdev_id)
15090{
15091 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
15092 wmi_buf_t buf;
15093 uint16_t len;
15094 QDF_STATUS ret;
15095
15096 len = sizeof(*cmd);
15097 buf = wmi_buf_alloc(wmi_handle, len);
15098
15099 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15100
15101 if (!buf) {
15102 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15103 return QDF_STATUS_E_NOMEM;
15104 }
15105
15106 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
15107 wmi_buf_data(buf);
15108
15109 WMITLV_SET_HDR(&cmd->tlv_header,
15110 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
15111 WMITLV_GET_STRUCT_TLVLEN(
15112 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
15113
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015114 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015115 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15116 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
15117 if (QDF_IS_STATUS_ERROR(ret)) {
15118 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15119 __func__, ret, pdev_id);
15120 wmi_buf_free(buf);
15121 return QDF_STATUS_E_FAILURE;
15122 }
15123
15124 return QDF_STATUS_SUCCESS;
15125}
15126
15127/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015128 * init_cmd_send_tlv() - send initialization cmd to fw
15129 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015130 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053015131 *
15132 * Return: QDF_STATUS_SUCCESS for success or error code
15133 */
15134static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053015135 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015136{
15137 wmi_buf_t buf;
15138 wmi_init_cmd_fixed_param *cmd;
15139 wmi_abi_version my_vers;
15140 int num_whitelist;
15141 uint8_t *buf_ptr;
15142 wmi_resource_config *resource_cfg;
15143 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053015144 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053015145 uint16_t idx;
15146 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053015147 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053015148
Kiran Venkatappa26117052016-12-23 19:58:54 +053015149 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
15150 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015151 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015152
15153 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
15154 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15155 WMI_TLV_HDR_SIZE +
15156 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
15157
15158 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053015159 if (!buf) {
15160 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15161 return QDF_STATUS_E_FAILURE;
15162 }
15163
15164 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15165 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
15166 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
15167
15168 host_mem_chunks = (wlan_host_memory_chunk *)
15169 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
15170 + WMI_TLV_HDR_SIZE);
15171
15172 WMITLV_SET_HDR(&cmd->tlv_header,
15173 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
15174 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
15175
Kiran Venkatappa26117052016-12-23 19:58:54 +053015176 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053015177 WMITLV_SET_HDR(&resource_cfg->tlv_header,
15178 WMITLV_TAG_STRUC_wmi_resource_config,
15179 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
15180
Kiran Venkatappa26117052016-12-23 19:58:54 +053015181 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053015182 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
15183 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
15184 WMITLV_GET_STRUCT_TLVLEN
15185 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053015186 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
15187 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
15188 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053015189 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
15190 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053015191 idx, host_mem_chunks[idx].size,
15192 host_mem_chunks[idx].ptr);
15193 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053015194 cmd->num_host_mem_chunks = param->num_mem_chunks;
15195 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
15196
Govind Singhe7f2f342016-05-23 12:12:52 +053015197 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
15198 WMITLV_TAG_ARRAY_STRUC,
15199 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053015200 param->num_mem_chunks));
15201
15202 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015203 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053015204
15205 num_whitelist = sizeof(version_whitelist) /
15206 sizeof(wmi_whitelist_version_info);
15207 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
15208 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
15209 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
15210 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
15211 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
15212 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
15213
Govind Singh87542482016-06-08 19:40:11 +053015214#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015215 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
15216 &my_vers,
15217 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
15218 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053015219#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015220 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
15221 __func__,
15222 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
15223 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
15224 cmd->host_abi_vers.abi_version_ns_0,
15225 cmd->host_abi_vers.abi_version_ns_1,
15226 cmd->host_abi_vers.abi_version_ns_2,
15227 cmd->host_abi_vers.abi_version_ns_3);
15228
15229 /* Save version sent from host -
15230 * Will be used to check ready event
15231 */
Govind Singh87542482016-06-08 19:40:11 +053015232#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015233 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
15234 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015235#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053015236 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
15237 if (QDF_IS_STATUS_ERROR(ret)) {
15238 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
15239 ret);
15240 wmi_buf_free(buf);
15241 }
15242 return ret;
15243
Govind Singhe7f2f342016-05-23 12:12:52 +053015244}
15245
15246/**
15247 * save_service_bitmap_tlv() - save service bitmap
15248 * @wmi_handle: wmi handle
15249 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080015250 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053015251 *
15252 * Return: None
15253 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015254#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015255static
Rajeev Kumar77901472017-02-12 02:12:17 -080015256void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15257 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015258{
15259 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15260 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15261
15262 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
15263 param_buf->wmi_service_bitmap,
15264 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080015265
15266 if (bitmap_buf)
15267 qdf_mem_copy(bitmap_buf,
15268 param_buf->wmi_service_bitmap,
15269 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053015270}
15271#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015272static
Rajeev Kumar77901472017-02-12 02:12:17 -080015273void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15274 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015275{
Rajeev Kumar77901472017-02-12 02:12:17 -080015276 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15277 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053015278
Rajeev Kumar77901472017-02-12 02:12:17 -080015279 if (bitmap_buf)
15280 qdf_mem_copy(bitmap_buf,
15281 param_buf->wmi_service_bitmap,
15282 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
15283}
Govind Singhe7f2f342016-05-23 12:12:52 +053015284#endif
15285
15286/**
15287 * is_service_enabled_tlv() - Check if service enabled
15288 * @param wmi_handle: wmi handle
15289 * @param service_id: service identifier
15290 *
15291 * Return: 1 enabled, 0 disabled
15292 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015293#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015294static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15295 uint32_t service_id)
15296{
15297 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
15298 service_id);
15299}
15300#else
15301static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15302 uint32_t service_id)
15303{
15304 return false;
15305}
15306#endif
15307
15308/**
15309 * extract_service_ready_tlv() - extract service ready event
15310 * @wmi_handle: wmi handle
15311 * @param evt_buf: pointer to received event buffer
15312 * @param cap: pointer to hold target capability information extracted from even
15313 *
15314 * Return: QDF_STATUS_SUCCESS for success or error code
15315 */
15316static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015317 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015318{
15319 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15320 wmi_service_ready_event_fixed_param *ev;
15321
15322
15323 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15324
15325 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15326 if (!ev) {
15327 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15328 return QDF_STATUS_E_FAILURE;
15329 }
15330
15331 cap->phy_capability = ev->phy_capability;
15332 cap->max_frag_entry = ev->max_frag_entry;
15333 cap->num_rf_chains = ev->num_rf_chains;
15334 cap->ht_cap_info = ev->ht_cap_info;
15335 cap->vht_cap_info = ev->vht_cap_info;
15336 cap->vht_supp_mcs = ev->vht_supp_mcs;
15337 cap->hw_min_tx_power = ev->hw_min_tx_power;
15338 cap->hw_max_tx_power = ev->hw_max_tx_power;
15339 cap->sys_cap_info = ev->sys_cap_info;
15340 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
15341 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
15342 cap->max_num_scan_channels = ev->max_num_scan_channels;
15343 cap->max_supported_macs = ev->max_supported_macs;
15344 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
15345 cap->txrx_chainmask = ev->txrx_chainmask;
15346 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
15347 cap->num_msdu_desc = ev->num_msdu_desc;
15348
15349 return QDF_STATUS_SUCCESS;
15350}
15351
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015352/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
15353 * to host internal WMI_HOST_REGDMN_MODE values.
15354 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
15355 * host currently. Add this in the future if required.
15356 * 11AX (Phase II) : 11ax related values are not currently
15357 * advertised separately by FW. As part of phase II regulatory bring-up,
15358 * finalize the advertisement mechanism.
15359 * @target_wireless_mode: target wireless mode received in message
15360 *
15361 * Return: returns the host internal wireless mode.
15362 */
15363static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
15364{
15365
15366 uint32_t wireless_modes = 0;
15367
15368 if (target_wireless_mode & REGDMN_MODE_11A)
15369 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
15370
15371 if (target_wireless_mode & REGDMN_MODE_TURBO)
15372 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
15373
15374 if (target_wireless_mode & REGDMN_MODE_11B)
15375 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
15376
15377 if (target_wireless_mode & REGDMN_MODE_PUREG)
15378 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
15379
15380 if (target_wireless_mode & REGDMN_MODE_11G)
15381 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
15382
15383 if (target_wireless_mode & REGDMN_MODE_108G)
15384 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
15385
15386 if (target_wireless_mode & REGDMN_MODE_108A)
15387 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
15388
15389 if (target_wireless_mode & REGDMN_MODE_XR)
15390 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
15391
15392 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
15393 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
15394
15395 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
15396 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
15397
15398 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
15399 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
15400
15401 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
15402 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
15403
15404 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
15405 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
15406
15407 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
15408 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
15409
15410 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
15411 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
15412
15413 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
15414 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
15415
15416 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
15417 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
15418
15419 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
15420 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
15421
15422 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
15423 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
15424
15425 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
15426 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
15427
15428 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
15429 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
15430
15431 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
15432 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
15433
15434 return wireless_modes;
15435}
15436
Govind Singhe7f2f342016-05-23 12:12:52 +053015437/**
15438 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
15439 * @wmi_handle: wmi handle
15440 * @param evt_buf: Pointer to event buffer
15441 * @param cap: pointer to hold HAL reg capabilities
15442 *
15443 * Return: QDF_STATUS_SUCCESS for success or error code
15444 */
15445static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015446 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015447{
15448 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15449
15450 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15451
15452 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
15453 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080015454 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053015455
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015456 cap->wireless_modes = convert_wireless_modes_tlv(
15457 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053015458
Govind Singhe7f2f342016-05-23 12:12:52 +053015459 return QDF_STATUS_SUCCESS;
15460}
15461
15462/**
15463 * extract_host_mem_req_tlv() - Extract host memory request event
15464 * @wmi_handle: wmi handle
15465 * @param evt_buf: pointer to event buffer
15466 * @param num_entries: pointer to hold number of entries requested
15467 *
15468 * Return: Number of entries requested
15469 */
15470static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
15471 void *evt_buf, uint8_t *num_entries)
15472{
15473 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15474 wmi_service_ready_event_fixed_param *ev;
15475
15476 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15477
15478 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15479 if (!ev) {
15480 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15481 return NULL;
15482 }
15483
15484 *num_entries = ev->num_mem_reqs;
15485
15486 return (host_mem_req *)param_buf->mem_reqs;
15487}
15488
15489/**
15490 * save_fw_version_in_service_ready_tlv() - Save fw version in service
15491 * ready function
15492 * @wmi_handle: wmi handle
15493 * @param evt_buf: pointer to event buffer
15494 *
15495 * Return: QDF_STATUS_SUCCESS for success or error code
15496 */
15497static QDF_STATUS
15498save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
15499{
15500 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15501 wmi_service_ready_event_fixed_param *ev;
15502
15503
15504 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15505
15506 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15507 if (!ev) {
15508 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15509 return QDF_STATUS_E_FAILURE;
15510 }
15511
Govind Singh87542482016-06-08 19:40:11 +053015512#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015513 /*Save fw version from service ready message */
15514 /*This will be used while sending INIT message */
15515 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
15516 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015517#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015518 return QDF_STATUS_SUCCESS;
15519}
15520
15521/**
15522 * ready_extract_init_status_tlv() - Extract init status from ready event
15523 * @wmi_handle: wmi handle
15524 * @param evt_buf: Pointer to event buffer
15525 *
15526 * Return: ready status
15527 */
15528static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
15529 void *evt_buf)
15530{
15531 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15532 wmi_ready_event_fixed_param *ev = NULL;
15533
15534
15535 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15536 ev = param_buf->fixed_param;
15537
15538 qdf_print("%s:%d\n", __func__, ev->status);
15539
15540 return ev->status;
15541}
15542
15543/**
15544 * ready_extract_mac_addr_tlv() - extract mac address from ready event
15545 * @wmi_handle: wmi handle
15546 * @param evt_buf: pointer to event buffer
15547 * @param macaddr: Pointer to hold MAC address
15548 *
15549 * Return: QDF_STATUS_SUCCESS for success or error code
15550 */
15551static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
15552 void *evt_buf, uint8_t *macaddr)
15553{
15554 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15555 wmi_ready_event_fixed_param *ev = NULL;
15556
15557
15558 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15559 ev = param_buf->fixed_param;
15560
15561 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
15562
15563 return QDF_STATUS_SUCCESS;
15564}
15565
15566/**
15567 * extract_dbglog_data_len_tlv() - extract debuglog data length
15568 * @wmi_handle: wmi handle
15569 * @param evt_buf: pointer to event buffer
15570 *
15571 * Return: length
15572 */
15573static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080015574 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053015575{
15576 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
15577
15578 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
15579
15580 *len = param_buf->num_bufp;
15581
15582 return param_buf->bufp;
15583}
15584
15585/**
15586 * extract_vdev_start_resp_tlv() - extract vdev start response
15587 * @wmi_handle: wmi handle
15588 * @param evt_buf: pointer to event buffer
15589 * @param vdev_rsp: Pointer to hold vdev response
15590 *
15591 * Return: QDF_STATUS_SUCCESS for success or error code
15592 */
15593static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
15594 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
15595{
15596 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
15597 wmi_vdev_start_response_event_fixed_param *ev;
15598
15599 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
15600 if (!param_buf) {
15601 qdf_print("Invalid start response event buffer\n");
15602 return QDF_STATUS_E_INVAL;
15603 }
15604
15605 ev = param_buf->fixed_param;
15606 if (!ev) {
15607 qdf_print("Invalid start response event buffer\n");
15608 return QDF_STATUS_E_INVAL;
15609 }
15610
15611 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
15612
15613 vdev_rsp->vdev_id = ev->vdev_id;
15614 vdev_rsp->requestor_id = ev->requestor_id;
15615 vdev_rsp->resp_type = ev->resp_type;
15616 vdev_rsp->status = ev->status;
15617 vdev_rsp->chain_mask = ev->chain_mask;
15618 vdev_rsp->smps_mode = ev->smps_mode;
15619 vdev_rsp->mac_id = ev->mac_id;
15620 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
15621 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
15622
15623 return QDF_STATUS_SUCCESS;
15624}
15625
15626/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015627 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053015628 * @wmi_handle: wmi handle
15629 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015630 * @param num_vdevs: Pointer to hold num vdev
15631 *
15632 * Return: QDF_STATUS_SUCCESS for success or error code
15633 */
15634static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
15635 void *evt_buf, uint32_t *num_vdevs)
15636{
15637 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15638 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
15639 uint32_t vdev_map;
15640
15641 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
15642 if (!param_buf) {
15643 qdf_print("Invalid tbtt update ext event buffer\n");
15644 return QDF_STATUS_E_INVAL;
15645 }
15646 tbtt_offset_event = param_buf->fixed_param;
15647 vdev_map = tbtt_offset_event->vdev_map;
15648 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
15649
15650 return QDF_STATUS_SUCCESS;
15651}
15652
15653/**
15654 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
15655 * @wmi_handle: wmi handle
15656 * @param evt_buf: pointer to event buffer
15657 * @param num_vdevs: Pointer to hold num vdev
15658 *
15659 * Return: QDF_STATUS_SUCCESS for success or error code
15660 */
15661static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
15662 void *evt_buf, uint32_t *num_vdevs)
15663{
15664 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
15665 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
15666
15667 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
15668 if (!param_buf) {
15669 qdf_print("Invalid tbtt update ext event buffer\n");
15670 return QDF_STATUS_E_INVAL;
15671 }
15672 tbtt_offset_ext_event = param_buf->fixed_param;
15673
15674 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
15675
15676 return QDF_STATUS_SUCCESS;
15677}
15678
15679/**
15680 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
15681 * @wmi_handle: wmi handle
15682 * @param evt_buf: pointer to event buffer
15683 * @param idx: Index refering to a vdev
15684 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053015685 *
15686 * Return: QDF_STATUS_SUCCESS for success or error code
15687 */
15688static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015689 void *evt_buf, uint8_t idx,
15690 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015691{
15692 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15693 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015694 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053015695
15696 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
15697 if (!param_buf) {
15698 qdf_print("Invalid tbtt update event buffer\n");
15699 return QDF_STATUS_E_INVAL;
15700 }
Govind Singhe7f2f342016-05-23 12:12:52 +053015701
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015702 tbtt_offset_event = param_buf->fixed_param;
15703 vdev_map = tbtt_offset_event->vdev_map;
15704 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
15705 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
15706 return QDF_STATUS_E_INVAL;
15707 tbtt_param->tbttoffset =
15708 param_buf->tbttoffset_list[tbtt_param->vdev_id];
15709
15710 return QDF_STATUS_SUCCESS;
15711}
15712
15713/**
15714 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
15715 * @wmi_handle: wmi handle
15716 * @param evt_buf: pointer to event buffer
15717 * @param idx: Index refering to a vdev
15718 * @param tbtt_param: Pointer to tbttoffset event param
15719 *
15720 * Return: QDF_STATUS_SUCCESS for success or error code
15721 */
15722static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
15723 void *evt_buf, uint8_t idx,
15724 struct tbttoffset_params *tbtt_param)
15725{
15726 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
15727 wmi_tbtt_offset_info *tbtt_offset_info;
15728
15729 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
15730 if (!param_buf) {
15731 qdf_print("Invalid tbtt update event buffer\n");
15732 return QDF_STATUS_E_INVAL;
15733 }
15734 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
15735
15736 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
15737 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053015738
15739 return QDF_STATUS_SUCCESS;
15740}
15741
15742/**
15743 * extract_mgmt_rx_params_tlv() - extract management rx params from event
15744 * @wmi_handle: wmi handle
15745 * @param evt_buf: pointer to event buffer
15746 * @param hdr: Pointer to hold header
15747 * @param bufp: Pointer to hold pointer to rx param buffer
15748 *
15749 * Return: QDF_STATUS_SUCCESS for success or error code
15750 */
15751static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053015752 void *evt_buf, struct mgmt_rx_event_params *hdr,
15753 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053015754{
15755 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
15756 wmi_mgmt_rx_hdr *ev_hdr = NULL;
15757
15758 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
15759 if (!param_tlvs) {
15760 WMI_LOGE("Get NULL point message from FW");
15761 return QDF_STATUS_E_INVAL;
15762 }
15763
15764 ev_hdr = param_tlvs->hdr;
15765 if (!hdr) {
15766 WMI_LOGE("Rx event is NULL");
15767 return QDF_STATUS_E_INVAL;
15768 }
15769
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015770 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
15771 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053015772
15773 hdr->channel = ev_hdr->channel;
15774 hdr->snr = ev_hdr->snr;
15775 hdr->rate = ev_hdr->rate;
15776 hdr->phy_mode = ev_hdr->phy_mode;
15777 hdr->buf_len = ev_hdr->buf_len;
15778 hdr->status = ev_hdr->status;
15779 hdr->flags = ev_hdr->flags;
15780 hdr->rssi = ev_hdr->rssi;
15781 hdr->tsf_delta = ev_hdr->tsf_delta;
15782 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
15783
15784 *bufp = param_tlvs->bufp;
15785
15786 return QDF_STATUS_SUCCESS;
15787}
15788
15789/**
15790 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
15791 * @wmi_handle: wmi handle
15792 * @param evt_buf: pointer to event buffer
15793 * @param vdev_id: Pointer to hold vdev identifier
15794 *
15795 * Return: QDF_STATUS_SUCCESS for success or error code
15796 */
15797static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
15798 void *evt_buf, uint32_t *vdev_id)
15799{
15800 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
15801 wmi_vdev_stopped_event_fixed_param *resp_event;
15802
15803 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
15804 if (!param_buf) {
15805 WMI_LOGE("Invalid event buffer");
15806 return QDF_STATUS_E_INVAL;
15807 }
15808 resp_event = param_buf->fixed_param;
15809 *vdev_id = resp_event->vdev_id;
15810
15811 return QDF_STATUS_SUCCESS;
15812}
15813
15814/**
15815 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
15816 * @wmi_handle: wmi handle
15817 * @param evt_buf: pointer to event buffer
15818 * @param param: Pointer to hold roam param
15819 *
15820 * Return: QDF_STATUS_SUCCESS for success or error code
15821 */
15822static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
15823 void *evt_buf, wmi_host_roam_event *param)
15824{
15825 WMI_ROAM_EVENTID_param_tlvs *param_buf;
15826 wmi_roam_event_fixed_param *evt;
15827
15828 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
15829 if (!param_buf) {
15830 WMI_LOGE("Invalid roam event buffer");
15831 return QDF_STATUS_E_INVAL;
15832 }
15833
15834 evt = param_buf->fixed_param;
15835 qdf_mem_zero(param, sizeof(*param));
15836
15837 param->vdev_id = evt->vdev_id;
15838 param->reason = evt->reason;
15839 param->rssi = evt->rssi;
15840
15841 return QDF_STATUS_SUCCESS;
15842}
15843
15844/**
15845 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
15846 * @wmi_handle: wmi handle
15847 * @param evt_buf: pointer to event buffer
15848 * @param param: Pointer to hold vdev scan param
15849 *
15850 * Return: QDF_STATUS_SUCCESS for success or error code
15851 */
15852static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015853 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015854{
15855 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
15856 wmi_scan_event_fixed_param *evt = NULL;
15857
15858 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
15859 evt = param_buf->fixed_param;
15860
15861 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015862
Govind Singhe7f2f342016-05-23 12:12:52 +053015863 switch (evt->event) {
15864 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015865 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015866 break;
15867 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015868 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015869 break;
15870 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015871 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015872 break;
15873 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015874 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015875 break;
15876 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015877 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015878 break;
15879 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015880 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015881 break;
15882 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015883 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015884 break;
15885 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015886 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015887 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053015888 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015889 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015890 break;
15891 case WMI_SCAN_EVENT_MAX:
15892 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015893 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015894 break;
15895 };
15896
15897 switch (evt->reason) {
15898 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015899 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015900 break;
15901 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015902 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015903 break;
15904 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015905 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015906 break;
15907 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015908 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015909 break;
15910 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015911 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015912 break;
15913 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015914 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015915 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015916 case WMI_SCAN_REASON_SUSPENDED:
15917 param->reason = SCAN_REASON_SUSPENDED;
15918 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015919 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015920 param->reason = SCAN_REASON_MAX;
15921 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015922 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015923 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015924 break;
15925 };
15926
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015927 param->chan_freq = evt->channel_freq;
15928 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053015929 param->scan_id = evt->scan_id;
15930 param->vdev_id = evt->vdev_id;
15931
15932 return QDF_STATUS_SUCCESS;
15933}
15934
Frank Liu3d5e9992017-03-15 17:51:43 +080015935#ifdef CONVERGED_TDLS_ENABLE
15936/**
15937 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
15938 * @wmi_handle: wmi handle
15939 * @param evt_buf: pointer to event buffer
15940 * @param param: Pointer to hold vdev tdls param
15941 *
15942 * Return: QDF_STATUS_SUCCESS for success or error code
15943 */
15944static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
15945 void *evt_buf, struct tdls_event_info *param)
15946{
15947 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
15948 wmi_tdls_peer_event_fixed_param *evt;
15949
15950 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
15951 if (!param_buf) {
15952 WMI_LOGE("%s: NULL param_buf", __func__);
15953 return QDF_STATUS_E_NULL_VALUE;
15954 }
15955
15956 evt = param_buf->fixed_param;
15957
15958 qdf_mem_zero(param, sizeof(*param));
15959
15960 param->vdev_id = evt->vdev_id;
15961 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
15962 param->peermac.bytes);
15963 switch (evt->peer_status) {
15964 case WMI_TDLS_SHOULD_DISCOVER:
15965 param->message_type = TDLS_SHOULD_DISCOVER;
15966 break;
15967 case WMI_TDLS_SHOULD_TEARDOWN:
15968 param->message_type = TDLS_SHOULD_TEARDOWN;
15969 break;
15970 case WMI_TDLS_PEER_DISCONNECTED:
15971 param->message_type = TDLS_PEER_DISCONNECTED;
15972 break;
15973 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
15974 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
15975 break;
15976 default:
15977 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
15978 __func__, evt->peer_status);
15979 return QDF_STATUS_E_INVAL;
15980 };
15981
15982 switch (evt->peer_reason) {
15983 case WMI_TDLS_TEARDOWN_REASON_TX:
15984 param->peer_reason = TDLS_TEARDOWN_TX;
15985 break;
15986 case WMI_TDLS_TEARDOWN_REASON_RSSI:
15987 param->peer_reason = TDLS_TEARDOWN_RSSI;
15988 break;
15989 case WMI_TDLS_TEARDOWN_REASON_SCAN:
15990 param->peer_reason = TDLS_TEARDOWN_SCAN;
15991 break;
15992 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
15993 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
15994 break;
15995 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
15996 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
15997 break;
15998 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
15999 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
16000 break;
16001 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
16002 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
16003 break;
16004 case WMI_TDLS_ENTER_BUF_STA:
16005 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
16006 break;
16007 case WMI_TDLS_EXIT_BUF_STA:
16008 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
16009 break;
16010 case WMI_TDLS_ENTER_BT_BUSY_MODE:
16011 param->peer_reason = TDLS_ENTER_BT_BUSY;
16012 break;
16013 case WMI_TDLS_EXIT_BT_BUSY_MODE:
16014 param->peer_reason = TDLS_EXIT_BT_BUSY;
16015 break;
16016 case WMI_TDLS_SCAN_STARTED_EVENT:
16017 param->peer_reason = TDLS_SCAN_STARTED;
16018 break;
16019 case WMI_TDLS_SCAN_COMPLETED_EVENT:
16020 param->peer_reason = TDLS_SCAN_COMPLETED;
16021 break;
16022
16023 default:
16024 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
16025 __func__, evt->peer_reason, evt->peer_status);
16026 return QDF_STATUS_E_INVAL;
16027 };
16028
16029 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
16030 __func__, param->peermac.bytes, param->message_type,
16031 param->peer_reason, param->vdev_id);
16032
16033 return QDF_STATUS_SUCCESS;
16034}
16035#endif
16036
Govind Singhe7f2f342016-05-23 12:12:52 +053016037/**
16038 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
16039 * @wmi_handle: wmi handle
16040 * @param evt_buf: pointer to event buffer
16041 * @param param: Pointer to hold MGMT TX completion params
16042 *
16043 * Return: QDF_STATUS_SUCCESS for success or error code
16044 */
16045static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
16046 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
16047{
16048 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16049 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
16050
16051 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
16052 evt_buf;
16053 if (!param_buf) {
16054 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
16055 return QDF_STATUS_E_INVAL;
16056 }
16057 cmpl_params = param_buf->fixed_param;
16058
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016059 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16060 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053016061 param->desc_id = cmpl_params->desc_id;
16062 param->status = cmpl_params->status;
16063
16064 return QDF_STATUS_SUCCESS;
16065}
16066
16067/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016068 * extract_offchan_data_tx_compl_param_tlv() -
16069 * extract Offchan data tx completion event params
16070 * @wmi_handle: wmi handle
16071 * @param evt_buf: pointer to event buffer
16072 * @param param: Pointer to hold offchan data TX completion params
16073 *
16074 * Return: QDF_STATUS_SUCCESS for success or error code
16075 */
16076static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
16077 wmi_unified_t wmi_handle, void *evt_buf,
16078 struct wmi_host_offchan_data_tx_compl_event *param)
16079{
16080 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16081 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
16082
16083 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
16084 evt_buf;
16085 if (!param_buf) {
16086 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
16087 return QDF_STATUS_E_INVAL;
16088 }
16089 cmpl_params = param_buf->fixed_param;
16090
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016091 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16092 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016093 param->desc_id = cmpl_params->desc_id;
16094 param->status = cmpl_params->status;
16095
16096 return QDF_STATUS_SUCCESS;
16097}
16098
16099/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016100 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
16101 * status tlv
16102 * @wmi_handle: wmi handle
16103 * @param evt_buf: pointer to event buffer
16104 * @param param: Pointer to hold csa switch count status event param
16105 *
16106 * Return: QDF_STATUS_SUCCESS for success or error code
16107 */
16108static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
16109 wmi_unified_t wmi_handle,
16110 void *evt_buf,
16111 struct pdev_csa_switch_count_status *param)
16112{
16113 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
16114 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
16115
16116 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
16117 evt_buf;
16118 if (!param_buf) {
16119 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
16120 return QDF_STATUS_E_INVAL;
16121 }
16122
16123 csa_status = param_buf->fixed_param;
16124
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016125 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16126 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016127 param->current_switch_count = csa_status->current_switch_count;
16128 param->num_vdevs = csa_status->num_vdevs;
16129 param->vdev_ids = param_buf->vdev_ids;
16130
16131 return QDF_STATUS_SUCCESS;
16132}
16133
16134/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016135 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053016136 * @wmi_handle: wmi handle
16137 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016138 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053016139 *
16140 * Return: QDF_STATUS_SUCCESS for success or error code
16141 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016142static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
16143 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053016144{
16145 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16146 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016147 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053016148
16149 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16150 if (!param_buf) {
16151 WMI_LOGE("Invalid swba event buffer");
16152 return QDF_STATUS_E_INVAL;
16153 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016154
Govind Singhe7f2f342016-05-23 12:12:52 +053016155 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016156 *num_vdevs = swba_event->num_vdevs;
16157 if (!(*num_vdevs)) {
16158 vdev_map = swba_event->vdev_map;
16159 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
16160 }
Govind Singhe7f2f342016-05-23 12:12:52 +053016161
16162 return QDF_STATUS_SUCCESS;
16163}
16164
16165/**
16166 * extract_swba_tim_info_tlv() - extract swba tim info from event
16167 * @wmi_handle: wmi handle
16168 * @param evt_buf: pointer to event buffer
16169 * @param idx: Index to bcn info
16170 * @param tim_info: Pointer to hold tim info
16171 *
16172 * Return: QDF_STATUS_SUCCESS for success or error code
16173 */
16174static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
16175 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
16176{
16177 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16178 wmi_tim_info *tim_info_ev;
16179
16180 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16181 if (!param_buf) {
16182 WMI_LOGE("Invalid swba event buffer");
16183 return QDF_STATUS_E_INVAL;
16184 }
16185
16186 tim_info_ev = &param_buf->tim_info[idx];
16187
16188 tim_info->tim_len = tim_info_ev->tim_len;
16189 tim_info->tim_mcast = tim_info_ev->tim_mcast;
16190 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
16191 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
16192 tim_info->tim_changed = tim_info_ev->tim_changed;
16193 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016194 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016195
16196 return QDF_STATUS_SUCCESS;
16197}
16198
16199/**
16200 * extract_swba_noa_info_tlv() - extract swba NoA information from event
16201 * @wmi_handle: wmi handle
16202 * @param evt_buf: pointer to event buffer
16203 * @param idx: Index to bcn info
16204 * @param p2p_desc: Pointer to hold p2p NoA info
16205 *
16206 * Return: QDF_STATUS_SUCCESS for success or error code
16207 */
16208static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
16209 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
16210{
16211 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16212 wmi_p2p_noa_info *p2p_noa_info;
16213 uint8_t i = 0;
16214
16215 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16216 if (!param_buf) {
16217 WMI_LOGE("Invalid swba event buffer");
16218 return QDF_STATUS_E_INVAL;
16219 }
16220
16221 p2p_noa_info = &param_buf->p2p_noa_info[idx];
16222
16223 p2p_desc->modified = false;
16224 p2p_desc->num_descriptors = 0;
16225 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
16226 p2p_desc->modified = true;
16227 p2p_desc->index =
16228 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
16229 p2p_desc->oppPS =
16230 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
16231 p2p_desc->ctwindow =
16232 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
16233 p2p_desc->num_descriptors =
16234 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
16235 (p2p_noa_info);
16236 for (i = 0; i < p2p_desc->num_descriptors; i++) {
16237 p2p_desc->noa_descriptors[i].type_count =
16238 (uint8_t) p2p_noa_info->noa_descriptors[i].
16239 type_count;
16240 p2p_desc->noa_descriptors[i].duration =
16241 p2p_noa_info->noa_descriptors[i].duration;
16242 p2p_desc->noa_descriptors[i].interval =
16243 p2p_noa_info->noa_descriptors[i].interval;
16244 p2p_desc->noa_descriptors[i].start_time =
16245 p2p_noa_info->noa_descriptors[i].start_time;
16246 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016247 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016248 }
16249
16250 return QDF_STATUS_SUCCESS;
16251}
16252
Wu Gaocd3a8512017-03-13 20:17:34 +080016253#ifdef CONVERGED_P2P_ENABLE
16254/**
16255 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
16256 * @wmi_handle: wmi handle
16257 * @param evt_buf: pointer to event buffer
16258 * @param param: Pointer to hold p2p noa info
16259 *
16260 * Return: QDF_STATUS_SUCCESS for success or error code
16261 */
16262static QDF_STATUS extract_p2p_noa_ev_param_tlv(
16263 wmi_unified_t wmi_handle, void *evt_buf,
16264 struct p2p_noa_info *param)
16265{
16266 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
16267 wmi_p2p_noa_event_fixed_param *fixed_param;
16268 uint8_t i;
16269 wmi_p2p_noa_info *wmi_noa_info;
16270 uint8_t *buf_ptr;
16271 uint32_t descriptors;
16272
16273 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
16274 if (!param_tlvs) {
16275 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
16276 return QDF_STATUS_E_INVAL;
16277 }
16278
16279 if (!param) {
16280 WMI_LOGE("noa information param is null");
16281 return QDF_STATUS_E_INVAL;
16282 }
16283
16284 fixed_param = param_tlvs->fixed_param;
16285 buf_ptr = (uint8_t *) fixed_param;
16286 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
16287 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
16288
16289 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
16290 WMI_LOGE("%s: noa attr is not modified", __func__);
16291 return QDF_STATUS_E_INVAL;
16292 }
16293
16294 param->vdev_id = fixed_param->vdev_id;
16295 param->index =
16296 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
16297 param->opps_ps =
16298 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
16299 param->ct_window =
16300 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
16301 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
16302 param->num_desc = (uint8_t) descriptors;
16303
16304 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
16305 param->index, param->opps_ps, param->ct_window,
16306 param->num_desc);
16307 for (i = 0; i < param->num_desc; i++) {
16308 param->noa_desc[i].type_count =
16309 (uint8_t) wmi_noa_info->noa_descriptors[i].
16310 type_count;
16311 param->noa_desc[i].duration =
16312 wmi_noa_info->noa_descriptors[i].duration;
16313 param->noa_desc[i].interval =
16314 wmi_noa_info->noa_descriptors[i].interval;
16315 param->noa_desc[i].start_time =
16316 wmi_noa_info->noa_descriptors[i].start_time;
16317 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
16318 __func__, i, param->noa_desc[i].type_count,
16319 param->noa_desc[i].duration,
16320 param->noa_desc[i].interval,
16321 param->noa_desc[i].start_time);
16322 }
16323
16324 return QDF_STATUS_SUCCESS;
16325}
16326
16327/**
16328 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
16329 * information from event
16330 * @wmi_handle: wmi handle
16331 * @param evt_buf: pointer to event buffer
16332 * @param param: Pointer to hold p2p lo stop event information
16333 *
16334 * Return: QDF_STATUS_SUCCESS for success or error code
16335 */
16336static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
16337 wmi_unified_t wmi_handle, void *evt_buf,
16338 struct p2p_lo_event *param)
16339{
16340 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
16341 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
16342
16343 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
16344 evt_buf;
16345 if (!param_tlvs) {
16346 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
16347 return QDF_STATUS_E_INVAL;
16348 }
16349
16350 if (!param) {
16351 WMI_LOGE("lo stop event param is null");
16352 return QDF_STATUS_E_INVAL;
16353 }
16354
16355 lo_param = param_tlvs->fixed_param;
16356 param->vdev_id = lo_param->vdev_id;
16357 param->reason_code = lo_param->reason;
16358 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
16359 param->vdev_id, param->reason_code);
16360
16361 return QDF_STATUS_SUCCESS;
16362}
16363#endif /* End of CONVERGED_P2P_ENABLE */
16364
Govind Singhe7f2f342016-05-23 12:12:52 +053016365/**
16366 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
16367 * @wmi_handle: wmi handle
16368 * @param evt_buf: pointer to event buffer
16369 * @param ev: Pointer to hold peer param
16370 *
16371 * Return: QDF_STATUS_SUCCESS for success or error code
16372 */
16373static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
16374 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
16375{
16376 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
16377 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
16378
16379 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
16380 kickout_event = param_buf->fixed_param;
16381
16382 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
16383 ev->peer_macaddr);
16384
16385 ev->reason = kickout_event->reason;
16386 ev->rssi = kickout_event->rssi;
16387
16388 return QDF_STATUS_SUCCESS;
16389}
16390
16391/**
16392 * extract_all_stats_counts_tlv() - extract all stats count from event
16393 * @wmi_handle: wmi handle
16394 * @param evt_buf: pointer to event buffer
16395 * @param stats_param: Pointer to hold stats count
16396 *
16397 * Return: QDF_STATUS_SUCCESS for success or error code
16398 */
16399static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
16400 void *evt_buf, wmi_host_stats_event *stats_param)
16401{
16402 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16403 wmi_stats_event_fixed_param *ev;
16404
16405 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16406
16407 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16408 if (!ev) {
16409 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
16410 return QDF_STATUS_E_FAILURE;
16411 }
16412
16413 switch (ev->stats_id) {
16414 case WMI_REQUEST_PEER_STAT:
16415 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
16416 break;
16417
16418 case WMI_REQUEST_AP_STAT:
16419 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
16420 break;
16421
16422 case WMI_REQUEST_PDEV_STAT:
16423 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
16424 break;
16425
16426 case WMI_REQUEST_VDEV_STAT:
16427 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
16428 break;
16429
16430 case WMI_REQUEST_BCNFLT_STAT:
16431 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
16432 break;
16433
16434 case WMI_REQUEST_VDEV_RATE_STAT:
16435 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
16436 break;
16437
16438 default:
16439 stats_param->stats_id = 0;
16440 break;
16441
16442 }
16443
16444 stats_param->num_pdev_stats = ev->num_pdev_stats;
16445 stats_param->num_pdev_ext_stats = 0;
16446 stats_param->num_vdev_stats = ev->num_vdev_stats;
16447 stats_param->num_peer_stats = ev->num_peer_stats;
16448 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
16449 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016450 stats_param->pdev_id = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016451
16452 return QDF_STATUS_SUCCESS;
16453}
16454
16455/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016456 * extract_pdev_tx_stats() - extract pdev tx stats from event
16457 */
16458static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
16459{
16460 /* Tx Stats */
16461 tx->comp_queued = tx_stats->comp_queued;
16462 tx->comp_delivered = tx_stats->comp_delivered;
16463 tx->msdu_enqued = tx_stats->msdu_enqued;
16464 tx->mpdu_enqued = tx_stats->mpdu_enqued;
16465 tx->wmm_drop = tx_stats->wmm_drop;
16466 tx->local_enqued = tx_stats->local_enqued;
16467 tx->local_freed = tx_stats->local_freed;
16468 tx->hw_queued = tx_stats->hw_queued;
16469 tx->hw_reaped = tx_stats->hw_reaped;
16470 tx->underrun = tx_stats->underrun;
16471 tx->tx_abort = tx_stats->tx_abort;
16472 tx->mpdus_requed = tx_stats->mpdus_requed;
16473 tx->data_rc = tx_stats->data_rc;
16474 tx->self_triggers = tx_stats->self_triggers;
16475 tx->sw_retry_failure = tx_stats->sw_retry_failure;
16476 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
16477 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
16478 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
16479 tx->pdev_resets = tx_stats->pdev_resets;
16480 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
16481 tx->phy_underrun = tx_stats->phy_underrun;
16482 tx->txop_ovf = tx_stats->txop_ovf;
16483
16484 return;
16485}
16486
16487
16488/**
16489 * extract_pdev_rx_stats() - extract pdev rx stats from event
16490 */
16491static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
16492{
16493 /* Rx Stats */
16494 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
16495 rx->status_rcvd = rx_stats->status_rcvd;
16496 rx->r0_frags = rx_stats->r0_frags;
16497 rx->r1_frags = rx_stats->r1_frags;
16498 rx->r2_frags = rx_stats->r2_frags;
16499 /* Only TLV */
16500 rx->r3_frags = 0;
16501 rx->htt_msdus = rx_stats->htt_msdus;
16502 rx->htt_mpdus = rx_stats->htt_mpdus;
16503 rx->loc_msdus = rx_stats->loc_msdus;
16504 rx->loc_mpdus = rx_stats->loc_mpdus;
16505 rx->oversize_amsdu = rx_stats->oversize_amsdu;
16506 rx->phy_errs = rx_stats->phy_errs;
16507 rx->phy_err_drop = rx_stats->phy_err_drop;
16508 rx->mpdu_errs = rx_stats->mpdu_errs;
16509
16510 return;
16511}
16512
16513/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016514 * extract_pdev_stats_tlv() - extract pdev stats from event
16515 * @wmi_handle: wmi handle
16516 * @param evt_buf: pointer to event buffer
16517 * @param index: Index into pdev stats
16518 * @param pdev_stats: Pointer to hold pdev stats
16519 *
16520 * Return: QDF_STATUS_SUCCESS for success or error code
16521 */
16522static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
16523 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
16524{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016525 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16526 wmi_stats_event_fixed_param *ev_param;
16527 uint8_t *data;
16528
16529 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16530 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16531
16532 data = param_buf->data;
16533
16534 if (index < ev_param->num_pdev_stats) {
16535 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
16536 (index * sizeof(wmi_pdev_stats)));
16537
16538 pdev_stats->chan_nf = ev->chan_nf;
16539 pdev_stats->tx_frame_count = ev->tx_frame_count;
16540 pdev_stats->rx_frame_count = ev->rx_frame_count;
16541 pdev_stats->rx_clear_count = ev->rx_clear_count;
16542 pdev_stats->cycle_count = ev->cycle_count;
16543 pdev_stats->phy_err_count = ev->phy_err_count;
16544 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
16545
16546 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
16547 &(ev->pdev_stats.tx));
16548 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
16549 &(ev->pdev_stats.rx));
16550 }
16551
Govind Singhe7f2f342016-05-23 12:12:52 +053016552 return QDF_STATUS_SUCCESS;
16553}
16554
16555/**
16556 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
16557 * @wmi_handle: wmi handle
16558 * @param evt_buf: pointer to event buffer
16559 * @param index: Index into extended pdev stats
16560 * @param pdev_ext_stats: Pointer to hold extended pdev stats
16561 *
16562 * Return: QDF_STATUS_SUCCESS for success or error code
16563 */
16564static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
16565 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
16566{
16567 return QDF_STATUS_SUCCESS;
16568}
16569
16570/**
16571 * extract_vdev_stats_tlv() - extract vdev stats from event
16572 * @wmi_handle: wmi handle
16573 * @param evt_buf: pointer to event buffer
16574 * @param index: Index into vdev stats
16575 * @param vdev_stats: Pointer to hold vdev stats
16576 *
16577 * Return: QDF_STATUS_SUCCESS for success or error code
16578 */
16579static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
16580 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
16581{
16582 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16583 wmi_stats_event_fixed_param *ev_param;
16584 uint8_t *data;
16585
16586 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16587 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16588 data = (uint8_t *) param_buf->data;
16589
16590 if (index < ev_param->num_vdev_stats) {
16591 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
16592 ((ev_param->num_pdev_stats) *
16593 sizeof(wmi_pdev_stats)) +
16594 (index * sizeof(wmi_vdev_stats)));
16595
16596 vdev_stats->vdev_id = ev->vdev_id;
16597 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
16598 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
16599
16600 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
16601 sizeof(ev->tx_frm_cnt));
16602 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
16603 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
16604 ev->multiple_retry_cnt,
16605 sizeof(ev->multiple_retry_cnt));
16606 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
16607 sizeof(ev->fail_cnt));
16608 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
16609 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
16610 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
16611 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
16612 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
16613 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
16614 sizeof(ev->tx_rate_history));
16615 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
16616 sizeof(ev->bcn_rssi_history));
16617
16618 }
16619
16620 return QDF_STATUS_SUCCESS;
16621}
16622
16623/**
16624 * extract_peer_stats_tlv() - extract peer stats from event
16625 * @wmi_handle: wmi handle
16626 * @param evt_buf: pointer to event buffer
16627 * @param index: Index into peer stats
16628 * @param peer_stats: Pointer to hold peer stats
16629 *
16630 * Return: QDF_STATUS_SUCCESS for success or error code
16631 */
16632static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
16633 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
16634{
16635 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16636 wmi_stats_event_fixed_param *ev_param;
16637 uint8_t *data;
16638
16639 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16640 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16641 data = (uint8_t *) param_buf->data;
16642
16643 if (index < ev_param->num_peer_stats) {
16644 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
16645 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16646 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16647 (index * sizeof(wmi_peer_stats)));
16648
16649 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
16650
16651 OS_MEMCPY(&(peer_stats->peer_macaddr),
16652 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
16653
16654 peer_stats->peer_rssi = ev->peer_rssi;
16655 peer_stats->peer_tx_rate = ev->peer_tx_rate;
16656 peer_stats->peer_rx_rate = ev->peer_rx_rate;
16657 }
16658
16659 return QDF_STATUS_SUCCESS;
16660}
16661
16662/**
16663 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
16664 * @wmi_handle: wmi handle
16665 * @param evt_buf: pointer to event buffer
16666 * @param index: Index into bcn fault stats
16667 * @param bcnflt_stats: Pointer to hold bcn fault stats
16668 *
16669 * Return: QDF_STATUS_SUCCESS for success or error code
16670 */
16671static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
16672 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
16673{
16674 return QDF_STATUS_SUCCESS;
16675}
16676
16677/**
16678 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
16679 * @wmi_handle: wmi handle
16680 * @param evt_buf: pointer to event buffer
16681 * @param index: Index into extended peer stats
16682 * @param peer_extd_stats: Pointer to hold extended peer stats
16683 *
16684 * Return: QDF_STATUS_SUCCESS for success or error code
16685 */
16686static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
16687 void *evt_buf, uint32_t index,
16688 wmi_host_peer_extd_stats *peer_extd_stats)
16689{
16690 return QDF_STATUS_SUCCESS;
16691}
16692
16693/**
16694 * extract_chan_stats_tlv() - extract chan stats from event
16695 * @wmi_handle: wmi handle
16696 * @param evt_buf: pointer to event buffer
16697 * @param index: Index into chan stats
16698 * @param vdev_extd_stats: Pointer to hold chan stats
16699 *
16700 * Return: QDF_STATUS_SUCCESS for success or error code
16701 */
16702static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
16703 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
16704{
16705 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16706 wmi_stats_event_fixed_param *ev_param;
16707 uint8_t *data;
16708
16709 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16710 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16711 data = (uint8_t *) param_buf->data;
16712
16713 if (index < ev_param->num_chan_stats) {
16714 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
16715 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16716 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16717 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
16718 (index * sizeof(wmi_chan_stats)));
16719
16720
16721 /* Non-TLV doesnt have num_chan_stats */
16722 chan_stats->chan_mhz = ev->chan_mhz;
16723 chan_stats->sampling_period_us = ev->sampling_period_us;
16724 chan_stats->rx_clear_count = ev->rx_clear_count;
16725 chan_stats->tx_duration_us = ev->tx_duration_us;
16726 chan_stats->rx_duration_us = ev->rx_duration_us;
16727 }
16728
16729 return QDF_STATUS_SUCCESS;
16730}
16731
16732/**
16733 * extract_profile_ctx_tlv() - extract profile context from event
16734 * @wmi_handle: wmi handle
16735 * @param evt_buf: pointer to event buffer
16736 * @idx: profile stats index to extract
16737 * @param profile_ctx: Pointer to hold profile context
16738 *
16739 * Return: QDF_STATUS_SUCCESS for success or error code
16740 */
16741static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
16742 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
16743{
16744 return QDF_STATUS_SUCCESS;
16745}
16746
16747/**
16748 * extract_profile_data_tlv() - extract profile data from event
16749 * @wmi_handle: wmi handle
16750 * @param evt_buf: pointer to event buffer
16751 * @param profile_data: Pointer to hold profile data
16752 *
16753 * Return: QDF_STATUS_SUCCESS for success or error code
16754 */
16755static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
16756 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
16757{
16758
16759 return QDF_STATUS_SUCCESS;
16760}
16761
16762/**
16763 * extract_chan_info_event_tlv() - extract chan information from event
16764 * @wmi_handle: wmi handle
16765 * @param evt_buf: pointer to event buffer
16766 * @param chan_info: Pointer to hold chan information
16767 *
16768 * Return: QDF_STATUS_SUCCESS for success or error code
16769 */
16770static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
16771 void *evt_buf, wmi_host_chan_info_event *chan_info)
16772{
16773 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
16774 wmi_chan_info_event_fixed_param *ev;
16775
16776 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
16777
16778 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
16779 if (!ev) {
16780 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
16781 return QDF_STATUS_E_FAILURE;
16782 }
16783
16784 chan_info->err_code = ev->err_code;
16785 chan_info->freq = ev->freq;
16786 chan_info->cmd_flags = ev->cmd_flags;
16787 chan_info->noise_floor = ev->noise_floor;
16788 chan_info->rx_clear_count = ev->rx_clear_count;
16789 chan_info->cycle_count = ev->cycle_count;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053016790 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
16791 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
16792 ev->vdev_id, WLAN_SCAN_ID);
Govind Singhe7f2f342016-05-23 12:12:52 +053016793
16794 return QDF_STATUS_SUCCESS;
16795}
16796
16797/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016798 * extract_pdev_utf_event_tlv() - extract UTF data info from event
16799 * @wmi_handle: WMI handle
16800 * @param evt_buf: Pointer to event buffer
16801 * @param param: Pointer to hold data
16802 *
16803 * Return : QDF_STATUS_SUCCESS for success or error code
16804 */
16805static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
16806 uint8_t *evt_buf,
16807 struct wmi_host_pdev_utf_event *event)
16808{
16809 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053016810 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016811
16812 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
16813 event->data = param_buf->data;
16814 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053016815 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053016816 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016817 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053016818 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016819
16820 return QDF_STATUS_SUCCESS;
16821}
Govind Singhe7f2f342016-05-23 12:12:52 +053016822
Kiran Venkatappa06520822016-08-10 23:55:40 +053016823/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016824 * extract_chainmask_tables_tlv() - extract chain mask tables from event
16825 * @wmi_handle: wmi handle
16826 * @param evt_buf: pointer to event buffer
16827 * @param param: Pointer to hold evt buf
16828 *
16829 * Return: QDF_STATUS_SUCCESS for success or error code
16830 */
16831static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
16832 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
16833{
16834 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16835 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
16836 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16837 uint8_t i = 0, j = 0;
16838
16839 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16840 if (!param_buf)
16841 return QDF_STATUS_E_INVAL;
16842
16843 hw_caps = param_buf->soc_hw_mode_caps;
16844 if (!hw_caps)
16845 return QDF_STATUS_E_INVAL;
16846
16847 if (!hw_caps->num_chainmask_tables)
16848 return QDF_STATUS_E_INVAL;
16849
16850 chainmask_caps = param_buf->mac_phy_chainmask_caps;
16851
16852 if (chainmask_caps == NULL)
16853 return QDF_STATUS_E_INVAL;
16854
16855 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
16856
16857 qdf_print("Dumping chain mask combo data for table : %d\n", i);
16858 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
16859
16860 chainmask_table[i].cap_list[j].chainmask =
16861 chainmask_caps->chainmask;
16862
16863 chainmask_table[i].cap_list[j].supports_chan_width_20 =
16864 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
16865
16866 chainmask_table[i].cap_list[j].supports_chan_width_40 =
16867 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
16868
16869 chainmask_table[i].cap_list[j].supports_chan_width_80 =
16870 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
16871
16872 chainmask_table[i].cap_list[j].supports_chan_width_160 =
16873 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
16874
16875 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
16876 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
16877
16878 chainmask_table[i].cap_list[j].chain_mask_2G =
16879 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
16880
16881 chainmask_table[i].cap_list[j].chain_mask_5G =
16882 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
16883
16884 chainmask_table[i].cap_list[j].chain_mask_tx =
16885 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
16886
16887 chainmask_table[i].cap_list[j].chain_mask_rx =
16888 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
16889
16890 chainmask_table[i].cap_list[j].supports_aDFS =
16891 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
16892
16893 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
16894 chainmask_caps->supported_flags,
16895 chainmask_caps->chainmask
16896 );
16897 chainmask_caps++;
16898 }
16899 }
16900
16901 return QDF_STATUS_SUCCESS;
16902}
16903
16904/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053016905 * extract_service_ready_ext_tlv() - extract basic extended service ready params
16906 * from event
16907 * @wmi_handle: wmi handle
16908 * @param evt_buf: pointer to event buffer
16909 * @param param: Pointer to hold evt buf
16910 *
16911 * Return: QDF_STATUS_SUCCESS for success or error code
16912 */
16913static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016914 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016915{
16916 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16917 wmi_service_ready_ext_event_fixed_param *ev;
16918 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16919 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016920 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
16921 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016922
16923 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16924 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016925 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016926
16927 ev = param_buf->fixed_param;
16928 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016929 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016930
16931 /* Move this to host based bitmap */
16932 param->default_conc_scan_config_bits =
16933 ev->default_conc_scan_config_bits;
16934 param->default_fw_config_bits = ev->default_fw_config_bits;
16935 param->he_cap_info = ev->he_cap_info;
16936 param->mpdu_density = ev->mpdu_density;
16937 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
16938 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
16939
16940 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016941 if (hw_caps)
16942 param->num_hw_modes = hw_caps->num_hw_modes;
16943 else
16944 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016945
16946 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016947 if (reg_caps)
16948 param->num_phy = reg_caps->num_phy;
16949 else
16950 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016951
Kapil Gupta0692a1a2017-05-15 15:57:36 +053016952 if (hw_caps) {
16953 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
16954 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
16955 } else
16956 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016957
16958 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
16959
16960 if (chain_mask_combo == NULL)
16961 return QDF_STATUS_SUCCESS;
16962
16963 qdf_print("Dumping chain mask combo data\n");
16964
Kapil Gupta0692a1a2017-05-15 15:57:36 +053016965 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016966
16967 qdf_print("table_id : %d Num valid chainmasks: %d\n",
16968 chain_mask_combo->chainmask_table_id,
16969 chain_mask_combo->num_valid_chainmask
16970 );
16971
16972 param->chainmask_table[i].table_id =
16973 chain_mask_combo->chainmask_table_id;
16974 param->chainmask_table[i].num_valid_chainmasks =
16975 chain_mask_combo->num_valid_chainmask;
16976 chain_mask_combo++;
16977 }
16978 qdf_print("chain mask combo end\n");
16979
Kiran Venkatappa06520822016-08-10 23:55:40 +053016980 return QDF_STATUS_SUCCESS;
16981}
16982
16983/**
16984 * extract_hw_mode_cap_service_ready_ext_tlv() -
16985 * extract HW mode cap from service ready event
16986 * @wmi_handle: wmi handle
16987 * @param evt_buf: pointer to event buffer
16988 * @param param: Pointer to hold evt buf
16989 * @param hw_mode_idx: hw mode idx should be less than num_mode
16990 *
16991 * Return: QDF_STATUS_SUCCESS for success or error code
16992 */
16993static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
16994 wmi_unified_t wmi_handle,
16995 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016996 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016997{
16998 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16999 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17000
17001 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17002 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017003 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017004
17005 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017006 if (!hw_caps)
17007 return QDF_STATUS_E_INVAL;
17008
Kiran Venkatappa06520822016-08-10 23:55:40 +053017009 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017010 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017011
17012 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
17013 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
17014
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017015 param->hw_mode_config_type =
17016 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
17017
Kiran Venkatappa06520822016-08-10 23:55:40 +053017018 return QDF_STATUS_SUCCESS;
17019}
17020
17021/**
17022 * extract_mac_phy_cap_service_ready_ext_tlv() -
17023 * extract MAC phy cap from service ready event
17024 * @wmi_handle: wmi handle
17025 * @param evt_buf: pointer to event buffer
17026 * @param param: Pointer to hold evt buf
17027 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017028 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053017029 *
17030 * Return: QDF_STATUS_SUCCESS for success or error code
17031 */
17032static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
17033 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017034 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017035 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017036{
17037 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017038 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017039 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17040 uint32_t phy_map;
17041 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017042
17043 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17044 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017045 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017046
17047 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017048 if (!hw_caps)
17049 return QDF_STATUS_E_INVAL;
17050
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017051 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
17052 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
17053 break;
17054
17055 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
17056 while (phy_map) {
17057 phy_map >>= 1;
17058 phy_idx++;
17059 }
17060 }
17061
17062 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017063 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017064
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017065 phy_idx += phy_id;
17066 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017067 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017068
17069 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053017070
17071 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017072 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17073 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017074 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017075 param->supports_11b =
17076 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
17077 param->supports_11g =
17078 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
17079 param->supports_11a =
17080 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
17081 param->supports_11n =
17082 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
17083 param->supports_11ac =
17084 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
17085 param->supports_11ax =
17086 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017087
17088 param->supported_bands = mac_phy_caps->supported_bands;
17089 param->ampdu_density = mac_phy_caps->ampdu_density;
17090 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
17091 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
17092 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
17093 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
17094 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
17095 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
17096 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
17097 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
17098 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
17099 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
17100 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
17101 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
17102 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
17103 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
17104 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
17105 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080017106 qdf_mem_copy(&param->he_cap_phy_info_2G,
17107 &mac_phy_caps->he_cap_phy_info_2G,
17108 sizeof(param->he_cap_phy_info_2G));
17109 qdf_mem_copy(&param->he_cap_phy_info_5G,
17110 &mac_phy_caps->he_cap_phy_info_5G,
17111 sizeof(param->he_cap_phy_info_5G));
17112 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
17113 sizeof(param->he_ppet2G));
17114 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
17115 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017116 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017117
17118 return QDF_STATUS_SUCCESS;
17119}
17120
17121/**
17122 * extract_reg_cap_service_ready_ext_tlv() -
17123 * extract REG cap from service ready event
17124 * @wmi_handle: wmi handle
17125 * @param evt_buf: pointer to event buffer
17126 * @param param: Pointer to hold evt buf
17127 * @param phy_idx: phy idx should be less than num_mode
17128 *
17129 * Return: QDF_STATUS_SUCCESS for success or error code
17130 */
17131static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
17132 wmi_unified_t wmi_handle,
17133 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017134 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017135{
17136 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17137 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
17138 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
17139
17140 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17141 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017142 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017143
17144 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017145 if (!reg_caps)
17146 return QDF_STATUS_E_INVAL;
17147
Kiran Venkatappa06520822016-08-10 23:55:40 +053017148 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017149 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017150
17151 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
17152
17153 param->phy_id = ext_reg_cap->phy_id;
17154 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
17155 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
17156 param->regcap1 = ext_reg_cap->regcap1;
17157 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017158 param->wireless_modes = convert_wireless_modes_tlv(
17159 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017160 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
17161 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
17162 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
17163 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
17164
17165 return QDF_STATUS_SUCCESS;
17166}
17167
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017168/**
17169 * extract_dcs_interference_type_tlv() - extract dcs interference type
17170 * from event
17171 * @wmi_handle: wmi handle
17172 * @param evt_buf: pointer to event buffer
17173 * @param param: Pointer to hold dcs interference param
17174 *
17175 * Return: 0 for success or error code
17176 */
17177static QDF_STATUS extract_dcs_interference_type_tlv(
17178 wmi_unified_t wmi_handle,
17179 void *evt_buf, struct wmi_host_dcs_interference_param *param)
17180{
17181 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17182
17183 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17184 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017185 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017186
17187 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017188 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17189 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017190
17191 return QDF_STATUS_SUCCESS;
17192}
17193
17194/*
17195 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
17196 * @wmi_handle: wmi handle
17197 * @param evt_buf: pointer to event buffer
17198 * @param cw_int: Pointer to hold cw interference
17199 *
17200 * Return: 0 for success or error code
17201 */
17202static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
17203 void *evt_buf,
17204 wmi_host_ath_dcs_cw_int *cw_int)
17205{
17206 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17207 wlan_dcs_cw_int *ev;
17208
17209 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17210 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017211 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017212
17213 ev = param_buf->cw_int;
17214
17215 cw_int->channel = ev->channel;
17216
17217 return QDF_STATUS_SUCCESS;
17218}
17219
17220/**
17221 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
17222 * @wmi_handle: wmi handle
17223 * @param evt_buf: pointer to event buffer
17224 * @param wlan_stat: Pointer to hold wlan stats
17225 *
17226 * Return: 0 for success or error code
17227 */
17228static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
17229 void *evt_buf,
17230 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
17231{
17232 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17233 wlan_dcs_im_tgt_stats_t *ev;
17234
17235 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17236 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017237 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017238
17239 ev = param_buf->wlan_stat;
17240 wlan_stat->reg_tsf32 = ev->reg_tsf32;
17241 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
17242 wlan_stat->tx_waste_time = ev->tx_waste_time;
17243 wlan_stat->rx_time = ev->rx_time;
17244 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
17245 wlan_stat->mib_stats.listen_time = ev->listen_time;
17246 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
17247 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
17248 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
17249 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
17250 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
17251 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
17252 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
17253 wlan_stat->chan_nf = ev->chan_nf;
17254 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
17255
17256 return QDF_STATUS_SUCCESS;
17257}
17258
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017259/**
17260 * extract_thermal_stats_tlv() - extract thermal stats from event
17261 * @wmi_handle: wmi handle
17262 * @param evt_buf: Pointer to event buffer
17263 * @param temp: Pointer to hold extracted temperature
17264 * @param level: Pointer to hold extracted level
17265 *
17266 * Return: 0 for success or error code
17267 */
17268static QDF_STATUS
17269extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
17270 void *evt_buf, uint32_t *temp,
17271 uint32_t *level, uint32_t *pdev_id)
17272{
17273 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17274 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
17275
17276 param_buf =
17277 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17278 if (!param_buf)
17279 return QDF_STATUS_E_INVAL;
17280
17281 tt_stats_event = param_buf->fixed_param;
17282
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017283 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17284 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017285 *temp = tt_stats_event->temp;
17286 *level = tt_stats_event->level;
17287
17288 return QDF_STATUS_SUCCESS;
17289}
17290
17291/**
17292 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
17293 * @wmi_handle: wmi handle
17294 * @param evt_buf: pointer to event buffer
17295 * @param idx: Index to level stats
17296 * @param levelcount: Pointer to hold levelcount
17297 * @param dccount: Pointer to hold dccount
17298 *
17299 * Return: 0 for success or error code
17300 */
17301static QDF_STATUS
17302extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
17303 void *evt_buf, uint8_t idx, uint32_t *levelcount,
17304 uint32_t *dccount)
17305{
17306 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17307 wmi_therm_throt_level_stats_info *tt_level_info;
17308
17309 param_buf =
17310 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17311 if (!param_buf)
17312 return QDF_STATUS_E_INVAL;
17313
17314 tt_level_info = param_buf->therm_throt_level_stats_info;
17315
17316 if (idx < THERMAL_LEVELS) {
17317 *levelcount = tt_level_info[idx].level_count;
17318 *dccount = tt_level_info[idx].dc_count;
17319 return QDF_STATUS_SUCCESS;
17320 }
17321
17322 return QDF_STATUS_E_FAILURE;
17323}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017324#ifdef BIG_ENDIAN_HOST
17325/**
17326 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
17327 * @param data_len - data length
17328 * @param data - pointer to data
17329 *
17330 * Return: QDF_STATUS - success or error status
17331 */
17332static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17333{
17334 uint8_t *data_aligned = NULL;
17335 int c;
17336 unsigned char *data_unaligned;
17337
17338 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
17339 FIPS_ALIGN));
17340 /* Assigning unaligned space to copy the data */
17341 /* Checking if kmalloc does succesful allocation */
17342 if (data_unaligned == NULL)
17343 return QDF_STATUS_E_FAILURE;
17344
17345 /* Checking if space is alligned */
17346 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
17347 /* align the data space */
17348 data_aligned =
17349 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
17350 } else {
17351 data_aligned = (u_int8_t *)data_unaligned;
17352 }
17353
17354 /* memset and copy content from data to data aligned */
17355 OS_MEMSET(data_aligned, 0, data_len);
17356 OS_MEMCPY(data_aligned, data, data_len);
17357 /* Endianness to LE */
17358 for (c = 0; c < data_len/4; c++) {
17359 *((u_int32_t *)data_aligned + c) =
17360 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
17361 }
17362
17363 /* Copy content to event->data */
17364 OS_MEMCPY(data, data_aligned, data_len);
17365
17366 /* clean up allocated space */
17367 qdf_mem_free(data_unaligned);
17368 data_aligned = NULL;
17369 data_unaligned = NULL;
17370
17371 /*************************************************************/
17372
17373 return QDF_STATUS_SUCCESS;
17374}
17375#else
17376/**
17377 * fips_conv_data_be() - DUMMY for LE platform
17378 *
17379 * Return: QDF_STATUS - success
17380 */
17381static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17382{
17383 return QDF_STATUS_SUCCESS;
17384}
17385#endif
17386
17387/**
17388 * extract_fips_event_data_tlv() - extract fips event data
17389 * @wmi_handle: wmi handle
17390 * @param evt_buf: pointer to event buffer
17391 * @param param: pointer FIPS event params
17392 *
17393 * Return: 0 for success or error code
17394 */
17395static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
17396 void *evt_buf, struct wmi_host_fips_event_param *param)
17397{
17398 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
17399 wmi_pdev_fips_event_fixed_param *event;
17400
17401 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
17402 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
17403
17404 if (fips_conv_data_be(event->data_len, param_buf->data) !=
17405 QDF_STATUS_SUCCESS)
17406 return QDF_STATUS_E_FAILURE;
17407
17408 param->data = (uint32_t *)param_buf->data;
17409 param->data_len = event->data_len;
17410 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017411 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17412 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017413
17414 return QDF_STATUS_SUCCESS;
17415}
17416
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017417/*
17418 * extract_peer_delete_response_event_tlv() - extract peer delete response event
17419 * @wmi_handle: wmi handle
17420 * @param evt_buf: pointer to event buffer
17421 * @param vdev_id: Pointer to hold vdev_id
17422 * @param mac_addr: Pointer to hold peer mac address
17423 *
17424 * Return: QDF_STATUS_SUCCESS for success or error code
17425 */
17426static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
17427 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
17428{
17429 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17430 wmi_peer_delete_resp_event_fixed_param *ev;
17431
17432 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
17433
17434 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
17435 if (!ev) {
17436 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
17437 return QDF_STATUS_E_FAILURE;
17438 }
17439
17440 param->vdev_id = ev->vdev_id;
17441 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
17442 &param->mac_address.bytes[0]);
17443
17444 return QDF_STATUS_SUCCESS;
17445}
17446
Govind Singhecf03cd2016-05-12 12:45:51 +053017447static bool is_management_record_tlv(uint32_t cmd_id)
17448{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053017449 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053017450 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053017451
Govind Singhecf03cd2016-05-12 12:45:51 +053017452 return false;
17453}
17454
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017455static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17456{
17457 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
17458
17459 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
17460
17461 switch (set_cmd->param_id) {
17462 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
17463 case WMI_VDEV_PARAM_DTIM_POLICY:
17464 return HTC_TX_PACKET_TAG_AUTO_PM;
17465 default:
17466 break;
17467 }
17468
17469 return 0;
17470}
17471
17472static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17473{
17474 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
17475
17476 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
17477
17478 switch (ps_cmd->param) {
17479 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
17480 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
17481 case WMI_STA_PS_ENABLE_QPOWER:
17482 return HTC_TX_PACKET_TAG_AUTO_PM;
17483 default:
17484 break;
17485 }
17486
17487 return 0;
17488}
17489
17490static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
17491 uint32_t cmd_id)
17492{
17493 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
17494 return 0;
17495
17496 switch (cmd_id) {
17497 case WMI_VDEV_SET_PARAM_CMDID:
17498 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
17499 case WMI_STA_POWERSAVE_PARAM_CMDID:
17500 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
17501 default:
17502 break;
17503 }
17504
17505 return 0;
17506}
17507
17508static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
17509{
17510 uint16_t tag = 0;
17511
17512 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
17513 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
17514 __func__);
17515 return tag;
17516 }
17517
17518 if (wmi_handle->tag_crash_inject)
17519 tag = HTC_TX_PACKET_TAG_AUTO_PM;
17520
17521 wmi_handle->tag_crash_inject = false;
17522 return tag;
17523}
17524
17525/**
17526 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
17527 * @wmi_handle: WMI handle
17528 * @buf: WMI buffer
17529 * @cmd_id: WMI command Id
17530 *
17531 * Return htc_tx_tag
17532 */
17533static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
17534 wmi_buf_t buf,
17535 uint32_t cmd_id)
17536{
17537 uint16_t htc_tx_tag = 0;
17538
17539 switch (cmd_id) {
17540 case WMI_WOW_ENABLE_CMDID:
17541 case WMI_PDEV_SUSPEND_CMDID:
17542 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
17543 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
17544 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
17545 case WMI_PDEV_RESUME_CMDID:
17546 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
17547 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
17548#ifdef FEATURE_WLAN_D0WOW
17549 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
17550#endif
17551 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
17552 break;
17553 case WMI_FORCE_FW_HANG_CMDID:
17554 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
17555 break;
17556 case WMI_VDEV_SET_PARAM_CMDID:
17557 case WMI_STA_POWERSAVE_PARAM_CMDID:
17558 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
17559 default:
17560 break;
17561 }
17562
17563 return htc_tx_tag;
17564}
17565
Sathish Kumard3ab1002017-02-07 17:10:59 +053017566/**
17567 * extract_channel_hopping_event_tlv() - extract channel hopping param
17568 * from event
17569 * @wmi_handle: wmi handle
17570 * @param evt_buf: pointer to event buffer
17571 * @param ch_hopping: Pointer to hold channel hopping param
17572 *
17573 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17574 */
17575static QDF_STATUS extract_channel_hopping_event_tlv(
17576 wmi_unified_t wmi_handle, void *evt_buf,
17577 wmi_host_pdev_channel_hopping_event *ch_hopping)
17578{
17579 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
17580 wmi_pdev_channel_hopping_event_fixed_param *event;
17581
17582 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
17583 event = (wmi_pdev_channel_hopping_event_fixed_param *)
17584 param_buf->fixed_param;
17585
17586 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
17587 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017588 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17589 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017590
17591 return QDF_STATUS_SUCCESS;
17592}
17593
17594/**
17595 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
17596 * @wmi_handle: wmi handle
17597 * @param evt_buf: pointer to event buffer
17598 * @param param: Pointer to hold tpc param
17599 *
17600 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17601 */
17602static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
17603 void *evt_buf,
17604 wmi_host_pdev_tpc_event *param)
17605{
17606 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
17607 wmi_pdev_tpc_event_fixed_param *event;
17608
17609 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
17610 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
17611
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017612 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17613 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017614 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
17615
17616 return QDF_STATUS_SUCCESS;
17617}
17618
17619
17620#ifdef BIG_ENDIAN_HOST
17621/**
17622 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
17623 * @param data_len - data length
17624 * @param data - pointer to data
17625 *
17626 * Return: QDF_STATUS - success or error status
17627 */
17628static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
17629{
17630 uint8_t *datap = (uint8_t *)ev;
17631 /* Skip swapping the first word */
17632 datap += sizeof(uint32_t);
17633 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
17634 i++, datap += sizeof(uint32_t)) {
17635 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
17636 }
17637
17638 return QDF_STATUS_SUCCESS;
17639}
17640#else
17641/**
17642 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
17643 * @param data_len - data length
17644 * @param data - pointer to data
17645 *
17646 * Return: QDF_STATUS - success or error status
17647 */
17648static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
17649{
17650 return QDF_STATUS_SUCCESS;
17651}
17652#endif
17653
17654/**
17655 * extract_wds_addr_event_tlv() - extract wds address from event
17656 * @wmi_handle: wmi handle
17657 * @param evt_buf: pointer to event buffer
17658 * @param wds_ev: Pointer to hold wds address
17659 *
17660 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17661 */
17662static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
17663 void *evt_buf,
17664 uint16_t len, wds_addr_event_t *wds_ev)
17665{
17666 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
17667 wmi_wds_addr_event_fixed_param *ev;
17668 int i;
17669
17670 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
17671 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
17672
17673 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
17674 return QDF_STATUS_E_FAILURE;
17675
17676 qdf_mem_copy(wds_ev->event_type, ev->event_type,
17677 sizeof(wds_ev->event_type));
17678 for (i = 0; i < 4; i++) {
17679 wds_ev->peer_mac[i] =
17680 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
17681 wds_ev->dest_mac[i] =
17682 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
17683 }
17684 for (i = 0; i < 2; i++) {
17685 wds_ev->peer_mac[4+i] =
17686 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
17687 wds_ev->dest_mac[4+i] =
17688 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
17689 }
17690 return QDF_STATUS_SUCCESS;
17691}
17692
17693/**
17694 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
17695 * from event
17696 * @wmi_handle: wmi handle
17697 * @param evt_buf: pointer to event buffer
17698 * @param ev: Pointer to hold peer param and ps state
17699 *
17700 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17701 */
17702static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
17703 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
17704{
17705 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
17706 wmi_peer_sta_ps_statechange_event_fixed_param *event;
17707
17708 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
17709 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
17710 param_buf->fixed_param;
17711
17712 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
17713 ev->peer_ps_state = event->peer_ps_state;
17714
17715 return QDF_STATUS_SUCCESS;
17716}
17717
17718/**
17719 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
17720 * @wmi_handle: wmi handle
17721 * @param evt_buf: pointer to event buffer
17722 * @param inst_rssi_resp: Pointer to hold inst rssi response
17723 *
17724 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17725 */
17726static QDF_STATUS extract_inst_rssi_stats_event_tlv(
17727 wmi_unified_t wmi_handle, void *evt_buf,
17728 wmi_host_inst_stats_resp *inst_rssi_resp)
17729{
17730 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
17731 wmi_inst_rssi_stats_resp_fixed_param *event;
17732
17733 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
17734 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
17735
17736 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
17737 &(event->peer_macaddr), sizeof(wmi_mac_addr));
17738 inst_rssi_resp->iRSSI = event->iRSSI;
17739
17740 return QDF_STATUS_SUCCESS;
17741}
17742
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017743static struct cur_reg_rule
17744*create_reg_rules_from_wmi(uint32_t num_reg_rules,
17745 wmi_regulatory_rule_struct *wmi_reg_rule)
17746{
17747 struct cur_reg_rule *reg_rule_ptr;
17748 uint32_t count;
17749
17750 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
17751
17752 if (NULL == reg_rule_ptr) {
17753 WMI_LOGE("memory allocation failure");
17754 return NULL;
17755 }
17756
17757 for (count = 0; count < num_reg_rules; count++) {
17758 reg_rule_ptr[count].start_freq =
17759 WMI_REG_RULE_START_FREQ_GET(
17760 wmi_reg_rule[count].freq_info);
17761 reg_rule_ptr[count].end_freq =
17762 WMI_REG_RULE_END_FREQ_GET(
17763 wmi_reg_rule[count].freq_info);
17764 reg_rule_ptr[count].max_bw =
17765 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017766 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017767 reg_rule_ptr[count].reg_power =
17768 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017769 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053017770 reg_rule_ptr[count].ant_gain =
17771 WMI_REG_RULE_ANTENNA_GAIN_GET(
17772 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017773 reg_rule_ptr[count].flags =
17774 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017775 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017776 }
17777
17778 return reg_rule_ptr;
17779}
17780
17781static QDF_STATUS extract_reg_chan_list_update_event_tlv(
17782 wmi_unified_t wmi_handle, uint8_t *evt_buf,
17783 struct cur_regulatory_info *reg_info, uint32_t len)
17784{
17785 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
17786 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
17787 wmi_regulatory_rule_struct *wmi_reg_rule;
17788 uint32_t num_2g_reg_rules, num_5g_reg_rules;
17789
17790 WMI_LOGD("processing regulatory channel list");
17791
17792 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
17793 if (!param_buf) {
17794 WMI_LOGE("invalid channel list event buf");
17795 return QDF_STATUS_E_FAILURE;
17796 }
17797
17798 chan_list_event_hdr = param_buf->fixed_param;
17799
17800 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
17801 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
17802 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
17803 REG_ALPHA2_LEN);
17804 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
17805 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070017806 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070017807 reg_info->num_phy = chan_list_event_hdr->num_phy;
17808 reg_info->ctry_code = chan_list_event_hdr->country_id;
17809 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
17810 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
17811 reg_info->status_code = REG_SET_CC_STATUS_PASS;
17812 else if (chan_list_event_hdr->status_code ==
17813 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
17814 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
17815 else if (chan_list_event_hdr->status_code ==
17816 WMI_REG_INIT_ALPHA2_NOT_FOUND)
17817 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
17818 else if (chan_list_event_hdr->status_code ==
17819 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
17820 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
17821 else if (chan_list_event_hdr->status_code ==
17822 WMI_REG_SET_CC_STATUS_NO_MEMORY)
17823 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
17824 else if (chan_list_event_hdr->status_code ==
17825 WMI_REG_SET_CC_STATUS_FAIL)
17826 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
17827
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017828 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
17829 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
17830 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
17831 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
17832
17833 num_2g_reg_rules = reg_info->num_2g_reg_rules;
17834 num_5g_reg_rules = reg_info->num_5g_reg_rules;
17835
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017836 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
17837 __func__, reg_info->alpha2, reg_info->dfs_region,
17838 reg_info->min_bw_2g, reg_info->max_bw_2g,
17839 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017840
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017841 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
17842 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070017843 wmi_reg_rule =
17844 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
17845 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
17846 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017847 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
17848 wmi_reg_rule);
17849 wmi_reg_rule += num_2g_reg_rules;
17850
17851 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
17852 wmi_reg_rule);
17853
17854 WMI_LOGD("processed regulatory channel list");
17855
17856 return QDF_STATUS_SUCCESS;
17857}
17858
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070017859static QDF_STATUS extract_reg_11d_new_country_event_tlv(
17860 wmi_unified_t wmi_handle, uint8_t *evt_buf,
17861 struct reg_11d_new_country *reg_11d_country, uint32_t len)
17862{
17863 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
17864 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
17865
17866 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
17867 if (!param_buf) {
17868 WMI_LOGE("invalid 11d country event buf");
17869 return QDF_STATUS_E_FAILURE;
17870 }
17871
17872 reg_11d_country_event = param_buf->fixed_param;
17873
17874 qdf_mem_copy(reg_11d_country->alpha2,
17875 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
17876
17877 WMI_LOGD("processed 11d country event, new cc %s",
17878 reg_11d_country->alpha2);
17879
17880 return QDF_STATUS_SUCCESS;
17881}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070017882#ifdef DFS_COMPONENT_ENABLE
17883/**
17884 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
17885 * @wmi_handle: wma handle
17886 * @evt_buf: event buffer
17887 * @vdev_id: vdev id
17888 * @len: length of buffer
17889 *
17890 * Return: 0 for success or error code
17891 */
17892static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
17893 uint8_t *evt_buf,
17894 uint32_t *vdev_id,
17895 uint32_t len)
17896{
17897 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
17898 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
17899
17900 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
17901 if (!param_tlvs) {
17902 WMI_LOGE("invalid cac complete event buf");
17903 return QDF_STATUS_E_FAILURE;
17904 }
17905
17906 cac_event = param_tlvs->fixed_param;
17907 *vdev_id = cac_event->vdev_id;
17908 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
17909
17910 return QDF_STATUS_SUCCESS;
17911}
17912
17913/**
17914 * extract_dfs_radar_detection_event_tlv() - extract radar found event
17915 * @wmi_handle: wma handle
17916 * @evt_buf: event buffer
17917 * @radar_found: radar found event info
17918 * @len: length of buffer
17919 *
17920 * Return: 0 for success or error code
17921 */
17922static QDF_STATUS extract_dfs_radar_detection_event_tlv(
17923 wmi_unified_t wmi_handle,
17924 uint8_t *evt_buf,
17925 struct radar_found_info *radar_found,
17926 uint32_t len)
17927{
17928 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
17929 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
17930
17931 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
17932 if (!param_tlv) {
17933 WMI_LOGE("invalid radar detection event buf");
17934 return QDF_STATUS_E_FAILURE;
17935 }
17936
17937 radar_event = param_tlv->fixed_param;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017938 radar_found->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17939 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070017940 radar_found->detection_mode = radar_event->detection_mode;
17941 radar_found->freq_offset = radar_event->chan_freq;
17942 radar_found->chan_width = radar_event->chan_width;
17943 radar_found->detector_id = radar_event->detector_id;
17944 radar_found->segment_id = radar_event->segment_id;
17945 radar_found->timestamp = radar_event->timestamp;
17946 radar_found->is_chirp = radar_event->is_chirp;
17947
17948 WMI_LOGD("processed radar found event pdev %d", radar_event->pdev_id);
17949
17950 return QDF_STATUS_SUCCESS;
17951}
17952#endif
17953
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017954/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017955 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
17956 * host to target defines. For legacy there is not conversion
17957 * required. Just return pdev_id as it is.
17958 * @param pdev_id: host pdev_id to be converted.
17959 * Return: target pdev_id after conversion.
17960 */
17961static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
17962 uint32_t pdev_id)
17963{
17964 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
17965 return WMI_PDEV_ID_SOC;
17966
17967 /*No conversion required*/
17968 return pdev_id;
17969}
17970
17971/**
17972 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
17973 * target to host defines. For legacy there is not conversion
17974 * required. Just return pdev_id as it is.
17975 * @param pdev_id: target pdev_id to be converted.
17976 * Return: host pdev_id after conversion.
17977 */
17978static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
17979 uint32_t pdev_id)
17980{
17981 /*No conversion required*/
17982 return pdev_id;
17983}
17984
17985/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017986 * send_set_country_cmd_tlv() - WMI scan channel list function
17987 * @param wmi_handle : handle to WMI.
17988 * @param param : pointer to hold scan channel list parameter
17989 *
17990 * Return: 0 on success and -ve on failure.
17991 */
17992static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
17993 struct set_country *params)
17994{
17995 wmi_buf_t buf;
17996 QDF_STATUS qdf_status;
17997 wmi_set_current_country_cmd_fixed_param *cmd;
17998 uint16_t len = sizeof(*cmd);
17999
18000 buf = wmi_buf_alloc(wmi_handle, len);
18001 if (!buf) {
18002 WMI_LOGE("Failed to allocate memory");
18003 qdf_status = QDF_STATUS_E_NOMEM;
18004 goto end;
18005 }
18006
18007 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
18008 WMITLV_SET_HDR(&cmd->tlv_header,
18009 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
18010 WMITLV_GET_STRUCT_TLVLEN
18011 (wmi_set_current_country_cmd_fixed_param));
18012
18013 WMI_LOGD("setting cuurnet country to %s", params->country);
18014
18015 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
18016
18017 cmd->pdev_id = params->pdev_id;
18018
18019 qdf_status = wmi_unified_cmd_send(wmi_handle,
18020 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
18021
18022 if (QDF_IS_STATUS_ERROR(qdf_status)) {
18023 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
18024 wmi_buf_free(buf);
18025 }
18026
18027end:
18028 return qdf_status;
18029}
18030
Govind Singh5eb51532016-03-09 11:34:12 +053018031struct wmi_ops tlv_ops = {
18032 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
18033 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
18034 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053018035 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
18036 .send_hidden_ssid_vdev_restart_cmd =
18037 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018038 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
18039 .send_peer_param_cmd = send_peer_param_cmd_tlv,
18040 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018041 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018042 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018043 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070018044 .send_peer_rx_reorder_queue_setup_cmd =
18045 send_peer_rx_reorder_queue_setup_cmd_tlv,
18046 .send_peer_rx_reorder_queue_remove_cmd =
18047 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053018048 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
18049 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
18050 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018051 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
18052 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
18053 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
18054 .send_suspend_cmd = send_suspend_cmd_tlv,
18055 .send_resume_cmd = send_resume_cmd_tlv,
18056 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
18057 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
18058 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
18059 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
18060 .send_dbglog_cmd = send_dbglog_cmd_tlv,
18061 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
18062 .send_stats_request_cmd = send_stats_request_cmd_tlv,
18063 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
18064 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018065 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018066 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
18067 .send_scan_start_cmd = send_scan_start_cmd_tlv,
18068 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
18069 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018070 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018071 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018072 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
18073 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018074 .send_set_sta_uapsd_auto_trig_cmd =
18075 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018076 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
18077 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
18078 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018079#ifdef CONVERGED_P2P_ENABLE
18080 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
18081 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
18082#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053018083 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
18084 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053018085 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
18086 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
18087 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
18088 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
18089 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
18090 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
18091 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018092 .send_ocb_start_timing_advert_cmd =
18093 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053018094 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
18095 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
18096 .send_set_mcc_channel_time_latency_cmd =
18097 send_set_mcc_channel_time_latency_cmd_tlv,
18098 .send_set_mcc_channel_time_quota_cmd =
18099 send_set_mcc_channel_time_quota_cmd_tlv,
18100 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
18101 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053018102 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018103 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
18104 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
18105 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018106 .send_probe_rsp_tmpl_send_cmd =
18107 send_probe_rsp_tmpl_send_cmd_tlv,
18108 .send_p2p_go_set_beacon_ie_cmd =
18109 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053018110 .send_setup_install_key_cmd =
18111 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018112 .send_set_gateway_params_cmd =
18113 send_set_gateway_params_cmd_tlv,
18114 .send_set_rssi_monitoring_cmd =
18115 send_set_rssi_monitoring_cmd_tlv,
18116 .send_scan_probe_setoui_cmd =
18117 send_scan_probe_setoui_cmd_tlv,
18118 .send_reset_passpoint_network_list_cmd =
18119 send_reset_passpoint_network_list_cmd_tlv,
18120 .send_set_passpoint_network_list_cmd =
18121 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053018122 .send_roam_scan_offload_rssi_thresh_cmd =
18123 send_roam_scan_offload_rssi_thresh_cmd_tlv,
18124 .send_roam_scan_filter_cmd =
18125 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018126 .send_set_epno_network_list_cmd =
18127 send_set_epno_network_list_cmd_tlv,
18128 .send_ipa_offload_control_cmd =
18129 send_ipa_offload_control_cmd_tlv,
18130 .send_extscan_get_capabilities_cmd =
18131 send_extscan_get_capabilities_cmd_tlv,
18132 .send_extscan_get_cached_results_cmd =
18133 send_extscan_get_cached_results_cmd_tlv,
18134 .send_extscan_stop_change_monitor_cmd =
18135 send_extscan_stop_change_monitor_cmd_tlv,
18136 .send_extscan_start_change_monitor_cmd =
18137 send_extscan_start_change_monitor_cmd_tlv,
18138 .send_extscan_stop_hotlist_monitor_cmd =
18139 send_extscan_stop_hotlist_monitor_cmd_tlv,
18140 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
18141 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
18142 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
18143 .send_plm_start_cmd = send_plm_start_cmd_tlv,
18144 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
18145 .send_pno_start_cmd = send_pno_start_cmd_tlv,
18146 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
18147 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
18148 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
18149 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
18150 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053018151 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018152 .send_snr_request_cmd = send_snr_request_cmd_tlv,
18153 .send_snr_cmd = send_snr_cmd_tlv,
18154 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018155#ifdef WLAN_PMO_ENABLE
18156 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
18157 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
18158 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
18159 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070018160 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018161 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
18162 .send_process_gtk_offload_getinfo_cmd =
18163 send_process_gtk_offload_getinfo_cmd_tlv,
18164 .send_enable_enhance_multicast_offload_cmd =
18165 send_enable_enhance_multicast_offload_tlv,
18166 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
18167#ifdef FEATURE_WLAN_RA_FILTERING
18168 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
18169#endif
18170 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018171 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
18172 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018173 .send_lphb_config_tcp_pkt_filter_cmd =
18174 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018175 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
18176 .send_lphb_config_udp_pkt_filter_cmd =
18177 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053018178 .send_enable_disable_packet_filter_cmd =
18179 send_enable_disable_packet_filter_cmd_tlv,
18180 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018181#endif /* End of WLAN_PMO_ENABLE */
18182#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053018183 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
18184 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
18185 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018186 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
18187 .send_process_update_edca_param_cmd =
18188 send_process_update_edca_param_cmd_tlv,
18189 .send_roam_scan_offload_mode_cmd =
18190 send_roam_scan_offload_mode_cmd_tlv,
18191 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
18192 .send_roam_scan_offload_ap_profile_cmd =
18193 send_roam_scan_offload_ap_profile_cmd_tlv,
18194#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018195 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
18196 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018197 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
18198 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070018199#ifdef WLAN_FEATURE_CIF_CFR
18200 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
18201#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018202 .send_dfs_phyerr_filter_offload_en_cmd =
18203 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018204 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
18205 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
18206 .send_del_ts_cmd = send_del_ts_cmd_tlv,
18207 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
18208 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018209 .send_process_add_periodic_tx_ptrn_cmd =
18210 send_process_add_periodic_tx_ptrn_cmd_tlv,
18211 .send_process_del_periodic_tx_ptrn_cmd =
18212 send_process_del_periodic_tx_ptrn_cmd_tlv,
18213 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
18214 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
18215 .send_set_app_type2_params_in_fw_cmd =
18216 send_set_app_type2_params_in_fw_cmd_tlv,
18217 .send_set_auto_shutdown_timer_cmd =
18218 send_set_auto_shutdown_timer_cmd_tlv,
18219 .send_nan_req_cmd = send_nan_req_cmd_tlv,
18220 .send_process_dhcpserver_offload_cmd =
18221 send_process_dhcpserver_offload_cmd_tlv,
18222 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
18223 .send_process_ch_avoid_update_cmd =
18224 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053018225 .send_pdev_set_regdomain_cmd =
18226 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018227 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
18228 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
18229 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
18230 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
18231 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
18232 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018233#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053018234 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018235#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053018236 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018237 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053018238 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053018239 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018240 .send_set_base_macaddr_indicate_cmd =
18241 send_set_base_macaddr_indicate_cmd_tlv,
18242 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
18243 .send_enable_specific_fw_logs_cmd =
18244 send_enable_specific_fw_logs_cmd_tlv,
18245 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053018246 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053018247 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053018248 .send_pdev_set_dual_mac_config_cmd =
18249 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018250 .send_app_type1_params_in_fw_cmd =
18251 send_app_type1_params_in_fw_cmd_tlv,
18252 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
18253 .send_process_roam_synch_complete_cmd =
18254 send_process_roam_synch_complete_cmd_tlv,
18255 .send_unit_test_cmd = send_unit_test_cmd_tlv,
18256 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
18257 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018258 .send_roam_scan_offload_scan_period_cmd =
18259 send_roam_scan_offload_scan_period_cmd_tlv,
18260 .send_roam_scan_offload_chan_list_cmd =
18261 send_roam_scan_offload_chan_list_cmd_tlv,
18262 .send_roam_scan_offload_rssi_change_cmd =
18263 send_roam_scan_offload_rssi_change_cmd_tlv,
18264 .send_get_buf_extscan_hotlist_cmd =
18265 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080018266 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053018267 .send_adapt_dwelltime_params_cmd =
18268 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053018269 .send_dbs_scan_sel_params_cmd =
18270 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018271 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053018272 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
18273 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
18274 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
18275 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
18276 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
18277 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
18278 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
18279 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
18280 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053018281 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
18282 .send_smart_ant_set_training_info_cmd =
18283 send_smart_ant_set_training_info_cmd_tlv,
18284 .send_smart_ant_set_node_config_cmd =
18285 send_smart_ant_set_node_config_cmd_tlv,
18286 .send_set_atf_cmd = send_set_atf_cmd_tlv,
18287 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
18288 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053018289 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
18290 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
18291 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
18292 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
18293 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
18294 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
18295 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018296 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
18297 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
18298 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
18299 .send_vdev_spectral_configure_cmd =
18300 send_vdev_spectral_configure_cmd_tlv,
18301 .send_vdev_spectral_enable_cmd =
18302 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018303 .send_thermal_mitigation_param_cmd =
18304 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018305 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
18306 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053018307 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018308 .send_set_country_cmd = send_set_country_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018309 .get_target_cap_from_service_ready = extract_service_ready_tlv,
18310 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
18311 .extract_host_mem_req = extract_host_mem_req_tlv,
18312 .save_service_bitmap = save_service_bitmap_tlv,
18313 .is_service_enabled = is_service_enabled_tlv,
18314 .save_fw_version = save_fw_version_in_service_ready_tlv,
18315 .ready_extract_init_status = ready_extract_init_status_tlv,
18316 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
18317 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
18318 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
18319 .extract_tbttoffset_update_params =
18320 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018321 .extract_ext_tbttoffset_update_params =
18322 extract_ext_tbttoffset_update_params_tlv,
18323 .extract_tbttoffset_num_vdevs =
18324 extract_tbttoffset_num_vdevs_tlv,
18325 .extract_ext_tbttoffset_num_vdevs =
18326 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018327 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
18328 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
18329 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
18330 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080018331#ifdef CONVERGED_TDLS_ENABLE
18332 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
18333#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053018334 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018335 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018336 .extract_swba_tim_info = extract_swba_tim_info_tlv,
18337 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018338#ifdef CONVERGED_P2P_ENABLE
18339 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
18340 .extract_p2p_lo_stop_ev_param =
18341 extract_p2p_lo_stop_ev_param_tlv,
18342#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018343 .extract_offchan_data_tx_compl_param =
18344 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018345 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
18346 .extract_all_stats_count = extract_all_stats_counts_tlv,
18347 .extract_pdev_stats = extract_pdev_stats_tlv,
18348 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
18349 .extract_vdev_stats = extract_vdev_stats_tlv,
18350 .extract_peer_stats = extract_peer_stats_tlv,
18351 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
18352 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
18353 .extract_chan_stats = extract_chan_stats_tlv,
18354 .extract_profile_ctx = extract_profile_ctx_tlv,
18355 .extract_profile_data = extract_profile_data_tlv,
18356 .extract_chan_info_event = extract_chan_info_event_tlv,
18357 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053018358 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053018359 .send_encrypt_decrypt_send_cmd =
18360 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080018361 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053018362 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053018363 .send_multiple_vdev_restart_req_cmd =
18364 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053018365 .extract_service_ready_ext = extract_service_ready_ext_tlv,
18366 .extract_hw_mode_cap_service_ready_ext =
18367 extract_hw_mode_cap_service_ready_ext_tlv,
18368 .extract_mac_phy_cap_service_ready_ext =
18369 extract_mac_phy_cap_service_ready_ext_tlv,
18370 .extract_reg_cap_service_ready_ext =
18371 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018372 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053018373 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018374 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
18375 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
18376 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053018377 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018378 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053018379 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018380 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018381 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053018382 .extract_pdev_csa_switch_count_status =
18383 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053018384 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
18385 .extract_wds_addr_event = extract_wds_addr_event_tlv,
18386 .extract_peer_sta_ps_statechange_ev =
18387 extract_peer_sta_ps_statechange_ev_tlv,
18388 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053018389 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080018390 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
18391 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018392 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053018393 extract_reg_chan_list_update_event_tlv,
18394 .extract_chainmask_tables =
18395 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018396 .extract_thermal_stats = extract_thermal_stats_tlv,
18397 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018398#ifdef DFS_COMPONENT_ENABLE
18399 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
18400 .extract_dfs_radar_detection_event =
18401 extract_dfs_radar_detection_event_tlv,
18402#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018403 .convert_pdev_id_host_to_target =
18404 convert_host_pdev_id_to_target_pdev_id_legacy,
18405 .convert_pdev_id_target_to_host =
18406 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070018407
18408 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
18409 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
18410 .extract_reg_11d_new_country_event =
18411 extract_reg_11d_new_country_event_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018412};
18413
Govind Singhe7f2f342016-05-23 12:12:52 +053018414/**
18415 * populate_tlv_event_id() - populates wmi event ids
18416 *
18417 * @param event_ids: Pointer to hold event ids
18418 * Return: None
18419 */
18420static void populate_tlv_events_id(uint32_t *event_ids)
18421{
18422 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
18423 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
18424 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
18425 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
18426 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
18427 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
18428 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
18429 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
18430 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
18431 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
18432 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
18433 event_ids[wmi_service_ready_ext_event_id] =
18434 WMI_SERVICE_READY_EXT_EVENTID;
18435 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
18436 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
18437 event_ids[wmi_vdev_install_key_complete_event_id] =
18438 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
18439 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
18440 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
18441
18442 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
18443 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
18444 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
18445 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
18446 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
18447 event_ids[wmi_peer_estimated_linkspeed_event_id] =
18448 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
18449 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053018450 event_ids[wmi_peer_delete_response_event_id] =
18451 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018452 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
18453 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
18454 event_ids[wmi_tbttoffset_update_event_id] =
18455 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018456 event_ids[wmi_ext_tbttoffset_update_event_id] =
18457 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018458 event_ids[wmi_offload_bcn_tx_status_event_id] =
18459 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
18460 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
18461 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
18462 event_ids[wmi_mgmt_tx_completion_event_id] =
18463 WMI_MGMT_TX_COMPLETION_EVENTID;
18464
18465 event_ids[wmi_tx_delba_complete_event_id] =
18466 WMI_TX_DELBA_COMPLETE_EVENTID;
18467 event_ids[wmi_tx_addba_complete_event_id] =
18468 WMI_TX_ADDBA_COMPLETE_EVENTID;
18469 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
18470
18471 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
18472
18473 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
18474 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
18475
18476 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
18477
18478 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
18479
18480 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080018481 event_ids[wmi_p2p_lo_stop_event_id] =
18482 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018483 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
18484 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
18485 event_ids[wmi_do_wow_disable_ack_event_id] =
18486 WMI_D0_WOW_DISABLE_ACK_EVENTID;
18487 event_ids[wmi_wow_initial_wakeup_event_id] =
18488 WMI_WOW_INITIAL_WAKEUP_EVENTID;
18489
18490 event_ids[wmi_rtt_meas_report_event_id] =
18491 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
18492 event_ids[wmi_tsf_meas_report_event_id] =
18493 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
18494 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
18495 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
18496 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
18497 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
18498 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
18499 event_ids[wmi_update_fw_mem_dump_event_id] =
18500 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
18501 event_ids[wmi_diag_event_id_log_supported_event_id] =
18502 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
18503 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
18504 event_ids[wmi_nlo_scan_complete_event_id] =
18505 WMI_NLO_SCAN_COMPLETE_EVENTID;
18506 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
18507 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
18508
18509 event_ids[wmi_gtk_offload_status_event_id] =
18510 WMI_GTK_OFFLOAD_STATUS_EVENTID;
18511 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
18512 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
18513 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
18514
18515 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
18516
18517 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
18518
18519 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
18520 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
18521 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
18522 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
18523 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
18524 event_ids[wmi_wlan_profile_data_event_id] =
18525 WMI_WLAN_PROFILE_DATA_EVENTID;
18526 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
18527 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
18528 event_ids[wmi_vdev_get_keepalive_event_id] =
18529 WMI_VDEV_GET_KEEPALIVE_EVENTID;
18530 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
18531
18532 event_ids[wmi_diag_container_event_id] =
18533 WMI_DIAG_DATA_CONTAINER_EVENTID;
18534
18535 event_ids[wmi_host_auto_shutdown_event_id] =
18536 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
18537
18538 event_ids[wmi_update_whal_mib_stats_event_id] =
18539 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
18540
18541 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
18542 event_ids[wmi_update_vdev_rate_stats_event_id] =
18543 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
18544
18545 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
18546
18547 /** Set OCB Sched Response, deprecated */
18548 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
18549
18550 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
18551 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
18552 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
18553
18554 /* GPIO Event */
18555 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
18556 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
18557
18558 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
18559 event_ids[wmi_rfkill_state_change_event_id] =
18560 WMI_RFKILL_STATE_CHANGE_EVENTID;
18561
18562 /* TDLS Event */
18563 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
18564
18565 event_ids[wmi_batch_scan_enabled_event_id] =
18566 WMI_BATCH_SCAN_ENABLED_EVENTID;
18567 event_ids[wmi_batch_scan_result_event_id] =
18568 WMI_BATCH_SCAN_RESULT_EVENTID;
18569 /* OEM Event */
18570 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
18571 event_ids[wmi_oem_meas_report_event_id] =
18572 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
18573 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
18574
18575 /* NAN Event */
18576 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
18577
18578 /* LPI Event */
18579 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
18580 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
18581 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
18582
18583 /* ExtScan events */
18584 event_ids[wmi_extscan_start_stop_event_id] =
18585 WMI_EXTSCAN_START_STOP_EVENTID;
18586 event_ids[wmi_extscan_operation_event_id] =
18587 WMI_EXTSCAN_OPERATION_EVENTID;
18588 event_ids[wmi_extscan_table_usage_event_id] =
18589 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
18590 event_ids[wmi_extscan_cached_results_event_id] =
18591 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
18592 event_ids[wmi_extscan_wlan_change_results_event_id] =
18593 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
18594 event_ids[wmi_extscan_hotlist_match_event_id] =
18595 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
18596 event_ids[wmi_extscan_capabilities_event_id] =
18597 WMI_EXTSCAN_CAPABILITIES_EVENTID;
18598 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
18599 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
18600
18601 /* mDNS offload events */
18602 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
18603
18604 /* SAP Authentication offload events */
18605 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
18606 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
18607
18608 /** Out-of-context-of-bss (OCB) events */
18609 event_ids[wmi_ocb_set_config_resp_event_id] =
18610 WMI_OCB_SET_CONFIG_RESP_EVENTID;
18611 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
18612 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
18613 event_ids[wmi_dcc_get_stats_resp_event_id] =
18614 WMI_DCC_GET_STATS_RESP_EVENTID;
18615 event_ids[wmi_dcc_update_ndl_resp_event_id] =
18616 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
18617 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
18618 /* System-On-Chip events */
18619 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
18620 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
18621 event_ids[wmi_soc_hw_mode_transition_event_id] =
18622 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
18623 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
18624 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018625 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053018626 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
18627 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018628 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053018629 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
18630 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
18631 event_ids[wmi_peer_sta_ps_statechg_event_id] =
18632 WMI_PEER_STA_PS_STATECHG_EVENTID;
18633 event_ids[wmi_pdev_channel_hopping_event_id] =
18634 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018635 event_ids[wmi_offchan_data_tx_completion_event] =
18636 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018637 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
18638 event_ids[wmi_dfs_radar_detection_event_id] =
18639 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018640 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070018641 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018642}
18643
Soumya Bhat488092d2017-03-22 14:41:01 +053018644#ifndef CONFIG_MCL
18645/**
18646 * populate_tlv_service() - populates wmi services
18647 *
18648 * @param wmi_service: Pointer to hold wmi_service
18649 * Return: None
18650 */
18651static void populate_tlv_service(uint32_t *wmi_service)
18652{
18653 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
18654 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
18655 wmi_service[wmi_service_roam_scan_offload] =
18656 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
18657 wmi_service[wmi_service_bcn_miss_offload] =
18658 WMI_SERVICE_BCN_MISS_OFFLOAD;
18659 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
18660 wmi_service[wmi_service_sta_advanced_pwrsave] =
18661 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
18662 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
18663 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
18664 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
18665 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
18666 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
18667 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
18668 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
18669 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
18670 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
18671 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
18672 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
18673 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
18674 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
18675 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
18676 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
18677 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
18678 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
18679 wmi_service[wmi_service_packet_power_save] =
18680 WMI_SERVICE_PACKET_POWER_SAVE;
18681 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
18682 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
18683 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
18684 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
18685 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
18686 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
18687 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
18688 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
18689 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
18690 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
18691 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
18692 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
18693 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
18694 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
18695 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
18696 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
18697 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
18698 wmi_service[wmi_service_mcc_bcn_interval_change] =
18699 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
18700 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
18701 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
18702 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
18703 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
18704 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
18705 wmi_service[wmi_service_lte_ant_share_support] =
18706 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
18707 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
18708 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
18709 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
18710 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
18711 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
18712 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
18713 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
18714 wmi_service[wmi_service_bcn_txrate_override] =
18715 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
18716 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
18717 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
18718 wmi_service[wmi_service_estimate_linkspeed] =
18719 WMI_SERVICE_ESTIMATE_LINKSPEED;
18720 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
18721 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
18722 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
18723 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
18724 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
18725 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
18726 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
18727 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
18728 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
18729 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
18730 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
18731 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
18732 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
18733 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
18734 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
18735 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
18736 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
18737 wmi_service[wmi_service_sap_auth_offload] =
18738 WMI_SERVICE_SAP_AUTH_OFFLOAD;
18739 wmi_service[wmi_service_dual_band_simultaneous_support] =
18740 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
18741 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
18742 wmi_service[wmi_service_ap_arpns_offload] =
18743 WMI_SERVICE_AP_ARPNS_OFFLOAD;
18744 wmi_service[wmi_service_per_band_chainmask_support] =
18745 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
18746 wmi_service[wmi_service_packet_filter_offload] =
18747 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
18748 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
18749 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
18750 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
18751 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
18752 wmi_service[wmi_service_multiple_vdev_restart] =
18753 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
18754
18755 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
18756 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
18757 wmi_service[wmi_service_smart_antenna_sw_support] =
18758 WMI_SERVICE_UNAVAILABLE;
18759 wmi_service[wmi_service_smart_antenna_hw_support] =
18760 WMI_SERVICE_UNAVAILABLE;
18761 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
18762 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018763 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053018764 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
18765 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
18766 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
18767 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
18768 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
18769 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
18770 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
18771 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053018772 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
18773 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
18774 wmi_service[wmi_service_periodic_chan_stat_support] =
18775 WMI_SERVICE_UNAVAILABLE;
18776 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
18777 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
18778 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
18779 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
18780 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
18781 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053018782 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
18783 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
18784 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
18785 wmi_service[wmi_service_unified_wow_capability] =
18786 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
18787 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
18788 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
18789 wmi_service[wmi_service_sync_delete_cmds] =
18790 WMI_SERVICE_SYNC_DELETE_CMDS;
18791 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
18792 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
18793 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
18794 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
18795 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
18796 wmi_service[wmi_service_deprecated_replace] =
18797 WMI_SERVICE_DEPRECATED_REPLACE;
18798 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
18799 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
18800 wmi_service[wmi_service_enhanced_mcast_filter] =
18801 WMI_SERVICE_ENHANCED_MCAST_FILTER;
18802 wmi_service[wmi_service_half_rate_quarter_rate_support] =
18803 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
18804 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
18805 wmi_service[wmi_service_p2p_listen_offload_support] =
18806 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
18807 wmi_service[wmi_service_mark_first_wakeup_packet] =
18808 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
18809 wmi_service[wmi_service_multiple_mcast_filter_set] =
18810 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
18811 wmi_service[wmi_service_host_managed_rx_reorder] =
18812 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
18813 wmi_service[wmi_service_flash_rdwr_support] =
18814 WMI_SERVICE_FLASH_RDWR_SUPPORT;
18815 wmi_service[wmi_service_wlan_stats_report] =
18816 WMI_SERVICE_WLAN_STATS_REPORT;
18817 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
18818 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
18819 wmi_service[wmi_service_dfs_phyerr_offload] =
18820 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
18821 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
18822 wmi_service[wmi_service_fw_mem_dump_support] =
18823 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
18824 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
18825 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
18826 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
18827 wmi_service[wmi_service_hw_data_filtering] =
18828 WMI_SERVICE_HW_DATA_FILTERING;
18829 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
18830 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053018831 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat488092d2017-03-22 14:41:01 +053018832}
18833
Govind Singhe7f2f342016-05-23 12:12:52 +053018834/**
18835 * populate_pdev_param_tlv() - populates pdev params
18836 *
18837 * @param pdev_param: Pointer to hold pdev params
18838 * Return: None
18839 */
18840static void populate_pdev_param_tlv(uint32_t *pdev_param)
18841{
18842 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
18843 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
18844 pdev_param[wmi_pdev_param_txpower_limit2g] =
18845 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
18846 pdev_param[wmi_pdev_param_txpower_limit5g] =
18847 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
18848 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
18849 pdev_param[wmi_pdev_param_beacon_gen_mode] =
18850 WMI_PDEV_PARAM_BEACON_GEN_MODE;
18851 pdev_param[wmi_pdev_param_beacon_tx_mode] =
18852 WMI_PDEV_PARAM_BEACON_TX_MODE;
18853 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
18854 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
18855 pdev_param[wmi_pdev_param_protection_mode] =
18856 WMI_PDEV_PARAM_PROTECTION_MODE;
18857 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
18858 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
18859 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
18860 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
18861 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
18862 pdev_param[wmi_pdev_param_sta_kickout_th] =
18863 WMI_PDEV_PARAM_STA_KICKOUT_TH;
18864 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
18865 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
18866 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
18867 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
18868 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
18869 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
18870 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
18871 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
18872 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
18873 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
18874 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
18875 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
18876 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
18877 pdev_param[wmi_pdev_param_ltr_sleep_override] =
18878 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
18879 pdev_param[wmi_pdev_param_ltr_rx_override] =
18880 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
18881 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
18882 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
18883 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
18884 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
18885 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
18886 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
18887 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
18888 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
18889 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
18890 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
18891 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
18892 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
18893 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
18894 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
18895 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
18896 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
18897 pdev_param[wmi_pdev_param_peer_stats_update_period] =
18898 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
18899 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
18900 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
18901 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
18902 pdev_param[wmi_pdev_param_arp_ac_override] =
18903 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
18904 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
18905 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
18906 pdev_param[wmi_pdev_param_ani_poll_period] =
18907 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
18908 pdev_param[wmi_pdev_param_ani_listen_period] =
18909 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
18910 pdev_param[wmi_pdev_param_ani_ofdm_level] =
18911 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
18912 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
18913 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
18914 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
18915 pdev_param[wmi_pdev_param_idle_ps_config] =
18916 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
18917 pdev_param[wmi_pdev_param_power_gating_sleep] =
18918 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
18919 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
18920 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
18921 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
18922 pdev_param[wmi_pdev_param_hw_rfkill_config] =
18923 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
18924 pdev_param[wmi_pdev_param_low_power_rf_enable] =
18925 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
18926 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
18927 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
18928 pdev_param[wmi_pdev_param_power_collapse_enable] =
18929 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
18930 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
18931 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
18932 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
18933 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
18934 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
18935 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
18936 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
18937 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
18938 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
18939 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
18940 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
18941 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
18942 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
18943 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
18944 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
18945 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
18946 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
18947 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
18948 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
18949 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
18950 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
18951 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
18952 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
18953 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
18954 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
18955 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
18956 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
18957 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
18958 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
18959 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
18960 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
18961 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
18962 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
18963 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
18964 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
18965 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
18966 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
18967 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
18968 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
18969 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
18970 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
18971 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
18972 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
18973 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
18974 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
18975 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
18976 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
18977 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
18978 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
18979 WMI_UNAVAILABLE_PARAM;
18980 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
18981 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
18982 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
18983 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
18984 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
18985 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018986 pdev_param[wmi_pdev_param_atf_strict_sch] =
18987 WMI_PDEV_PARAM_ATF_STRICT_SCH;
18988 pdev_param[wmi_pdev_param_atf_sched_duration] =
18989 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Govind Singhe7f2f342016-05-23 12:12:52 +053018990 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
18991 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
18992 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
18993 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
18994 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
18995 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
18996 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
18997 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
18998 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
18999 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
19000 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
19001 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
19002 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
19003 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
19004 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
19005 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019006 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
19007 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053019008 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019009 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Govind Singhe7f2f342016-05-23 12:12:52 +053019010 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019011 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
19012 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019013 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
19014 WMI_UNAVAILABLE_PARAM;
19015 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
19016 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
19017 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
19018 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
19019 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
19020 WMI_UNAVAILABLE_PARAM;
19021 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
19022 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
19023 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019024 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
19025 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019026 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053019027 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
19028 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053019029 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
19030 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
19031 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
19032 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
19033 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
19034 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
19035 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
19036 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
19037 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
19038 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
19039 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
19040 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
19041 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
19042 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
19043 pdev_param[wmi_pdev_param_fast_channel_reset] =
19044 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
19045 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019046}
19047
19048/**
19049 * populate_vdev_param_tlv() - populates vdev params
19050 *
19051 * @param vdev_param: Pointer to hold vdev params
19052 * Return: None
19053 */
19054static void populate_vdev_param_tlv(uint32_t *vdev_param)
19055{
19056 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
19057 vdev_param[wmi_vdev_param_fragmentation_threshold] =
19058 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
19059 vdev_param[wmi_vdev_param_beacon_interval] =
19060 WMI_VDEV_PARAM_BEACON_INTERVAL;
19061 vdev_param[wmi_vdev_param_listen_interval] =
19062 WMI_VDEV_PARAM_LISTEN_INTERVAL;
19063 vdev_param[wmi_vdev_param_multicast_rate] =
19064 WMI_VDEV_PARAM_MULTICAST_RATE;
19065 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
19066 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
19067 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
19068 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
19069 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
19070 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
19071 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
19072 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
19073 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
19074 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
19075 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
19076 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
19077 vdev_param[wmi_vdev_param_bmiss_count_max] =
19078 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
19079 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
19080 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
19081 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
19082 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
19083 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
19084 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
19085 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
19086 vdev_param[wmi_vdev_param_disable_htprotection] =
19087 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
19088 vdev_param[wmi_vdev_param_sta_quickkickout] =
19089 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
19090 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
19091 vdev_param[wmi_vdev_param_protection_mode] =
19092 WMI_VDEV_PARAM_PROTECTION_MODE;
19093 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
19094 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
19095 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
19096 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
19097 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
19098 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
19099 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
19100 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
19101 vdev_param[wmi_vdev_param_bcast_data_rate] =
19102 WMI_VDEV_PARAM_BCAST_DATA_RATE;
19103 vdev_param[wmi_vdev_param_mcast_data_rate] =
19104 WMI_VDEV_PARAM_MCAST_DATA_RATE;
19105 vdev_param[wmi_vdev_param_mcast_indicate] =
19106 WMI_VDEV_PARAM_MCAST_INDICATE;
19107 vdev_param[wmi_vdev_param_dhcp_indicate] =
19108 WMI_VDEV_PARAM_DHCP_INDICATE;
19109 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
19110 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
19111 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
19112 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
19113 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
19114 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
19115 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
19116 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
19117 vdev_param[wmi_vdev_param_ap_enable_nawds] =
19118 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
19119 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
19120 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
19121 vdev_param[wmi_vdev_param_packet_powersave] =
19122 WMI_VDEV_PARAM_PACKET_POWERSAVE;
19123 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
19124 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
19125 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
19126 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
19127 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
19128 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
19129 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
19130 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
19131 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
19132 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
19133 vdev_param[wmi_vdev_param_early_rx_slop_step] =
19134 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
19135 vdev_param[wmi_vdev_param_early_rx_init_slop] =
19136 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
19137 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
19138 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
19139 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
19140 vdev_param[wmi_vdev_param_snr_num_for_cal] =
19141 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
19142 vdev_param[wmi_vdev_param_roam_fw_offload] =
19143 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
19144 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
19145 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
19146 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
19147 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
19148 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
19149 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
19150 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
19151 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
19152 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
19153 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
19154 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
19155 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
19156 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
19157 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
19158 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
19159 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
19160 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
19161 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
19162 vdev_param[wmi_vdev_param_inactivity_cnt] =
19163 WMI_VDEV_PARAM_INACTIVITY_CNT;
19164 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
19165 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
19166 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
19167 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
19168 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
19169 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
19170 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
19171 vdev_param[wmi_vdev_param_rx_leak_window] =
19172 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
19173 vdev_param[wmi_vdev_param_stats_avg_factor] =
19174 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
19175 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
19176 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
19177 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
19178 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
19179 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
19180 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019181 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
19182 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053019183 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080019184 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
19185 vdev_param[wmi_vdev_param_he_range_ext_enable] =
19186 WMI_VDEV_PARAM_HE_RANGE_EXT;
19187 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
19188 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053019189 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
19190 vdev_param[wmi_vdev_param_dtim_enable_cts] =
19191 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
19192 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
19193 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
19194 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
19195 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053019196 vdev_param[wmi_vdev_param_mcast2ucast_set] =
19197 WMI_VDEV_PARAM_MCAST2UCAST_SET;
19198 vdev_param[wmi_vdev_param_rc_num_retries] =
19199 WMI_VDEV_PARAM_RC_NUM_RETRIES;
19200 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
19201 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
19202 vdev_param[wmi_vdev_param_rts_fixed_rate] =
19203 WMI_VDEV_PARAM_RTS_FIXED_RATE;
19204 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
19205 vdev_param[wmi_vdev_param_vht80_ratemask] =
19206 WMI_VDEV_PARAM_VHT80_RATEMASK;
19207 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
19208 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
19209 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Govind Singhe7f2f342016-05-23 12:12:52 +053019210}
19211#endif
19212
Govind Singh5eb51532016-03-09 11:34:12 +053019213/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019214 * populate_target_defines_tlv() - Populate target defines and params
19215 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053019216 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019217 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053019218 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053019219#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019220static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053019221{
Govind Singhe7f2f342016-05-23 12:12:52 +053019222 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053019223 populate_pdev_param_tlv(wmi_handle->pdev_param);
19224 populate_vdev_param_tlv(wmi_handle->vdev_param);
19225}
19226#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019227static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
19228{ }
19229#endif
19230
19231/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019232 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
19233 * host to target defines.
19234 * @param pdev_id: host pdev_id to be converted.
19235 * Return: target pdev_id after conversion.
19236 */
19237static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
19238{
19239 switch (pdev_id) {
19240 case WMI_HOST_PDEV_ID_SOC:
19241 return WMI_PDEV_ID_SOC;
19242 case WMI_HOST_PDEV_ID_0:
19243 return WMI_PDEV_ID_1ST;
19244 case WMI_HOST_PDEV_ID_1:
19245 return WMI_PDEV_ID_2ND;
19246 case WMI_HOST_PDEV_ID_2:
19247 return WMI_PDEV_ID_3RD;
19248 }
19249
19250 QDF_ASSERT(0);
19251
19252 return WMI_PDEV_ID_SOC;
19253}
19254
19255/**
19256 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
19257 * target to host defines.
19258 * @param pdev_id: target pdev_id to be converted.
19259 * Return: host pdev_id after conversion.
19260 */
19261static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
19262{
19263 switch (pdev_id) {
19264 case WMI_PDEV_ID_SOC:
19265 return WMI_HOST_PDEV_ID_SOC;
19266 case WMI_PDEV_ID_1ST:
19267 return WMI_HOST_PDEV_ID_0;
19268 case WMI_PDEV_ID_2ND:
19269 return WMI_HOST_PDEV_ID_1;
19270 case WMI_PDEV_ID_3RD:
19271 return WMI_HOST_PDEV_ID_2;
19272 }
19273
19274 QDF_ASSERT(0);
19275
19276 return WMI_HOST_PDEV_ID_SOC;
19277}
19278
19279/**
19280 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
19281 *
19282 * Return None.
19283 */
19284void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
19285{
19286 wmi_handle->ops->convert_pdev_id_host_to_target =
19287 convert_host_pdev_id_to_target_pdev_id;
19288 wmi_handle->ops->convert_pdev_id_target_to_host =
19289 convert_target_pdev_id_to_host_pdev_id;
19290}
19291/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019292 * wmi_tlv_attach() - Attach TLV APIs
19293 *
19294 * Return: None
19295 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019296void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053019297{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019298 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053019299#ifdef WMI_INTERFACE_EVENT_LOGGING
19300 wmi_handle->log_info.buf_offset_command = 2;
19301 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053019302#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053019303 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019304 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053019305}