blob: ff401fd2a90f08336675b90fc2bdd7861af88ffd [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"
Govind Singh5eb51532016-03-09 11:34:12 +053033
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053034
35/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
36 * buffer.
37 * @cmd: pointer target vdev create command buffer
38 * @param: pointer host params for vdev create
39 *
40 * Return: None
41 */
42#ifdef CONFIG_MCL
43static inline void copy_vdev_create_pdev_id(
44 wmi_vdev_create_cmd_fixed_param * cmd,
45 struct vdev_create_params *param)
46{
47 cmd->pdev_id = WMI_PDEV_ID_SOC;
48}
49#else
50static inline void copy_vdev_create_pdev_id(
51 wmi_vdev_create_cmd_fixed_param * cmd,
52 struct vdev_create_params *param)
53{
54 cmd->pdev_id = param->pdev_id;
55}
56#endif
57
Govind Singh5eb51532016-03-09 11:34:12 +053058/**
59 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
60 * @wmi_handle: wmi handle
61 * @param: pointer to hold vdev create parameter
62 * @macaddr: vdev mac address
63 *
Govind Singhe7f2f342016-05-23 12:12:52 +053064 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053065 */
Sathish Kumarfd347372017-02-13 12:29:09 +053066static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053067 uint8_t macaddr[IEEE80211_ADDR_LEN],
68 struct vdev_create_params *param)
69{
70 wmi_vdev_create_cmd_fixed_param *cmd;
71 wmi_buf_t buf;
72 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053073 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070074 int num_bands = 2;
75 uint8_t *buf_ptr;
76 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053077
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070078 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053079 buf = wmi_buf_alloc(wmi_handle, len);
80 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053081 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053082 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053083 }
84 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
85 WMITLV_SET_HDR(&cmd->tlv_header,
86 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
87 WMITLV_GET_STRUCT_TLVLEN
88 (wmi_vdev_create_cmd_fixed_param));
89 cmd->vdev_id = param->if_id;
90 cmd->vdev_type = param->type;
91 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070092 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053093 copy_vdev_create_pdev_id(cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +053094 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +053095 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +053096 __func__, param->if_id,
97 macaddr[0], macaddr[1], macaddr[2],
98 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070099 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
100 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
101 (num_bands * sizeof(wmi_vdev_txrx_streams)));
102 buf_ptr += WMI_TLV_HDR_SIZE;
103
Govind Singh224a7312016-06-21 14:33:26 +0530104 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700105 param->type, param->subtype,
106 param->nss_2g, param->nss_5g);
107 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
108 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
109 txrx_streams->supported_tx_streams = param->nss_2g;
110 txrx_streams->supported_rx_streams = param->nss_2g;
111 WMITLV_SET_HDR(&txrx_streams->tlv_header,
112 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
113 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
114
115 txrx_streams++;
116 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
117 txrx_streams->supported_tx_streams = param->nss_5g;
118 txrx_streams->supported_rx_streams = param->nss_5g;
119 WMITLV_SET_HDR(&txrx_streams->tlv_header,
120 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
121 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530122 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530123 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530124 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530125 wmi_buf_free(buf);
126 }
127
128 return ret;
129}
130
131/**
132 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
133 * @wmi_handle: wmi handle
134 * @if_id: vdev id
135 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530136 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530137 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530138static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530139 uint8_t if_id)
140{
141 wmi_vdev_delete_cmd_fixed_param *cmd;
142 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530143 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530144
145 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
146 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530147 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530148 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530149 }
150
151 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
152 WMITLV_SET_HDR(&cmd->tlv_header,
153 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
154 WMITLV_GET_STRUCT_TLVLEN
155 (wmi_vdev_delete_cmd_fixed_param));
156 cmd->vdev_id = if_id;
157 ret = wmi_unified_cmd_send(wmi_handle, buf,
158 sizeof(wmi_vdev_delete_cmd_fixed_param),
159 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530160 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530161 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530162 wmi_buf_free(buf);
163 }
Govind Singhb53420c2016-03-09 14:32:57 +0530164 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530165
166 return ret;
167}
168
169/**
170 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
171 * @wmi: wmi handle
172 * @vdev_id: vdev id
173 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530174 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530175 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530176static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530177 uint8_t vdev_id)
178{
179 wmi_vdev_stop_cmd_fixed_param *cmd;
180 wmi_buf_t buf;
181 int32_t len = sizeof(*cmd);
182
183 buf = wmi_buf_alloc(wmi, len);
184 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530185 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530186 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530187 }
188 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
189 WMITLV_SET_HDR(&cmd->tlv_header,
190 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
191 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
192 cmd->vdev_id = vdev_id;
193 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530194 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530195 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530196 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530197 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530198 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530199
200 return 0;
201}
202
203/**
204 * send_vdev_down_cmd_tlv() - send vdev down command to fw
205 * @wmi: wmi handle
206 * @vdev_id: vdev id
207 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530208 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530209 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530210static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530211{
212 wmi_vdev_down_cmd_fixed_param *cmd;
213 wmi_buf_t buf;
214 int32_t len = sizeof(*cmd);
215
216 buf = wmi_buf_alloc(wmi, len);
217 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530218 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530219 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530220 }
221 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
222 WMITLV_SET_HDR(&cmd->tlv_header,
223 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
224 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
225 cmd->vdev_id = vdev_id;
226 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530227 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530228 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530229 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530230 }
Govind Singhb53420c2016-03-09 14:32:57 +0530231 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530232
233 return 0;
234}
235
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530236#ifdef CONFIG_MCL
237static inline void copy_channel_info(
238 wmi_vdev_start_request_cmd_fixed_param * cmd,
239 wmi_channel *chan,
240 struct vdev_start_params *req)
241{
242 chan->mhz = req->chan_freq;
243
244 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
245
246 chan->band_center_freq1 = req->band_center_freq1;
247 chan->band_center_freq2 = req->band_center_freq2;
248
249 if (req->is_half_rate)
250 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
251 else if (req->is_quarter_rate)
252 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
253
Naveen Rawat44f2f432016-12-01 12:58:57 -0800254 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530255 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
256 cmd->disable_hw_ack = req->dis_hw_ack;
257 }
258
259 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
260 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
261
262}
263#else
264static inline void copy_channel_info(
265 wmi_vdev_start_request_cmd_fixed_param * cmd,
266 wmi_channel *chan,
267 struct vdev_start_params *req)
268{
269 chan->mhz = req->channel.mhz;
270
271 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
272
273 chan->band_center_freq1 = req->channel.cfreq1;
274 chan->band_center_freq2 = req->channel.cfreq2;
275
276 if (req->channel.half_rate)
277 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
278 else if (req->channel.quarter_rate)
279 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
280
281 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530282 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530283 cmd->disable_hw_ack = req->disable_hw_ack;
284 }
285
286 /* FIXME: Find out min, max and regulatory power levels */
287 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
288 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
289
290}
291#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530292/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530293 * send_vdev_start_cmd_tlv() - send vdev start request to fw
294 * @wmi_handle: wmi handle
295 * @req: vdev start params
296 *
297 * Return: QDF status
298 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530299static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530300 struct vdev_start_params *req)
301{
302 wmi_vdev_start_request_cmd_fixed_param *cmd;
303 wmi_buf_t buf;
304 wmi_channel *chan;
305 int32_t len, ret;
306 uint8_t *buf_ptr;
307
308 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
309 buf = wmi_buf_alloc(wmi_handle, len);
310 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530311 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530312 return QDF_STATUS_E_NOMEM;
313 }
314 buf_ptr = (uint8_t *) wmi_buf_data(buf);
315 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
316 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
317 WMITLV_SET_HDR(&cmd->tlv_header,
318 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
319 WMITLV_GET_STRUCT_TLVLEN
320 (wmi_vdev_start_request_cmd_fixed_param));
321 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
322 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
323 cmd->vdev_id = req->vdev_id;
324
325 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530326 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530327
328 cmd->beacon_interval = req->beacon_intval;
329 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530330
331 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530332 cmd->beacon_interval = req->beacon_intval;
333 cmd->dtim_period = req->dtim_period;
334
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530335 /* Copy the SSID */
336 if (req->ssid.length) {
337 if (req->ssid.length < sizeof(cmd->ssid.ssid))
338 cmd->ssid.ssid_len = req->ssid.length;
339 else
340 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
341 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
342 cmd->ssid.ssid_len);
343 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530344
345 if (req->hidden_ssid)
346 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
347
348 if (req->pmf_enabled)
349 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530350 }
351
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530352 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530353 cmd->preferred_rx_streams = req->preferred_rx_streams;
354 cmd->preferred_tx_streams = req->preferred_tx_streams;
355
356 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
357 sizeof(wmi_channel));
358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
359 cmd->num_noa_descriptors *
360 sizeof(wmi_p2p_noa_descriptor));
Naveen Rawat44f2f432016-12-01 12:58:57 -0800361 WMI_LOGA("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530362 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
363 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
364 "Tx SS %d, Rx SS %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800365 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530366 req->is_dfs, req->beacon_intval, cmd->dtim_period,
367 chan->band_center_freq1, chan->band_center_freq2,
368 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
369 req->preferred_tx_streams, req->preferred_rx_streams);
370
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530371 if (req->is_restart)
372 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
373 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530374 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530375 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
376 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530377 if (ret) {
378 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530379 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530380 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530381 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530382
383 return QDF_STATUS_SUCCESS;
384}
385
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530386/**
387 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
388 * @wmi_handle: wmi handle
389 * @restart_params: vdev restart params
390 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530391 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530392 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530393static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530394 struct hidden_ssid_vdev_restart_params *restart_params)
395{
396 wmi_vdev_start_request_cmd_fixed_param *cmd;
397 wmi_buf_t buf;
398 wmi_channel *chan;
399 int32_t len;
400 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530401 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530402
403 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
404 buf = wmi_buf_alloc(wmi_handle, len);
405 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530406 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530407 return QDF_STATUS_E_NOMEM;
408 }
409 buf_ptr = (uint8_t *) wmi_buf_data(buf);
410 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
411 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
412
413 WMITLV_SET_HDR(&cmd->tlv_header,
414 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
415 WMITLV_GET_STRUCT_TLVLEN
416 (wmi_vdev_start_request_cmd_fixed_param));
417
418 WMITLV_SET_HDR(&chan->tlv_header,
419 WMITLV_TAG_STRUC_wmi_channel,
420 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
421
422 cmd->vdev_id = restart_params->session_id;
423 cmd->ssid.ssid_len = restart_params->ssid_len;
424 qdf_mem_copy(cmd->ssid.ssid,
425 restart_params->ssid,
426 cmd->ssid.ssid_len);
427 cmd->flags = restart_params->flags;
428 cmd->requestor_id = restart_params->requestor_id;
429 cmd->disable_hw_ack = restart_params->disable_hw_ack;
430
431 chan->mhz = restart_params->mhz;
432 chan->band_center_freq1 =
433 restart_params->band_center_freq1;
434 chan->band_center_freq2 =
435 restart_params->band_center_freq2;
436 chan->info = restart_params->info;
437 chan->reg_info_1 = restart_params->reg_info_1;
438 chan->reg_info_2 = restart_params->reg_info_2;
439
440 cmd->num_noa_descriptors = 0;
441 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
442 sizeof(wmi_channel));
443 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
444 cmd->num_noa_descriptors *
445 sizeof(wmi_p2p_noa_descriptor));
446
447 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
448 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530449 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530450 wmi_buf_free(buf);
451 return QDF_STATUS_E_FAILURE;
452 }
453 return QDF_STATUS_SUCCESS;
454}
455
456
457/**
Govind Singh5eb51532016-03-09 11:34:12 +0530458 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
459 * @wmi: wmi handle
460 * @peer_addr: peer mac address
461 * @param: pointer to hold peer flush tid parameter
462 *
463 * Return: 0 for sucess or error code
464 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530465static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530466 uint8_t peer_addr[IEEE80211_ADDR_LEN],
467 struct peer_flush_params *param)
468{
469 wmi_peer_flush_tids_cmd_fixed_param *cmd;
470 wmi_buf_t buf;
471 int32_t len = sizeof(*cmd);
472
473 buf = wmi_buf_alloc(wmi, len);
474 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530475 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530476 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530477 }
478 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
479 WMITLV_SET_HDR(&cmd->tlv_header,
480 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
481 WMITLV_GET_STRUCT_TLVLEN
482 (wmi_peer_flush_tids_cmd_fixed_param));
483 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
484 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
485 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530486 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530487 peer_addr, param->vdev_id,
488 param->peer_tid_bitmap);
489 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530490 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530491 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530492 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530493 }
494
495 return 0;
496}
497
498/**
499 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
500 * @wmi: wmi handle
501 * @peer_addr: peer mac addr
502 * @vdev_id: vdev id
503 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530504 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530505 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530506static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530507 uint8_t peer_addr[IEEE80211_ADDR_LEN],
508 uint8_t vdev_id)
509{
510 wmi_peer_delete_cmd_fixed_param *cmd;
511 wmi_buf_t buf;
512 int32_t len = sizeof(*cmd);
513 buf = wmi_buf_alloc(wmi, len);
514 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530515 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530516 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530517 }
518 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
519 WMITLV_SET_HDR(&cmd->tlv_header,
520 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
521 WMITLV_GET_STRUCT_TLVLEN
522 (wmi_peer_delete_cmd_fixed_param));
523 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
524 cmd->vdev_id = vdev_id;
525
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800526 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530527 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530528 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530529 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530530 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530531 }
Govind Singh5eb51532016-03-09 11:34:12 +0530532
533 return 0;
534}
535
536/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530537 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
538 * to target id.
539 * @targ_paramid: Target parameter id to hold the result.
540 * @peer_param_id: host param id.
541 *
542 * Return: QDF_STATUS_SUCCESS for success
543 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
544 */
545#ifdef CONFIG_MCL
546static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
547 uint32_t *targ_paramid,
548 uint32_t peer_param_id)
549{
550 *targ_paramid = peer_param_id;
551 return QDF_STATUS_SUCCESS;
552}
553#else
554static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
555 uint32_t *targ_paramid,
556 uint32_t peer_param_id)
557{
558 switch (peer_param_id) {
559 case WMI_HOST_PEER_MIMO_PS_STATE:
560 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
561 break;
562 case WMI_HOST_PEER_AMPDU:
563 *targ_paramid = WMI_PEER_AMPDU;
564 break;
565 case WMI_HOST_PEER_AUTHORIZE:
566 *targ_paramid = WMI_PEER_AUTHORIZE;
567 break;
568 case WMI_HOST_PEER_CHWIDTH:
569 *targ_paramid = WMI_PEER_CHWIDTH;
570 break;
571 case WMI_HOST_PEER_NSS:
572 *targ_paramid = WMI_PEER_NSS;
573 break;
574 case WMI_HOST_PEER_USE_4ADDR:
575 *targ_paramid = WMI_PEER_USE_4ADDR;
576 break;
577 case WMI_HOST_PEER_MEMBERSHIP:
578 *targ_paramid = WMI_PEER_MEMBERSHIP;
579 break;
580 case WMI_HOST_PEER_USERPOS:
581 *targ_paramid = WMI_PEER_USERPOS;
582 break;
583 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
584 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
585 break;
586 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
587 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
588 break;
589 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
590 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
591 break;
592 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
593 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
594 break;
595 case WMI_HOST_PEER_PHYMODE:
596 *targ_paramid = WMI_PEER_PHYMODE;
597 break;
598 case WMI_HOST_PEER_USE_FIXED_PWR:
599 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
600 break;
601 case WMI_HOST_PEER_PARAM_FIXED_RATE:
602 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
603 break;
604 case WMI_HOST_PEER_SET_MU_WHITELIST:
605 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
606 break;
607 case WMI_HOST_PEER_SET_MAC_TX_RATE:
608 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
609 break;
610 case WMI_HOST_PEER_SET_MIN_TX_RATE:
611 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
612 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530613 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
614 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
615 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530616 default:
617 return QDF_STATUS_E_NOSUPPORT;
618 }
619
620 return QDF_STATUS_SUCCESS;
621}
622#endif
623/**
Govind Singh5eb51532016-03-09 11:34:12 +0530624 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530625 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530626 * @peer_addr: peer mac address
627 * @param : pointer to hold peer set parameter
628 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530629 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530630 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530631static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530632 uint8_t peer_addr[IEEE80211_ADDR_LEN],
633 struct peer_set_params *param)
634{
635 wmi_peer_set_param_cmd_fixed_param *cmd;
636 wmi_buf_t buf;
637 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530638 uint32_t param_id;
639
640 if (convert_host_peer_id_to_target_id_tlv(&param_id,
641 param->param_id) != QDF_STATUS_SUCCESS)
642 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530643
644 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
645 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530646 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530647 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530648 }
649 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
650 WMITLV_SET_HDR(&cmd->tlv_header,
651 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
652 WMITLV_GET_STRUCT_TLVLEN
653 (wmi_peer_set_param_cmd_fixed_param));
654 cmd->vdev_id = param->vdev_id;
655 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530656 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530657 cmd->param_value = param->param_value;
658 err = wmi_unified_cmd_send(wmi, buf,
659 sizeof(wmi_peer_set_param_cmd_fixed_param),
660 WMI_PEER_SET_PARAM_CMDID);
661 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530662 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530663 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530664 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530665 }
666
667 return 0;
668}
669
670/**
671 * send_vdev_up_cmd_tlv() - send vdev up command in fw
672 * @wmi: wmi handle
673 * @bssid: bssid
674 * @vdev_up_params: pointer to hold vdev up parameter
675 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530676 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530677 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530678static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530679 uint8_t bssid[IEEE80211_ADDR_LEN],
680 struct vdev_up_params *params)
681{
682 wmi_vdev_up_cmd_fixed_param *cmd;
683 wmi_buf_t buf;
684 int32_t len = sizeof(*cmd);
685
Govind Singhb53420c2016-03-09 14:32:57 +0530686 WMI_LOGD("%s: VDEV_UP", __func__);
687 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530688 params->vdev_id, params->assoc_id, bssid);
689 buf = wmi_buf_alloc(wmi, len);
690 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530691 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530692 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530693 }
694 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
695 WMITLV_SET_HDR(&cmd->tlv_header,
696 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
697 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
698 cmd->vdev_id = params->vdev_id;
699 cmd->vdev_assoc_id = params->assoc_id;
700 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
701 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530702 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530703 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530704 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530705 }
706
707 return 0;
708}
709
710/**
711 * send_peer_create_cmd_tlv() - send peer create command to fw
712 * @wmi: wmi handle
713 * @peer_addr: peer mac address
714 * @peer_type: peer type
715 * @vdev_id: vdev id
716 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530717 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530718 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530719static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530720 struct peer_create_params *param)
721{
722 wmi_peer_create_cmd_fixed_param *cmd;
723 wmi_buf_t buf;
724 int32_t len = sizeof(*cmd);
725
726 buf = wmi_buf_alloc(wmi, len);
727 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530728 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530729 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530730 }
731 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
732 WMITLV_SET_HDR(&cmd->tlv_header,
733 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
734 WMITLV_GET_STRUCT_TLVLEN
735 (wmi_peer_create_cmd_fixed_param));
736 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
737 cmd->peer_type = param->peer_type;
738 cmd->vdev_id = param->vdev_id;
739
740 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530741 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530742 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530743 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530744 }
Govind Singhb53420c2016-03-09 14:32:57 +0530745 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530746 param->vdev_id);
747
748 return 0;
749}
750
751/**
Leo Changeee40872016-09-28 13:43:36 -0700752 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
753 * command to fw
754 * @wmi: wmi handle
755 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
756 *
757 * Return: 0 for success or error code
758 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700759static
Leo Changeee40872016-09-28 13:43:36 -0700760QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
761 struct rx_reorder_queue_setup_params *param)
762{
763 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
764 wmi_buf_t buf;
765 int32_t len = sizeof(*cmd);
766
767 buf = wmi_buf_alloc(wmi, len);
768 if (!buf) {
769 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
770 return QDF_STATUS_E_NOMEM;
771 }
772 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
773 WMITLV_SET_HDR(&cmd->tlv_header,
774 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
775 WMITLV_GET_STRUCT_TLVLEN
776 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
777 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
778 cmd->vdev_id = param->vdev_id;
779 cmd->tid = param->tid;
780 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
781 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
782 cmd->queue_no = param->queue_no;
783
784 if (wmi_unified_cmd_send(wmi, buf, len,
785 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
786 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
787 __func__);
788 qdf_nbuf_free(buf);
789 return QDF_STATUS_E_FAILURE;
790 }
791 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
792 param->peer_macaddr, param->vdev_id, param->tid);
793
794 return QDF_STATUS_SUCCESS;
795}
796
797/**
798 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
799 * command to fw
800 * @wmi: wmi handle
801 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
802 *
803 * Return: 0 for success or error code
804 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700805static
Leo Changeee40872016-09-28 13:43:36 -0700806QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
807 struct rx_reorder_queue_remove_params *param)
808{
809 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
810 wmi_buf_t buf;
811 int32_t len = sizeof(*cmd);
812
813 buf = wmi_buf_alloc(wmi, len);
814 if (!buf) {
815 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
816 return QDF_STATUS_E_NOMEM;
817 }
818 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
819 wmi_buf_data(buf);
820 WMITLV_SET_HDR(&cmd->tlv_header,
821 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
822 WMITLV_GET_STRUCT_TLVLEN
823 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
824 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
825 cmd->vdev_id = param->vdev_id;
826 cmd->tid_mask = param->peer_tid_bitmap;
827
828 if (wmi_unified_cmd_send(wmi, buf, len,
829 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
830 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
831 __func__);
832 qdf_nbuf_free(buf);
833 return QDF_STATUS_E_FAILURE;
834 }
835 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
836 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
837
838 return QDF_STATUS_SUCCESS;
839}
840
841/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530842 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
843 * @wmi_handle: wmi handle
844 * @param: pointer holding peer details
845 *
846 * Return: 0 for success or error code
847 */
848static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
849 struct peer_add_wds_entry_params *param)
850{
851 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
852 wmi_buf_t buf;
853 int len = sizeof(*cmd);
854
855 buf = wmi_buf_alloc(wmi_handle, len);
856 if (!buf) {
857 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
858 return QDF_STATUS_E_FAILURE;
859 }
860 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
861 WMITLV_SET_HDR(&cmd->tlv_header,
862 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
863 WMITLV_GET_STRUCT_TLVLEN
864 (wmi_peer_add_wds_entry_cmd_fixed_param));
865 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
866 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
867 cmd->flags = param->flags;
868
869 return wmi_unified_cmd_send(wmi_handle, buf, len,
870 WMI_PEER_ADD_WDS_ENTRY_CMDID);
871}
872
873/**
874 * send_peer_del_wds_entry_cmd_non_tlv() - send peer delete command to fw
875 * @wmi_handle: wmi handle
876 * @param: pointer holding peer details
877 *
878 * Return: 0 for success or error code
879 */
880static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
881 struct peer_del_wds_entry_params *param)
882{
883 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
884 wmi_buf_t buf;
885 int len = sizeof(*cmd);
886
887 buf = wmi_buf_alloc(wmi_handle, len);
888 if (!buf) {
889 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
890 return QDF_STATUS_E_NOMEM;
891 }
892 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
893 WMITLV_SET_HDR(&cmd->tlv_header,
894 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
895 WMITLV_GET_STRUCT_TLVLEN
896 (wmi_peer_remove_wds_entry_cmd_fixed_param));
897 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
898 return wmi_unified_cmd_send(wmi_handle, buf, len,
899 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
900}
901
902/**
903 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
904 * @wmi_handle: wmi handle
905 * @param: pointer holding peer details
906 *
907 * Return: 0 for success or error code
908 */
909static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
910 struct peer_update_wds_entry_params *param)
911{
912 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
913 wmi_buf_t buf;
914 int len = sizeof(*cmd);
915
916 buf = wmi_buf_alloc(wmi_handle, len);
917 if (!buf) {
918 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
919 return QDF_STATUS_E_NOMEM;
920 }
921
922 /* wmi_buf_alloc returns zeroed command buffer */
923 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
924 WMITLV_SET_HDR(&cmd->tlv_header,
925 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
926 WMITLV_GET_STRUCT_TLVLEN
927 (wmi_peer_update_wds_entry_cmd_fixed_param));
928 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
929 if (param->wds_macaddr)
930 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
931 &cmd->wds_macaddr);
932 if (param->peer_macaddr)
933 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
934 &cmd->peer_macaddr);
935 return wmi_unified_cmd_send(wmi_handle, buf, len,
936 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
937}
938
939
940
941/**
Govind Singh5eb51532016-03-09 11:34:12 +0530942 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
943 * @wmi_handle: wmi handle
944 * @value: value
945 * @mac_id: mac id to have radio context
946 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530947 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530948 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530949static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530950 uint32_t value, uint8_t mac_id)
951{
952 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
953 wmi_buf_t buf;
954 int32_t len = sizeof(*cmd);
955
Govind Singhb53420c2016-03-09 14:32:57 +0530956 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530957
958 buf = wmi_buf_alloc(wmi_handle, len);
959 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530960 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530961 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530962 }
963
964 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
965 WMITLV_SET_HDR(&cmd->tlv_header,
966 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
967 WMITLV_GET_STRUCT_TLVLEN
968 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530969 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530970 cmd->enable = value;
971
972 if (wmi_unified_cmd_send(wmi_handle, buf, len,
973 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530974 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530975 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530976 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530977 }
978
979 return 0;
980}
981
982/**
983 * send_pdev_utf_cmd_tlv() - send utf command to fw
984 * @wmi_handle: wmi handle
985 * @param: pointer to pdev_utf_params
986 * @mac_id: mac id to have radio context
987 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530988 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530989 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530990static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530991send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
992 struct pdev_utf_params *param,
993 uint8_t mac_id)
994{
995 wmi_buf_t buf;
996 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -0700997 /* if param->len is 0 no data is sent, return error */
998 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +0530999 static uint8_t msgref = 1;
1000 uint8_t segNumber = 0, segInfo, numSegments;
1001 uint16_t chunk_len, total_bytes;
1002 uint8_t *bufpos;
1003 struct seg_hdr_info segHdrInfo;
1004
1005 bufpos = param->utf_payload;
1006 total_bytes = param->len;
1007 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1008 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1009 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1010
1011 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1012 numSegments++;
1013
1014 while (param->len) {
1015 if (param->len > MAX_WMI_UTF_LEN)
1016 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1017 else
1018 chunk_len = param->len;
1019
1020 buf = wmi_buf_alloc(wmi_handle,
1021 (chunk_len + sizeof(segHdrInfo) +
1022 WMI_TLV_HDR_SIZE));
1023 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301024 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301025 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301026 }
1027
1028 cmd = (uint8_t *) wmi_buf_data(buf);
1029
1030 segHdrInfo.len = total_bytes;
1031 segHdrInfo.msgref = msgref;
1032 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1033 segHdrInfo.segmentInfo = segInfo;
1034 segHdrInfo.pad = 0;
1035
Govind Singhb53420c2016-03-09 14:32:57 +05301036 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301037 " segHdrInfo.segmentInfo = %d",
1038 __func__, segHdrInfo.len, segHdrInfo.msgref,
1039 segHdrInfo.segmentInfo);
1040
Govind Singhb53420c2016-03-09 14:32:57 +05301041 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301042 "chunk len %d", __func__, total_bytes, segNumber,
1043 numSegments, chunk_len);
1044
1045 segNumber++;
1046
1047 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1048 (chunk_len + sizeof(segHdrInfo)));
1049 cmd += WMI_TLV_HDR_SIZE;
1050 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1051 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1052
1053 ret = wmi_unified_cmd_send(wmi_handle, buf,
1054 (chunk_len + sizeof(segHdrInfo) +
1055 WMI_TLV_HDR_SIZE),
1056 WMI_PDEV_UTF_CMDID);
1057
Govind Singh67922e82016-04-01 16:48:57 +05301058 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301059 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301060 wmi_buf_free(buf);
1061 break;
1062 }
1063
1064 param->len -= chunk_len;
1065 bufpos += chunk_len;
1066 }
1067
1068 msgref++;
1069
1070 return ret;
1071}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301072#ifdef CONFIG_MCL
1073static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1074 uint32_t host_param)
1075{
1076 return host_param;
1077}
1078#else
1079static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1080 uint32_t host_param)
1081{
1082 if (host_param < wmi_pdev_param_max)
1083 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301084
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301085 return WMI_UNAVAILABLE_PARAM;
1086}
1087#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301088/**
1089 * send_pdev_param_cmd_tlv() - set pdev parameters
1090 * @wmi_handle: wmi handle
1091 * @param: pointer to pdev parameter
1092 * @mac_id: radio context
1093 *
1094 * Return: 0 on success, errno on failure
1095 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301096static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301097send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1098 struct pdev_params *param,
1099 uint8_t mac_id)
1100{
Govind Singh67922e82016-04-01 16:48:57 +05301101 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301102 wmi_pdev_set_param_cmd_fixed_param *cmd;
1103 wmi_buf_t buf;
1104 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301105 uint32_t pdev_param;
1106
1107 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1108 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1109 WMI_LOGW("%s: Unavailable param %d\n",
1110 __func__, param->param_id);
1111 return QDF_STATUS_E_INVAL;
1112 }
Govind Singh5eb51532016-03-09 11:34:12 +05301113
1114 buf = wmi_buf_alloc(wmi_handle, len);
1115 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301116 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301117 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301118 }
1119 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1120 WMITLV_SET_HDR(&cmd->tlv_header,
1121 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1122 WMITLV_GET_STRUCT_TLVLEN
1123 (wmi_pdev_set_param_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +05301124 cmd->pdev_id = 0;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301125 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301126 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301127 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301128 param->param_value);
1129 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1130 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301131 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301132 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301133 wmi_buf_free(buf);
1134 }
1135 return ret;
1136}
1137
1138/**
1139 * send_suspend_cmd_tlv() - WMI suspend function
1140 * @param wmi_handle : handle to WMI.
1141 * @param param : pointer to hold suspend parameter
1142 * @mac_id: radio context
1143 *
1144 * Return 0 on success and -ve on failure.
1145 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301146static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301147 struct suspend_params *param,
1148 uint8_t mac_id)
1149{
1150 wmi_pdev_suspend_cmd_fixed_param *cmd;
1151 wmi_buf_t wmibuf;
1152 uint32_t len = sizeof(*cmd);
1153 int32_t ret;
1154
1155 /*
1156 * send the comand to Target to ignore the
1157 * PCIE reset so as to ensure that Host and target
1158 * states are in sync
1159 */
1160 wmibuf = wmi_buf_alloc(wmi_handle, len);
1161 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301162 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301163
1164 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1165 WMITLV_SET_HDR(&cmd->tlv_header,
1166 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1167 WMITLV_GET_STRUCT_TLVLEN
1168 (wmi_pdev_suspend_cmd_fixed_param));
1169 if (param->disable_target_intr)
1170 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1171 else
1172 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1173 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1174 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301175 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301176 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301177 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301178 }
1179
1180 return ret;
1181}
1182
1183/**
1184 * send_resume_cmd_tlv() - WMI resume function
1185 * @param wmi_handle : handle to WMI.
1186 * @mac_id: radio context
1187 *
1188 * Return: 0 on success and -ve on failure.
1189 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301190static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301191 uint8_t mac_id)
1192{
1193 wmi_buf_t wmibuf;
1194 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301195 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301196
1197 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1198 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301199 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301200 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1201 WMITLV_SET_HDR(&cmd->tlv_header,
1202 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1203 WMITLV_GET_STRUCT_TLVLEN
1204 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07001205 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +05301206 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1207 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301208 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301209 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301210 wmi_buf_free(wmibuf);
1211 }
1212
1213 return ret;
1214}
1215
1216/**
1217 * send_wow_enable_cmd_tlv() - WMI wow enable function
1218 * @param wmi_handle : handle to WMI.
1219 * @param param : pointer to hold wow enable parameter
1220 * @mac_id: radio context
1221 *
1222 * Return: 0 on success and -ve on failure.
1223 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301224static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301225 struct wow_cmd_params *param,
1226 uint8_t mac_id)
1227{
1228 wmi_wow_enable_cmd_fixed_param *cmd;
1229 wmi_buf_t buf;
1230 int32_t len;
1231 int32_t ret;
1232
1233 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1234
1235 buf = wmi_buf_alloc(wmi_handle, len);
1236 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301237 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1238 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301239 }
1240 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1241 WMITLV_SET_HDR(&cmd->tlv_header,
1242 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1243 WMITLV_GET_STRUCT_TLVLEN
1244 (wmi_wow_enable_cmd_fixed_param));
1245 cmd->enable = param->enable;
1246 if (param->can_suspend_link)
1247 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1248 else
1249 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001250 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301251
Govind Singhb53420c2016-03-09 14:32:57 +05301252 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301253 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1254 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1255
1256 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1257 WMI_WOW_ENABLE_CMDID);
1258 if (ret)
1259 wmi_buf_free(buf);
1260
1261 return ret;
1262}
1263
1264/**
1265 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301266 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301267 * @peer_addr: peer mac address
1268 * @param: pointer to ap_ps parameter structure
1269 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301270 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301271 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301272static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301273 uint8_t *peer_addr,
1274 struct ap_ps_params *param)
1275{
1276 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1277 wmi_buf_t buf;
1278 int32_t err;
1279
1280 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1281 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301282 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301283 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301284 }
1285 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1286 WMITLV_SET_HDR(&cmd->tlv_header,
1287 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1288 WMITLV_GET_STRUCT_TLVLEN
1289 (wmi_ap_ps_peer_cmd_fixed_param));
1290 cmd->vdev_id = param->vdev_id;
1291 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1292 cmd->param = param->param;
1293 cmd->value = param->value;
1294 err = wmi_unified_cmd_send(wmi_handle, buf,
1295 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1296 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301297 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301298 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301299 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301300 }
1301
1302 return 0;
1303}
1304
1305/**
1306 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301307 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301308 * @peer_addr: peer mac address
1309 * @param: pointer to sta_ps parameter structure
1310 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301311 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301312 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301313static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301314 struct sta_ps_params *param)
1315{
1316 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1317 wmi_buf_t buf;
1318 int32_t len = sizeof(*cmd);
1319
1320 buf = wmi_buf_alloc(wmi_handle, len);
1321 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301322 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301323 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301324 }
1325
1326 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1327 WMITLV_SET_HDR(&cmd->tlv_header,
1328 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1329 WMITLV_GET_STRUCT_TLVLEN
1330 (wmi_sta_powersave_param_cmd_fixed_param));
1331 cmd->vdev_id = param->vdev_id;
1332 cmd->param = param->param;
1333 cmd->value = param->value;
1334
1335 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1336 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301337 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301338 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301339 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301340 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301341 }
1342
1343 return 0;
1344}
1345
1346/**
1347 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301348 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301349 * @param: ponirt to crash inject paramter structure
1350 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301351 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301352 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301353static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301354 struct crash_inject *param)
1355{
1356 int32_t ret = 0;
1357 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1358 uint16_t len = sizeof(*cmd);
1359 wmi_buf_t buf;
1360
1361 buf = wmi_buf_alloc(wmi_handle, len);
1362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301363 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301364 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301365 }
1366
1367 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1368 WMITLV_SET_HDR(&cmd->tlv_header,
1369 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1370 WMITLV_GET_STRUCT_TLVLEN
1371 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1372 cmd->type = param->type;
1373 cmd->delay_time_ms = param->delay_time_ms;
1374
1375 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1376 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301377 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301378 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301379 __func__, ret);
1380 wmi_buf_free(buf);
1381 }
1382
1383 return ret;
1384}
1385
1386/**
1387 * send_dbglog_cmd_tlv() - set debug log level
1388 * @param wmi_handle : handle to WMI.
1389 * @param param : pointer to hold dbglog level parameter
1390 *
1391 * Return: 0 on success and -ve on failure.
1392 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301393 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301394send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1395 struct dbglog_params *dbglog_param)
1396{
1397 wmi_buf_t buf;
1398 wmi_debug_log_config_cmd_fixed_param *configmsg;
1399 A_STATUS status = A_OK;
1400 int32_t i;
1401 int32_t len;
1402 int8_t *buf_ptr;
1403 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1404
1405 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1406
1407 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1408 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1409 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1410 buf = wmi_buf_alloc(wmi_handle, len);
1411 if (buf == NULL)
1412 return A_NO_MEMORY;
1413
1414 configmsg =
1415 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1416 buf_ptr = (int8_t *) configmsg;
1417 WMITLV_SET_HDR(&configmsg->tlv_header,
1418 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1419 WMITLV_GET_STRUCT_TLVLEN
1420 (wmi_debug_log_config_cmd_fixed_param));
1421 configmsg->dbg_log_param = dbglog_param->param;
1422 configmsg->value = dbglog_param->val;
1423 /* Filling in the data part of second tlv -- should
1424 * follow first tlv _ WMI_TLV_HDR_SIZE */
1425 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1426 sizeof
1427 (wmi_debug_log_config_cmd_fixed_param)
1428 + WMI_TLV_HDR_SIZE);
1429 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1430 WMITLV_TAG_ARRAY_UINT32,
1431 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1432 if (dbglog_param->module_id_bitmap) {
1433 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1434 module_id_bitmap_array[i] =
1435 dbglog_param->module_id_bitmap[i];
1436 }
1437 }
1438
1439 status = wmi_unified_cmd_send(wmi_handle, buf,
1440 len, WMI_DBGLOG_CFG_CMDID);
1441
1442 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301443 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301444
1445 return status;
1446}
1447
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301448#ifdef CONFIG_MCL
1449static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1450 uint32_t host_param)
1451{
1452 return host_param;
1453}
1454#else
1455static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1456 uint32_t host_param)
1457{
1458 if (host_param < wmi_vdev_param_max)
1459 return wmi_handle->vdev_param[host_param];
1460
1461 return WMI_UNAVAILABLE_PARAM;
1462}
1463#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301464/**
1465 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1466 * @param wmi_handle : handle to WMI.
1467 * @param macaddr : MAC address
1468 * @param param : pointer to hold vdev set parameter
1469 *
1470 * Return: 0 on success and -ve on failure.
1471 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301472static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301473 struct vdev_set_params *param)
1474{
Govind Singh67922e82016-04-01 16:48:57 +05301475 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301476 wmi_vdev_set_param_cmd_fixed_param *cmd;
1477 wmi_buf_t buf;
1478 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301479 uint32_t vdev_param;
1480
1481 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1482 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1483 WMI_LOGW("%s:Vdev param %d not available", __func__,
1484 param->param_id);
1485 return QDF_STATUS_E_INVAL;
1486
1487 }
Govind Singh5eb51532016-03-09 11:34:12 +05301488
1489 buf = wmi_buf_alloc(wmi_handle, len);
1490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301491 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301492 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301493 }
1494 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1495 WMITLV_SET_HDR(&cmd->tlv_header,
1496 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1497 WMITLV_GET_STRUCT_TLVLEN
1498 (wmi_vdev_set_param_cmd_fixed_param));
1499 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301500 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301501 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301502 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301503 param->if_id, param->param_id, param->param_value);
1504 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1505 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301506 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301507 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301508 wmi_buf_free(buf);
1509 }
1510
1511 return ret;
1512}
1513
1514/**
1515 * send_stats_request_cmd_tlv() - WMI request stats function
1516 * @param wmi_handle : handle to WMI.
1517 * @param macaddr : MAC address
1518 * @param param : pointer to hold stats request parameter
1519 *
1520 * Return: 0 on success and -ve on failure.
1521 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301522static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301523 uint8_t macaddr[IEEE80211_ADDR_LEN],
1524 struct stats_request_params *param)
1525{
Govind Singhd3156eb2016-02-26 17:50:39 +05301526 int32_t ret;
1527 wmi_request_stats_cmd_fixed_param *cmd;
1528 wmi_buf_t buf;
1529 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1530
1531 buf = wmi_buf_alloc(wmi_handle, len);
1532 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301533 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1534 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301535 }
1536
1537 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1538 WMITLV_SET_HDR(&cmd->tlv_header,
1539 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1540 WMITLV_GET_STRUCT_TLVLEN
1541 (wmi_request_stats_cmd_fixed_param));
1542 cmd->stats_id = param->stats_id;
1543 cmd->vdev_id = param->vdev_id;
1544 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1545 WMI_REQUEST_STATS_CMDID);
1546 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301547 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301548 wmi_buf_free(buf);
1549 }
1550
1551 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301552}
1553
Govind Singh87542482016-06-08 19:40:11 +05301554#ifdef CONFIG_WIN
1555/**
1556 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1557 * @param wmi_handle : handle to WMI.
1558 * @param macaddr : MAC address
1559 * @param param : pointer to hold stats request parameter
1560 *
1561 * Return: 0 on success and -ve on failure.
1562 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301563static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301564 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1565{
1566 return 0;
1567}
1568#else
Govind Singh5eb51532016-03-09 11:34:12 +05301569/**
1570 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1571 * @param wmi_handle : handle to WMI.
1572 * @param macaddr : MAC address
1573 * @param param : pointer to hold stats request parameter
1574 *
1575 * Return: 0 on success and -ve on failure.
1576 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301577static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301578 uint8_t macaddr[IEEE80211_ADDR_LEN],
1579 struct packet_enable_params *param)
1580{
1581 return 0;
1582}
Govind Singh87542482016-06-08 19:40:11 +05301583#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301584
Govind Singh87542482016-06-08 19:40:11 +05301585#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301586/**
1587 * send_beacon_send_cmd_tlv() - WMI beacon send function
1588 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301589 * @param param : pointer to hold beacon send cmd parameter
1590 *
1591 * Return: 0 on success and -ve on failure.
1592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301593static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301594 struct beacon_params *param)
1595{
Govind Singhd3156eb2016-02-26 17:50:39 +05301596 int32_t ret;
1597 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1598 wmi_bcn_prb_info *bcn_prb_info;
1599 wmi_buf_t wmi_buf;
1600 uint8_t *buf_ptr;
1601 uint32_t wmi_buf_len;
1602
1603 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1604 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1605 param->tmpl_len_aligned;
1606 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1607 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301608 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301609 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301610 }
1611 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1612 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1613 WMITLV_SET_HDR(&cmd->tlv_header,
1614 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1615 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1616 cmd->vdev_id = param->vdev_id;
1617 cmd->tim_ie_offset = param->tim_ie_offset;
1618 cmd->buf_len = param->tmpl_len;
1619 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1620
1621 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1622 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1623 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1624 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1625 bcn_prb_info->caps = 0;
1626 bcn_prb_info->erp = 0;
1627 buf_ptr += sizeof(wmi_bcn_prb_info);
1628
1629 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1630 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301631 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301632
1633 ret = wmi_unified_cmd_send(wmi_handle,
1634 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1635 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301636 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301637 wmi_buf_free(wmi_buf);
1638 }
Govind Singh5eb51532016-03-09 11:34:12 +05301639 return 0;
1640}
Govind Singh87542482016-06-08 19:40:11 +05301641#else
Sathish Kumarfd347372017-02-13 12:29:09 +05301642static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301643 struct beacon_params *param)
1644{
1645 return 0;
1646}
1647
1648/**
1649 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1650 * @param wmi_handle : handle to WMI.
1651 * @param param : pointer to hold beacon send cmd parameter
1652 *
1653 * Return: 0 on success and -ve on failure.
1654 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301655static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301656 struct beacon_tmpl_params *param)
1657{
1658 int32_t ret;
1659 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1660 wmi_bcn_prb_info *bcn_prb_info;
1661 wmi_buf_t wmi_buf;
1662 uint8_t *buf_ptr;
1663 uint32_t wmi_buf_len;
1664
Sathish Kumar45e991b2017-02-27 10:35:40 +05301665 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301666 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1667 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1668 param->tmpl_len_aligned;
1669 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1670 if (!wmi_buf) {
1671 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1672 return QDF_STATUS_E_NOMEM;
1673 }
1674 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1675 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1676 WMITLV_SET_HDR(&cmd->tlv_header,
1677 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1678 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1679 cmd->vdev_id = param->vdev_id;
1680 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301681 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1682 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301683 cmd->buf_len = param->tmpl_len;
1684 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1685
1686 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1687 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1688 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1689 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1690 bcn_prb_info->caps = 0;
1691 bcn_prb_info->erp = 0;
1692 buf_ptr += sizeof(wmi_bcn_prb_info);
1693
1694 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1695 buf_ptr += WMI_TLV_HDR_SIZE;
1696 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1697
1698 ret = wmi_unified_cmd_send(wmi_handle,
1699 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1700 if (ret) {
1701 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1702 wmi_buf_free(wmi_buf);
1703 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301704
Govind Singh87542482016-06-08 19:40:11 +05301705 return 0;
1706}
1707#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301708
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301709#ifdef CONFIG_MCL
1710static inline void copy_peer_flags_tlv(
1711 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1712 struct peer_assoc_params *param)
1713{
1714 cmd->peer_flags = param->peer_flags;
1715}
1716#else
1717static inline void copy_peer_flags_tlv(
1718 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1719 struct peer_assoc_params *param)
1720{
1721 /*
1722 * The target only needs a subset of the flags maintained in the host.
1723 * Just populate those flags and send it down
1724 */
1725 cmd->peer_flags = 0;
1726
1727 /*
1728 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1729 */
1730 if (param->is_wme_set) {
1731
1732 if (param->qos_flag)
1733 cmd->peer_flags |= WMI_PEER_QOS;
1734 if (param->apsd_flag)
1735 cmd->peer_flags |= WMI_PEER_APSD;
1736 if (param->ht_flag)
1737 cmd->peer_flags |= WMI_PEER_HT;
1738 if (param->bw_40)
1739 cmd->peer_flags |= WMI_PEER_40MHZ;
1740 if (param->bw_80)
1741 cmd->peer_flags |= WMI_PEER_80MHZ;
1742 if (param->bw_160)
1743 cmd->peer_flags |= WMI_PEER_160MHZ;
1744
1745 /* Typically if STBC is enabled for VHT it should be enabled
1746 * for HT as well
1747 **/
1748 if (param->stbc_flag)
1749 cmd->peer_flags |= WMI_PEER_STBC;
1750
1751 /* Typically if LDPC is enabled for VHT it should be enabled
1752 * for HT as well
1753 **/
1754 if (param->ldpc_flag)
1755 cmd->peer_flags |= WMI_PEER_LDPC;
1756
1757 if (param->static_mimops_flag)
1758 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1759 if (param->dynamic_mimops_flag)
1760 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1761 if (param->spatial_mux_flag)
1762 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1763 if (param->vht_flag)
1764 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001765 if (param->he_flag)
1766 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301767 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001768
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301769 /*
1770 * Suppress authorization for all AUTH modes that need 4-way handshake
1771 * (during re-association).
1772 * Authorization will be done for these modes on key installation.
1773 */
1774 if (param->auth_flag)
1775 cmd->peer_flags |= WMI_PEER_AUTH;
1776 if (param->need_ptk_4_way)
1777 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1778 else
1779 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1780 if (param->need_gtk_2_way)
1781 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1782 /* safe mode bypass the 4-way handshake */
1783 if (param->safe_mode_enabled)
1784 cmd->peer_flags &=
1785 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1786 /* Disable AMSDU for station transmit, if user configures it */
1787 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1788 * it
1789 * if (param->amsdu_disable) Add after FW support
1790 **/
1791
1792 /* Target asserts if node is marked HT and all MCS is set to 0.
1793 * Mark the node as non-HT if all the mcs rates are disabled through
1794 * iwpriv
1795 **/
1796 if (param->peer_ht_rates.num_rates == 0)
1797 cmd->peer_flags &= ~WMI_PEER_HT;
1798}
1799#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301800
1801#ifdef CONFIG_MCL
1802static inline void copy_peer_mac_addr_tlv(
1803 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1804 struct peer_assoc_params *param)
1805{
1806 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1807 sizeof(param->peer_macaddr));
1808}
1809#else
1810static inline void copy_peer_mac_addr_tlv(
1811 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1812 struct peer_assoc_params *param)
1813{
1814 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1815}
1816#endif
1817
Govind Singh5eb51532016-03-09 11:34:12 +05301818/**
1819 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1820 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301821 * @param param : pointer to peer assoc parameter
1822 *
1823 * Return: 0 on success and -ve on failure.
1824 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301825static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301826 struct peer_assoc_params *param)
1827{
Govind Singhd3156eb2016-02-26 17:50:39 +05301828 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1829 wmi_vht_rate_set *mcs;
1830 wmi_buf_t buf;
1831 int32_t len;
1832 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301833 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301834 uint32_t peer_legacy_rates_align;
1835 uint32_t peer_ht_rates_align;
1836
1837
1838 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1839 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301840
1841 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301842 (peer_legacy_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301843 WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301844 (peer_ht_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301845 sizeof(wmi_vht_rate_set);
1846
1847 buf = wmi_buf_alloc(wmi_handle, len);
1848 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301849 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301850 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301851 }
1852
1853 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1854 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1855 WMITLV_SET_HDR(&cmd->tlv_header,
1856 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1857 WMITLV_GET_STRUCT_TLVLEN
1858 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301859
Govind Singhd3156eb2016-02-26 17:50:39 +05301860 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301861
Govind Singhd3156eb2016-02-26 17:50:39 +05301862 cmd->peer_new_assoc = param->peer_new_assoc;
1863 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301864
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301865 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301866 copy_peer_mac_addr_tlv(cmd, param);
1867
Govind Singhd3156eb2016-02-26 17:50:39 +05301868 cmd->peer_rate_caps = param->peer_rate_caps;
1869 cmd->peer_caps = param->peer_caps;
1870 cmd->peer_listen_intval = param->peer_listen_intval;
1871 cmd->peer_ht_caps = param->peer_ht_caps;
1872 cmd->peer_max_mpdu = param->peer_max_mpdu;
1873 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301874 cmd->peer_vht_caps = param->peer_vht_caps;
1875 cmd->peer_phymode = param->peer_phymode;
1876
1877 /* Update peer legacy rate information */
1878 buf_ptr += sizeof(*cmd);
1879 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301880 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301881 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301882 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301883 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301884 param->peer_legacy_rates.num_rates);
1885
1886 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001887 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301888 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301889 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301890 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301891 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301892 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301893 param->peer_ht_rates.num_rates);
1894
1895 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001896 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301897 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1898 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1899
1900 cmd->peer_nss = param->peer_nss;
1901 mcs = (wmi_vht_rate_set *) buf_ptr;
1902 if (param->vht_capable) {
1903 mcs->rx_max_rate = param->rx_max_rate;
1904 mcs->rx_mcs_set = param->rx_mcs_set;
1905 mcs->tx_max_rate = param->tx_max_rate;
1906 mcs->tx_mcs_set = param->tx_mcs_set;
1907 }
Kris Muthusamy61fe3692017-02-20 02:35:47 -08001908 /* Update 11ax capabilities */
1909 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1910 cmd->peer_he_ops = param->peer_he_ops;
1911 cmd->peer_he_mcs = param->peer_he_mcs;
1912 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1913 sizeof(param->peer_he_cap_phyinfo));
1914 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1915 sizeof(param->peer_ppet));
Govind Singhd3156eb2016-02-26 17:50:39 +05301916
Govind Singhb53420c2016-03-09 14:32:57 +05301917 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301918 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1919 "nss %d phymode %d peer_mpdu_density %d "
1920 "cmd->peer_vht_caps %x", __func__,
1921 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1922 cmd->peer_rate_caps, cmd->peer_caps,
1923 cmd->peer_listen_intval, cmd->peer_ht_caps,
1924 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1925 cmd->peer_mpdu_density,
1926 cmd->peer_vht_caps);
1927
1928 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1929 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301930 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301931 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301932 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301933 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301934 }
1935
1936 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301937}
1938
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301939/* copy_scan_notify_events() - Helper routine to copy scan notify events
1940 */
1941#ifdef CONFIG_MCL
1942static inline void copy_scan_notify_ev_flags(
1943 wmi_start_scan_cmd_fixed_param * cmd,
1944 struct scan_start_params *params)
1945{
1946 cmd->notify_scan_events = params->notify_scan_events;
1947 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1948}
1949#else
1950static inline void copy_scan_notify_ev_flags(
1951 wmi_start_scan_cmd_fixed_param * cmd,
1952 struct scan_start_params *params)
1953{
1954 cmd->notify_scan_events = WMI_SCAN_EVENT_STARTED |
1955 WMI_SCAN_EVENT_COMPLETED |
1956 WMI_SCAN_EVENT_BSS_CHANNEL |
1957 WMI_SCAN_EVENT_FOREIGN_CHANNEL |
1958 WMI_SCAN_EVENT_DEQUEUED
1959 ;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301960
1961 cmd->scan_ctrl_flags = (params->passive_flag) ?
1962 WMI_SCAN_FLAG_PASSIVE : 0;
1963
1964 if (params->is_strict_pscan_en)
1965 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301966
1967 if (params->is_phy_error)
1968 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301969
1970 if (params->half_rate)
1971 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
1972
1973 if (params->quarter_rate)
1974 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
1975
1976 if (params->is_phy_error)
1977 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
1978
1979 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
1980 /* add cck rates if required */
1981 if (params->add_cck_rates)
1982 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
1983 /** It enables the Channel stat event indication to host */
1984 if (params->chan_stat_enable)
1985 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
1986 if (params->add_bcast_probe_reqd)
1987 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
1988 /* off channel TX control */
1989 if (params->offchan_tx_mgmt)
1990 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
1991 if (params->offchan_tx_data)
1992 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301993}
1994#endif
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05301995
1996
1997/* scan_copy_ie_buffer() - Copy scan ie_data */
1998#ifndef CONFIG_MCL
1999static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
2000 struct scan_start_params *params)
2001{
2002 qdf_mem_copy(buf_ptr, params->ie_data, params->ie_len);
2003}
2004#else
2005static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
2006 struct scan_start_params *params)
2007{
2008 qdf_mem_copy(buf_ptr,
2009 (uint8_t *) params->ie_base +
2010 (params->uie_fieldOffset), params->ie_len);
2011}
2012#endif
2013
Govind Singh5eb51532016-03-09 11:34:12 +05302014/**
2015 * send_scan_start_cmd_tlv() - WMI scan start function
2016 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302017 * @param param : pointer to hold scan start cmd parameter
2018 *
2019 * Return: 0 on success and -ve on failure.
2020 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302021static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302022 struct scan_start_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302023{
Govind Singhd3156eb2016-02-26 17:50:39 +05302024 int32_t ret = 0;
2025 int32_t i;
2026 wmi_buf_t wmi_buf;
2027 wmi_start_scan_cmd_fixed_param *cmd;
2028 uint8_t *buf_ptr;
2029 uint32_t *tmp_ptr;
2030 wmi_ssid *ssid = NULL;
2031 wmi_mac_addr *bssid;
2032 int len = sizeof(*cmd);
2033
2034 /* Length TLV placeholder for array of uint32_t */
2035 len += WMI_TLV_HDR_SIZE;
2036 /* calculate the length of buffer required */
2037 if (params->num_chan)
2038 len += params->num_chan * sizeof(uint32_t);
2039
2040 /* Length TLV placeholder for array of wmi_ssid structures */
2041 len += WMI_TLV_HDR_SIZE;
2042 if (params->num_ssids)
2043 len += params->num_ssids * sizeof(wmi_ssid);
2044
2045 /* Length TLV placeholder for array of wmi_mac_addr structures */
2046 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302047 if (params->num_bssid)
2048 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302049
2050 /* Length TLV placeholder for array of bytes */
2051 len += WMI_TLV_HDR_SIZE;
2052 if (params->ie_len)
2053 len += roundup(params->ie_len, sizeof(uint32_t));
2054
2055 /* Allocate the memory */
2056 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2057 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302058 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302059 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302060 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302061 }
2062 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2063 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2064 WMITLV_SET_HDR(&cmd->tlv_header,
2065 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2066 WMITLV_GET_STRUCT_TLVLEN
2067 (wmi_start_scan_cmd_fixed_param));
2068
2069 cmd->scan_id = params->scan_id;
2070 cmd->scan_req_id = params->scan_req_id;
2071 cmd->vdev_id = params->vdev_id;
2072 cmd->scan_priority = params->scan_priority;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302073 copy_scan_notify_ev_flags(cmd, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05302074 cmd->dwell_time_active = params->dwell_time_active;
2075 cmd->dwell_time_passive = params->dwell_time_passive;
2076 cmd->min_rest_time = params->min_rest_time;
2077 cmd->max_rest_time = params->max_rest_time;
2078 cmd->repeat_probe_time = params->repeat_probe_time;
2079 cmd->probe_spacing_time = params->probe_spacing_time;
2080 cmd->idle_time = params->idle_time;
2081 cmd->max_scan_time = params->max_scan_time;
2082 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302083 cmd->burst_duration = params->burst_duration;
2084 cmd->num_chan = params->num_chan;
2085 cmd->num_bssid = params->num_bssid;
2086 cmd->num_ssids = params->num_ssids;
2087 cmd->ie_len = params->ie_len;
2088 cmd->n_probes = params->n_probes;
2089 buf_ptr += sizeof(*cmd);
2090 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2091 for (i = 0; i < params->num_chan; ++i)
2092 tmp_ptr[i] = params->chan_list[i];
2093
2094 WMITLV_SET_HDR(buf_ptr,
2095 WMITLV_TAG_ARRAY_UINT32,
2096 (params->num_chan * sizeof(uint32_t)));
2097 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302098 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302099 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302100 goto error;
2101 }
2102
2103 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2104 (params->num_ssids * sizeof(wmi_ssid)));
2105
2106 if (params->num_ssids) {
2107 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2108 for (i = 0; i < params->num_ssids; ++i) {
2109 ssid->ssid_len = params->ssid[i].length;
Govind Singhb53420c2016-03-09 14:32:57 +05302110 qdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302111 params->ssid[i].length);
2112 ssid++;
2113 }
2114 }
2115 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2116
2117 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2118 (params->num_bssid * sizeof(wmi_mac_addr)));
2119 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302120#if CONFIG_MCL
Govind Singhd3156eb2016-02-26 17:50:39 +05302121 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302122#else
2123 if (params->num_bssid) {
2124 for (i = 0; i < params->num_bssid; ++i) {
2125 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->bssid_list[i],
2126 bssid);
2127 bssid++;
2128 }
2129 }
2130#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302131 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
2132
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302133 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2134 roundup(params->ie_len, sizeof(uint32_t)));
Govind Singhd3156eb2016-02-26 17:50:39 +05302135 if (params->ie_len) {
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302136 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05302137 }
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302138 buf_ptr += WMI_TLV_HDR_SIZE + roundup(params->ie_len, sizeof(uint32_t));
Govind Singhd3156eb2016-02-26 17:50:39 +05302139
2140 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
2141 len, WMI_START_SCAN_CMDID);
2142 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302143 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302144 wmi_buf_free(wmi_buf);
2145 }
2146 return ret;
2147error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302148 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302149 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302150}
2151
2152/**
2153 * send_scan_stop_cmd_tlv() - WMI scan start function
2154 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302155 * @param param : pointer to hold scan start cmd parameter
2156 *
2157 * Return: 0 on success and -ve on failure.
2158 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302159static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302160 struct scan_stop_params *param)
2161{
Govind Singhd3156eb2016-02-26 17:50:39 +05302162 wmi_stop_scan_cmd_fixed_param *cmd;
2163 int ret;
2164 int len = sizeof(*cmd);
2165 wmi_buf_t wmi_buf;
2166
2167 /* Allocate the memory */
2168 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2169 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302170 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302171 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302172 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302173 goto error;
2174 }
2175
2176 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2177 WMITLV_SET_HDR(&cmd->tlv_header,
2178 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2179 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2180 cmd->vdev_id = param->vdev_id;
2181 cmd->requestor = param->requestor;
2182 cmd->scan_id = param->scan_id;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05302183 cmd->pdev_id = param->pdev_id;
Govind Singhd3156eb2016-02-26 17:50:39 +05302184 /* stop the scan with the corresponding scan_id */
2185 cmd->req_type = param->req_type;
2186 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
2187 len, WMI_STOP_SCAN_CMDID);
2188 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302189 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302190 wmi_buf_free(wmi_buf);
2191 }
2192
2193error:
2194 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302195}
2196
Govind Singh87542482016-06-08 19:40:11 +05302197#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302198/**
2199 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2200 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302201 * @param param : pointer to hold scan channel list parameter
2202 *
2203 * Return: 0 on success and -ve on failure.
2204 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302205static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302206 struct scan_chan_list_params *chan_list)
2207{
2208 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302209 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302210 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302211 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302212 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302213 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302214 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2215
2216 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2217 buf = wmi_buf_alloc(wmi_handle, len);
2218 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302219 WMI_LOGE("Failed to allocate memory");
2220 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302221 goto end;
2222 }
2223
2224 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2225 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2226 WMITLV_SET_HDR(&cmd->tlv_header,
2227 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2228 WMITLV_GET_STRUCT_TLVLEN
2229 (wmi_scan_chan_list_cmd_fixed_param));
2230
Govind Singhb53420c2016-03-09 14:32:57 +05302231 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302232
2233 cmd->num_scan_chans = chan_list->num_scan_chans;
2234 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2235 WMITLV_TAG_ARRAY_STRUC,
2236 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302237 chan_info = (wmi_channel_param *)
2238 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302239 tchan_info = chan_list->chan_info;
2240
2241 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2242 WMITLV_SET_HDR(&chan_info->tlv_header,
2243 WMITLV_TAG_STRUC_wmi_channel,
2244 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2245 chan_info->mhz = tchan_info->mhz;
2246 chan_info->band_center_freq1 =
2247 tchan_info->band_center_freq1;
2248 chan_info->band_center_freq2 =
2249 tchan_info->band_center_freq2;
2250 chan_info->info = tchan_info->info;
2251 chan_info->reg_info_1 = tchan_info->reg_info_1;
2252 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302253 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302254
2255 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2256 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2257 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2258 tchan_info++;
2259 chan_info++;
2260 }
2261
Govind Singh67922e82016-04-01 16:48:57 +05302262 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singhd3156eb2016-02-26 17:50:39 +05302263 WMI_SCAN_CHAN_LIST_CMDID);
2264
Govind Singh67922e82016-04-01 16:48:57 +05302265 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302266 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302267 wmi_buf_free(buf);
2268 }
Govind Singh67922e82016-04-01 16:48:57 +05302269
Govind Singhd3156eb2016-02-26 17:50:39 +05302270end:
Govind Singhb53420c2016-03-09 14:32:57 +05302271 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302272}
Govind Singh87542482016-06-08 19:40:11 +05302273#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302274static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302275 struct scan_chan_list_params *chan_list)
2276{
2277 wmi_buf_t buf;
2278 QDF_STATUS qdf_status;
2279 wmi_scan_chan_list_cmd_fixed_param *cmd;
2280 int i;
2281 uint8_t *buf_ptr;
2282 wmi_channel *chan_info;
2283 struct channel_param *tchan_info;
2284 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302285
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302286 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302287 buf = wmi_buf_alloc(wmi_handle, len);
2288 if (!buf) {
2289 WMI_LOGE("Failed to allocate memory");
2290 qdf_status = QDF_STATUS_E_NOMEM;
2291 goto end;
2292 }
2293
2294 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2295 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2296 WMITLV_SET_HDR(&cmd->tlv_header,
2297 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2298 WMITLV_GET_STRUCT_TLVLEN
2299 (wmi_scan_chan_list_cmd_fixed_param));
2300
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302301 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302302
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05302303 cmd->pdev_id = chan_list->pdev_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302304 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302305 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2306 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302307 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302308 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2309 tchan_info = &(chan_list->ch_param[0]);
2310
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302311 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302312 WMITLV_SET_HDR(&chan_info->tlv_header,
2313 WMITLV_TAG_STRUC_wmi_channel,
2314 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2315 chan_info->mhz = tchan_info->mhz;
2316 chan_info->band_center_freq1 =
2317 tchan_info->cfreq1;
2318 chan_info->band_center_freq2 =
2319 tchan_info->cfreq2;
2320
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302321 if (tchan_info->is_chan_passive)
2322 WMI_SET_CHANNEL_FLAG(chan_info,
2323 WMI_CHAN_FLAG_PASSIVE);
2324
2325 if (tchan_info->allow_vht)
2326 WMI_SET_CHANNEL_FLAG(chan_info,
2327 WMI_CHAN_FLAG_ALLOW_VHT);
2328 else if (tchan_info->allow_ht)
2329 WMI_SET_CHANNEL_FLAG(chan_info,
2330 WMI_CHAN_FLAG_ALLOW_HT);
2331 WMI_SET_CHANNEL_MODE(chan_info,
2332 tchan_info->phy_mode);
2333
2334 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2335 * after FW support
2336 */
2337
2338 /* also fill in power information */
2339 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2340 tchan_info->minpower);
2341 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2342 tchan_info->maxpower);
2343 WMI_SET_CHANNEL_REG_POWER(chan_info,
2344 tchan_info->maxregpower);
2345 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2346 tchan_info->antennamax);
2347 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2348 tchan_info->reg_class_id);
2349
Govind Singh87542482016-06-08 19:40:11 +05302350 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2351
Govind Singh87542482016-06-08 19:40:11 +05302352 tchan_info++;
2353 chan_info++;
2354 }
2355
2356 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
2357 WMI_SCAN_CHAN_LIST_CMDID);
2358
2359 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2360 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2361 wmi_buf_free(buf);
2362 }
2363
2364end:
2365 return qdf_status;
2366}
2367#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302368/**
2369 * send_mgmt_cmd_tlv() - WMI scan start function
2370 * @wmi_handle : handle to WMI.
2371 * @param : pointer to hold mgmt cmd parameter
2372 *
2373 * Return: 0 on success and -ve on failure.
2374 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302375static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302376 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302377{
Govind Singh427ee5a2016-02-26 18:09:36 +05302378 wmi_buf_t buf;
2379 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2380 int32_t cmd_len;
2381 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302382 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302383 uint8_t *bufp;
2384 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2385 mgmt_tx_dl_frm_len;
2386
2387 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2388 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2389
2390 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2391 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302392 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2393 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302394 }
2395
2396 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2397 bufp = (uint8_t *) cmd;
2398 WMITLV_SET_HDR(&cmd->tlv_header,
2399 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2400 WMITLV_GET_STRUCT_TLVLEN
2401 (wmi_mgmt_tx_send_cmd_fixed_param));
2402
2403 cmd->vdev_id = param->vdev_id;
2404
Govind Singh224a7312016-06-21 14:33:26 +05302405 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302406 cmd->chanfreq = param->chanfreq;
2407 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2408 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2409 sizeof(uint32_t)));
2410 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302411 qdf_mem_copy(bufp, param->pdata, bufp_len);
2412 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2413 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302414 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002415#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302416 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2417#endif
2418 cmd->frame_len = param->frm_len;
2419 cmd->buf_len = bufp_len;
2420
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002421 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002422 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002423
Govind Singh427ee5a2016-02-26 18:09:36 +05302424 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2425 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302426 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302427 goto err1;
2428 }
Govind Singhb53420c2016-03-09 14:32:57 +05302429 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302430
2431err1:
2432 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302433 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302434}
2435
2436/**
2437 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2438 * @wmi_handle: wmi handle
2439 * @param_value: parameter value
2440 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302441 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302442 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302443static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302444 uint32_t param_value)
2445{
Govind Singh67922e82016-04-01 16:48:57 +05302446 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302447 wmi_modem_power_state_cmd_param *cmd;
2448 wmi_buf_t buf;
2449 uint16_t len = sizeof(*cmd);
2450
2451 buf = wmi_buf_alloc(wmi_handle, len);
2452 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302453 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302454 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302455 }
2456 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2457 WMITLV_SET_HDR(&cmd->tlv_header,
2458 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2459 WMITLV_GET_STRUCT_TLVLEN
2460 (wmi_modem_power_state_cmd_param));
2461 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302462 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302463 param_value);
2464 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2465 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302466 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302467 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302468 wmi_buf_free(buf);
2469 }
Govind Singh67922e82016-04-01 16:48:57 +05302470
Govind Singh427ee5a2016-02-26 18:09:36 +05302471 return ret;
2472}
2473
2474/**
2475 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2476 * @wmi_handle: wmi handle
2477 * @vdev_id: vdev id
2478 * @val: value
2479 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302480 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302481 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302482static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302483 uint32_t vdev_id, uint8_t val)
2484{
2485 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2486 wmi_buf_t buf;
2487 int32_t len = sizeof(*cmd);
2488
Govind Singhb53420c2016-03-09 14:32:57 +05302489 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302490
2491 buf = wmi_buf_alloc(wmi_handle, len);
2492 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302493 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302494 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302495 }
2496 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2497 WMITLV_SET_HDR(&cmd->tlv_header,
2498 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2499 WMITLV_GET_STRUCT_TLVLEN
2500 (wmi_sta_powersave_mode_cmd_fixed_param));
2501 cmd->vdev_id = vdev_id;
2502 if (val)
2503 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2504 else
2505 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2506
2507 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2508 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302509 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302510 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302511 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302512 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302513 }
Govind Singh5eb51532016-03-09 11:34:12 +05302514 return 0;
2515}
2516
Govind Singh427ee5a2016-02-26 18:09:36 +05302517/**
2518 * send_set_mimops_cmd_tlv() - set MIMO powersave
2519 * @wmi_handle: wmi handle
2520 * @vdev_id: vdev id
2521 * @value: value
2522 *
Govind Singhb53420c2016-03-09 14:32:57 +05302523 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302524 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302525static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302526 uint8_t vdev_id, int value)
2527{
Govind Singh67922e82016-04-01 16:48:57 +05302528 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302529 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2530 wmi_buf_t buf;
2531 uint16_t len = sizeof(*cmd);
2532
2533 buf = wmi_buf_alloc(wmi_handle, len);
2534 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302535 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302536 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302537 }
2538 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2539 WMITLV_SET_HDR(&cmd->tlv_header,
2540 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2541 WMITLV_GET_STRUCT_TLVLEN
2542 (wmi_sta_smps_force_mode_cmd_fixed_param));
2543
2544 cmd->vdev_id = vdev_id;
2545
Houston Hoffmanb5168052016-04-14 02:18:01 -07002546 /* WMI_SMPS_FORCED_MODE values do not directly map
2547 * to SM power save values defined in the specification.
2548 * Make sure to send the right mapping.
2549 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302550 switch (value) {
2551 case 0:
2552 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2553 break;
2554 case 1:
2555 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2556 break;
2557 case 2:
2558 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2559 break;
2560 case 3:
2561 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2562 break;
2563 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302564 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2565 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302566 }
2567
Govind Singhb53420c2016-03-09 14:32:57 +05302568 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302569
2570 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2571 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302572 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302573 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302574 wmi_buf_free(buf);
2575 }
2576
2577 return ret;
2578}
2579
2580/**
2581 * send_set_smps_params_cmd_tlv() - set smps params
2582 * @wmi_handle: wmi handle
2583 * @vdev_id: vdev id
2584 * @value: value
2585 *
Govind Singhb53420c2016-03-09 14:32:57 +05302586 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302587 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302588static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302589 int value)
2590{
Govind Singh67922e82016-04-01 16:48:57 +05302591 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302592 wmi_sta_smps_param_cmd_fixed_param *cmd;
2593 wmi_buf_t buf;
2594 uint16_t len = sizeof(*cmd);
2595
2596 buf = wmi_buf_alloc(wmi_handle, len);
2597 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302598 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302599 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302600 }
2601 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2602 WMITLV_SET_HDR(&cmd->tlv_header,
2603 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2604 WMITLV_GET_STRUCT_TLVLEN
2605 (wmi_sta_smps_param_cmd_fixed_param));
2606
2607 cmd->vdev_id = vdev_id;
2608 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2609 cmd->param =
2610 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2611
Govind Singhb53420c2016-03-09 14:32:57 +05302612 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302613 cmd->param);
2614
2615 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2616 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302617 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302618 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302619 wmi_buf_free(buf);
2620 }
2621
2622 return ret;
2623}
2624
2625/**
2626 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2627 * @wmi_handle: wmi handle
2628 * @noa: p2p power save parameters
2629 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302630 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302631 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302632static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302633 struct p2p_ps_params *noa)
2634{
2635 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2636 wmi_p2p_noa_descriptor *noa_discriptor;
2637 wmi_buf_t buf;
2638 uint8_t *buf_ptr;
2639 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302640 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302641 uint32_t duration;
2642
Govind Singhb53420c2016-03-09 14:32:57 +05302643 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302644 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2645 buf = wmi_buf_alloc(wmi_handle, len);
2646 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302647 WMI_LOGE("Failed to allocate memory");
2648 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302649 goto end;
2650 }
2651
2652 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2653 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2654 WMITLV_SET_HDR(&cmd->tlv_header,
2655 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2656 WMITLV_GET_STRUCT_TLVLEN
2657 (wmi_p2p_set_noa_cmd_fixed_param));
2658 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2659 cmd->vdev_id = noa->session_id;
2660 cmd->enable = (duration) ? true : false;
2661 cmd->num_noa = 1;
2662
2663 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2664 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2665 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2666 sizeof
2667 (wmi_p2p_set_noa_cmd_fixed_param)
2668 + WMI_TLV_HDR_SIZE);
2669 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2670 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2671 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2672 noa_discriptor->type_count = noa->count;
2673 noa_discriptor->duration = duration;
2674 noa_discriptor->interval = noa->interval;
2675 noa_discriptor->start_time = 0;
2676
Govind Singhb53420c2016-03-09 14:32:57 +05302677 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302678 cmd->vdev_id, noa->count, noa_discriptor->duration,
2679 noa->interval);
2680 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2681 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302682 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302683 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302684 wmi_buf_free(buf);
2685 }
2686
2687end:
Govind Singhb53420c2016-03-09 14:32:57 +05302688 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302689 return status;
2690}
2691
2692
2693/**
2694 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2695 * @wmi_handle: wmi handle
2696 * @noa: p2p opp power save parameters
2697 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302698 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302699 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302700static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302701 struct p2p_ps_params *oppps)
2702{
2703 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2704 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302705 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302706
Govind Singhb53420c2016-03-09 14:32:57 +05302707 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302708 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2709 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302710 WMI_LOGE("Failed to allocate memory");
2711 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302712 goto end;
2713 }
2714
2715 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2716 WMITLV_SET_HDR(&cmd->tlv_header,
2717 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2718 WMITLV_GET_STRUCT_TLVLEN
2719 (wmi_p2p_set_oppps_cmd_fixed_param));
2720 cmd->vdev_id = oppps->session_id;
2721 if (oppps->ctwindow)
2722 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2723
2724 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302725 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302726 cmd->vdev_id, oppps->ctwindow);
2727 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2728 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302729 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302730 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302731 wmi_buf_free(buf);
2732 }
2733
2734end:
Govind Singhb53420c2016-03-09 14:32:57 +05302735 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302736 return status;
2737}
2738
2739/**
2740 * send_get_temperature_cmd_tlv() - get pdev temperature req
2741 * @wmi_handle: wmi handle
2742 *
Govind Singhb53420c2016-03-09 14:32:57 +05302743 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302744 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302745static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05302746{
2747 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
2748 wmi_buf_t wmi_buf;
2749 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
2750 uint8_t *buf_ptr;
2751
2752 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05302753 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
2754 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05302755 }
2756
2757 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2758 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302759 WMI_LOGE(FL("wmi_buf_alloc failed"));
2760 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302761 }
2762
2763 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2764
2765 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
2766 WMITLV_SET_HDR(&cmd->tlv_header,
2767 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
2768 WMITLV_GET_STRUCT_TLVLEN
2769 (wmi_pdev_get_temperature_cmd_fixed_param));
2770
2771 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
2772 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302773 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05302774 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302775 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302776 }
Govind Singh2edc80f2016-03-01 15:30:53 +05302777
Govind Singhb53420c2016-03-09 14:32:57 +05302778 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302779}
2780
2781/**
2782 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
2783 * @wmi_handle: wmi handle
2784 * @vdevid: vdev id
2785 * @peer_addr: peer mac address
2786 * @auto_triggerparam: auto trigger parameters
2787 * @num_ac: number of access category
2788 *
2789 * This function sets the trigger
2790 * uapsd params such as service interval, delay interval
2791 * and suspend interval which will be used by the firmware
2792 * to send trigger frames periodically when there is no
2793 * traffic on the transmit side.
2794 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302795 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302796 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302797static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302798 struct sta_uapsd_trig_params *param)
2799{
2800 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302801 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302802 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
2803 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
2804 uint32_t i;
2805 wmi_buf_t buf;
2806 uint8_t *buf_ptr;
2807
2808 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2809 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302810 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302811 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302812 }
2813
2814 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2815 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
2816 WMITLV_SET_HDR(&cmd->tlv_header,
2817 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
2818 WMITLV_GET_STRUCT_TLVLEN
2819 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
2820 cmd->vdev_id = param->vdevid;
2821 cmd->num_ac = param->num_ac;
2822 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
2823
2824 /* TLV indicating array of structures to follow */
2825 buf_ptr += sizeof(*cmd);
2826 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
2827
2828 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302829 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302830
2831 /*
2832 * Update tag and length for uapsd auto trigger params (this will take
2833 * care of updating tag and length if it is not pre-filled by caller).
2834 */
2835 for (i = 0; i < param->num_ac; i++) {
2836 WMITLV_SET_HDR((buf_ptr +
2837 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
2838 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
2839 WMITLV_GET_STRUCT_TLVLEN
2840 (wmi_sta_uapsd_auto_trig_param));
2841 }
2842
2843 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2844 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302845 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302846 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302847 wmi_buf_free(buf);
2848 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05302849
Govind Singh427ee5a2016-02-26 18:09:36 +05302850 return ret;
2851}
2852
Govind Singh2edc80f2016-03-01 15:30:53 +05302853/**
2854 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
2855 * @wmi_handle: pointer to the wmi handle
2856 * @utc: pointer to the UTC time struct
2857 *
2858 * Return: 0 on succes
2859 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302860static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302861 struct ocb_utc_param *utc)
2862{
Govind Singh67922e82016-04-01 16:48:57 +05302863 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302864 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
2865 uint8_t *buf_ptr;
2866 uint32_t len, i;
2867 wmi_buf_t buf;
2868
2869 len = sizeof(*cmd);
2870 buf = wmi_buf_alloc(wmi_handle, len);
2871 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302872 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302873 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302874 }
2875
2876 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2877 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
2878 WMITLV_SET_HDR(&cmd->tlv_header,
2879 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
2880 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
2881 cmd->vdev_id = utc->vdev_id;
2882
2883 for (i = 0; i < SIZE_UTC_TIME; i++)
2884 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
2885
2886 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
2887 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
2888
2889 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2890 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302891 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302892 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302893 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302894 }
2895
Govind Singh67922e82016-04-01 16:48:57 +05302896 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302897}
2898
2899/**
2900 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
2901 * frames on a channel
2902 * @wmi_handle: pointer to the wmi handle
2903 * @timing_advert: pointer to the timing advertisement struct
2904 *
2905 * Return: 0 on succes
2906 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302907static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302908 struct ocb_timing_advert_param *timing_advert)
2909{
Govind Singh67922e82016-04-01 16:48:57 +05302910 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302911 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
2912 uint8_t *buf_ptr;
2913 uint32_t len, len_template;
2914 wmi_buf_t buf;
2915
2916 len = sizeof(*cmd) +
2917 WMI_TLV_HDR_SIZE;
2918
2919 len_template = timing_advert->template_length;
2920 /* Add padding to the template if needed */
2921 if (len_template % 4 != 0)
2922 len_template += 4 - (len_template % 4);
2923 len += len_template;
2924
2925 buf = wmi_buf_alloc(wmi_handle, len);
2926 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302927 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302928 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302929 }
2930
2931 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2932 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
2933 WMITLV_SET_HDR(&cmd->tlv_header,
2934 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
2935 WMITLV_GET_STRUCT_TLVLEN(
2936 wmi_ocb_start_timing_advert_cmd_fixed_param));
2937 cmd->vdev_id = timing_advert->vdev_id;
2938 cmd->repeat_rate = timing_advert->repeat_rate;
2939 cmd->channel_freq = timing_advert->chan_freq;
2940 cmd->timestamp_offset = timing_advert->timestamp_offset;
2941 cmd->time_value_offset = timing_advert->time_value_offset;
2942 cmd->timing_advert_template_length = timing_advert->template_length;
2943 buf_ptr += sizeof(*cmd);
2944
2945 /* Add the timing advert template */
2946 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2947 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05302948 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05302949 (uint8_t *)timing_advert->template_value,
2950 timing_advert->template_length);
2951
2952 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2953 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302954 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302955 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302956 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302957 }
2958
Govind Singh67922e82016-04-01 16:48:57 +05302959 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302960}
2961
2962/**
2963 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
2964 * on a channel
2965 * @wmi_handle: pointer to the wmi handle
2966 * @timing_advert: pointer to the timing advertisement struct
2967 *
2968 * Return: 0 on succes
2969 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302970static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302971 struct ocb_timing_advert_param *timing_advert)
2972{
Govind Singh67922e82016-04-01 16:48:57 +05302973 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302974 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
2975 uint8_t *buf_ptr;
2976 uint32_t len;
2977 wmi_buf_t buf;
2978
2979 len = sizeof(*cmd);
2980 buf = wmi_buf_alloc(wmi_handle, len);
2981 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302982 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302983 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302984 }
2985
2986 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2987 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
2988 WMITLV_SET_HDR(&cmd->tlv_header,
2989 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
2990 WMITLV_GET_STRUCT_TLVLEN(
2991 wmi_ocb_stop_timing_advert_cmd_fixed_param));
2992 cmd->vdev_id = timing_advert->vdev_id;
2993 cmd->channel_freq = timing_advert->chan_freq;
2994
2995 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2996 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302997 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302998 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302999 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303000 }
3001
Govind Singh67922e82016-04-01 16:48:57 +05303002 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303003}
3004
3005/**
3006 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3007 * @wmi_handle: pointer to the wmi handle
3008 * @request: pointer to the request
3009 *
3010 * Return: 0 on succes
3011 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303012static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303013 uint8_t vdev_id)
3014{
Govind Singhb53420c2016-03-09 14:32:57 +05303015 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303016 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3017 uint8_t *buf_ptr;
3018 wmi_buf_t buf;
3019 int32_t len;
3020
3021 len = sizeof(*cmd);
3022 buf = wmi_buf_alloc(wmi_handle, len);
3023 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303024 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303025 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303026 }
3027 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3028
3029 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303030 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303031 WMITLV_SET_HDR(&cmd->tlv_header,
3032 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3033 WMITLV_GET_STRUCT_TLVLEN(
3034 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3035 cmd->vdev_id = vdev_id;
3036
3037 /* Send the WMI command */
3038 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3039 WMI_OCB_GET_TSF_TIMER_CMDID);
3040 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303041 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303042 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303043 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303044 }
3045
Govind Singh67922e82016-04-01 16:48:57 +05303046 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303047}
3048
3049/**
3050 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3051 * @wmi_handle: pointer to the wmi handle
3052 * @get_stats_param: pointer to the dcc stats
3053 *
3054 * Return: 0 on succes
3055 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303056static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303057 struct dcc_get_stats_param *get_stats_param)
3058{
Govind Singh67922e82016-04-01 16:48:57 +05303059 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303060 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3061 wmi_dcc_channel_stats_request *channel_stats_array;
3062 wmi_buf_t buf;
3063 uint8_t *buf_ptr;
3064 uint32_t len;
3065 uint32_t i;
3066
3067 /* Validate the input */
3068 if (get_stats_param->request_array_len !=
3069 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303070 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303071 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303072 }
3073
3074 /* Allocate memory for the WMI command */
3075 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3076 get_stats_param->request_array_len;
3077
3078 buf = wmi_buf_alloc(wmi_handle, len);
3079 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303080 WMI_LOGE(FL("wmi_buf_alloc failed"));
3081 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303082 }
3083
3084 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303085 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303086
3087 /* Populate the WMI command */
3088 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3089 buf_ptr += sizeof(*cmd);
3090
3091 WMITLV_SET_HDR(&cmd->tlv_header,
3092 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3093 WMITLV_GET_STRUCT_TLVLEN(
3094 wmi_dcc_get_stats_cmd_fixed_param));
3095 cmd->vdev_id = get_stats_param->vdev_id;
3096 cmd->num_channels = get_stats_param->channel_count;
3097
3098 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3099 get_stats_param->request_array_len);
3100 buf_ptr += WMI_TLV_HDR_SIZE;
3101
3102 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303103 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303104 get_stats_param->request_array_len);
3105 for (i = 0; i < cmd->num_channels; i++)
3106 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3107 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3108 WMITLV_GET_STRUCT_TLVLEN(
3109 wmi_dcc_channel_stats_request));
3110
3111 /* Send the WMI command */
3112 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3113 WMI_DCC_GET_STATS_CMDID);
3114
Govind Singh67922e82016-04-01 16:48:57 +05303115 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303116 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303117 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303118 }
3119
Govind Singh67922e82016-04-01 16:48:57 +05303120 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303121}
3122
3123/**
3124 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3125 * @wmi_handle: pointer to the wmi handle
3126 * @vdev_id: vdev id
3127 * @dcc_stats_bitmap: dcc status bitmap
3128 *
3129 * Return: 0 on succes
3130 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303131static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303132 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3133{
Govind Singh67922e82016-04-01 16:48:57 +05303134 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303135 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3136 wmi_buf_t buf;
3137 uint8_t *buf_ptr;
3138 uint32_t len;
3139
3140 /* Allocate memory for the WMI command */
3141 len = sizeof(*cmd);
3142
3143 buf = wmi_buf_alloc(wmi_handle, len);
3144 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303145 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303146 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303147 }
3148
3149 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303150 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303151
3152 /* Populate the WMI command */
3153 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3154
3155 WMITLV_SET_HDR(&cmd->tlv_header,
3156 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3157 WMITLV_GET_STRUCT_TLVLEN(
3158 wmi_dcc_clear_stats_cmd_fixed_param));
3159 cmd->vdev_id = vdev_id;
3160 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3161
3162 /* Send the WMI command */
3163 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3164 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303165 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303166 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303167 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303168 }
3169
Govind Singh67922e82016-04-01 16:48:57 +05303170 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303171}
3172
3173/**
3174 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3175 * @wmi_handle: pointer to the wmi handle
3176 * @update_ndl_param: pointer to the request parameters
3177 *
3178 * Return: 0 on success
3179 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303180static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303181 struct dcc_update_ndl_param *update_ndl_param)
3182{
Govind Singhb53420c2016-03-09 14:32:57 +05303183 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303184 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3185 wmi_dcc_ndl_chan *ndl_chan_array;
3186 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3187 uint32_t active_state_count;
3188 wmi_buf_t buf;
3189 uint8_t *buf_ptr;
3190 uint32_t len;
3191 uint32_t i;
3192
3193 /* validate the input */
3194 if (update_ndl_param->dcc_ndl_chan_list_len !=
3195 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303196 WMI_LOGE(FL("Invalid parameter"));
3197 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303198 }
3199 active_state_count = 0;
3200 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3201 for (i = 0; i < update_ndl_param->channel_count; i++)
3202 active_state_count +=
3203 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3204 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3205 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303206 WMI_LOGE(FL("Invalid parameter"));
3207 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303208 }
3209
3210 /* Allocate memory for the WMI command */
3211 len = sizeof(*cmd) +
3212 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3213 WMI_TLV_HDR_SIZE +
3214 update_ndl_param->dcc_ndl_active_state_list_len;
3215
3216 buf = wmi_buf_alloc(wmi_handle, len);
3217 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303218 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303219 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303220 }
3221
3222 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303223 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303224
3225 /* Populate the WMI command */
3226 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3227 buf_ptr += sizeof(*cmd);
3228
3229 WMITLV_SET_HDR(&cmd->tlv_header,
3230 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3231 WMITLV_GET_STRUCT_TLVLEN(
3232 wmi_dcc_update_ndl_cmd_fixed_param));
3233 cmd->vdev_id = update_ndl_param->vdev_id;
3234 cmd->num_channel = update_ndl_param->channel_count;
3235
3236 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3237 update_ndl_param->dcc_ndl_chan_list_len);
3238 buf_ptr += WMI_TLV_HDR_SIZE;
3239
3240 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303241 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303242 update_ndl_param->dcc_ndl_chan_list_len);
3243 for (i = 0; i < cmd->num_channel; i++)
3244 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3245 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3246 WMITLV_GET_STRUCT_TLVLEN(
3247 wmi_dcc_ndl_chan));
3248 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3249
3250 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3251 update_ndl_param->dcc_ndl_active_state_list_len);
3252 buf_ptr += WMI_TLV_HDR_SIZE;
3253
3254 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303255 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303256 update_ndl_param->dcc_ndl_active_state_list,
3257 update_ndl_param->dcc_ndl_active_state_list_len);
3258 for (i = 0; i < active_state_count; i++) {
3259 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3260 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3261 WMITLV_GET_STRUCT_TLVLEN(
3262 wmi_dcc_ndl_active_state_config));
3263 }
3264 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3265
3266 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303267 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303268 WMI_DCC_UPDATE_NDL_CMDID);
3269 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303270 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303271 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303272 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303273 }
3274
Govind Singh67922e82016-04-01 16:48:57 +05303275 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303276}
3277
3278/**
3279 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3280 * @wmi_handle: pointer to the wmi handle
3281 * @config: the OCB configuration
3282 *
3283 * Return: 0 on success
3284 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303285static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303286 struct ocb_config_param *config, uint32_t *ch_mhz)
3287{
Govind Singh67922e82016-04-01 16:48:57 +05303288 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303289 wmi_ocb_set_config_cmd_fixed_param *cmd;
3290 wmi_channel *chan;
3291 wmi_ocb_channel *ocb_chan;
3292 wmi_qos_parameter *qos_param;
3293 wmi_dcc_ndl_chan *ndl_chan;
3294 wmi_dcc_ndl_active_state_config *ndl_active_config;
3295 wmi_ocb_schedule_element *sched_elem;
3296 uint8_t *buf_ptr;
3297 wmi_buf_t buf;
3298 int32_t len;
3299 int32_t i, j, active_state_count;
3300
3301 /*
3302 * Validate the dcc_ndl_chan_list_len and count the number of active
3303 * states. Validate dcc_ndl_active_state_list_len.
3304 */
3305 active_state_count = 0;
3306 if (config->dcc_ndl_chan_list_len) {
3307 if (!config->dcc_ndl_chan_list ||
3308 config->dcc_ndl_chan_list_len !=
3309 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303310 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303311 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303312 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303313 }
3314
3315 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3316 i < config->channel_count; ++i, ++ndl_chan)
3317 active_state_count +=
3318 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3319
3320 if (active_state_count) {
3321 if (!config->dcc_ndl_active_state_list ||
3322 config->dcc_ndl_active_state_list_len !=
3323 active_state_count *
3324 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303325 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303326 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303327 }
3328 }
3329 }
3330
3331 len = sizeof(*cmd) +
3332 WMI_TLV_HDR_SIZE + config->channel_count *
3333 sizeof(wmi_channel) +
3334 WMI_TLV_HDR_SIZE + config->channel_count *
3335 sizeof(wmi_ocb_channel) +
3336 WMI_TLV_HDR_SIZE + config->channel_count *
3337 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3338 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3339 WMI_TLV_HDR_SIZE + active_state_count *
3340 sizeof(wmi_dcc_ndl_active_state_config) +
3341 WMI_TLV_HDR_SIZE + config->schedule_size *
3342 sizeof(wmi_ocb_schedule_element);
3343 buf = wmi_buf_alloc(wmi_handle, len);
3344 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303345 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303346 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303347 }
3348
3349 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3350 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3351 WMITLV_SET_HDR(&cmd->tlv_header,
3352 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3353 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3354 cmd->vdev_id = config->session_id;
3355 cmd->channel_count = config->channel_count;
3356 cmd->schedule_size = config->schedule_size;
3357 cmd->flags = config->flags;
3358 buf_ptr += sizeof(*cmd);
3359
3360 /* Add the wmi_channel info */
3361 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3362 config->channel_count*sizeof(wmi_channel));
3363 buf_ptr += WMI_TLV_HDR_SIZE;
3364 for (i = 0; i < config->channel_count; i++) {
3365 chan = (wmi_channel *)buf_ptr;
3366 WMITLV_SET_HDR(&chan->tlv_header,
3367 WMITLV_TAG_STRUC_wmi_channel,
3368 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3369 chan->mhz = config->channels[i].chan_freq;
3370 chan->band_center_freq1 = config->channels[i].chan_freq;
3371 chan->band_center_freq2 = 0;
3372 chan->info = 0;
3373
3374 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3375 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3376 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3377 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3378 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3379 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3380 config->channels[i].antenna_max);
3381
3382 if (config->channels[i].bandwidth < 10)
3383 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3384 else if (config->channels[i].bandwidth < 20)
3385 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3386 buf_ptr += sizeof(*chan);
3387 }
3388
3389 /* Add the wmi_ocb_channel info */
3390 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3391 config->channel_count*sizeof(wmi_ocb_channel));
3392 buf_ptr += WMI_TLV_HDR_SIZE;
3393 for (i = 0; i < config->channel_count; i++) {
3394 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3395 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3396 WMITLV_TAG_STRUC_wmi_ocb_channel,
3397 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3398 ocb_chan->bandwidth = config->channels[i].bandwidth;
3399 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3400 config->channels[i].mac_address.bytes,
3401 &ocb_chan->mac_address);
3402 buf_ptr += sizeof(*ocb_chan);
3403 }
3404
3405 /* Add the wmi_qos_parameter info */
3406 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3407 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3408 buf_ptr += WMI_TLV_HDR_SIZE;
3409 /* WMI_MAX_NUM_AC parameters for each channel */
3410 for (i = 0; i < config->channel_count; i++) {
3411 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3412 qos_param = (wmi_qos_parameter *)buf_ptr;
3413 WMITLV_SET_HDR(&qos_param->tlv_header,
3414 WMITLV_TAG_STRUC_wmi_qos_parameter,
3415 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3416 qos_param->aifsn =
3417 config->channels[i].qos_params[j].aifsn;
3418 qos_param->cwmin =
3419 config->channels[i].qos_params[j].cwmin;
3420 qos_param->cwmax =
3421 config->channels[i].qos_params[j].cwmax;
3422 buf_ptr += sizeof(*qos_param);
3423 }
3424 }
3425
3426 /* Add the wmi_dcc_ndl_chan (per channel) */
3427 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3428 config->dcc_ndl_chan_list_len);
3429 buf_ptr += WMI_TLV_HDR_SIZE;
3430 if (config->dcc_ndl_chan_list_len) {
3431 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303432 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303433 config->dcc_ndl_chan_list_len);
3434 for (i = 0; i < config->channel_count; i++)
3435 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3436 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3437 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3438 buf_ptr += config->dcc_ndl_chan_list_len;
3439 }
3440
3441 /* Add the wmi_dcc_ndl_active_state_config */
3442 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3443 sizeof(wmi_dcc_ndl_active_state_config));
3444 buf_ptr += WMI_TLV_HDR_SIZE;
3445 if (active_state_count) {
3446 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303447 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303448 config->dcc_ndl_active_state_list,
3449 active_state_count * sizeof(*ndl_active_config));
3450 for (i = 0; i < active_state_count; ++i)
3451 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3452 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3453 WMITLV_GET_STRUCT_TLVLEN(
3454 wmi_dcc_ndl_active_state_config));
3455 buf_ptr += active_state_count *
3456 sizeof(*ndl_active_config);
3457 }
3458
3459 /* Add the wmi_ocb_schedule_element info */
3460 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3461 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3462 buf_ptr += WMI_TLV_HDR_SIZE;
3463 for (i = 0; i < config->schedule_size; i++) {
3464 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3465 WMITLV_SET_HDR(&sched_elem->tlv_header,
3466 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3467 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3468 sched_elem->channel_freq = config->schedule[i].chan_freq;
3469 sched_elem->total_duration = config->schedule[i].total_duration;
3470 sched_elem->guard_interval = config->schedule[i].guard_interval;
3471 buf_ptr += sizeof(*sched_elem);
3472 }
3473
3474
3475 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3476 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303477 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303478 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303479 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303480 }
3481
Govind Singh67922e82016-04-01 16:48:57 +05303482 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303483}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303484
3485/**
3486 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3487 * @wmi_handle: wmi handle
3488 * @mcc_adaptive_scheduler: enable/disable
3489 *
3490 * This function enable/disable mcc adaptive scheduler in fw.
3491 *
Govind Singhb53420c2016-03-09 14:32:57 +05303492 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303494static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003495 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3496 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303497{
Govind Singh67922e82016-04-01 16:48:57 +05303498 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303499 wmi_buf_t buf = 0;
3500 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3501 uint16_t len =
3502 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3503
3504 buf = wmi_buf_alloc(wmi_handle, len);
3505 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303506 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3507 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303508 }
3509 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3510 wmi_buf_data(buf);
3511
3512 WMITLV_SET_HDR(&cmd->tlv_header,
3513 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3514 WMITLV_GET_STRUCT_TLVLEN
3515 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3516 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003517 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303518
3519 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3520 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303521 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303522 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303523 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303524 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303525 }
Govind Singh67922e82016-04-01 16:48:57 +05303526
3527 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303528}
3529
3530/**
3531 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3532 * @wmi: wmi handle
3533 * @mcc_channel: mcc channel
3534 * @mcc_channel_time_latency: MCC channel time latency.
3535 *
3536 * Currently used to set time latency for an MCC vdev/adapter using operating
3537 * channel of it and channel number. The info is provided run time using
3538 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3539 *
3540 * Return: CDF status
3541 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303542static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303543 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3544{
Govind Singh67922e82016-04-01 16:48:57 +05303545 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303546 wmi_buf_t buf = 0;
3547 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3548 uint16_t len = 0;
3549 uint8_t *buf_ptr = NULL;
3550 wmi_resmgr_chan_latency chan_latency;
3551 /* Note: we only support MCC time latency for a single channel */
3552 uint32_t num_channels = 1;
3553 uint32_t chan1_freq = mcc_channel_freq;
3554 uint32_t latency_chan1 = mcc_channel_time_latency;
3555
3556
3557 /* If 0ms latency is provided, then FW will set to a default.
3558 * Otherwise, latency must be at least 30ms.
3559 */
3560 if ((latency_chan1 > 0) &&
3561 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303562 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303563 "Minimum is 30ms (or 0 to use default value by "
3564 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303565 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303566 }
3567
3568 /* Set WMI CMD for channel time latency here */
3569 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3570 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3571 num_channels * sizeof(wmi_resmgr_chan_latency);
3572 buf = wmi_buf_alloc(wmi_handle, len);
3573 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303574 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3575 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303576 }
3577 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3578 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3579 wmi_buf_data(buf);
3580 WMITLV_SET_HDR(&cmdTL->tlv_header,
3581 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3582 WMITLV_GET_STRUCT_TLVLEN
3583 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3584 cmdTL->num_chans = num_channels;
3585 /* Update channel time latency information for home channel(s) */
3586 buf_ptr += sizeof(*cmdTL);
3587 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3588 num_channels * sizeof(wmi_resmgr_chan_latency));
3589 buf_ptr += WMI_TLV_HDR_SIZE;
3590 chan_latency.chan_mhz = chan1_freq;
3591 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303592 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303593 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3594 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303595 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303596 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303597 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303598 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303599 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303600 }
Govind Singh67922e82016-04-01 16:48:57 +05303601
3602 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303603}
3604
3605/**
3606 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3607 * @wmi: wmi handle
3608 * @adapter_1_chan_number: adapter 1 channel number
3609 * @adapter_1_quota: adapter 1 quota
3610 * @adapter_2_chan_number: adapter 2 channel number
3611 *
3612 * Return: CDF status
3613 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303614static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303615 uint32_t adapter_1_chan_freq,
3616 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3617{
Govind Singh67922e82016-04-01 16:48:57 +05303618 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303619 wmi_buf_t buf = 0;
3620 uint16_t len = 0;
3621 uint8_t *buf_ptr = NULL;
3622 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3623 wmi_resmgr_chan_time_quota chan_quota;
3624 uint32_t quota_chan1 = adapter_1_quota;
3625 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3626 uint32_t quota_chan2 = 100 - quota_chan1;
3627 /* Note: setting time quota for MCC requires info for 2 channels */
3628 uint32_t num_channels = 2;
3629 uint32_t chan1_freq = adapter_1_chan_freq;
3630 uint32_t chan2_freq = adapter_2_chan_freq;
3631
Govind Singhb53420c2016-03-09 14:32:57 +05303632 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303633 "freq2:%dMHz, Quota2:%dms", __func__,
3634 chan1_freq, quota_chan1, chan2_freq,
3635 quota_chan2);
3636
3637 /*
3638 * Perform sanity check on time quota values provided.
3639 */
3640 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3641 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303642 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303643 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303644 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303645 }
3646 /* Set WMI CMD for channel time quota here */
3647 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3648 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3649 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3650 buf = wmi_buf_alloc(wmi_handle, len);
3651 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303652 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3653 QDF_ASSERT(0);
3654 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303655 }
3656 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3657 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3658 wmi_buf_data(buf);
3659 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3660 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3661 WMITLV_GET_STRUCT_TLVLEN
3662 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3663 cmdTQ->num_chans = num_channels;
3664
3665 /* Update channel time quota information for home channel(s) */
3666 buf_ptr += sizeof(*cmdTQ);
3667 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3668 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3669 buf_ptr += WMI_TLV_HDR_SIZE;
3670 chan_quota.chan_mhz = chan1_freq;
3671 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303672 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303673 /* Construct channel and quota record for the 2nd MCC mode. */
3674 buf_ptr += sizeof(chan_quota);
3675 chan_quota.chan_mhz = chan2_freq;
3676 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05303677 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303678
3679 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3680 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303681 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303682 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303683 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303684 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303685 }
Govind Singh67922e82016-04-01 16:48:57 +05303686
3687 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303688}
3689
3690/**
3691 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3692 * @wmi_handle: Pointer to wmi handle
3693 * @thermal_info: Thermal command information
3694 *
3695 * This function sends the thermal management command
3696 * to the firmware
3697 *
Govind Singhb53420c2016-03-09 14:32:57 +05303698 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303699 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303700static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303701 struct thermal_cmd_params *thermal_info)
3702{
3703 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3704 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303705 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303706 uint32_t len = 0;
3707
3708 len = sizeof(*cmd);
3709
3710 buf = wmi_buf_alloc(wmi_handle, len);
3711 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303712 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3713 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303714 }
3715
3716 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3717
3718 WMITLV_SET_HDR(&cmd->tlv_header,
3719 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3720 WMITLV_GET_STRUCT_TLVLEN
3721 (wmi_thermal_mgmt_cmd_fixed_param));
3722
3723 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3724 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3725 cmd->enable = thermal_info->thermal_enable;
3726
Govind Singhb53420c2016-03-09 14:32:57 +05303727 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303728 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3729
3730 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3731 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303732 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303733 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303734 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303735 }
3736
Govind Singh67922e82016-04-01 16:48:57 +05303737 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303738}
3739
3740
3741/**
3742 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303743 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303744 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3745 *
3746 * This function sends down the LRO configuration parameters to
3747 * the firmware to enable LRO, sets the TCP flags and sets the
3748 * seed values for the toeplitz hash generation
3749 *
Govind Singhb53420c2016-03-09 14:32:57 +05303750 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303751 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303752static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303753 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3754{
3755 wmi_lro_info_cmd_fixed_param *cmd;
3756 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303757 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303758
3759
3760 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3761 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303762 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3763 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303764 }
3765
3766 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3767
3768 WMITLV_SET_HDR(&cmd->tlv_header,
3769 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3770 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3771
3772 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3773 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3774 wmi_lro_cmd->tcp_flag);
3775 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3776 wmi_lro_cmd->tcp_flag_mask);
3777 cmd->toeplitz_hash_ipv4_0_3 =
3778 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3779 cmd->toeplitz_hash_ipv4_4_7 =
3780 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3781 cmd->toeplitz_hash_ipv4_8_11 =
3782 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3783 cmd->toeplitz_hash_ipv4_12_15 =
3784 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3785 cmd->toeplitz_hash_ipv4_16 =
3786 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3787
3788 cmd->toeplitz_hash_ipv6_0_3 =
3789 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3790 cmd->toeplitz_hash_ipv6_4_7 =
3791 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3792 cmd->toeplitz_hash_ipv6_8_11 =
3793 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3794 cmd->toeplitz_hash_ipv6_12_15 =
3795 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3796 cmd->toeplitz_hash_ipv6_16_19 =
3797 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3798 cmd->toeplitz_hash_ipv6_20_23 =
3799 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3800 cmd->toeplitz_hash_ipv6_24_27 =
3801 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3802 cmd->toeplitz_hash_ipv6_28_31 =
3803 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3804 cmd->toeplitz_hash_ipv6_32_35 =
3805 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3806 cmd->toeplitz_hash_ipv6_36_39 =
3807 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3808 cmd->toeplitz_hash_ipv6_40 =
3809 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3810
Govind Singhb53420c2016-03-09 14:32:57 +05303811 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303812 cmd->lro_enable, cmd->tcp_flag_u32);
3813
3814 status = wmi_unified_cmd_send(wmi_handle, buf,
3815 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303816 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303817 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303818 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303819 }
3820
Govind Singh67922e82016-04-01 16:48:57 +05303821 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303822}
3823
Govind Singh4eacd2b2016-03-07 14:24:22 +05303824/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303825 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3826 * @wmi_handle: Pointer to wmi handle
3827 * @rate_report_params: Pointer to peer rate report parameters
3828 *
3829 *
3830 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3831 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303832static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303833 struct wmi_peer_rate_report_params *rate_report_params)
3834{
3835 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3836 wmi_buf_t buf = NULL;
3837 QDF_STATUS status = 0;
3838 uint32_t len = 0;
3839 uint32_t i, j;
3840
3841 len = sizeof(*cmd);
3842
3843 buf = wmi_buf_alloc(wmi_handle, len);
3844 if (!buf) {
3845 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
3846 return QDF_STATUS_E_FAILURE;
3847 }
3848
3849 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3850 wmi_buf_data(buf);
3851
3852 WMITLV_SET_HDR(
3853 &cmd->tlv_header,
3854 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3855 WMITLV_GET_STRUCT_TLVLEN(
3856 wmi_peer_set_rate_report_condition_fixed_param));
3857
3858 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3859 cmd->report_backoff_time = rate_report_params->backoff_time;
3860 cmd->report_timer_period = rate_report_params->timer_period;
3861 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
3862 cmd->cond_per_phy[i].val_cond_flags =
3863 rate_report_params->report_per_phy[i].cond_flags;
3864 cmd->cond_per_phy[i].rate_delta.min_delta =
3865 rate_report_params->report_per_phy[i].delta.delta_min;
3866 cmd->cond_per_phy[i].rate_delta.percentage =
3867 rate_report_params->report_per_phy[i].delta.percent;
3868 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3869 cmd->cond_per_phy[i].rate_threshold[j] =
3870 rate_report_params->report_per_phy[i].
3871 report_rate_threshold[j];
3872 }
3873 }
3874
3875 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
3876 cmd->enable_rate_report,
3877 cmd->report_backoff_time, cmd->report_timer_period);
3878
3879 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3880 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3881 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303882 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303883 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3884 __func__);
3885 }
3886 return status;
3887}
3888
3889/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303890 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3891 * @wmi_handle: wmi handle
3892 * @param: bcn ll cmd parameter
3893 *
Govind Singhb53420c2016-03-09 14:32:57 +05303894 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303895 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303896static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303897 wmi_bcn_send_from_host_cmd_fixed_param *param)
3898{
3899 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3900 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303901 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303902
3903 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3904 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303905 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3906 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303907 }
3908
3909 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3910 WMITLV_SET_HDR(&cmd->tlv_header,
3911 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3912 WMITLV_GET_STRUCT_TLVLEN
3913 (wmi_bcn_send_from_host_cmd_fixed_param));
3914 cmd->vdev_id = param->vdev_id;
3915 cmd->data_len = param->data_len;
3916 cmd->frame_ctrl = param->frame_ctrl;
3917 cmd->frag_ptr = param->frag_ptr;
3918 cmd->dtim_flag = param->dtim_flag;
3919
3920 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3921 WMI_PDEV_SEND_BCN_CMDID);
3922
Govind Singh67922e82016-04-01 16:48:57 +05303923 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303924 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303925 wmi_buf_free(wmi_buf);
3926 }
3927
3928 return ret;
3929}
3930
3931/**
3932 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
3933 * @wmi_handle: wmi handle
3934 * @vdev_id: vdev id
3935 * @max_retries: max retries
3936 * @retry_interval: retry interval
3937 * This function sets sta query related parameters in fw.
3938 *
Govind Singhb53420c2016-03-09 14:32:57 +05303939 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303940 */
3941
Sathish Kumarfd347372017-02-13 12:29:09 +05303942static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303943 uint8_t vdev_id, uint32_t max_retries,
3944 uint32_t retry_interval)
3945{
3946 wmi_buf_t buf;
3947 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
3948 int len;
3949
3950 len = sizeof(*cmd);
3951 buf = wmi_buf_alloc(wmi_handle, len);
3952 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303953 WMI_LOGE(FL("wmi_buf_alloc failed"));
3954 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303955 }
3956
3957 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
3958 WMITLV_SET_HDR(&cmd->tlv_header,
3959 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
3960 WMITLV_GET_STRUCT_TLVLEN
3961 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
3962
3963
3964 cmd->vdev_id = vdev_id;
3965 cmd->sa_query_max_retry_count = max_retries;
3966 cmd->sa_query_retry_interval = retry_interval;
3967
Govind Singhb53420c2016-03-09 14:32:57 +05303968 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303969 vdev_id, retry_interval, max_retries);
3970
3971 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3972 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303973 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05303974 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303975 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303976 }
3977
Govind Singhb53420c2016-03-09 14:32:57 +05303978 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303979 return 0;
3980}
3981
3982/**
3983 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
3984 * @wmi_handle: wmi handle
3985 * @params: sta keep alive parameter
3986 *
3987 * This function sets keep alive related parameters in fw.
3988 *
3989 * Return: CDF status
3990 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303991static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303992 struct sta_params *params)
3993{
3994 wmi_buf_t buf;
3995 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
3996 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
3997 uint8_t *buf_ptr;
3998 int len;
Govind Singh67922e82016-04-01 16:48:57 +05303999 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304000
Govind Singhb53420c2016-03-09 14:32:57 +05304001 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304002
Govind Singh4eacd2b2016-03-07 14:24:22 +05304003 len = sizeof(*cmd) + sizeof(*arp_rsp);
4004 buf = wmi_buf_alloc(wmi_handle, len);
4005 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304006 WMI_LOGE("wmi_buf_alloc failed");
4007 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304008 }
4009
4010 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4011 buf_ptr = (uint8_t *) cmd;
4012 WMITLV_SET_HDR(&cmd->tlv_header,
4013 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4014 WMITLV_GET_STRUCT_TLVLEN
4015 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4016 cmd->interval = params->timeperiod;
4017 cmd->enable = (params->timeperiod) ? 1 : 0;
4018 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304019 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304020 params->timeperiod, params->method);
4021 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4022 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4023 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4024 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4025
4026 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4027 if ((NULL == params->hostv4addr) ||
4028 (NULL == params->destv4addr) ||
4029 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304030 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304031 "destv4addr:%p destmac:%p ", __func__,
4032 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304033 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304034 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304035 }
4036 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304037 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304038 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304039 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304040 WMI_IPV4_ADDR_LEN);
4041 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4042 } else {
4043 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4044 }
4045
Govind Singh67922e82016-04-01 16:48:57 +05304046 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4047 WMI_STA_KEEPALIVE_CMDID);
4048 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304049 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304050 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304051 }
4052
Govind Singhb53420c2016-03-09 14:32:57 +05304053 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304054 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304055}
4056
4057/**
4058 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4059 * @wmi_handle: wmi handle
4060 * @if_id: vdev id
4061 * @gtx_info: GTX config params
4062 *
4063 * This function set GTX related params in firmware.
4064 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304065 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304066 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304067static 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 +05304068 struct wmi_gtx_config *gtx_info)
4069{
4070 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4071 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304072 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304073 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304074
Govind Singh4eacd2b2016-03-07 14:24:22 +05304075 buf = wmi_buf_alloc(wmi_handle, len);
4076 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304077 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304078 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304079 }
4080 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4081 WMITLV_SET_HDR(&cmd->tlv_header,
4082 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4083 WMITLV_GET_STRUCT_TLVLEN
4084 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4085 cmd->vdev_id = if_id;
4086
4087 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4088 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4089 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4090 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4091 cmd->gtxPERMargin = gtx_info->gtx_margin;
4092 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4093 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4094 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4095
Govind Singhb53420c2016-03-09 14:32:57 +05304096 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304097 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4098 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4099 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4100 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4101
Abhishek Singh716c46c2016-05-04 16:24:07 +05304102 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304103 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304104 if (QDF_IS_STATUS_ERROR(ret)) {
4105 WMI_LOGE("Failed to set GTX PARAMS");
4106 wmi_buf_free(buf);
4107 }
4108 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304109}
4110
4111/**
4112 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4113 * @wmi_handle: wmi handle
4114 * @edca_params: edca parameters
4115 *
4116 * This function updates EDCA parameters to the target
4117 *
4118 * Return: CDF Status
4119 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304120static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304121 uint8_t vdev_id,
4122 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4123{
4124 uint8_t *buf_ptr;
4125 wmi_buf_t buf;
4126 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4127 wmi_wmm_vparams *wmm_param, *twmm_param;
4128 int len = sizeof(*cmd);
4129 int ac;
4130
4131 buf = wmi_buf_alloc(wmi_handle, len);
4132
4133 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304134 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4135 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304136 }
4137
4138 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4139 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4140 WMITLV_SET_HDR(&cmd->tlv_header,
4141 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4142 WMITLV_GET_STRUCT_TLVLEN
4143 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4144 cmd->vdev_id = vdev_id;
4145
4146 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4147 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4148 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4149 WMITLV_SET_HDR(&wmm_param->tlv_header,
4150 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4151 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4152 wmm_param->cwmin = twmm_param->cwmin;
4153 wmm_param->cwmax = twmm_param->cwmax;
4154 wmm_param->aifs = twmm_param->aifs;
4155 wmm_param->txoplimit = twmm_param->txoplimit;
4156 wmm_param->acm = twmm_param->acm;
4157 wmm_param->no_ack = twmm_param->no_ack;
4158 }
4159
4160 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4161 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4162 goto fail;
4163
Govind Singhb53420c2016-03-09 14:32:57 +05304164 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304165
4166fail:
4167 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304168 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4169 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304170}
4171
4172/**
4173 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4174 * @wmi_handle: wmi handle
4175 * @vdev_id: vdev id
4176 * @probe_rsp_info: probe response info
4177 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304178 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304179 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304180static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304181 uint8_t vdev_id,
4182 struct wmi_probe_resp_params *probe_rsp_info,
4183 uint8_t *frm)
4184{
4185 wmi_prb_tmpl_cmd_fixed_param *cmd;
4186 wmi_bcn_prb_info *bcn_prb_info;
4187 wmi_buf_t wmi_buf;
4188 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4189 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304190 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304191
Govind Singhb53420c2016-03-09 14:32:57 +05304192 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304193
4194 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4195 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4196
4197 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4198 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4199 tmpl_len_aligned;
4200
4201 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304202 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304203 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304204 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304205 }
4206
4207 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4208 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304209 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304210 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304211 }
4212
4213 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4214
4215 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4216 WMITLV_SET_HDR(&cmd->tlv_header,
4217 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4218 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4219 cmd->vdev_id = vdev_id;
4220 cmd->buf_len = tmpl_len;
4221 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4222
4223 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4224 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4225 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4226 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4227 bcn_prb_info->caps = 0;
4228 bcn_prb_info->erp = 0;
4229 buf_ptr += sizeof(wmi_bcn_prb_info);
4230
4231 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4232 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304233 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304234
4235 ret = wmi_unified_cmd_send(wmi_handle,
4236 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304237 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304238 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304239 wmi_buf_free(wmi_buf);
4240 }
4241
4242 return ret;
4243}
4244
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304245#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304246#define WPI_IV_LEN 16
4247
4248/**
4249 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4250 *
4251 * @dest_tx: destination address of tsc key counter
4252 * @src_tx: source address of tsc key counter
4253 * @dest_rx: destination address of rsc key counter
4254 * @src_rx: source address of rsc key counter
4255 *
4256 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4257 *
4258 * Return: None
4259 *
4260 */
4261static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4262 uint8_t *dest_rx, uint8_t *src_rx)
4263{
4264 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4265 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4266}
4267#else
4268static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4269 uint8_t *dest_rx, uint8_t *src_rx)
4270{
4271 return;
4272}
4273#endif
4274
4275/**
4276 * send_setup_install_key_cmd_tlv() - set key parameters
4277 * @wmi_handle: wmi handle
4278 * @key_params: key parameters
4279 *
4280 * This function fills structure from information
4281 * passed in key_params.
4282 *
4283 * Return: QDF_STATUS_SUCCESS - success
4284 * QDF_STATUS_E_FAILURE - failure
4285 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4286 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304287static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304288 struct set_key_params *key_params)
4289{
4290 wmi_vdev_install_key_cmd_fixed_param *cmd;
4291 wmi_buf_t buf;
4292 uint8_t *buf_ptr;
4293 uint32_t len;
4294 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304295 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304296
4297 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4298 WMI_TLV_HDR_SIZE;
4299
4300 buf = wmi_buf_alloc(wmi_handle, len);
4301 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304302 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304303 return QDF_STATUS_E_NOMEM;
4304 }
4305
4306 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4307 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4308 WMITLV_SET_HDR(&cmd->tlv_header,
4309 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4310 WMITLV_GET_STRUCT_TLVLEN
4311 (wmi_vdev_install_key_cmd_fixed_param));
4312 cmd->vdev_id = key_params->vdev_id;
4313 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304314
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304315
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304316 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4317 cmd->key_flags |= key_params->key_flags;
4318 cmd->key_cipher = key_params->key_cipher;
4319 if ((key_params->key_txmic_len) &&
4320 (key_params->key_rxmic_len)) {
4321 cmd->key_txmic_len = key_params->key_txmic_len;
4322 cmd->key_rxmic_len = key_params->key_rxmic_len;
4323 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304324#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304325 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4326 key_params->tx_iv,
4327 cmd->wpi_key_rsc_counter,
4328 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304329#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304330 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4331 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4332 roundup(key_params->key_len, sizeof(uint32_t)));
4333 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4334 qdf_mem_copy((void *)key_data,
4335 (const void *)key_params->key_data, key_params->key_len);
4336 cmd->key_len = key_params->key_len;
4337
4338 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4339 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304340 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304341 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304342
Govind Singh67922e82016-04-01 16:48:57 +05304343 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304344}
4345
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304346/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004347 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4348 * @wmi_handle: wmi handle
4349 * @params: sar limit params
4350 *
4351 * Return: QDF_STATUS_SUCCESS for success or error code
4352 */
4353static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4354 struct sar_limit_cmd_params *sar_limit_params)
4355{
4356 wmi_buf_t buf;
4357 QDF_STATUS qdf_status;
4358 wmi_sar_limits_cmd_fixed_param *cmd;
4359 int i;
4360 uint8_t *buf_ptr;
4361 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4362 struct sar_limit_cmd_row *sar_rows_list;
4363 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4364
4365 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4366 buf = wmi_buf_alloc(wmi_handle, len);
4367 if (!buf) {
4368 WMI_LOGE("Failed to allocate memory");
4369 qdf_status = QDF_STATUS_E_NOMEM;
4370 goto end;
4371 }
4372
4373 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4374 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4375 WMITLV_SET_HDR(&cmd->tlv_header,
4376 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4377 WMITLV_GET_STRUCT_TLVLEN
4378 (wmi_sar_limits_cmd_fixed_param));
4379 cmd->sar_enable = sar_limit_params->sar_enable;
4380 cmd->commit_limits = sar_limit_params->commit_limits;
4381 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4382
4383 WMI_LOGD("no of sar rows = %d, len = %d",
4384 sar_limit_params->num_limit_rows, len);
4385 buf_ptr += sizeof(*cmd);
4386 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4387 sizeof(wmi_sar_limit_cmd_row) *
4388 sar_limit_params->num_limit_rows);
4389 if (cmd->num_limit_rows == 0)
4390 goto send_sar_limits;
4391
4392 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4393 (buf_ptr + WMI_TLV_HDR_SIZE);
4394 sar_rows_list = sar_limit_params->sar_limit_row_list;
4395
4396 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4397 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4398 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4399 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4400 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4401 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4402 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4403 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4404 wmi_sar_rows_list->validity_bitmap =
4405 sar_rows_list->validity_bitmap;
4406 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4407 i, wmi_sar_rows_list->band_id,
4408 wmi_sar_rows_list->chain_id,
4409 wmi_sar_rows_list->mod_id,
4410 wmi_sar_rows_list->limit_value,
4411 wmi_sar_rows_list->validity_bitmap);
4412 sar_rows_list++;
4413 wmi_sar_rows_list++;
4414 }
4415send_sar_limits:
4416 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4417 WMI_SAR_LIMITS_CMDID);
4418
4419 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4420 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4421 wmi_buf_free(buf);
4422 }
4423
4424end:
4425 return qdf_status;
4426}
4427
4428/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304429 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4430 * @wmi_handle: wmi handle
4431 * @params: encrypt/decrypt params
4432 *
4433 * Return: QDF_STATUS_SUCCESS for success or error code
4434 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004435static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304436QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4437 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4438{
4439 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4440 wmi_buf_t wmi_buf;
4441 uint8_t *buf_ptr;
4442 QDF_STATUS ret;
4443 uint32_t len;
4444
4445 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4446
4447 len = sizeof(*cmd) +
4448 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4449 WMI_TLV_HDR_SIZE;
4450 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4451 if (!wmi_buf) {
4452 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4453 __func__);
4454 return QDF_STATUS_E_NOMEM;
4455 }
4456
4457 buf_ptr = wmi_buf_data(wmi_buf);
4458 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4459
4460 WMITLV_SET_HDR(&cmd->tlv_header,
4461 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4462 WMITLV_GET_STRUCT_TLVLEN(
4463 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4464
4465 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4466 cmd->key_flag = encrypt_decrypt_params->key_flag;
4467 cmd->key_idx = encrypt_decrypt_params->key_idx;
4468 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4469 cmd->key_len = encrypt_decrypt_params->key_len;
4470 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4471 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4472
4473 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4474 encrypt_decrypt_params->key_len);
4475
4476 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4477 MAX_MAC_HEADER_LEN);
4478
4479 cmd->data_len = encrypt_decrypt_params->data_len;
4480
4481 if (cmd->data_len) {
4482 buf_ptr += sizeof(*cmd);
4483 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4484 roundup(encrypt_decrypt_params->data_len,
4485 sizeof(A_UINT32)));
4486 buf_ptr += WMI_TLV_HDR_SIZE;
4487 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4488 encrypt_decrypt_params->data_len);
4489 }
4490
4491 /* This conversion is to facilitate data to FW in little endian */
4492 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4493 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4494 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4495 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4496 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4497 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4498
4499 ret = wmi_unified_cmd_send(wmi_handle,
4500 wmi_buf, len,
4501 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4502 if (QDF_IS_STATUS_ERROR(ret)) {
4503 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4504 wmi_buf_free(wmi_buf);
4505 }
4506
4507 return ret;
4508}
4509
4510
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304511
Govind Singh4eacd2b2016-03-07 14:24:22 +05304512/**
4513 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4514 * @wmi_handle: wmi handle
4515 * @vdev_id: vdev id
4516 * @p2p_ie: p2p IE
4517 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304518 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304519 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304520static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304521 A_UINT32 vdev_id, uint8_t *p2p_ie)
4522{
Govind Singh67922e82016-04-01 16:48:57 +05304523 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304524 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4525 wmi_buf_t wmi_buf;
4526 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4527 uint8_t *buf_ptr;
4528
4529 ie_len = (uint32_t) (p2p_ie[1] + 2);
4530
4531 /* More than one P2P IE may be included in a single frame.
4532 If multiple P2P IEs are present, the complete P2P attribute
4533 data consists of the concatenation of the P2P Attribute
4534 fields of the P2P IEs. The P2P Attributes field of each
4535 P2P IE may be any length up to the maximum (251 octets).
4536 In this case host sends one P2P IE to firmware so the length
4537 should not exceed more than 251 bytes
4538 */
4539 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304540 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304541 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304542 }
4543
4544 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4545
4546 wmi_buf_len =
4547 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4548 WMI_TLV_HDR_SIZE;
4549
4550 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4551 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304552 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304553 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304554 }
4555
4556 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4557
4558 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4559 WMITLV_SET_HDR(&cmd->tlv_header,
4560 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4561 WMITLV_GET_STRUCT_TLVLEN
4562 (wmi_p2p_go_set_beacon_ie_fixed_param));
4563 cmd->vdev_id = vdev_id;
4564 cmd->ie_buf_len = ie_len;
4565
4566 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4567 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4568 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304569 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304570
Govind Singhb53420c2016-03-09 14:32:57 +05304571 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304572
4573 ret = wmi_unified_cmd_send(wmi_handle,
4574 wmi_buf, wmi_buf_len,
4575 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304576 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304577 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304578 wmi_buf_free(wmi_buf);
4579 }
4580
Govind Singhb53420c2016-03-09 14:32:57 +05304581 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304582 return ret;
4583}
4584
4585/**
4586 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4587 * @wmi_handle: wmi handle
4588 * @req: gateway parameter update request structure
4589 *
4590 * This function reads the incoming @req and fill in the destination
4591 * WMI structure and sends down the gateway configs down to the firmware
4592 *
Govind Singhb53420c2016-03-09 14:32:57 +05304593 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304594 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304595static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304596 struct gateway_update_req_param *req)
4597{
4598 wmi_roam_subnet_change_config_fixed_param *cmd;
4599 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304600 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304601 int len = sizeof(*cmd);
4602
4603 buf = wmi_buf_alloc(wmi_handle, len);
4604 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304605 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4606 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304607 }
4608
4609 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4610 WMITLV_SET_HDR(&cmd->tlv_header,
4611 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4612 WMITLV_GET_STRUCT_TLVLEN(
4613 wmi_roam_subnet_change_config_fixed_param));
4614
4615 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304616 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4617 QDF_IPV4_ADDR_SIZE);
4618 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4619 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304620 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4621 &cmd->inet_gw_mac_addr);
4622 cmd->max_retries = req->max_retries;
4623 cmd->timeout = req->timeout;
4624 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4625 cmd->flag = 0;
4626 if (req->ipv4_addr_type)
4627 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4628
4629 if (req->ipv6_addr_type)
4630 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4631
4632 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4633 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304634 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304635 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304636 ret);
4637 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304638 }
4639
Govind Singh67922e82016-04-01 16:48:57 +05304640 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304641}
4642
4643/**
4644 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4645 * @wmi_handle: wmi handle
4646 * @req: rssi monitoring request structure
4647 *
4648 * This function reads the incoming @req and fill in the destination
4649 * WMI structure and send down the rssi monitoring configs down to the firmware
4650 *
4651 * Return: 0 on success; error number otherwise
4652 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304653static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304654 struct rssi_monitor_param *req)
4655{
4656 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4657 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304658 QDF_STATUS ret;
4659 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304660
4661 buf = wmi_buf_alloc(wmi_handle, len);
4662 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304663 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4664 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304665 }
4666
4667 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4668 WMITLV_SET_HDR(&cmd->tlv_header,
4669 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4670 WMITLV_GET_STRUCT_TLVLEN(
4671 wmi_rssi_breach_monitor_config_fixed_param));
4672
4673 cmd->vdev_id = req->session_id;
4674 cmd->request_id = req->request_id;
4675 cmd->lo_rssi_reenable_hysteresis = 0;
4676 cmd->hi_rssi_reenable_histeresis = 0;
4677 cmd->min_report_interval = 0;
4678 cmd->max_num_report = 1;
4679 if (req->control) {
4680 /* enable one threshold for each min/max */
4681 cmd->enabled_bitmap = 0x09;
4682 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4683 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4684 } else {
4685 cmd->enabled_bitmap = 0;
4686 cmd->low_rssi_breach_threshold[0] = 0;
4687 cmd->hi_rssi_breach_threshold[0] = 0;
4688 }
4689
4690 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4691 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304692 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304693 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304694 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304695 }
4696
Govind Singhb53420c2016-03-09 14:32:57 +05304697 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304698 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304699}
4700
4701/**
4702 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4703 * @wmi_handle: wmi handle
4704 * @psetoui: OUI parameters
4705 *
4706 * set scan probe OUI parameters in firmware
4707 *
4708 * Return: CDF status
4709 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304710static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304711 struct scan_mac_oui *psetoui)
4712{
4713 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4714 wmi_buf_t wmi_buf;
4715 uint32_t len;
4716 uint8_t *buf_ptr;
4717 uint32_t *oui_buf;
4718
4719 len = sizeof(*cmd);
4720 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4721 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304722 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4723 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304724 }
4725 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4726 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4727 WMITLV_SET_HDR(&cmd->tlv_header,
4728 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4729 WMITLV_GET_STRUCT_TLVLEN
4730 (wmi_scan_prob_req_oui_cmd_fixed_param));
4731
4732 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304733 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304734 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4735 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304736 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304737 cmd->prob_req_oui);
4738
4739 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4740 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304741 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304742 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304743 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304744 }
Govind Singhb53420c2016-03-09 14:32:57 +05304745 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304746}
4747
4748/**
4749 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
4750 * @wmi_handle: wmi handle
4751 * @req: passpoint network request structure
4752 *
4753 * This function sends down WMI command with network id set to wildcard id.
4754 * firmware shall clear all the config entries
4755 *
Govind Singhb53420c2016-03-09 14:32:57 +05304756 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304757 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304758static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304759 struct wifi_passpoint_req_param *req)
4760{
4761 wmi_passpoint_config_cmd_fixed_param *cmd;
4762 wmi_buf_t buf;
4763 uint32_t len;
4764 int ret;
4765
4766 len = sizeof(*cmd);
4767 buf = wmi_buf_alloc(wmi_handle, len);
4768 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304769 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4770 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304771 }
4772
4773 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
4774
4775 WMITLV_SET_HDR(&cmd->tlv_header,
4776 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4777 WMITLV_GET_STRUCT_TLVLEN(
4778 wmi_passpoint_config_cmd_fixed_param));
4779 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
4780
4781 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4782 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4783 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304784 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304785 __func__);
4786 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304787 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304788 }
4789
Govind Singhb53420c2016-03-09 14:32:57 +05304790 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304791}
4792
4793/**
4794 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
4795 * @wmi_handle: wmi handle
4796 * @req: passpoint network request structure
4797 *
4798 * This function reads the incoming @req and fill in the destination
4799 * WMI structure and send down the passpoint configs down to the firmware
4800 *
Govind Singhb53420c2016-03-09 14:32:57 +05304801 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304802 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304803static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304804 struct wifi_passpoint_req_param *req)
4805{
4806 wmi_passpoint_config_cmd_fixed_param *cmd;
4807 u_int8_t i, j, *bytes;
4808 wmi_buf_t buf;
4809 uint32_t len;
4810 int ret;
4811
4812 len = sizeof(*cmd);
4813 for (i = 0; i < req->num_networks; i++) {
4814 buf = wmi_buf_alloc(wmi_handle, len);
4815 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304816 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4817 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304818 }
4819
4820 cmd = (wmi_passpoint_config_cmd_fixed_param *)
4821 wmi_buf_data(buf);
4822
4823 WMITLV_SET_HDR(&cmd->tlv_header,
4824 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4825 WMITLV_GET_STRUCT_TLVLEN(
4826 wmi_passpoint_config_cmd_fixed_param));
4827 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05304828 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
4829 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304830 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05304831 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304832 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
4833 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05304834 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304835 j, bytes[0], bytes[1], bytes[2], bytes[3],
4836 bytes[4], bytes[5], bytes[6], bytes[7]);
4837
Govind Singhb53420c2016-03-09 14:32:57 +05304838 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05304839 &req->networks[i].roaming_consortium_ids[j],
4840 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
4841 }
Govind Singhb53420c2016-03-09 14:32:57 +05304842 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304843 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304844 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304845 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
4846
4847 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4848 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4849 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304850 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304851 __func__);
4852 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304853 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304854 }
4855 }
4856
Govind Singhb53420c2016-03-09 14:32:57 +05304857 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304858}
4859
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304860/**
4861 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
4862 * @wmi_handle: wmi handle
4863 * @scan_cmd_fp: start scan command ptr
4864 * @roam_req: roam request param
4865 *
4866 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
4867 * of WMI_ROAM_SCAN_MODE.
4868 *
4869 * Return: QDF status
4870 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304871static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304872 wmi_start_scan_cmd_fixed_param *
4873 scan_cmd_fp,
4874 struct roam_offload_scan_params *roam_req)
4875{
4876 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304877 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304878 int len;
4879 uint8_t *buf_ptr;
4880 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05304881
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304882#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4883 int auth_mode = roam_req->auth_mode;
4884 wmi_roam_offload_tlv_param *roam_offload_params;
4885 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
4886 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
4887 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304888 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304889#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4890 /* Need to create a buf with roam_scan command at
4891 * front and piggyback with scan command */
4892 len = sizeof(wmi_roam_scan_mode_fixed_param) +
4893#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4894 (2 * WMI_TLV_HDR_SIZE) +
4895#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4896 sizeof(wmi_start_scan_cmd_fixed_param);
4897#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4898 if (roam_req->is_roam_req_valid &&
4899 roam_req->roam_offload_enabled) {
4900 len += sizeof(wmi_roam_offload_tlv_param);
4901 len += WMI_TLV_HDR_SIZE;
4902 if ((auth_mode != WMI_AUTH_NONE) &&
4903 ((auth_mode != WMI_AUTH_OPEN) ||
4904 (auth_mode == WMI_AUTH_OPEN &&
4905 roam_req->mdid.mdie_present) ||
4906 roam_req->is_ese_assoc)) {
4907 len += WMI_TLV_HDR_SIZE;
4908 if (roam_req->is_ese_assoc)
4909 len +=
4910 sizeof(wmi_roam_ese_offload_tlv_param);
4911 else if (auth_mode == WMI_AUTH_FT_RSNA ||
4912 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
4913 (auth_mode == WMI_AUTH_OPEN &&
4914 roam_req->mdid.mdie_present))
4915 len +=
4916 sizeof(wmi_roam_11r_offload_tlv_param);
4917 else
4918 len +=
4919 sizeof(wmi_roam_11i_offload_tlv_param);
4920 } else {
4921 len += WMI_TLV_HDR_SIZE;
4922 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304923
4924 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
4925 + roundup(roam_req->assoc_ie_length,
4926 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304927 } else {
4928 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05304929 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304930 __func__, roam_req->roam_offload_enabled);
4931 else
Govind Singhe7f2f342016-05-23 12:12:52 +05304932 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304933 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304934 }
4935 if (roam_req->is_roam_req_valid &&
4936 roam_req->roam_offload_enabled) {
4937 roam_req->mode = roam_req->mode |
4938 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
4939 }
4940#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4941
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304942 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4943 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4944 len = sizeof(wmi_roam_scan_mode_fixed_param);
4945
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304946 buf = wmi_buf_alloc(wmi_handle, len);
4947 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304948 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304949 return QDF_STATUS_E_NOMEM;
4950 }
4951
4952 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304953
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304954 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
4955 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
4956 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
4957 WMITLV_GET_STRUCT_TLVLEN
4958 (wmi_roam_scan_mode_fixed_param));
4959
4960 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
4961 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304962 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4963 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4964 goto send_roam_scan_mode_cmd;
4965
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304966 /* Fill in scan parameters suitable for roaming scan */
4967 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304968
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304969 qdf_mem_copy(buf_ptr, scan_cmd_fp,
4970 sizeof(wmi_start_scan_cmd_fixed_param));
4971 /* Ensure there is no additional IEs */
4972 scan_cmd_fp->ie_len = 0;
4973 WMITLV_SET_HDR(buf_ptr,
4974 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
4975 WMITLV_GET_STRUCT_TLVLEN
4976 (wmi_start_scan_cmd_fixed_param));
4977#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4978 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
4979 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
4980 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4981 sizeof(wmi_roam_offload_tlv_param));
4982 buf_ptr += WMI_TLV_HDR_SIZE;
4983 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
4984 WMITLV_SET_HDR(buf_ptr,
4985 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
4986 WMITLV_GET_STRUCT_TLVLEN
4987 (wmi_roam_offload_tlv_param));
4988 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
4989 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
4990 roam_offload_params->select_5g_margin =
4991 roam_req->select_5ghz_margin;
4992 roam_offload_params->reassoc_failure_timeout =
4993 roam_req->reassoc_failure_timeout;
4994
4995 /* Fill the capabilities */
4996 roam_offload_params->capability =
4997 roam_req->roam_offload_params.capability;
4998 roam_offload_params->ht_caps_info =
4999 roam_req->roam_offload_params.ht_caps_info;
5000 roam_offload_params->ampdu_param =
5001 roam_req->roam_offload_params.ampdu_param;
5002 roam_offload_params->ht_ext_cap =
5003 roam_req->roam_offload_params.ht_ext_cap;
5004 roam_offload_params->ht_txbf =
5005 roam_req->roam_offload_params.ht_txbf;
5006 roam_offload_params->asel_cap =
5007 roam_req->roam_offload_params.asel_cap;
5008 roam_offload_params->qos_caps =
5009 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005010 roam_offload_params->qos_enabled =
5011 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305012 roam_offload_params->wmm_caps =
5013 roam_req->roam_offload_params.wmm_caps;
5014 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5015 (uint8_t *)roam_req->roam_offload_params.mcsset,
5016 ROAM_OFFLOAD_NUM_MCS_SET);
5017
5018 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5019 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5020 * they are filled in the same order.Depending on the
5021 * authentication type, the other mode TLV's are nullified
5022 * and only headers are filled.*/
5023 if ((auth_mode != WMI_AUTH_NONE) &&
5024 ((auth_mode != WMI_AUTH_OPEN) ||
5025 (auth_mode == WMI_AUTH_OPEN
5026 && roam_req->mdid.mdie_present) ||
5027 roam_req->is_ese_assoc)) {
5028 if (roam_req->is_ese_assoc) {
5029 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5030 WMITLV_GET_STRUCT_TLVLEN(0));
5031 buf_ptr += WMI_TLV_HDR_SIZE;
5032 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5033 WMITLV_GET_STRUCT_TLVLEN(0));
5034 buf_ptr += WMI_TLV_HDR_SIZE;
5035 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5036 sizeof(wmi_roam_ese_offload_tlv_param));
5037 buf_ptr += WMI_TLV_HDR_SIZE;
5038 roam_offload_ese =
5039 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5040 qdf_mem_copy(roam_offload_ese->krk,
5041 roam_req->krk,
5042 sizeof(roam_req->krk));
5043 qdf_mem_copy(roam_offload_ese->btk,
5044 roam_req->btk,
5045 sizeof(roam_req->btk));
5046 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5047 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5048 WMITLV_GET_STRUCT_TLVLEN
5049 (wmi_roam_ese_offload_tlv_param));
5050 buf_ptr +=
5051 sizeof(wmi_roam_ese_offload_tlv_param);
5052 } else if (auth_mode == WMI_AUTH_FT_RSNA
5053 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5054 || (auth_mode == WMI_AUTH_OPEN
5055 && roam_req->mdid.mdie_present)) {
5056 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5057 0);
5058 buf_ptr += WMI_TLV_HDR_SIZE;
5059 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5060 sizeof(wmi_roam_11r_offload_tlv_param));
5061 buf_ptr += WMI_TLV_HDR_SIZE;
5062 roam_offload_11r =
5063 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5064 roam_offload_11r->r0kh_id_len =
5065 roam_req->rokh_id_length;
5066 qdf_mem_copy(roam_offload_11r->r0kh_id,
5067 roam_req->rokh_id,
5068 roam_offload_11r->r0kh_id_len);
5069 qdf_mem_copy(roam_offload_11r->psk_msk,
5070 roam_req->psk_pmk,
5071 sizeof(roam_req->psk_pmk));
5072 roam_offload_11r->psk_msk_len =
5073 roam_req->pmk_len;
5074 roam_offload_11r->mdie_present =
5075 roam_req->mdid.mdie_present;
5076 roam_offload_11r->mdid =
5077 roam_req->mdid.mobility_domain;
5078 if (auth_mode == WMI_AUTH_OPEN) {
5079 /* If FT-Open ensure pmk length
5080 and r0khid len are zero */
5081 roam_offload_11r->r0kh_id_len = 0;
5082 roam_offload_11r->psk_msk_len = 0;
5083 }
5084 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5085 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5086 WMITLV_GET_STRUCT_TLVLEN
5087 (wmi_roam_11r_offload_tlv_param));
5088 buf_ptr +=
5089 sizeof(wmi_roam_11r_offload_tlv_param);
5090 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5091 WMITLV_GET_STRUCT_TLVLEN(0));
5092 buf_ptr += WMI_TLV_HDR_SIZE;
5093 } else {
5094 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5095 sizeof(wmi_roam_11i_offload_tlv_param));
5096 buf_ptr += WMI_TLV_HDR_SIZE;
5097 roam_offload_11i =
5098 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005099 if (roam_req->roam_key_mgmt_offload_enabled &&
5100 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305101 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5102 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305103 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305104 } else {
5105 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5106 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305107 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305108 }
5109
5110 qdf_mem_copy(roam_offload_11i->pmk,
5111 roam_req->psk_pmk,
5112 sizeof(roam_req->psk_pmk));
5113 roam_offload_11i->pmk_len = roam_req->pmk_len;
5114 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5115 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5116 WMITLV_GET_STRUCT_TLVLEN
5117 (wmi_roam_11i_offload_tlv_param));
5118 buf_ptr +=
5119 sizeof(wmi_roam_11i_offload_tlv_param);
5120 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5121 0);
5122 buf_ptr += WMI_TLV_HDR_SIZE;
5123 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5124 0);
5125 buf_ptr += WMI_TLV_HDR_SIZE;
5126 }
5127 } else {
5128 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5129 WMITLV_GET_STRUCT_TLVLEN(0));
5130 buf_ptr += WMI_TLV_HDR_SIZE;
5131 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5132 WMITLV_GET_STRUCT_TLVLEN(0));
5133 buf_ptr += WMI_TLV_HDR_SIZE;
5134 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5135 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305136 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305137 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305138
5139 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5140 sizeof(*assoc_ies));
5141 buf_ptr += WMI_TLV_HDR_SIZE;
5142
5143 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5144 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5145 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5146 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5147 assoc_ies->buf_len = roam_req->assoc_ie_length;
5148
5149 buf_ptr += sizeof(*assoc_ies);
5150
5151 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5152 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5153 buf_ptr += WMI_TLV_HDR_SIZE;
5154
5155 if (assoc_ies->buf_len != 0) {
5156 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5157 assoc_ies->buf_len);
5158 }
5159
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305160 } else {
5161 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5162 WMITLV_GET_STRUCT_TLVLEN(0));
5163 buf_ptr += WMI_TLV_HDR_SIZE;
5164 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5165 WMITLV_GET_STRUCT_TLVLEN(0));
5166 buf_ptr += WMI_TLV_HDR_SIZE;
5167 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5168 WMITLV_GET_STRUCT_TLVLEN(0));
5169 buf_ptr += WMI_TLV_HDR_SIZE;
5170 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5171 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305172 buf_ptr += WMI_TLV_HDR_SIZE;
5173 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5174 WMITLV_GET_STRUCT_TLVLEN(0));
5175 buf_ptr += WMI_TLV_HDR_SIZE;
5176 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5177 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305178 }
5179#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305180
5181send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305182 status = wmi_unified_cmd_send(wmi_handle, buf,
5183 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305184 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305185 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305186 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5187 status);
5188 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305189 }
5190
Govind Singh67922e82016-04-01 16:48:57 +05305191 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305192}
5193
5194
5195/**
5196 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5197 * rssi threashold
5198 * @wmi_handle: wmi handle
5199 * @roam_req: Roaming request buffer
5200 *
5201 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5202 *
5203 * Return: QDF status
5204 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305205static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305206 struct roam_offload_scan_rssi_params *roam_req)
5207{
5208 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305209 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305210 int len;
5211 uint8_t *buf_ptr;
5212 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5213 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5214 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305215 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305216
5217 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5218 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5219 len += sizeof(wmi_roam_scan_extended_threshold_param);
5220 len += WMI_TLV_HDR_SIZE;
5221 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305222 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5223 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305224 buf = wmi_buf_alloc(wmi_handle, len);
5225 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305226 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305227 return QDF_STATUS_E_NOMEM;
5228 }
5229
5230 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5231 rssi_threshold_fp =
5232 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5233 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5234 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5235 WMITLV_GET_STRUCT_TLVLEN
5236 (wmi_roam_scan_rssi_threshold_fixed_param));
5237 /* fill in threshold values */
5238 rssi_threshold_fp->vdev_id = roam_req->session_id;
5239 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5240 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5241 rssi_threshold_fp->hirssi_scan_max_count =
5242 roam_req->hi_rssi_scan_max_count;
5243 rssi_threshold_fp->hirssi_scan_delta =
5244 roam_req->hi_rssi_scan_rssi_delta;
5245 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5246
5247 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5248 WMITLV_SET_HDR(buf_ptr,
5249 WMITLV_TAG_ARRAY_STRUC,
5250 sizeof(wmi_roam_scan_extended_threshold_param));
5251 buf_ptr += WMI_TLV_HDR_SIZE;
5252 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5253
5254 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5255 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5256 ext_thresholds->boost_threshold_5g =
5257 roam_req->boost_threshold_5g;
5258
5259 ext_thresholds->boost_algorithm_5g =
5260 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5261 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5262 ext_thresholds->penalty_algorithm_5g =
5263 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5264 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5265 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5266 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5267 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5268
5269 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5270 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5271 WMITLV_GET_STRUCT_TLVLEN
5272 (wmi_roam_scan_extended_threshold_param));
5273 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5274 WMITLV_SET_HDR(buf_ptr,
5275 WMITLV_TAG_ARRAY_STRUC,
5276 sizeof(wmi_roam_earlystop_rssi_thres_param));
5277 buf_ptr += WMI_TLV_HDR_SIZE;
5278 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5279 early_stop_thresholds->roam_earlystop_thres_min =
5280 roam_req->roam_earlystop_thres_min;
5281 early_stop_thresholds->roam_earlystop_thres_max =
5282 roam_req->roam_earlystop_thres_max;
5283 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5284 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5285 WMITLV_GET_STRUCT_TLVLEN
5286 (wmi_roam_earlystop_rssi_thres_param));
5287
Gupta, Kapil7e652922016-04-12 15:02:00 +05305288 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5289 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5290 sizeof(wmi_roam_dense_thres_param));
5291 buf_ptr += WMI_TLV_HDR_SIZE;
5292 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5293 dense_thresholds->roam_dense_rssi_thres_offset =
5294 roam_req->dense_rssi_thresh_offset;
5295 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5296 dense_thresholds->roam_dense_traffic_thres =
5297 roam_req->traffic_threshold;
5298 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5299 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5300 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5301 WMITLV_GET_STRUCT_TLVLEN
5302 (wmi_roam_dense_thres_param));
5303
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305304 status = wmi_unified_cmd_send(wmi_handle, buf,
5305 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305306 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305307 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305308 status);
5309 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305310 }
5311
Govind Singh67922e82016-04-01 16:48:57 +05305312 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305313}
5314
5315/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305316 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5317 * configuration params
5318 * @wma_handle: wma handler
5319 * @dwelltime_params: pointer to dwelltime_params
5320 *
5321 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5322 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005323static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305324QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5325 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5326{
5327 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5328 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5329 wmi_buf_t buf;
5330 uint8_t *buf_ptr;
5331 int32_t err;
5332 int len;
5333
5334 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5335 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5336 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5337 buf = wmi_buf_alloc(wmi_handle, len);
5338 if (!buf) {
5339 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5340 __func__);
5341 return QDF_STATUS_E_NOMEM;
5342 }
5343 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5344 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5345 WMITLV_SET_HDR(&dwell_param->tlv_header,
5346 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5347 WMITLV_GET_STRUCT_TLVLEN
5348 (wmi_scan_adaptive_dwell_config_fixed_param));
5349
5350 dwell_param->enable = dwelltime_params->is_enabled;
5351 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5352 WMITLV_SET_HDR(buf_ptr,
5353 WMITLV_TAG_ARRAY_STRUC,
5354 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5355 buf_ptr += WMI_TLV_HDR_SIZE;
5356
5357 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5358 WMITLV_SET_HDR(&cmd->tlv_header,
5359 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5360 WMITLV_GET_STRUCT_TLVLEN(
5361 wmi_scan_adaptive_dwell_parameters_tlv));
5362
5363 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5364 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5365 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5366 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5367 err = wmi_unified_cmd_send(wmi_handle, buf,
5368 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5369 if (err) {
5370 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5371 wmi_buf_free(buf);
5372 return QDF_STATUS_E_FAILURE;
5373 }
5374
5375 return QDF_STATUS_SUCCESS;
5376}
5377
5378
5379/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305380 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5381 * @wmi_handle: wmi handle
5382 * @roam_req: Request which contains the filters
5383 *
5384 * There are filters such as whitelist, blacklist and preferred
5385 * list that need to be applied to the scan results to form the
5386 * probable candidates for roaming.
5387 *
5388 * Return: Return success upon succesfully passing the
5389 * parameters to the firmware, otherwise failure.
5390 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305391static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305392 struct roam_scan_filter_params *roam_req)
5393{
5394 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305395 QDF_STATUS status;
5396 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305397 uint32_t len;
5398 uint8_t *buf_ptr;
5399 wmi_roam_filter_fixed_param *roam_filter;
5400 uint8_t *bssid_src_ptr = NULL;
5401 wmi_mac_addr *bssid_dst_ptr = NULL;
5402 wmi_ssid *ssid_ptr = NULL;
5403 uint32_t *bssid_preferred_factor_ptr = NULL;
5404
5405 len = sizeof(wmi_roam_filter_fixed_param);
5406 len += WMI_TLV_HDR_SIZE;
5407 len += roam_req->len;
5408
5409 buf = wmi_buf_alloc(wmi_handle, len);
5410 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305411 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305412 return QDF_STATUS_E_NOMEM;
5413 }
5414
5415 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5416 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5417 WMITLV_SET_HDR(&roam_filter->tlv_header,
5418 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5419 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5420 /* fill in fixed values */
5421 roam_filter->vdev_id = roam_req->session_id;
5422 roam_filter->flags = 0;
5423 roam_filter->op_bitmap = roam_req->op_bitmap;
5424 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5425 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5426 roam_filter->num_bssid_preferred_list =
5427 roam_req->num_bssid_preferred_list;
5428 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5429
5430 WMITLV_SET_HDR((buf_ptr),
5431 WMITLV_TAG_ARRAY_FIXED_STRUC,
5432 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5433 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5434 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5435 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5436 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5437 bssid_src_ptr += ATH_MAC_LEN;
5438 bssid_dst_ptr++;
5439 }
5440 buf_ptr += WMI_TLV_HDR_SIZE +
5441 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5442 WMITLV_SET_HDR((buf_ptr),
5443 WMITLV_TAG_ARRAY_FIXED_STRUC,
5444 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5445 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5446 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5447 qdf_mem_copy(&ssid_ptr->ssid,
5448 &roam_req->ssid_allowed_list[i].mac_ssid,
5449 roam_req->ssid_allowed_list[i].length);
5450 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5451 ssid_ptr++;
5452 }
5453 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5454 sizeof(wmi_ssid));
5455 WMITLV_SET_HDR((buf_ptr),
5456 WMITLV_TAG_ARRAY_FIXED_STRUC,
5457 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5458 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5459 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5460 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5461 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5462 (wmi_mac_addr *)bssid_dst_ptr);
5463 bssid_src_ptr += ATH_MAC_LEN;
5464 bssid_dst_ptr++;
5465 }
5466 buf_ptr += WMI_TLV_HDR_SIZE +
5467 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5469 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5470 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5471 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5472 *bssid_preferred_factor_ptr =
5473 roam_req->bssid_favored_factor[i];
5474 bssid_preferred_factor_ptr++;
5475 }
5476 buf_ptr += WMI_TLV_HDR_SIZE +
5477 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5478
5479 status = wmi_unified_cmd_send(wmi_handle, buf,
5480 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305481 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305482 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305483 status);
5484 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305485 }
Govind Singh67922e82016-04-01 16:48:57 +05305486
5487 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305488}
5489
Govind Singh4eacd2b2016-03-07 14:24:22 +05305490/** send_set_epno_network_list_cmd_tlv() - set epno network list
5491 * @wmi_handle: wmi handle
5492 * @req: epno config params request structure
5493 *
5494 * This function reads the incoming epno config request structure
5495 * and constructs the WMI message to the firmware.
5496 *
5497 * Returns: 0 on success, error number otherwise
5498 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305499static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305500 struct wifi_enhanched_pno_params *req)
5501{
5502 wmi_nlo_config_cmd_fixed_param *cmd;
5503 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305504 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305505 u_int8_t i, *buf_ptr;
5506 wmi_buf_t buf;
5507 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305508 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305509
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305510 /* Fixed Params */
5511 len = sizeof(*cmd);
5512 if (req->num_networks) {
5513 /* TLV place holder for array of structures
5514 * then each nlo_configured_parameters(nlo_list) TLV.
5515 */
5516 len += WMI_TLV_HDR_SIZE;
5517 len += (sizeof(nlo_configured_parameters)
5518 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5519 /* TLV for array of uint32 channel_list */
5520 len += WMI_TLV_HDR_SIZE;
5521 /* TLV for nlo_channel_prediction_cfg */
5522 len += WMI_TLV_HDR_SIZE;
5523 /* TLV for candidate score params */
5524 len += sizeof(enlo_candidate_score_params);
5525 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305526
5527 buf = wmi_buf_alloc(wmi_handle, len);
5528 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305529 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5530 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305531 }
5532
5533 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5534
5535 buf_ptr = (u_int8_t *) cmd;
5536 WMITLV_SET_HDR(&cmd->tlv_header,
5537 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5538 WMITLV_GET_STRUCT_TLVLEN(
5539 wmi_nlo_config_cmd_fixed_param));
5540 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305541
5542 /* set flag to reset if num of networks are 0 */
5543 cmd->flags = (req->num_networks == 0 ?
5544 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305545
5546 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5547
Govind Singhb53420c2016-03-09 14:32:57 +05305548 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305549 WMI_LOGD("SSID count: %d flags: %d",
5550 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305551
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305552 /* Fill nlo_config only when num_networks are non zero */
5553 if (cmd->no_of_ssids) {
5554 /* Fill networks */
5555 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5556 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5557 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305558
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305559 nlo_list = (nlo_configured_parameters *) buf_ptr;
5560 for (i = 0; i < cmd->no_of_ssids; i++) {
5561 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5562 WMITLV_TAG_ARRAY_BYTE,
5563 WMITLV_GET_STRUCT_TLVLEN(
5564 nlo_configured_parameters));
5565 /* Copy ssid and it's length */
5566 nlo_list[i].ssid.valid = true;
5567 nlo_list[i].ssid.ssid.ssid_len =
5568 req->networks[i].ssid.length;
5569 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5570 req->networks[i].ssid.mac_ssid,
5571 nlo_list[i].ssid.ssid.ssid_len);
5572 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5573 nlo_list[i].ssid.ssid.ssid_len,
5574 (char *) nlo_list[i].ssid.ssid.ssid,
5575 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305576
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305577 /* Copy pno flags */
5578 nlo_list[i].bcast_nw_type.valid = true;
5579 nlo_list[i].bcast_nw_type.bcast_nw_type =
5580 req->networks[i].flags;
5581 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305582 nlo_list[i].bcast_nw_type.bcast_nw_type);
5583
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305584 /* Copy auth bit field */
5585 nlo_list[i].auth_type.valid = true;
5586 nlo_list[i].auth_type.auth_type =
5587 req->networks[i].auth_bit_field;
5588 WMI_LOGD("Auth bit field (%u)",
5589 nlo_list[i].auth_type.auth_type);
5590 }
5591
5592 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5593 /* Fill the channel list */
5594 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5595 buf_ptr += WMI_TLV_HDR_SIZE;
5596
5597 /* Fill prediction_param */
5598 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5599 buf_ptr += WMI_TLV_HDR_SIZE;
5600
5601 /* Fill epno candidate score params */
5602 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5603 WMITLV_SET_HDR(buf_ptr,
5604 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5605 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5606 cand_score_params->min5GHz_rssi =
5607 req->min_5ghz_rssi;
5608 cand_score_params->min24GHz_rssi =
5609 req->min_24ghz_rssi;
5610 cand_score_params->initial_score_max =
5611 req->initial_score_max;
5612 cand_score_params->current_connection_bonus =
5613 req->current_connection_bonus;
5614 cand_score_params->same_network_bonus =
5615 req->same_network_bonus;
5616 cand_score_params->secure_bonus =
5617 req->secure_bonus;
5618 cand_score_params->band5GHz_bonus =
5619 req->band_5ghz_bonus;
5620 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305621 }
5622
Govind Singh4eacd2b2016-03-07 14:24:22 +05305623 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305624 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305625 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305626 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305627 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305628 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305629 }
5630
Govind Singhb53420c2016-03-09 14:32:57 +05305631 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305632 req->session_id);
5633
Govind Singh67922e82016-04-01 16:48:57 +05305634 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305635}
5636
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305637
Govind Singh4eacd2b2016-03-07 14:24:22 +05305638/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5639 * @wmi_handle: wmi handle
5640 * @ipa_offload: ipa offload control parameter
5641 *
5642 * Returns: 0 on success, error number otherwise
5643 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305644static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305645 struct ipa_offload_control_params *ipa_offload)
5646{
5647 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5648 wmi_buf_t wmi_buf;
5649 uint32_t len;
5650 u_int8_t *buf_ptr;
5651
5652 len = sizeof(*cmd);
5653 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5654 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305655 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5656 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305657 }
5658
Govind Singhb53420c2016-03-09 14:32:57 +05305659 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305660 ipa_offload->offload_type, ipa_offload->enable);
5661
5662 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5663
5664 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5665 WMITLV_SET_HDR(&cmd->tlv_header,
5666 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5667 WMITLV_GET_STRUCT_TLVLEN(
5668 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5669
5670 cmd->offload_type = ipa_offload->offload_type;
5671 cmd->vdev_id = ipa_offload->vdev_id;
5672 cmd->enable = ipa_offload->enable;
5673
5674 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5675 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305676 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305677 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305678 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305679 }
5680
Govind Singhb53420c2016-03-09 14:32:57 +05305681 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305682}
5683
5684/**
5685 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5686 * @wmi_handle: wmi handle
5687 * @pgetcapab: get capabilities params
5688 *
5689 * This function send request to fw to get extscan capabilities.
5690 *
5691 * Return: CDF status
5692 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305693static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305694 struct extscan_capabilities_params *pgetcapab)
5695{
5696 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5697 wmi_buf_t wmi_buf;
5698 uint32_t len;
5699 uint8_t *buf_ptr;
5700
5701 len = sizeof(*cmd);
5702 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5703 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305704 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5705 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305706 }
5707 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5708
5709 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5710 WMITLV_SET_HDR(&cmd->tlv_header,
5711 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5712 WMITLV_GET_STRUCT_TLVLEN
5713 (wmi_extscan_get_capabilities_cmd_fixed_param));
5714
5715 cmd->request_id = pgetcapab->request_id;
5716
5717 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5718 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305719 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305720 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305721 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305722 }
Govind Singhb53420c2016-03-09 14:32:57 +05305723 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305724}
5725
5726/**
5727 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5728 * @wmi_handle: wmi handle
5729 * @pcached_results: cached results parameters
5730 *
5731 * This function send request to fw to get cached results.
5732 *
5733 * Return: CDF status
5734 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305735static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305736 struct extscan_cached_result_params *pcached_results)
5737{
5738 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5739 wmi_buf_t wmi_buf;
5740 uint32_t len;
5741 uint8_t *buf_ptr;
5742
5743 len = sizeof(*cmd);
5744 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5745 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305746 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5747 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305748 }
5749 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5750
5751 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
5752 WMITLV_SET_HDR(&cmd->tlv_header,
5753 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
5754 WMITLV_GET_STRUCT_TLVLEN
5755 (wmi_extscan_get_cached_results_cmd_fixed_param));
5756
5757 cmd->request_id = pcached_results->request_id;
5758 cmd->vdev_id = pcached_results->session_id;
5759 cmd->control_flags = pcached_results->flush;
5760
5761 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5762 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305763 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305764 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305765 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305766 }
Govind Singhb53420c2016-03-09 14:32:57 +05305767 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305768}
5769
5770/**
5771 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
5772 * @wmi_handle: wmi handle
5773 * @reset_req: Reset change request params
5774 *
5775 * This function sends stop change monitor request to fw.
5776 *
5777 * Return: CDF status
5778 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305779static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305780 struct extscan_capabilities_reset_params *reset_req)
5781{
5782 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5783 wmi_buf_t wmi_buf;
5784 uint32_t len;
5785 uint8_t *buf_ptr;
5786 int change_list = 0;
5787
5788 len = sizeof(*cmd);
5789
5790 /* reset significant change tlv is set to 0 */
5791 len += WMI_TLV_HDR_SIZE;
5792 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
5793 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5794 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305795 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5796 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305797 }
5798 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5799
5800 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5801 buf_ptr;
5802 WMITLV_SET_HDR(&cmd->tlv_header,
5803 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5804 WMITLV_GET_STRUCT_TLVLEN
5805 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5806
5807 cmd->request_id = reset_req->request_id;
5808 cmd->vdev_id = reset_req->session_id;
5809 cmd->mode = 0;
5810
5811 buf_ptr += sizeof(*cmd);
5812 WMITLV_SET_HDR(buf_ptr,
5813 WMITLV_TAG_ARRAY_STRUC,
5814 change_list *
5815 sizeof(wmi_extscan_wlan_change_bssid_param));
5816 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
5817 sizeof
5818 (wmi_extscan_wlan_change_bssid_param));
5819
5820 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5821 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305822 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305823 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305824 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305825 }
Govind Singhb53420c2016-03-09 14:32:57 +05305826 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305827}
5828
5829/**
5830 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
5831 * @wmi_handle: wmi handle
5832 * @psigchange: change monitor request params
5833 * @buf: wmi buffer
5834 * @buf_len: buffer length
5835 *
5836 * This function fills elements of change monitor request buffer.
5837 *
5838 * Return: CDF status
5839 */
Govind Singhb53420c2016-03-09 14:32:57 +05305840static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305841 struct extscan_set_sig_changereq_params
5842 *psigchange, wmi_buf_t *buf, int *buf_len)
5843{
5844 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5845 wmi_extscan_wlan_change_bssid_param *dest_chglist;
5846 uint8_t *buf_ptr;
5847 int j;
5848 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08005849 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305850 struct ap_threshold_params *src_ap = psigchange->ap;
5851
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08005852 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305853 WMI_LOGE("%s: Invalid number of bssid's", __func__);
5854 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305855 }
5856 len += WMI_TLV_HDR_SIZE;
5857 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
5858
5859 *buf = wmi_buf_alloc(wmi_handle, len);
5860 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305861 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305862 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305863 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305864 }
5865 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5866 cmd =
5867 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5868 buf_ptr;
5869 WMITLV_SET_HDR(&cmd->tlv_header,
5870 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5871 WMITLV_GET_STRUCT_TLVLEN
5872 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5873
5874 cmd->request_id = psigchange->request_id;
5875 cmd->vdev_id = psigchange->session_id;
5876 cmd->total_entries = numap;
5877 cmd->mode = 1;
5878 cmd->num_entries_in_page = numap;
5879 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
5880 cmd->max_rssi_samples = psigchange->rssi_sample_size;
5881 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
5882 cmd->max_out_of_range_count = psigchange->min_breaching;
5883
5884 buf_ptr += sizeof(*cmd);
5885 WMITLV_SET_HDR(buf_ptr,
5886 WMITLV_TAG_ARRAY_STRUC,
5887 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5888 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
5889 (buf_ptr + WMI_TLV_HDR_SIZE);
5890
5891 for (j = 0; j < numap; j++) {
5892 WMITLV_SET_HDR(dest_chglist,
5893 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5894 WMITLV_GET_STRUCT_TLVLEN
5895 (wmi_extscan_wlan_change_bssid_param));
5896
5897 dest_chglist->lower_rssi_limit = src_ap->low;
5898 dest_chglist->upper_rssi_limit = src_ap->high;
5899 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
5900 &dest_chglist->bssid);
5901
Govind Singhb53420c2016-03-09 14:32:57 +05305902 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305903 dest_chglist->lower_rssi_limit);
5904 dest_chglist++;
5905 src_ap++;
5906 }
5907 buf_ptr += WMI_TLV_HDR_SIZE +
5908 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5909 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305910 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305911}
5912
5913/**
5914 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
5915 * @wmi_handle: wmi handle
5916 * @psigchange: change monitor request params
5917 *
5918 * This function sends start change monitor request to fw.
5919 *
5920 * Return: CDF status
5921 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305922static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305923 struct extscan_set_sig_changereq_params *
5924 psigchange)
5925{
Govind Singhb53420c2016-03-09 14:32:57 +05305926 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305927 wmi_buf_t buf;
5928 int len;
5929
5930
Govind Singhb53420c2016-03-09 14:32:57 +05305931 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305932 psigchange, &buf,
5933 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305934 if (qdf_status != QDF_STATUS_SUCCESS) {
5935 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305936 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305937 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305938 }
5939 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305940 WMI_LOGE("%s: Failed to get buffer", __func__);
5941 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305942 }
5943 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5944 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305945 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305946 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305947 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305948 }
Govind Singhb53420c2016-03-09 14:32:57 +05305949 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305950}
5951
5952/**
5953 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
5954 * @wmi_handle: wmi handle
5955 * @photlist_reset: hotlist reset params
5956 *
5957 * This function configures hotlist monitor to stop in fw.
5958 *
5959 * Return: CDF status
5960 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305961static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305962 struct extscan_bssid_hotlist_reset_params *photlist_reset)
5963{
5964 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
5965 wmi_buf_t wmi_buf;
5966 uint32_t len;
5967 uint8_t *buf_ptr;
5968 int hotlist_entries = 0;
5969
5970 len = sizeof(*cmd);
5971
5972 /* reset bssid hotlist with tlv set to 0 */
5973 len += WMI_TLV_HDR_SIZE;
5974 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
5975
5976 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5977 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305978 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5979 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305980 }
5981
5982 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5983 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
5984 buf_ptr;
5985 WMITLV_SET_HDR(&cmd->tlv_header,
5986 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
5987 WMITLV_GET_STRUCT_TLVLEN
5988 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
5989
5990 cmd->request_id = photlist_reset->request_id;
5991 cmd->vdev_id = photlist_reset->session_id;
5992 cmd->mode = 0;
5993
5994 buf_ptr += sizeof(*cmd);
5995 WMITLV_SET_HDR(buf_ptr,
5996 WMITLV_TAG_ARRAY_STRUC,
5997 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5998 buf_ptr += WMI_TLV_HDR_SIZE +
5999 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6000
6001 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6002 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306003 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306004 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306005 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306006 }
Govind Singhb53420c2016-03-09 14:32:57 +05306007 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306008}
6009
6010/**
6011 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6012 * @wmi_handle: wmi handle
6013 * @pstopcmd: stop scan command request params
6014 *
6015 * This function sends stop extscan request to fw.
6016 *
6017 * Return: CDF Status.
6018 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306019static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306020 struct extscan_stop_req_params *pstopcmd)
6021{
6022 wmi_extscan_stop_cmd_fixed_param *cmd;
6023 wmi_buf_t wmi_buf;
6024 uint32_t len;
6025 uint8_t *buf_ptr;
6026
6027 len = sizeof(*cmd);
6028 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6029 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306030 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6031 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306032 }
6033 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6034 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6035 WMITLV_SET_HDR(&cmd->tlv_header,
6036 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6037 WMITLV_GET_STRUCT_TLVLEN
6038 (wmi_extscan_stop_cmd_fixed_param));
6039
6040 cmd->request_id = pstopcmd->request_id;
6041 cmd->vdev_id = pstopcmd->session_id;
6042
6043 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6044 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306045 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306046 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306047 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306048 }
6049
Govind Singhb53420c2016-03-09 14:32:57 +05306050 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306051}
6052
6053/**
6054 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6055 * @wmi_handle: wmi handle
6056 * @pstart: scan command request params
6057 * @buf: event buffer
6058 * @buf_len: length of buffer
6059 *
6060 * This function fills individual elements of extscan request and
6061 * TLV for buckets, channel list.
6062 *
6063 * Return: CDF Status.
6064 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006065static
Govind Singhb53420c2016-03-09 14:32:57 +05306066QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306067 struct wifi_scan_cmd_req_params *pstart,
6068 wmi_buf_t *buf, int *buf_len)
6069{
6070 wmi_extscan_start_cmd_fixed_param *cmd;
6071 wmi_extscan_bucket *dest_blist;
6072 wmi_extscan_bucket_channel *dest_clist;
6073 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6074 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6075 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6076
6077 uint8_t *buf_ptr;
6078 int i, k, count = 0;
6079 int len = sizeof(*cmd);
6080 int nbuckets = pstart->numBuckets;
6081 int nchannels = 0;
6082
6083 /* These TLV's are are NULL by default */
6084 uint32_t ie_len_with_pad = 0;
6085 int num_ssid = 0;
6086 int num_bssid = 0;
6087 int ie_len = 0;
6088
6089 uint32_t base_period = pstart->basePeriod;
6090
6091 /* TLV placeholder for ssid_list (NULL) */
6092 len += WMI_TLV_HDR_SIZE;
6093 len += num_ssid * sizeof(wmi_ssid);
6094
6095 /* TLV placeholder for bssid_list (NULL) */
6096 len += WMI_TLV_HDR_SIZE;
6097 len += num_bssid * sizeof(wmi_mac_addr);
6098
6099 /* TLV placeholder for ie_data (NULL) */
6100 len += WMI_TLV_HDR_SIZE;
6101 len += ie_len * sizeof(uint32_t);
6102
6103 /* TLV placeholder for bucket */
6104 len += WMI_TLV_HDR_SIZE;
6105 len += nbuckets * sizeof(wmi_extscan_bucket);
6106
6107 /* TLV channel placeholder */
6108 len += WMI_TLV_HDR_SIZE;
6109 for (i = 0; i < nbuckets; i++) {
6110 nchannels += src_bucket->numChannels;
6111 src_bucket++;
6112 }
6113
Govind Singhb53420c2016-03-09 14:32:57 +05306114 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306115 __func__, nbuckets, nchannels);
6116 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6117 /* Allocate the memory */
6118 *buf = wmi_buf_alloc(wmi_handle, len);
6119 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306120 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306121 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306122 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306123 }
6124 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6125 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6126 WMITLV_SET_HDR(&cmd->tlv_header,
6127 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6128 WMITLV_GET_STRUCT_TLVLEN
6129 (wmi_extscan_start_cmd_fixed_param));
6130
6131 cmd->request_id = pstart->requestId;
6132 cmd->vdev_id = pstart->sessionId;
6133 cmd->base_period = pstart->basePeriod;
6134 cmd->num_buckets = nbuckets;
6135 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306136 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306137 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306138 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306139 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306140#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306141 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6142 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306143 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6144 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6145#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306146 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6147
6148 /* The max dwell time is retrieved from the first channel
6149 * of the first bucket and kept common for all channels.
6150 */
6151 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6152 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6153 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6154 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6155 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6156 cmd->max_table_usage = pstart->report_threshold_percent;
6157 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6158
6159 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306160 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306161 cmd->probe_delay = 0;
6162 cmd->probe_spacing_time = 0;
6163 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306164 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6165 WMI_SCAN_ADD_CCK_RATES |
6166 WMI_SCAN_ADD_OFDM_RATES |
6167 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6168 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306169 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6170 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306171 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306172 cmd->num_ssids = 0;
6173 cmd->num_bssid = 0;
6174 cmd->ie_len = 0;
6175 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6176 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6177
6178 buf_ptr += sizeof(*cmd);
6179 WMITLV_SET_HDR(buf_ptr,
6180 WMITLV_TAG_ARRAY_FIXED_STRUC,
6181 num_ssid * sizeof(wmi_ssid));
6182 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6183
6184 WMITLV_SET_HDR(buf_ptr,
6185 WMITLV_TAG_ARRAY_FIXED_STRUC,
6186 num_bssid * sizeof(wmi_mac_addr));
6187 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6188
6189 ie_len_with_pad = 0;
6190 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6191 ie_len_with_pad);
6192 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6193
6194 WMITLV_SET_HDR(buf_ptr,
6195 WMITLV_TAG_ARRAY_STRUC,
6196 nbuckets * sizeof(wmi_extscan_bucket));
6197 dest_blist = (wmi_extscan_bucket *)
6198 (buf_ptr + WMI_TLV_HDR_SIZE);
6199 src_bucket = pstart->buckets;
6200
6201 /* Retrieve scanning information from each bucket and
6202 * channels and send it to the target
6203 */
6204 for (i = 0; i < nbuckets; i++) {
6205 WMITLV_SET_HDR(dest_blist,
6206 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6207 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6208
6209 dest_blist->bucket_id = src_bucket->bucket;
6210 dest_blist->base_period_multiplier =
6211 src_bucket->period / base_period;
6212 dest_blist->min_period = src_bucket->period;
6213 dest_blist->max_period = src_bucket->max_period;
6214 dest_blist->exp_backoff = src_bucket->exponent;
6215 dest_blist->exp_max_step_count = src_bucket->step_count;
6216 dest_blist->channel_band = src_bucket->band;
6217 dest_blist->num_channels = src_bucket->numChannels;
6218 dest_blist->notify_extscan_events = 0;
6219
6220 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6221 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006222 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6223 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306224
6225 if (src_bucket->reportEvents &
6226 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6227 dest_blist->forwarding_flags =
6228 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6229 dest_blist->notify_extscan_events |=
6230 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6231 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6232 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6233 } else {
6234 dest_blist->forwarding_flags =
6235 WMI_EXTSCAN_NO_FORWARDING;
6236 }
6237
6238 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6239 dest_blist->configuration_flags = 0;
6240 else
6241 dest_blist->configuration_flags =
6242 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6243
Govind Singhb53420c2016-03-09 14:32:57 +05306244 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306245 __func__, dest_blist->notify_extscan_events,
6246 dest_blist->configuration_flags,
6247 dest_blist->forwarding_flags);
6248
6249 dest_blist->min_dwell_time_active =
6250 src_bucket->min_dwell_time_active;
6251 dest_blist->max_dwell_time_active =
6252 src_bucket->max_dwell_time_active;
6253 dest_blist->min_dwell_time_passive =
6254 src_bucket->min_dwell_time_passive;
6255 dest_blist->max_dwell_time_passive =
6256 src_bucket->max_dwell_time_passive;
6257 src_channel = src_bucket->channels;
6258
6259 /* save the channel info to later populate
6260 * the channel TLV
6261 */
6262 for (k = 0; k < src_bucket->numChannels; k++) {
6263 save_channel[count++].channel = src_channel->channel;
6264 src_channel++;
6265 }
6266 dest_blist++;
6267 src_bucket++;
6268 }
6269 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6270 WMITLV_SET_HDR(buf_ptr,
6271 WMITLV_TAG_ARRAY_STRUC,
6272 nchannels * sizeof(wmi_extscan_bucket_channel));
6273 dest_clist = (wmi_extscan_bucket_channel *)
6274 (buf_ptr + WMI_TLV_HDR_SIZE);
6275
6276 /* Active or passive scan is based on the bucket dwell time
6277 * and channel specific active,passive scans are not
6278 * supported yet
6279 */
6280 for (i = 0; i < nchannels; i++) {
6281 WMITLV_SET_HDR(dest_clist,
6282 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6283 WMITLV_GET_STRUCT_TLVLEN
6284 (wmi_extscan_bucket_channel));
6285 dest_clist->channel = save_channel[i].channel;
6286 dest_clist++;
6287 }
6288 buf_ptr += WMI_TLV_HDR_SIZE +
6289 (nchannels * sizeof(wmi_extscan_bucket_channel));
6290 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306291 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306292}
6293
6294/**
6295 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6296 * @wmi_handle: wmi handle
6297 * @pstart: scan command request params
6298 *
6299 * This function sends start extscan request to fw.
6300 *
6301 * Return: CDF Status.
6302 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306303static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306304 struct wifi_scan_cmd_req_params *pstart)
6305{
Govind Singhb53420c2016-03-09 14:32:57 +05306306 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306307 wmi_buf_t buf;
6308 int len;
6309
6310 /* Fill individual elements of extscan request and
6311 * TLV for buckets, channel list.
6312 */
Govind Singhb53420c2016-03-09 14:32:57 +05306313 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306314 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306315 if (qdf_status != QDF_STATUS_SUCCESS) {
6316 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6317 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306318 }
6319 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306320 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306321 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306322 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306323 }
6324 if (wmi_unified_cmd_send(wmi_handle, buf,
6325 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306326 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306327 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306328 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306329 }
6330
Govind Singhb53420c2016-03-09 14:32:57 +05306331 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306332}
6333
6334/**
6335 * send_plm_stop_cmd_tlv() - plm stop request
6336 * @wmi_handle: wmi handle
6337 * @plm: plm request parameters
6338 *
6339 * This function request FW to stop PLM.
6340 *
6341 * Return: CDF status
6342 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306343static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306344 const struct plm_req_params *plm)
6345{
6346 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6347 int32_t len;
6348 wmi_buf_t buf;
6349 uint8_t *buf_ptr;
6350 int ret;
6351
6352 len = sizeof(*cmd);
6353 buf = wmi_buf_alloc(wmi_handle, len);
6354 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306355 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6356 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306357 }
6358
6359 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6360
6361 buf_ptr = (uint8_t *) cmd;
6362
6363 WMITLV_SET_HDR(&cmd->tlv_header,
6364 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6365 WMITLV_GET_STRUCT_TLVLEN
6366 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6367
6368 cmd->vdev_id = plm->session_id;
6369
6370 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306371 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306372
6373 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6374 WMI_VDEV_PLMREQ_STOP_CMDID);
6375 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306376 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306377 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306378 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306379 }
6380
Govind Singhb53420c2016-03-09 14:32:57 +05306381 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306382}
6383
6384/**
6385 * send_plm_start_cmd_tlv() - plm start request
6386 * @wmi_handle: wmi handle
6387 * @plm: plm request parameters
6388 *
6389 * This function request FW to start PLM.
6390 *
6391 * Return: CDF status
6392 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306393static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306394 const struct plm_req_params *plm,
6395 uint32_t *gchannel_list)
6396{
6397 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6398 uint32_t *channel_list;
6399 int32_t len;
6400 wmi_buf_t buf;
6401 uint8_t *buf_ptr;
6402 uint8_t count;
6403 int ret;
6404
6405 /* TLV place holder for channel_list */
6406 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6407 len += sizeof(uint32_t) * plm->plm_num_ch;
6408
6409 buf = wmi_buf_alloc(wmi_handle, len);
6410 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306411 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6412 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306413 }
6414 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6415
6416 buf_ptr = (uint8_t *) cmd;
6417
6418 WMITLV_SET_HDR(&cmd->tlv_header,
6419 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6420 WMITLV_GET_STRUCT_TLVLEN
6421 (wmi_vdev_plmreq_start_cmd_fixed_param));
6422
6423 cmd->vdev_id = plm->session_id;
6424
6425 cmd->meas_token = plm->meas_token;
6426 cmd->dialog_token = plm->diag_token;
6427 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306428 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306429 cmd->off_duration = plm->meas_duration;
6430 cmd->burst_cycle = plm->burst_len;
6431 cmd->tx_power = plm->desired_tx_pwr;
6432 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6433 cmd->num_chans = plm->plm_num_ch;
6434
6435 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6436
Govind Singhb53420c2016-03-09 14:32:57 +05306437 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6438 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6439 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6440 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6441 WMI_LOGD("off_duration: %d", cmd->off_duration);
6442 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6443 WMI_LOGD("tx_power: %d", cmd->tx_power);
6444 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306445
6446 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6447 (cmd->num_chans * sizeof(uint32_t)));
6448
6449 buf_ptr += WMI_TLV_HDR_SIZE;
6450 if (cmd->num_chans) {
6451 channel_list = (uint32_t *) buf_ptr;
6452 for (count = 0; count < cmd->num_chans; count++) {
6453 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306454 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306455 channel_list[count] =
6456 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306457 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306458 }
6459 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6460 }
6461
6462 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6463 WMI_VDEV_PLMREQ_START_CMDID);
6464 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306465 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306466 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306467 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306468 }
6469
Govind Singhb53420c2016-03-09 14:32:57 +05306470 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306471}
6472
6473/**
6474 * send_pno_stop_cmd_tlv() - PNO stop request
6475 * @wmi_handle: wmi handle
6476 * @vdev_id: vdev id
6477 *
6478 * This function request FW to stop ongoing PNO operation.
6479 *
6480 * Return: CDF status
6481 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306482static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306483{
6484 wmi_nlo_config_cmd_fixed_param *cmd;
6485 int32_t len = sizeof(*cmd);
6486 wmi_buf_t buf;
6487 uint8_t *buf_ptr;
6488 int ret;
6489
6490 /*
6491 * TLV place holder for array of structures nlo_configured_parameters
6492 * TLV place holder for array of uint32_t channel_list
6493 * TLV place holder for chnl prediction cfg
6494 */
6495 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6496 buf = wmi_buf_alloc(wmi_handle, len);
6497 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306498 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6499 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306500 }
6501
6502 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6503 buf_ptr = (uint8_t *) cmd;
6504
6505 WMITLV_SET_HDR(&cmd->tlv_header,
6506 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6507 WMITLV_GET_STRUCT_TLVLEN
6508 (wmi_nlo_config_cmd_fixed_param));
6509
6510 cmd->vdev_id = vdev_id;
6511 cmd->flags = WMI_NLO_CONFIG_STOP;
6512 buf_ptr += sizeof(*cmd);
6513
6514 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6515 buf_ptr += WMI_TLV_HDR_SIZE;
6516
6517 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6518 buf_ptr += WMI_TLV_HDR_SIZE;
6519
6520 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6521 buf_ptr += WMI_TLV_HDR_SIZE;
6522
6523
6524 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6525 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6526 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306527 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306528 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306529 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306530 }
6531
Govind Singhb53420c2016-03-09 14:32:57 +05306532 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306533}
6534
6535/**
Govind Singhccb0c272016-04-01 16:30:08 +05306536 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6537 * @buf_ptr: Buffer passed by upper layers
6538 * @pno: Buffer to be sent to the firmware
6539 *
6540 * Copy the PNO Channel prediction configuration parameters
6541 * passed by the upper layers to a WMI format TLV and send it
6542 * down to the firmware.
6543 *
6544 * Return: None
6545 */
6546static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6547 struct pno_scan_req_params *pno)
6548{
6549 nlo_channel_prediction_cfg *channel_prediction_cfg =
6550 (nlo_channel_prediction_cfg *) buf_ptr;
6551 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6552 WMITLV_TAG_ARRAY_BYTE,
6553 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306554#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306555 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6556 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6557 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6558 channel_prediction_cfg->full_scan_period_ms =
6559 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306560#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306561 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6562 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6563 channel_prediction_cfg->enable,
6564 channel_prediction_cfg->top_k_num,
6565 channel_prediction_cfg->stationary_threshold,
6566 channel_prediction_cfg->full_scan_period_ms);
6567}
6568
6569/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306570 * send_pno_start_cmd_tlv() - PNO start request
6571 * @wmi_handle: wmi handle
6572 * @pno: PNO request
6573 *
6574 * This function request FW to start PNO request.
6575 * Request: CDF status
6576 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306577static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306578 struct pno_scan_req_params *pno,
6579 uint32_t *gchannel_freq_list)
6580{
6581 wmi_nlo_config_cmd_fixed_param *cmd;
6582 nlo_configured_parameters *nlo_list;
6583 uint32_t *channel_list;
6584 int32_t len;
6585 wmi_buf_t buf;
6586 uint8_t *buf_ptr;
6587 uint8_t i;
6588 int ret;
6589
6590 /*
6591 * TLV place holder for array nlo_configured_parameters(nlo_list)
6592 * TLV place holder for array of uint32_t channel_list
6593 * TLV place holder for chnnl prediction cfg
6594 */
6595 len = sizeof(*cmd) +
6596 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6597
Govind Singhb53420c2016-03-09 14:32:57 +05306598 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306599 WMI_NLO_MAX_CHAN);
6600 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306601 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306602 len += sizeof(nlo_channel_prediction_cfg);
6603
6604 buf = wmi_buf_alloc(wmi_handle, len);
6605 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306606 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6607 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306608 }
6609
6610 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6611
6612 buf_ptr = (uint8_t *) cmd;
6613 WMITLV_SET_HDR(&cmd->tlv_header,
6614 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6615 WMITLV_GET_STRUCT_TLVLEN
6616 (wmi_nlo_config_cmd_fixed_param));
6617 cmd->vdev_id = pno->sessionId;
6618 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6619
Govind Singh87542482016-06-08 19:40:11 +05306620#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306621 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6622 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306623#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306624 /* Current FW does not support min-max range for dwell time */
6625 cmd->active_dwell_time = pno->active_max_time;
6626 cmd->passive_dwell_time = pno->passive_max_time;
6627
6628 /* Copy scan interval */
6629 cmd->fast_scan_period = pno->fast_scan_period;
6630 cmd->slow_scan_period = pno->slow_scan_period;
6631 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306632 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306633 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306634 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306635
6636 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6637
Govind Singhb53420c2016-03-09 14:32:57 +05306638 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6639 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306640 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6641 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6642 buf_ptr += WMI_TLV_HDR_SIZE;
6643
6644 nlo_list = (nlo_configured_parameters *) buf_ptr;
6645 for (i = 0; i < cmd->no_of_ssids; i++) {
6646 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6647 WMITLV_TAG_ARRAY_BYTE,
6648 WMITLV_GET_STRUCT_TLVLEN
6649 (nlo_configured_parameters));
6650 /* Copy ssid and it's length */
6651 nlo_list[i].ssid.valid = true;
6652 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306653 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306654 pno->aNetworks[i].ssid.mac_ssid,
6655 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306656 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306657 nlo_list[i].ssid.ssid.ssid_len,
6658 (char *)nlo_list[i].ssid.ssid.ssid,
6659 nlo_list[i].ssid.ssid.ssid_len);
6660
6661 /* Copy rssi threshold */
6662 if (pno->aNetworks[i].rssiThreshold &&
6663 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6664 nlo_list[i].rssi_cond.valid = true;
6665 nlo_list[i].rssi_cond.rssi =
6666 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306667 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306668 nlo_list[i].rssi_cond.rssi);
6669 }
6670 nlo_list[i].bcast_nw_type.valid = true;
6671 nlo_list[i].bcast_nw_type.bcast_nw_type =
6672 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306673 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306674 nlo_list[i].bcast_nw_type.bcast_nw_type);
6675 }
6676 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6677
6678 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306679 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306680 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306681 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306682 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6683 (cmd->num_of_channels * sizeof(uint32_t)));
6684 buf_ptr += WMI_TLV_HDR_SIZE;
6685
6686 channel_list = (uint32_t *) buf_ptr;
6687 for (i = 0; i < cmd->num_of_channels; i++) {
6688 channel_list[i] = pno->aNetworks[0].aChannels[i];
6689
6690 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6691 channel_list[i] = gchannel_freq_list[i];
6692
Govind Singhb53420c2016-03-09 14:32:57 +05306693 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306694 }
6695 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6696 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6697 sizeof(nlo_channel_prediction_cfg));
6698 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306699 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306700 buf_ptr += WMI_TLV_HDR_SIZE;
6701 /** TODO: Discrete firmware doesn't have command/option to configure
6702 * App IE which comes from wpa_supplicant as of part PNO start request.
6703 */
6704 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6705 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6706 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306707 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306708 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306709 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306710 }
6711
Govind Singhb53420c2016-03-09 14:32:57 +05306712 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306713}
6714
6715/* send_set_ric_req_cmd_tlv() - set ric request element
6716 * @wmi_handle: wmi handle
6717 * @msg: message
6718 * @is_add_ts: is addts required
6719 *
6720 * This function sets ric request element for 11r roaming.
6721 *
6722 * Return: CDF status
6723 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306724static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306725 void *msg, uint8_t is_add_ts)
6726{
6727 wmi_ric_request_fixed_param *cmd;
6728 wmi_ric_tspec *tspec_param;
6729 wmi_buf_t buf;
6730 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306731 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306732 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6733 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6734
6735 buf = wmi_buf_alloc(wmi_handle, len);
6736 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306737 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6738 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306739 }
6740
6741 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6742
6743 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6744 WMITLV_SET_HDR(&cmd->tlv_header,
6745 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6746 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6747 if (is_add_ts)
6748 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
6749 else
6750 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
6751 cmd->num_ric_request = 1;
6752 cmd->is_add_ric = is_add_ts;
6753
6754 buf_ptr += sizeof(wmi_ric_request_fixed_param);
6755 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
6756
6757 buf_ptr += WMI_TLV_HDR_SIZE;
6758 tspec_param = (wmi_ric_tspec *) buf_ptr;
6759 WMITLV_SET_HDR(&tspec_param->tlv_header,
6760 WMITLV_TAG_STRUC_wmi_ric_tspec,
6761 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
6762
6763 if (is_add_ts)
6764 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05306765#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05306766 else
6767 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05306768#endif
6769 if (ptspecIE) {
6770 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05306771#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05306772 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
6773 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306774#else
Govind Singh87542482016-06-08 19:40:11 +05306775 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
6776 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306777#endif /* ANI_LITTLE_BIT_ENDIAN */
6778
Govind Singh87542482016-06-08 19:40:11 +05306779 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
6780 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
6781 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
6782 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
6783 tspec_param->inactivity_interval = ptspecIE->inactInterval;
6784 tspec_param->suspension_interval = ptspecIE->suspendInterval;
6785 tspec_param->svc_start_time = ptspecIE->svcStartTime;
6786 tspec_param->min_data_rate = ptspecIE->minDataRate;
6787 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
6788 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
6789 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
6790 tspec_param->delay_bound = ptspecIE->delayBound;
6791 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
6792 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
6793 tspec_param->medium_time = 0;
6794 }
Govind Singhb53420c2016-03-09 14:32:57 +05306795 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306796
6797 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6798 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306799 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306800 __func__);
6801 if (is_add_ts)
6802 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05306803 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05306804 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306805 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306806 }
6807
Govind Singhb53420c2016-03-09 14:32:57 +05306808 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306809}
6810
6811/**
6812 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
6813 * @wmi_handle: wmi handle
6814 * @clear_req: ll stats clear request command params
6815 *
Govind Singhb53420c2016-03-09 14:32:57 +05306816 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306817 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306818static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306819 const struct ll_stats_clear_params *clear_req,
6820 uint8_t addr[IEEE80211_ADDR_LEN])
6821{
6822 wmi_clear_link_stats_cmd_fixed_param *cmd;
6823 int32_t len;
6824 wmi_buf_t buf;
6825 uint8_t *buf_ptr;
6826 int ret;
6827
6828 len = sizeof(*cmd);
6829 buf = wmi_buf_alloc(wmi_handle, len);
6830
6831 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306832 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6833 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306834 }
6835
6836 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306837 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306838 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
6839
6840 WMITLV_SET_HDR(&cmd->tlv_header,
6841 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
6842 WMITLV_GET_STRUCT_TLVLEN
6843 (wmi_clear_link_stats_cmd_fixed_param));
6844
6845 cmd->stop_stats_collection_req = clear_req->stop_req;
6846 cmd->vdev_id = clear_req->sta_id;
6847 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
6848
6849 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6850 &cmd->peer_macaddr);
6851
Govind Singhb53420c2016-03-09 14:32:57 +05306852 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
6853 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
6854 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
6855 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
6856 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306857 cmd->peer_macaddr); */
6858
6859 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6860 WMI_CLEAR_LINK_STATS_CMDID);
6861 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306862 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306863 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306864 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306865 }
6866
Govind Singhb53420c2016-03-09 14:32:57 +05306867 WMI_LOGD("Clear Link Layer Stats request sent successfully");
6868 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306869}
6870
6871/**
6872 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
6873 * @wmi_handle: wmi handle
6874 * @setReq: ll stats set request command params
6875 *
Govind Singhb53420c2016-03-09 14:32:57 +05306876 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306877 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306878static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306879 const struct ll_stats_set_params *set_req)
6880{
6881 wmi_start_link_stats_cmd_fixed_param *cmd;
6882 int32_t len;
6883 wmi_buf_t buf;
6884 uint8_t *buf_ptr;
6885 int ret;
6886
6887 len = sizeof(*cmd);
6888 buf = wmi_buf_alloc(wmi_handle, len);
6889
6890 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306891 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6892 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306893 }
6894
6895 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306896 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306897 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
6898
6899 WMITLV_SET_HDR(&cmd->tlv_header,
6900 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
6901 WMITLV_GET_STRUCT_TLVLEN
6902 (wmi_start_link_stats_cmd_fixed_param));
6903
6904 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
6905 cmd->aggressive_statistics_gathering =
6906 set_req->aggressive_statistics_gathering;
6907
Govind Singhb53420c2016-03-09 14:32:57 +05306908 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
6909 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
6910 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306911
6912 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6913 WMI_START_LINK_STATS_CMDID);
6914 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306915 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306916 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306917 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306918 }
6919
Govind Singhb53420c2016-03-09 14:32:57 +05306920 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306921}
6922
6923/**
6924 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
6925 * @wmi_handle:wmi handle
6926 * @get_req:ll stats get request command params
6927 * @addr: mac address
6928 *
Govind Singhb53420c2016-03-09 14:32:57 +05306929 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306930 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306931static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306932 const struct ll_stats_get_params *get_req,
6933 uint8_t addr[IEEE80211_ADDR_LEN])
6934{
6935 wmi_request_link_stats_cmd_fixed_param *cmd;
6936 int32_t len;
6937 wmi_buf_t buf;
6938 uint8_t *buf_ptr;
6939 int ret;
6940
6941 len = sizeof(*cmd);
6942 buf = wmi_buf_alloc(wmi_handle, len);
6943
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05306944 if (!buf) {
6945 WMI_LOGE("%s: buf allocation failed", __func__);
6946 return QDF_STATUS_E_NOMEM;
6947 }
6948
Govind Singh4eacd2b2016-03-07 14:24:22 +05306949 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306950 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306951 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
6952
6953 WMITLV_SET_HDR(&cmd->tlv_header,
6954 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
6955 WMITLV_GET_STRUCT_TLVLEN
6956 (wmi_request_link_stats_cmd_fixed_param));
6957
6958 cmd->request_id = get_req->req_id;
6959 cmd->stats_type = get_req->param_id_mask;
6960 cmd->vdev_id = get_req->sta_id;
6961
6962 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6963 &cmd->peer_macaddr);
6964
Govind Singhb53420c2016-03-09 14:32:57 +05306965 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
6966 WMI_LOGD("Request ID : %d", cmd->request_id);
6967 WMI_LOGD("Stats Type : %d", cmd->stats_type);
6968 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
6969 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306970
6971 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6972 WMI_REQUEST_LINK_STATS_CMDID);
6973 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306974 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306975 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306976 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306977 }
6978
Govind Singhb53420c2016-03-09 14:32:57 +05306979 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306980}
6981
6982/**
6983 * send_get_stats_cmd_tlv() - get stats request
6984 * @wmi_handle: wmi handle
6985 * @get_stats_param: stats params
6986 * @addr: mac address
6987 *
6988 * Return: CDF status
6989 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306990static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306991 struct pe_stats_req *get_stats_param,
6992 uint8_t addr[IEEE80211_ADDR_LEN])
6993{
6994 wmi_buf_t buf;
6995 wmi_request_stats_cmd_fixed_param *cmd;
6996 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6997
6998 buf = wmi_buf_alloc(wmi_handle, len);
6999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307000 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7001 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307002 }
7003
7004
7005 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7006 WMITLV_SET_HDR(&cmd->tlv_header,
7007 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7008 WMITLV_GET_STRUCT_TLVLEN
7009 (wmi_request_stats_cmd_fixed_param));
7010 cmd->stats_id =
7011 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05307012 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307013 cmd->vdev_id = get_stats_param->session_id;
7014 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307015 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307016 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7017 WMI_REQUEST_STATS_CMDID)) {
7018
Govind Singhb53420c2016-03-09 14:32:57 +05307019 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307020 __func__);
7021 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307022 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307023 }
7024
Govind Singhb53420c2016-03-09 14:32:57 +05307025 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307026
7027}
7028
Govind Singh20c5dac2016-03-07 15:33:31 +05307029/**
7030 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7031 * @wmi_handle: wmi handle
7032 * @rssi_req: get RSSI request
7033 *
7034 * Return: CDF status
7035 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307036static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307037{
7038 wmi_buf_t buf;
7039 wmi_request_stats_cmd_fixed_param *cmd;
7040 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7041
7042 buf = wmi_buf_alloc(wmi_handle, len);
7043 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307044 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7045 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307046 }
7047
7048 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7049 WMITLV_SET_HDR(&cmd->tlv_header,
7050 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7051 WMITLV_GET_STRUCT_TLVLEN
7052 (wmi_request_stats_cmd_fixed_param));
7053 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7054 if (wmi_unified_cmd_send
7055 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307056 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307057 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307058 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307059 }
7060
Govind Singhb53420c2016-03-09 14:32:57 +05307061 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307062}
7063
7064/**
7065 * send_snr_cmd_tlv() - get RSSI from fw
7066 * @wmi_handle: wmi handle
7067 * @vdev_id: vdev id
7068 *
7069 * Return: CDF status
7070 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307071static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307072{
7073 wmi_buf_t buf;
7074 wmi_request_stats_cmd_fixed_param *cmd;
7075 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7076
7077 buf = wmi_buf_alloc(wmi_handle, len);
7078 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307079 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7080 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307081 }
7082
7083 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7084 cmd->vdev_id = vdev_id;
7085
7086 WMITLV_SET_HDR(&cmd->tlv_header,
7087 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7088 WMITLV_GET_STRUCT_TLVLEN
7089 (wmi_request_stats_cmd_fixed_param));
7090 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7091 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7092 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307093 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307094 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307095 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307096 }
7097
Govind Singhb53420c2016-03-09 14:32:57 +05307098 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307099}
7100
7101/**
7102 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7103 * @wmi_handle: wmi handle
7104 * @link_status: get link params
7105 *
7106 * Return: CDF status
7107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307108static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307109 struct link_status_params *link_status)
7110{
7111 wmi_buf_t buf;
7112 wmi_request_stats_cmd_fixed_param *cmd;
7113 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7114
7115 buf = wmi_buf_alloc(wmi_handle, len);
7116 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307117 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7118 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307119 }
7120
7121 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7122 WMITLV_SET_HDR(&cmd->tlv_header,
7123 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7124 WMITLV_GET_STRUCT_TLVLEN
7125 (wmi_request_stats_cmd_fixed_param));
7126 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7127 cmd->vdev_id = link_status->session_id;
7128 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7129 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307130 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307131 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307132 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307133 }
7134
Govind Singhb53420c2016-03-09 14:32:57 +05307135 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307136}
7137
Govind Singh20c5dac2016-03-07 15:33:31 +05307138/**
7139 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7140 * @wmi_handle: wmi handle
7141 * @ta_dhcp_ind: DHCP indication parameter
7142 *
7143 * Return: CDF Status
7144 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307145static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307146 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7147{
Govind Singh67922e82016-04-01 16:48:57 +05307148 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307149 wmi_buf_t buf = NULL;
7150 uint8_t *buf_ptr;
7151 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7152 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7153
7154
7155 buf = wmi_buf_alloc(wmi_handle, len);
7156 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307157 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7158 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307159 }
7160
7161 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7162 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7163 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7164 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7165 WMITLV_GET_STRUCT_TLVLEN
7166 (wmi_peer_set_param_cmd_fixed_param));
7167
7168 /* fill in values */
7169 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7170 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7171 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307172 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307173 &ta_dhcp_ind->peer_macaddr,
7174 sizeof(ta_dhcp_ind->peer_macaddr));
7175
7176 status = wmi_unified_cmd_send(wmi_handle, buf,
7177 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307178 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307179 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307180 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307181 wmi_buf_free(buf);
7182 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307183
Govind Singh67922e82016-04-01 16:48:57 +05307184 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307185}
7186
7187/**
7188 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7189 * @wmi_handle: wmi handle
7190 * @pLinkSpeed: link speed info
7191 *
7192 * Return: CDF status
7193 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307194static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307195 wmi_mac_addr peer_macaddr)
7196{
7197 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7198 wmi_buf_t wmi_buf;
7199 uint32_t len;
7200 uint8_t *buf_ptr;
7201
7202 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7203 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7204 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307205 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7206 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307207 }
7208 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7209
7210 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7211 WMITLV_SET_HDR(&cmd->tlv_header,
7212 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7213 WMITLV_GET_STRUCT_TLVLEN
7214 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7215
7216 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307217 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307218 &peer_macaddr,
7219 sizeof(peer_macaddr));
7220
7221
7222 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7223 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307224 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307225 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307226 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307227 }
Govind Singhb53420c2016-03-09 14:32:57 +05307228 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307229}
7230
7231/**
7232 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7233 * @wmi_handle: wmi handler
7234 * @egap_params: pointer to egap_params
7235 *
7236 * Return: 0 for success, otherwise appropriate error code
7237 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307238static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307239 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7240{
7241 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7242 wmi_buf_t buf;
7243 int32_t err;
7244
7245 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7246 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307247 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7248 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307249 }
7250 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7251 WMITLV_SET_HDR(&cmd->tlv_header,
7252 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7253 WMITLV_GET_STRUCT_TLVLEN(
7254 wmi_ap_ps_egap_param_cmd_fixed_param));
7255
7256 cmd->enable = egap_params->enable;
7257 cmd->inactivity_time = egap_params->inactivity_time;
7258 cmd->wait_time = egap_params->wait_time;
7259 cmd->flags = egap_params->flags;
7260 err = wmi_unified_cmd_send(wmi_handle, buf,
7261 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7262 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307263 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307264 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307265 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307266 }
7267
Govind Singhb53420c2016-03-09 14:32:57 +05307268 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307269}
7270
7271/**
7272 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7273 * @wmi_handl: wmi handle
7274 * @cmd: Profiling command index
7275 * @value1: parameter1 value
7276 * @value2: parameter2 value
7277 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307278 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307279 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307280static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307281 uint32_t cmd, uint32_t value1, uint32_t value2)
7282{
7283 wmi_buf_t buf;
7284 int32_t len = 0;
7285 int ret;
7286 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7287 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7288 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7289 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7290
7291 switch (cmd) {
7292 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7293 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7294 buf = wmi_buf_alloc(wmi_handle, len);
7295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307296 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307297 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307298 }
7299 prof_trig_cmd =
7300 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7301 wmi_buf_data(buf);
7302 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7303 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7304 WMITLV_GET_STRUCT_TLVLEN
7305 (wmi_wlan_profile_trigger_cmd_fixed_param));
7306 prof_trig_cmd->enable = value1;
7307 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7308 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7309 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307310 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307311 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307312 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307313 return ret;
7314 }
7315 break;
7316
7317 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7318 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7319 buf = wmi_buf_alloc(wmi_handle, len);
7320 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307321 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307322 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307323 }
7324 profile_getdata_cmd =
7325 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7326 wmi_buf_data(buf);
7327 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7328 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7329 WMITLV_GET_STRUCT_TLVLEN
7330 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7331 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7332 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7333 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307334 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307335 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307336 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307337 return ret;
7338 }
7339 break;
7340
7341 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7342 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7343 buf = wmi_buf_alloc(wmi_handle, len);
7344 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307345 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307346 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307347 }
7348 hist_intvl_cmd =
7349 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7350 wmi_buf_data(buf);
7351 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7352 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7353 WMITLV_GET_STRUCT_TLVLEN
7354 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7355 hist_intvl_cmd->profile_id = value1;
7356 hist_intvl_cmd->value = value2;
7357 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7358 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7359 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307360 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307361 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307362 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307363 return ret;
7364 }
7365 break;
7366
7367 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7368 len =
7369 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7370 buf = wmi_buf_alloc(wmi_handle, len);
7371 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307372 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307373 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307374 }
7375 profile_enable_cmd =
7376 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7377 wmi_buf_data(buf);
7378 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7379 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7380 WMITLV_GET_STRUCT_TLVLEN
7381 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7382 profile_enable_cmd->profile_id = value1;
7383 profile_enable_cmd->enable = value2;
7384 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7385 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7386 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307387 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307388 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307389 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307390 return ret;
7391 }
7392 break;
7393
7394 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307395 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307396 break;
7397 }
7398
7399 return 0;
7400}
7401
Govind Singh20c5dac2016-03-07 15:33:31 +05307402/**
7403 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7404 * @wmi_handle: wmi handle
7405 * @vdev_id: vdev id
7406 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307407 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307408 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307409static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307410{
7411 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7412 wmi_buf_t buf;
7413 int32_t len = sizeof(*cmd);
7414
Govind Singhb53420c2016-03-09 14:32:57 +05307415 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307416 buf = wmi_buf_alloc(wmi_handle, len);
7417 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307418 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307419 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307420 }
7421 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7422 wmi_buf_data(buf);
7423 WMITLV_SET_HDR(&cmd->tlv_header,
7424 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7425 WMITLV_GET_STRUCT_TLVLEN
7426 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7427 cmd->vdev_id = vdev_id;
7428 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7429 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7430 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307431 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307432 __func__);
7433 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307434 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307435 }
7436
7437 return 0;
7438}
7439
7440/**
7441 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7442 * @wmi_handle: wmi handle
7443 * @vdev_id: vdev id
7444 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307445 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307446 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307447static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307448 uint8_t vdev_id)
7449{
7450 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7451 wmi_buf_t buf;
7452 int32_t len = sizeof(*cmd);
7453
Govind Singhb53420c2016-03-09 14:32:57 +05307454 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307455 buf = wmi_buf_alloc(wmi_handle, len);
7456 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307457 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307458 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307459 }
7460 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7461 WMITLV_SET_HDR(&cmd->tlv_header,
7462 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7463 WMITLV_GET_STRUCT_TLVLEN
7464 (wmi_csa_offload_enable_cmd_fixed_param));
7465 cmd->vdev_id = vdev_id;
7466 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7467 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7468 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307469 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307470 __func__);
7471 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307472 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307473 }
7474
7475 return 0;
7476}
7477
7478/**
7479 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7480 * @wmi_handle: wmi handle
7481 * @startOemDataReq: start request params
7482 *
7483 * Return: CDF status
7484 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307485static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007486 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307487 uint8_t *data)
7488{
7489 wmi_buf_t buf;
7490 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307491 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307492
7493 buf = wmi_buf_alloc(wmi_handle,
7494 (data_len + WMI_TLV_HDR_SIZE));
7495 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307496 WMI_LOGE(FL("wmi_buf_alloc failed"));
7497 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307498 }
7499
7500 cmd = (uint8_t *) wmi_buf_data(buf);
7501
7502 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7503 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307504 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307505 data_len);
7506
Govind Singhb53420c2016-03-09 14:32:57 +05307507 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307508 data_len);
7509
7510 ret = wmi_unified_cmd_send(wmi_handle, buf,
7511 (data_len +
7512 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7513
Govind Singh67922e82016-04-01 16:48:57 +05307514 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307515 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307516 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307517 }
7518
Govind Singh67922e82016-04-01 16:48:57 +05307519 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307520}
7521
7522/**
7523 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7524 * @wmi_handle: wmi handle
7525 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7526 *
7527 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7528 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7529 * to firmware based on phyerr filtering
7530 * offload status.
7531 *
7532 * Return: 1 success, 0 failure
7533 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307534static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307535send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7536 bool dfs_phyerr_filter_offload)
7537{
7538 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7539 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7540 wmi_buf_t buf;
7541 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307542 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307543
7544
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007545 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307546 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307547 __func__);
7548 len = sizeof(*disable_phyerr_offload_cmd);
7549 buf = wmi_buf_alloc(wmi_handle, len);
7550 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307551 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307552 return 0;
7553 }
7554 disable_phyerr_offload_cmd =
7555 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7556 wmi_buf_data(buf);
7557
7558 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7559 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7560 WMITLV_GET_STRUCT_TLVLEN
7561 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7562
7563 /*
7564 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7565 * to the firmware to disable the phyerror
7566 * filtering offload.
7567 */
7568 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7569 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307570 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307571 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307572 __func__, ret);
7573 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307574 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307575 }
Govind Singhb53420c2016-03-09 14:32:57 +05307576 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307577 __func__);
7578 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307579 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307580 __func__);
7581
7582 len = sizeof(*enable_phyerr_offload_cmd);
7583 buf = wmi_buf_alloc(wmi_handle, len);
7584 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307585 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7586 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307587 }
7588
7589 enable_phyerr_offload_cmd =
7590 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7591 wmi_buf_data(buf);
7592
7593 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7594 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7595 WMITLV_GET_STRUCT_TLVLEN
7596 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7597
7598 /*
7599 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7600 * to the firmware to enable the phyerror
7601 * filtering offload.
7602 */
7603 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7604 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7605
Govind Singh67922e82016-04-01 16:48:57 +05307606 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307607 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307608 __func__, ret);
7609 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307610 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307611 }
Govind Singhb53420c2016-03-09 14:32:57 +05307612 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307613 __func__);
7614 }
7615
Govind Singhb53420c2016-03-09 14:32:57 +05307616 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307617}
7618
7619#if !defined(REMOVE_PKT_LOG)
7620/**
7621 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7622 * @wmi_handle: wmi handle
7623 * @pktlog_event: pktlog event
7624 * @cmd_id: pktlog cmd id
7625 *
7626 * Return: CDF status
7627 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307628static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307629 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307630 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307631{
7632 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7633 WMI_CMD_ID CMD_ID;
7634 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7635 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7636 int len = 0;
7637 wmi_buf_t buf;
7638
7639 PKTLOG_EVENT = pktlog_event;
7640 CMD_ID = cmd_id;
7641
7642 switch (CMD_ID) {
7643 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7644 len = sizeof(*cmd);
7645 buf = wmi_buf_alloc(wmi_handle, len);
7646 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307647 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7648 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307649 }
7650 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7651 wmi_buf_data(buf);
7652 WMITLV_SET_HDR(&cmd->tlv_header,
7653 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7654 WMITLV_GET_STRUCT_TLVLEN
7655 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7656 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307657 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7658 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007659 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307660 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7661 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307662 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307663 goto wmi_send_failed;
7664 }
7665 break;
7666 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7667 len = sizeof(*disable_cmd);
7668 buf = wmi_buf_alloc(wmi_handle, len);
7669 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307670 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7671 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307672 }
7673 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7674 wmi_buf_data(buf);
7675 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7676 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7677 WMITLV_GET_STRUCT_TLVLEN
7678 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007679 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307680 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7681 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307682 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307683 goto wmi_send_failed;
7684 }
7685 break;
7686 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307687 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307688 break;
7689 }
7690
Govind Singhb53420c2016-03-09 14:32:57 +05307691 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307692
7693wmi_send_failed:
7694 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307695 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307696}
7697#endif /* REMOVE_PKT_LOG */
7698
7699/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307700 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
7701 * @wmi_handle: wmi handle
7702 * @ptrn_id: pattern id
7703 * @vdev_id: vdev id
7704 *
7705 * Return: CDF status
7706 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05307707static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
7708 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307709{
7710 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
7711 wmi_buf_t buf;
7712 int32_t len;
7713 int ret;
7714
7715 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
7716
7717
7718 buf = wmi_buf_alloc(wmi_handle, len);
7719 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307720 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7721 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307722 }
7723
7724 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7725
7726 WMITLV_SET_HDR(&cmd->tlv_header,
7727 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
7728 WMITLV_GET_STRUCT_TLVLEN(
7729 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
7730 cmd->vdev_id = vdev_id;
7731 cmd->pattern_id = ptrn_id;
7732 cmd->pattern_type = WOW_BITMAP_PATTERN;
7733
Govind Singhb53420c2016-03-09 14:32:57 +05307734 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05307735 cmd->pattern_id, vdev_id);
7736
7737 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7738 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
7739 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307740 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307741 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307742 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307743 }
7744
Govind Singhb53420c2016-03-09 14:32:57 +05307745 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307746}
7747
7748/**
7749 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
7750 * @wmi_handle: wmi handle
7751 *
7752 * Sends host wakeup indication to FW. On receiving this indication,
7753 * FW will come out of WOW.
7754 *
7755 * Return: CDF status
7756 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307757static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307758{
7759 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
7760 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05307761 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307762 int32_t len;
7763 int ret;
7764
7765 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
7766
7767 buf = wmi_buf_alloc(wmi_handle, len);
7768 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307769 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7770 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307771 }
7772
7773 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
7774 wmi_buf_data(buf);
7775 WMITLV_SET_HDR(&cmd->tlv_header,
7776 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
7777 WMITLV_GET_STRUCT_TLVLEN
7778 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
7779
7780
7781 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7782 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
7783 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307784 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307785 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307786 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307787 }
7788
Govind Singhb53420c2016-03-09 14:32:57 +05307789 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307790}
7791
7792/**
7793 * send_del_ts_cmd_tlv() - send DELTS request to fw
7794 * @wmi_handle: wmi handle
7795 * @msg: delts params
7796 *
7797 * Return: CDF status
7798 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307799static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307800 uint8_t ac)
7801{
7802 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
7803 wmi_buf_t buf;
7804 int32_t len = sizeof(*cmd);
7805
7806 buf = wmi_buf_alloc(wmi_handle, len);
7807 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307808 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7809 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307810 }
7811 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
7812 WMITLV_SET_HDR(&cmd->tlv_header,
7813 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
7814 WMITLV_GET_STRUCT_TLVLEN
7815 (wmi_vdev_wmm_delts_cmd_fixed_param));
7816 cmd->vdev_id = vdev_id;
7817 cmd->ac = ac;
7818
Govind Singhb53420c2016-03-09 14:32:57 +05307819 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307820 cmd->vdev_id, cmd->ac, __func__, __LINE__);
7821 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7822 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307823 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307824 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307825 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307826 }
7827
Govind Singhb53420c2016-03-09 14:32:57 +05307828 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307829}
7830
7831/**
7832 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
7833 * @wmi_handle: handle to wmi
7834 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
7835 *
Govind Singhb53420c2016-03-09 14:32:57 +05307836 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05307837 * ADD_TS requestes to firmware in loop for all the ACs with
7838 * active flow.
7839 *
7840 * Return: CDF status
7841 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307842static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307843 struct aggr_add_ts_param *aggr_qos_rsp_msg)
7844{
7845 int i = 0;
7846 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
7847 wmi_buf_t buf;
7848 int32_t len = sizeof(*cmd);
7849
7850 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
7851 /* if flow in this AC is active */
7852 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
7853 /*
7854 * as per implementation of wma_add_ts_req() we
7855 * are not waiting any response from firmware so
7856 * apart from sending ADDTS to firmware just send
7857 * success to upper layers
7858 */
Govind Singhb53420c2016-03-09 14:32:57 +05307859 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307860
7861 buf = wmi_buf_alloc(wmi_handle, len);
7862 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307863 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7864 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307865 }
7866 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
7867 wmi_buf_data(buf);
7868 WMITLV_SET_HDR(&cmd->tlv_header,
7869 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
7870 WMITLV_GET_STRUCT_TLVLEN
7871 (wmi_vdev_wmm_addts_cmd_fixed_param));
7872 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
7873 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05307874 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05307875 traffic.userPrio);
7876 cmd->medium_time_us =
7877 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
7878 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05307879 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307880 __func__, __LINE__, cmd->vdev_id, cmd->ac,
7881 cmd->medium_time_us, cmd->downgrade_type);
7882 if (wmi_unified_cmd_send
7883 (wmi_handle, buf, len,
7884 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307885 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307886 __func__);
7887 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05307888 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307889 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307890 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307891 }
7892 }
7893 }
7894
Govind Singhb53420c2016-03-09 14:32:57 +05307895 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307896}
7897
7898/**
7899 * send_add_ts_cmd_tlv() - send ADDTS request to fw
7900 * @wmi_handle: wmi handle
7901 * @msg: ADDTS params
7902 *
7903 * Return: CDF status
7904 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307905static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307906 struct add_ts_param *msg)
7907{
7908 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
7909 wmi_buf_t buf;
7910 int32_t len = sizeof(*cmd);
7911
Govind Singhb53420c2016-03-09 14:32:57 +05307912 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307913
7914 buf = wmi_buf_alloc(wmi_handle, len);
7915 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307916 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7917 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307918 }
7919 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
7920 WMITLV_SET_HDR(&cmd->tlv_header,
7921 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
7922 WMITLV_GET_STRUCT_TLVLEN
7923 (wmi_vdev_wmm_addts_cmd_fixed_param));
7924 cmd->vdev_id = msg->sme_session_id;
7925 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
7926 cmd->medium_time_us = msg->tspec.mediumTime * 32;
7927 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05307928 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307929 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
7930 cmd->downgrade_type, __func__, __LINE__);
7931 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7932 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307933 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
7934 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307935 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307936 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307937 }
7938
Govind Singhb53420c2016-03-09 14:32:57 +05307939 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307940}
7941
7942/**
7943 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
7944 * @wmi_handle: wmi handle
7945 * @vdev_id: vdev id
7946 * @enable: Flag to enable/disable packet filter
7947 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307948 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307949 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307950static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307951 uint8_t vdev_id, bool enable)
7952{
7953 int32_t len;
7954 int ret = 0;
7955 wmi_buf_t buf;
7956 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
7957
7958 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
7959
7960 buf = wmi_buf_alloc(wmi_handle, len);
7961 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307962 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307963 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307964 }
7965
7966 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
7967 WMITLV_SET_HDR(&cmd->tlv_header,
7968 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
7969 WMITLV_GET_STRUCT_TLVLEN(
7970 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
7971
7972 cmd->vdev_id = vdev_id;
7973 if (enable)
7974 cmd->enable = PACKET_FILTER_SET_ENABLE;
7975 else
7976 cmd->enable = PACKET_FILTER_SET_DISABLE;
7977
Govind Singhb53420c2016-03-09 14:32:57 +05307978 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307979 __func__, cmd->enable, vdev_id);
7980
7981 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7982 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307983 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307984 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05307985 wmi_buf_free(buf);
7986 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307987
7988 return ret;
7989}
7990
7991/**
7992 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
7993 * @wmi_handle: wmi handle
7994 * @vdev_id: vdev id
7995 * @rcv_filter_param: Packet filter parameters
7996 * @filter_id: Filter id
7997 * @enable: Flag to add/delete packet filter configuration
7998 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307999 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308000 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308001static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308002 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8003 uint8_t filter_id, bool enable)
8004{
8005 int len, i;
8006 int err = 0;
8007 wmi_buf_t buf;
8008 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8009
8010
8011 /* allocate the memory */
8012 len = sizeof(*cmd);
8013 buf = wmi_buf_alloc(wmi_handle, len);
8014 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308015 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308016 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308017 }
8018
8019 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8020 WMITLV_SET_HDR(&cmd->tlv_header,
8021 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8022 WMITLV_GET_STRUCT_TLVLEN
8023 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8024
8025 cmd->vdev_id = vdev_id;
8026 cmd->filter_id = filter_id;
8027 if (enable)
8028 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8029 else
8030 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8031
8032 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308033 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308034 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8035 rcv_filter_param->numFieldParams);
8036 cmd->filter_type = rcv_filter_param->filterType;
8037 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8038
8039 for (i = 0; i < cmd->num_params; i++) {
8040 cmd->paramsData[i].proto_type =
8041 rcv_filter_param->paramsData[i].protocolLayer;
8042 cmd->paramsData[i].cmp_type =
8043 rcv_filter_param->paramsData[i].cmpFlag;
8044 cmd->paramsData[i].data_length =
8045 rcv_filter_param->paramsData[i].dataLength;
8046 cmd->paramsData[i].data_offset =
8047 rcv_filter_param->paramsData[i].dataOffset;
8048 memcpy(&cmd->paramsData[i].compareData,
8049 rcv_filter_param->paramsData[i].compareData,
8050 sizeof(cmd->paramsData[i].compareData));
8051 memcpy(&cmd->paramsData[i].dataMask,
8052 rcv_filter_param->paramsData[i].dataMask,
8053 sizeof(cmd->paramsData[i].dataMask));
8054 }
8055 }
8056
Govind Singhb53420c2016-03-09 14:32:57 +05308057 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308058 cmd->filter_action, cmd->filter_id, cmd->num_params);
8059 /* send the command along with data */
8060 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8061 WMI_PACKET_FILTER_CONFIG_CMDID);
8062 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308063 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308064 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308065 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308066 }
8067
8068
8069 return 0;
8070}
8071
8072/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308073 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8074 * @wmi_handle: wmi handle
8075 * @pAddPeriodicTxPtrnParams: tx ptrn params
8076 *
8077 * Retrun: CDF status
8078 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308079static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308080 struct periodic_tx_pattern *
8081 pAddPeriodicTxPtrnParams,
8082 uint8_t vdev_id)
8083{
8084 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8085 wmi_buf_t wmi_buf;
8086 uint32_t len;
8087 uint8_t *buf_ptr;
8088 uint32_t ptrn_len, ptrn_len_aligned;
8089 int j;
8090
8091 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8092 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8093 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8094 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8095
8096 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8097 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308098 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8099 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308100 }
8101
8102 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8103
8104 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8105 WMITLV_SET_HDR(&cmd->tlv_header,
8106 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8107 WMITLV_GET_STRUCT_TLVLEN
8108 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8109
8110 /* Pass the pattern id to delete for the corresponding vdev id */
8111 cmd->vdev_id = vdev_id;
8112 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8113 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8114 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8115
8116 /* Pattern info */
8117 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8118 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8119 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308120 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308121 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308122 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308123
Govind Singhb53420c2016-03-09 14:32:57 +05308124 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308125 __func__, cmd->pattern_id, cmd->vdev_id);
8126
8127 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8128 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308129 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308130 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308131 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308132 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308133 }
Govind Singhb53420c2016-03-09 14:32:57 +05308134 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308135}
8136
8137/**
8138 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8139 * @wmi_handle: wmi handle
8140 * @vdev_id: vdev id
8141 * @pattern_id: pattern id
8142 *
8143 * Retrun: CDF status
8144 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308145static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308146 uint8_t vdev_id,
8147 uint8_t pattern_id)
8148{
8149 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8150 wmi_buf_t wmi_buf;
8151 uint32_t len =
8152 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8153
8154 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8155 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308156 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8157 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308158 }
8159
8160 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8161 wmi_buf_data(wmi_buf);
8162 WMITLV_SET_HDR(&cmd->tlv_header,
8163 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8164 WMITLV_GET_STRUCT_TLVLEN
8165 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8166
8167 /* Pass the pattern id to delete for the corresponding vdev id */
8168 cmd->vdev_id = vdev_id;
8169 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308170 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308171 __func__, cmd->pattern_id, cmd->vdev_id);
8172
8173 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8174 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308175 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308176 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308177 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308178 }
Govind Singhb53420c2016-03-09 14:32:57 +05308179 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308180}
8181
8182/**
8183 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8184 * @wmi_handle: wmi handle
8185 * @preq: stats ext params
8186 *
8187 * Return: CDF status
8188 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308189static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308190 struct stats_ext_params *preq)
8191{
Govind Singh67922e82016-04-01 16:48:57 +05308192 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308193 wmi_req_stats_ext_cmd_fixed_param *cmd;
8194 wmi_buf_t buf;
8195 uint16_t len;
8196 uint8_t *buf_ptr;
8197
8198 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8199
8200 buf = wmi_buf_alloc(wmi_handle, len);
8201 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308202 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308203 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308204 }
8205
8206 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8207 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8208
8209 WMITLV_SET_HDR(&cmd->tlv_header,
8210 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8211 WMITLV_GET_STRUCT_TLVLEN
8212 (wmi_req_stats_ext_cmd_fixed_param));
8213 cmd->vdev_id = preq->vdev_id;
8214 cmd->data_len = preq->request_data_len;
8215
Govind Singhb53420c2016-03-09 14:32:57 +05308216 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308217 __func__, preq->request_data_len, preq->vdev_id);
8218
8219 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8220 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8221
8222 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308223 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308224
8225 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8226 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308227 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308228 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308229 ret);
8230 wmi_buf_free(buf);
8231 }
8232
8233 return ret;
8234}
8235
8236/**
8237 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8238 * @wmi_handle: wmi handle
8239 * @params: ext wow params
8240 *
8241 * Return:0 for success or error code
8242 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308243static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308244 struct ext_wow_params *params)
8245{
8246 wmi_extwow_enable_cmd_fixed_param *cmd;
8247 wmi_buf_t buf;
8248 int32_t len;
8249 int ret;
8250
8251 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8252 buf = wmi_buf_alloc(wmi_handle, len);
8253 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308254 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8255 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308256 }
8257
8258 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8259
8260 WMITLV_SET_HDR(&cmd->tlv_header,
8261 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8262 WMITLV_GET_STRUCT_TLVLEN
8263 (wmi_extwow_enable_cmd_fixed_param));
8264
8265 cmd->vdev_id = params->vdev_id;
8266 cmd->type = params->type;
8267 cmd->wakeup_pin_num = params->wakeup_pin_num;
8268
Govind Singhb53420c2016-03-09 14:32:57 +05308269 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308270 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8271
8272 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8273 WMI_EXTWOW_ENABLE_CMDID);
8274 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308275 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308276 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308277 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308278 }
8279
Govind Singhb53420c2016-03-09 14:32:57 +05308280 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308281
8282}
8283
8284/**
8285 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8286 * @wmi_handle: wmi handle
8287 * @app_type1_params: app type1 params
8288 *
8289 * Return: CDF status
8290 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308291static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308292 struct app_type1_params *app_type1_params)
8293{
8294 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8295 wmi_buf_t buf;
8296 int32_t len;
8297 int ret;
8298
8299 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8300 buf = wmi_buf_alloc(wmi_handle, len);
8301 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308302 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8303 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308304 }
8305
8306 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8307 wmi_buf_data(buf);
8308
8309 WMITLV_SET_HDR(&cmd->tlv_header,
8310 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8311 WMITLV_GET_STRUCT_TLVLEN
8312 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8313
8314 cmd->vdev_id = app_type1_params->vdev_id;
8315 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8316 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308317 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308318 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308319 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308320 cmd->passwd_len = app_type1_params->pass_length;
8321
Govind Singhb53420c2016-03-09 14:32:57 +05308322 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308323 "identification_id %.8s id_length %u "
8324 "password %.16s pass_length %u",
8325 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8326 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8327
8328 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8329 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8330 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308331 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308332 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308333 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308334 }
8335
Govind Singhb53420c2016-03-09 14:32:57 +05308336 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308337}
8338
8339/**
8340 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8341 * @wmi_handle: wmi handle
8342 * @appType2Params: app type2 params
8343 *
8344 * Return: CDF status
8345 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308346static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308347 struct app_type2_params *appType2Params)
8348{
8349 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8350 wmi_buf_t buf;
8351 int32_t len;
8352 int ret;
8353
8354 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8355 buf = wmi_buf_alloc(wmi_handle, len);
8356 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308357 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8358 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308359 }
8360
8361 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8362 wmi_buf_data(buf);
8363
8364 WMITLV_SET_HDR(&cmd->tlv_header,
8365 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8366 WMITLV_GET_STRUCT_TLVLEN
8367 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8368
8369 cmd->vdev_id = appType2Params->vdev_id;
8370
Govind Singhb53420c2016-03-09 14:32:57 +05308371 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308372 cmd->rc4_key_len = appType2Params->rc4_key_len;
8373
8374 cmd->ip_id = appType2Params->ip_id;
8375 cmd->ip_device_ip = appType2Params->ip_device_ip;
8376 cmd->ip_server_ip = appType2Params->ip_server_ip;
8377
8378 cmd->tcp_src_port = appType2Params->tcp_src_port;
8379 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8380 cmd->tcp_seq = appType2Params->tcp_seq;
8381 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8382
8383 cmd->keepalive_init = appType2Params->keepalive_init;
8384 cmd->keepalive_min = appType2Params->keepalive_min;
8385 cmd->keepalive_max = appType2Params->keepalive_max;
8386 cmd->keepalive_inc = appType2Params->keepalive_inc;
8387
8388 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8389 &cmd->gateway_mac);
8390 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8391 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8392
Govind Singhb53420c2016-03-09 14:32:57 +05308393 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308394 "rc4_key %.16s rc4_key_len %u "
8395 "ip_id %x ip_device_ip %x ip_server_ip %x "
8396 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8397 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8398 "keepalive_max %u keepalive_inc %u "
8399 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8400 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8401 cmd->rc4_key, cmd->rc4_key_len,
8402 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8403 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8404 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8405 cmd->keepalive_max, cmd->keepalive_inc,
8406 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8407
8408 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8409 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8410 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308411 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308412 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308413 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308414 }
8415
Govind Singhb53420c2016-03-09 14:32:57 +05308416 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308417
8418}
8419
8420/**
8421 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8422 * @wmi_handle: wmi handle
8423 * @timer_val: auto shutdown timer value
8424 *
8425 * Return: CDF status
8426 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308427static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308428 uint32_t timer_val)
8429{
Govind Singh67922e82016-04-01 16:48:57 +05308430 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308431 wmi_buf_t buf = NULL;
8432 uint8_t *buf_ptr;
8433 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8434 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8435
Govind Singhb53420c2016-03-09 14:32:57 +05308436 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308437 __func__, timer_val);
8438
8439 buf = wmi_buf_alloc(wmi_handle, len);
8440 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308441 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8442 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308443 }
8444
8445 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8446 wmi_auto_sh_cmd =
8447 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8448 wmi_auto_sh_cmd->timer_value = timer_val;
8449
8450 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8451 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8452 WMITLV_GET_STRUCT_TLVLEN
8453 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8454
8455 status = wmi_unified_cmd_send(wmi_handle, buf,
8456 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308457 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308458 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308459 __func__, status);
8460 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308461 }
8462
Govind Singh67922e82016-04-01 16:48:57 +05308463 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308464}
8465
8466/**
8467 * send_nan_req_cmd_tlv() - to send nan request to target
8468 * @wmi_handle: wmi handle
8469 * @nan_req: request data which will be non-null
8470 *
8471 * Return: CDF status
8472 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308473static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308474 struct nan_req_params *nan_req)
8475{
Govind Singh67922e82016-04-01 16:48:57 +05308476 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308477 wmi_nan_cmd_param *cmd;
8478 wmi_buf_t buf;
8479 uint16_t len = sizeof(*cmd);
8480 uint16_t nan_data_len, nan_data_len_aligned;
8481 uint8_t *buf_ptr;
8482
8483 /*
8484 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8485 * +------------+----------+-----------------------+--------------+
8486 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8487 * +------------+----------+-----------------------+--------------+
8488 */
8489 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308490 WMI_LOGE("%s:nan req is not valid", __func__);
8491 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308492 }
8493 nan_data_len = nan_req->request_data_len;
8494 nan_data_len_aligned = roundup(nan_req->request_data_len,
8495 sizeof(uint32_t));
8496 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8497 buf = wmi_buf_alloc(wmi_handle, len);
8498 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308499 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8500 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308501 }
8502 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8503 cmd = (wmi_nan_cmd_param *) buf_ptr;
8504 WMITLV_SET_HDR(&cmd->tlv_header,
8505 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8506 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8507 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308508 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308509 __func__, nan_req->request_data_len);
8510 buf_ptr += sizeof(wmi_nan_cmd_param);
8511 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8512 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308513 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308514
8515 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8516 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308517 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308518 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308519 __func__, ret);
8520 wmi_buf_free(buf);
8521 }
8522
8523 return ret;
8524}
8525
8526/**
8527 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8528 * @wmi_handle: wmi handle
8529 * @pDhcpSrvOffloadInfo: DHCP server offload info
8530 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308531 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308532 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308533static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308534 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8535{
8536 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8537 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308538 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308539
8540 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8541 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308542 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308543 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308544 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308545 }
8546
8547 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308548 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308549
8550 WMITLV_SET_HDR(&cmd->tlv_header,
8551 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8552 WMITLV_GET_STRUCT_TLVLEN
8553 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8554 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8555 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8556 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8557 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8558 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308559 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308560 sizeof(*cmd),
8561 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308562 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308563 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308564 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308565 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308566 }
Govind Singhb53420c2016-03-09 14:32:57 +05308567 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308568 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308569
8570 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308571}
8572
8573/**
8574 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8575 * @wmi_handle: wmi handle
8576 * @flashing: flashing request
8577 *
8578 * Return: CDF status
8579 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308580static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308581 struct flashing_req_params *flashing)
8582{
8583 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308584 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308585 wmi_buf_t buf;
8586 uint8_t *buf_ptr;
8587 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8588
8589 buf = wmi_buf_alloc(wmi_handle, len);
8590 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308591 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308592 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308593 }
8594 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8595 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8596 WMITLV_SET_HDR(&cmd->tlv_header,
8597 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8598 WMITLV_GET_STRUCT_TLVLEN
8599 (wmi_set_led_flashing_cmd_fixed_param));
8600 cmd->pattern_id = flashing->pattern_id;
8601 cmd->led_x0 = flashing->led_x0;
8602 cmd->led_x1 = flashing->led_x1;
8603
8604 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8605 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308606 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308607 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308608 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308609 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308610 }
Govind Singh67922e82016-04-01 16:48:57 +05308611
8612 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308613}
8614
8615/**
8616 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8617 * @wmi_handle: wmi handle
8618 * @ch_avoid_update_req: channel avoid update params
8619 *
8620 * Return: CDF status
8621 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308622static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308623{
Govind Singh67922e82016-04-01 16:48:57 +05308624 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308625 wmi_buf_t buf = NULL;
8626 uint8_t *buf_ptr;
8627 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
8628 int len = sizeof(wmi_chan_avoid_update_cmd_param);
8629
8630
8631 buf = wmi_buf_alloc(wmi_handle, len);
8632 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308633 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8634 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308635 }
8636
8637 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8638 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
8639 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
8640 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
8641 WMITLV_GET_STRUCT_TLVLEN
8642 (wmi_chan_avoid_update_cmd_param));
8643
8644 status = wmi_unified_cmd_send(wmi_handle, buf,
8645 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308646 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308647 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05308648 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
8649 " returned Error %d", status);
8650 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308651 }
8652
Govind Singh67922e82016-04-01 16:48:57 +05308653 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308654}
8655
8656/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05308657 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
8658 * @wmi_handle: wmi handle
8659 * @param: pointer to pdev regdomain params
8660 *
8661 * Return: 0 for success or error code
8662 */
8663static QDF_STATUS
8664send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
8665 struct pdev_set_regdomain_params *param)
8666{
8667 wmi_buf_t buf;
8668 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8669 int32_t len = sizeof(*cmd);
8670
8671
8672 buf = wmi_buf_alloc(wmi_handle, len);
8673 if (!buf) {
8674 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8675 return QDF_STATUS_E_NOMEM;
8676 }
8677 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8678 WMITLV_SET_HDR(&cmd->tlv_header,
8679 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8680 WMITLV_GET_STRUCT_TLVLEN
8681 (wmi_pdev_set_regdomain_cmd_fixed_param));
8682
8683 cmd->reg_domain = param->currentRDinuse;
8684 cmd->reg_domain_2G = param->currentRD2G;
8685 cmd->reg_domain_5G = param->currentRD5G;
8686 cmd->conformance_test_limit_2G = param->ctl_2G;
8687 cmd->conformance_test_limit_5G = param->ctl_5G;
8688 cmd->dfs_domain = param->dfsDomain;
8689 cmd->pdev_id = param->pdev_id;
8690
8691 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8692 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
8693 WMI_LOGE("%s: Failed to send pdev set regdomain command",
8694 __func__);
8695 wmi_buf_free(buf);
8696 return QDF_STATUS_E_FAILURE;
8697 }
8698
8699 return QDF_STATUS_SUCCESS;
8700}
8701
8702/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308703 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
8704 * @wmi_handle: wmi handle
8705 * @reg_dmn: reg domain
8706 * @regdmn2G: 2G reg domain
8707 * @regdmn5G: 5G reg domain
8708 * @ctl2G: 2G test limit
8709 * @ctl5G: 5G test limit
8710 *
8711 * Return: none
8712 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308713static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308714 uint32_t reg_dmn, uint16_t regdmn2G,
8715 uint16_t regdmn5G, int8_t ctl2G,
8716 int8_t ctl5G)
8717{
8718 wmi_buf_t buf;
8719 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8720 int32_t len = sizeof(*cmd);
8721
8722
8723 buf = wmi_buf_alloc(wmi_handle, len);
8724 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308725 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8726 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308727 }
8728 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8729 WMITLV_SET_HDR(&cmd->tlv_header,
8730 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8731 WMITLV_GET_STRUCT_TLVLEN
8732 (wmi_pdev_set_regdomain_cmd_fixed_param));
8733 cmd->reg_domain = reg_dmn;
8734 cmd->reg_domain_2G = regdmn2G;
8735 cmd->reg_domain_5G = regdmn5G;
8736 cmd->conformance_test_limit_2G = ctl2G;
8737 cmd->conformance_test_limit_5G = ctl5G;
8738
8739 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8740 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308741 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308742 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308743 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308744 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308745 }
8746
Govind Singhb53420c2016-03-09 14:32:57 +05308747 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308748}
8749
8750
8751/**
8752 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
8753 * @wmi_handle: wmi handle
8754 * @chan_switch_params: Pointer to tdls channel switch parameter structure
8755 *
8756 * This function sets tdls off channel mode
8757 *
8758 * Return: 0 on success; Negative errno otherwise
8759 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308760static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308761 struct tdls_channel_switch_params *chan_switch_params)
8762{
8763 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
8764 wmi_buf_t wmi_buf;
8765 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
8766
8767 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8768 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308769 WMI_LOGE(FL("wmi_buf_alloc failed"));
8770 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308771 }
8772 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
8773 wmi_buf_data(wmi_buf);
8774 WMITLV_SET_HDR(&cmd->tlv_header,
8775 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
8776 WMITLV_GET_STRUCT_TLVLEN(
8777 wmi_tdls_set_offchan_mode_cmd_fixed_param));
8778
8779 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
8780 &cmd->peer_macaddr);
8781 cmd->vdev_id = chan_switch_params->vdev_id;
8782 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
8783 cmd->is_peer_responder = chan_switch_params->is_responder;
8784 cmd->offchan_num = chan_switch_params->tdls_off_ch;
8785 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
8786 cmd->offchan_oper_class = chan_switch_params->oper_class;
8787
Govind Singhb53420c2016-03-09 14:32:57 +05308788 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308789 cmd->peer_macaddr.mac_addr31to0,
8790 cmd->peer_macaddr.mac_addr47to32);
8791
Govind Singhb53420c2016-03-09 14:32:57 +05308792 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05308793 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
8794 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
8795 ),
8796 cmd->vdev_id,
8797 cmd->offchan_mode,
8798 cmd->offchan_num,
8799 cmd->offchan_bw_bitmap,
8800 cmd->is_peer_responder,
8801 cmd->offchan_oper_class);
8802
8803 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8804 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308805 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308806 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308807 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308808 }
8809
8810
Govind Singhb53420c2016-03-09 14:32:57 +05308811 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308812}
8813
8814/**
8815 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
8816 * @wmi_handle: wmi handle
8817 * @pwmaTdlsparams: TDLS params
8818 *
8819 * Return: 0 for sucess or error code
8820 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308821static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308822 void *tdls_param, uint8_t tdls_state)
8823{
8824 wmi_tdls_set_state_cmd_fixed_param *cmd;
8825 wmi_buf_t wmi_buf;
8826
8827 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
8828 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
8829
8830 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8831 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308832 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
8833 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308834 }
8835 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
8836 WMITLV_SET_HDR(&cmd->tlv_header,
8837 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
8838 WMITLV_GET_STRUCT_TLVLEN
8839 (wmi_tdls_set_state_cmd_fixed_param));
8840 cmd->vdev_id = wmi_tdls->vdev_id;
8841 cmd->state = tdls_state;
8842 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
8843 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
8844 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
8845 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
8846 cmd->rssi_delta = wmi_tdls->rssi_delta;
8847 cmd->tdls_options = wmi_tdls->tdls_options;
8848 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
8849 cmd->tdls_peer_traffic_response_timeout_ms =
8850 wmi_tdls->peer_traffic_response_timeout;
8851 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
8852 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
8853 cmd->tdls_puapsd_rx_frame_threshold =
8854 wmi_tdls->puapsd_rx_frame_threshold;
8855 cmd->teardown_notification_ms =
8856 wmi_tdls->teardown_notification_ms;
8857 cmd->tdls_peer_kickout_threshold =
8858 wmi_tdls->tdls_peer_kickout_threshold;
8859
Govind Singhb53420c2016-03-09 14:32:57 +05308860 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05308861 "notification_interval_ms: %d, "
8862 "tx_discovery_threshold: %d, "
8863 "tx_teardown_threshold: %d, "
8864 "rssi_teardown_threshold: %d, "
8865 "rssi_delta: %d, "
8866 "tdls_options: 0x%x, "
8867 "tdls_peer_traffic_ind_window: %d, "
8868 "tdls_peer_traffic_response_timeout: %d, "
8869 "tdls_puapsd_mask: 0x%x, "
8870 "tdls_puapsd_inactivity_time: %d, "
8871 "tdls_puapsd_rx_frame_threshold: %d, "
8872 "teardown_notification_ms: %d, "
8873 "tdls_peer_kickout_threshold: %d",
8874 __func__, tdls_state, cmd->state,
8875 cmd->notification_interval_ms,
8876 cmd->tx_discovery_threshold,
8877 cmd->tx_teardown_threshold,
8878 cmd->rssi_teardown_threshold,
8879 cmd->rssi_delta,
8880 cmd->tdls_options,
8881 cmd->tdls_peer_traffic_ind_window,
8882 cmd->tdls_peer_traffic_response_timeout_ms,
8883 cmd->tdls_puapsd_mask,
8884 cmd->tdls_puapsd_inactivity_time_ms,
8885 cmd->tdls_puapsd_rx_frame_threshold,
8886 cmd->teardown_notification_ms,
8887 cmd->tdls_peer_kickout_threshold);
8888
8889 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8890 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308891 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308892 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308893 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308894 }
Govind Singhb53420c2016-03-09 14:32:57 +05308895 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308896
Govind Singhb53420c2016-03-09 14:32:57 +05308897 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308898}
8899
8900/**
8901 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
8902 * @wmi_handle: wmi handle
8903 * @peerStateParams: TDLS peer state params
8904 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308905 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308906 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308907static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308908 struct tdls_peer_state_params *peerStateParams,
8909 uint32_t *ch_mhz)
8910{
8911 wmi_tdls_peer_update_cmd_fixed_param *cmd;
8912 wmi_tdls_peer_capabilities *peer_cap;
8913 wmi_channel *chan_info;
8914 wmi_buf_t wmi_buf;
8915 uint8_t *buf_ptr;
8916 uint32_t i;
8917 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
8918 sizeof(wmi_tdls_peer_capabilities);
8919
8920
8921 len += WMI_TLV_HDR_SIZE +
8922 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
8923
8924 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8925 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308926 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8927 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308928 }
8929
8930 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8931 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
8932 WMITLV_SET_HDR(&cmd->tlv_header,
8933 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
8934 WMITLV_GET_STRUCT_TLVLEN
8935 (wmi_tdls_peer_update_cmd_fixed_param));
8936
8937 cmd->vdev_id = peerStateParams->vdevId;
8938 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
8939 &cmd->peer_macaddr);
8940
8941
8942 cmd->peer_state = peerStateParams->peerState;
8943
Govind Singhb53420c2016-03-09 14:32:57 +05308944 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05308945 "peer_macaddr.mac_addr31to0: 0x%x, "
8946 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
8947 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
8948 cmd->peer_macaddr.mac_addr31to0,
8949 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
8950
8951 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
8952 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
8953 WMITLV_SET_HDR(&peer_cap->tlv_header,
8954 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
8955 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
8956
8957 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
8958 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
8959 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
8960 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
8961 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
8962 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
8963 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
8964 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
8965
8966 /* Ack and More Data Ack are sent as 0, so no need to set
8967 * but fill SP
8968 */
8969 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
8970 peerStateParams->peerCap.peerMaxSp);
8971
8972 peer_cap->buff_sta_support =
8973 peerStateParams->peerCap.peerBuffStaSupport;
8974 peer_cap->off_chan_support =
8975 peerStateParams->peerCap.peerOffChanSupport;
8976 peer_cap->peer_curr_operclass =
8977 peerStateParams->peerCap.peerCurrOperClass;
8978 /* self curr operclass is not being used and so pass op class for
8979 * preferred off chan in it.
8980 */
8981 peer_cap->self_curr_operclass =
8982 peerStateParams->peerCap.opClassForPrefOffChan;
8983 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
8984 peer_cap->peer_operclass_len =
8985 peerStateParams->peerCap.peerOperClassLen;
8986
Govind Singhb53420c2016-03-09 14:32:57 +05308987 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308988 __func__, peer_cap->peer_operclass_len);
8989 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
8990 peer_cap->peer_operclass[i] =
8991 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05308992 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308993 __func__, i, peer_cap->peer_operclass[i]);
8994 }
8995
8996 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
8997 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
8998 peer_cap->pref_offchan_bw =
8999 peerStateParams->peerCap.prefOffChanBandwidth;
9000
Govind Singhb53420c2016-03-09 14:32:57 +05309001 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309002 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9003 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9004 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9005 " %d, pref_offchan_bw: %d",
9006 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9007 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9008 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9009 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9010 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9011
9012 /* next fill variable size array of peer chan info */
9013 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9014 WMITLV_SET_HDR(buf_ptr,
9015 WMITLV_TAG_ARRAY_STRUC,
9016 sizeof(wmi_channel) *
9017 peerStateParams->peerCap.peerChanLen);
9018 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9019
9020 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9021 WMITLV_SET_HDR(&chan_info->tlv_header,
9022 WMITLV_TAG_STRUC_wmi_channel,
9023 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9024 chan_info->mhz = ch_mhz[i];
9025 chan_info->band_center_freq1 = chan_info->mhz;
9026 chan_info->band_center_freq2 = 0;
9027
Govind Singhb53420c2016-03-09 14:32:57 +05309028 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309029
9030 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9031 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309032 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309033 peerStateParams->peerCap.peerChan[i].chanId,
9034 peerStateParams->peerCap.peerChan[i].dfsSet);
9035 }
9036
9037 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9038 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9039 else
9040 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9041
9042 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9043 peerStateParams->peerCap.
9044 peerChan[i].pwr);
9045
9046 WMI_SET_CHANNEL_REG_POWER(chan_info,
9047 peerStateParams->peerCap.peerChan[i].
9048 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309049 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309050 peerStateParams->peerCap.peerChan[i].pwr);
9051
9052 chan_info++;
9053 }
9054
9055 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9056 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309057 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309058 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309059 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309060 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309061 }
9062
9063
Govind Singhb53420c2016-03-09 14:32:57 +05309064 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309065}
9066
9067/*
9068 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9069 * firmware
9070 * @wmi_handle: Pointer to wmi handle
9071 * @mem_dump_req: Pointer for mem_dump_req
9072 *
9073 * This function sends memory dump request to firmware
9074 *
Govind Singhb53420c2016-03-09 14:32:57 +05309075 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309076 *
9077 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309078static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309079 struct fw_dump_req_param *mem_dump_req)
9080{
9081 wmi_get_fw_mem_dump_fixed_param *cmd;
9082 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309083 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309084 int32_t len;
9085 wmi_buf_t buf;
9086 u_int8_t *buf_ptr;
9087 int ret, loop;
9088
9089 /*
9090 * len = sizeof(fixed param) that includes tlv header +
9091 * tlv header for array of struc +
9092 * sizeof (each struct)
9093 */
9094 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9095 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9096 buf = wmi_buf_alloc(wmi_handle, len);
9097
9098 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309099 WMI_LOGE(FL("Failed allocate wmi buffer"));
9100 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309101 }
9102
9103 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309104 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309105 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9106
9107 WMITLV_SET_HDR(&cmd->tlv_header,
9108 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9109 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9110
9111 cmd->request_id = mem_dump_req->request_id;
9112 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9113
9114 /* TLV indicating array of structures to follow */
9115 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9116 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9117 sizeof(wmi_fw_mem_dump) *
9118 cmd->num_fw_mem_dump_segs);
9119
9120 buf_ptr += WMI_TLV_HDR_SIZE;
9121 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9122
Govind Singhb53420c2016-03-09 14:32:57 +05309123 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309124 mem_dump_req->request_id, mem_dump_req->num_seg);
9125 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309126 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309127 ((uint8_t *)(mem_dump_req->segment) +
9128 loop * sizeof(*seg_req));
9129 WMITLV_SET_HDR(&dump_params->tlv_header,
9130 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9131 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9132 dump_params->seg_id = seg_req->seg_id;
9133 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9134 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9135 dump_params->seg_length = seg_req->seg_length;
9136 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9137 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309138 WMI_LOGI(FL("seg_number:%d"), loop);
9139 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309140 dump_params->seg_id, dump_params->seg_start_addr_lo,
9141 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309142 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309143 dump_params->seg_length, dump_params->dest_addr_lo,
9144 dump_params->dest_addr_hi);
9145 dump_params++;
9146 }
9147
9148 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9149 WMI_GET_FW_MEM_DUMP_CMDID);
9150 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309151 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309152 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309153 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309154 }
9155
Govind Singhb53420c2016-03-09 14:32:57 +05309156 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9157 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309158}
9159
9160/*
9161 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9162 * @wmi_handle: Pointer to WMi handle
9163 * @ie_data: Pointer for ie data
9164 *
9165 * This function sends IE information to firmware
9166 *
Govind Singhb53420c2016-03-09 14:32:57 +05309167 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309168 *
9169 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309170static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309171 struct vdev_ie_info_param *ie_info)
9172{
9173 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9174 wmi_buf_t buf;
9175 uint8_t *buf_ptr;
9176 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309177 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309178
9179
9180 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9181 /* Allocate memory for the WMI command */
9182 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9183
9184 buf = wmi_buf_alloc(wmi_handle, len);
9185 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309186 WMI_LOGE(FL("wmi_buf_alloc failed"));
9187 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309188 }
9189
9190 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309191 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309192
9193 /* Populate the WMI command */
9194 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9195
9196 WMITLV_SET_HDR(&cmd->tlv_header,
9197 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9198 WMITLV_GET_STRUCT_TLVLEN(
9199 wmi_vdev_set_ie_cmd_fixed_param));
9200 cmd->vdev_id = ie_info->vdev_id;
9201 cmd->ie_id = ie_info->ie_id;
9202 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009203 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309204
Govind Singhb53420c2016-03-09 14:32:57 +05309205 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309206 ie_info->length, ie_info->vdev_id);
9207
9208 buf_ptr += sizeof(*cmd);
9209 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9210 buf_ptr += WMI_TLV_HDR_SIZE;
9211
Govind Singhb53420c2016-03-09 14:32:57 +05309212 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309213
9214 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9215 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309216 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309217 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309218 wmi_buf_free(buf);
9219 }
9220
9221 return ret;
9222}
9223
Sathish Kumar497bef42017-03-01 14:02:36 +05309224/**
9225 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9226 *
9227 * @param wmi_handle : handle to WMI.
9228 * @param param : pointer to antenna param
9229 *
9230 * This function sends smart antenna enable command to FW
9231 *
9232 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9233 */
9234static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9235 struct smart_ant_enable_params *param)
9236{
9237 /* Send WMI COMMAND to Enable */
9238 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9239 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9240 wmi_buf_t buf;
9241 uint8_t *buf_ptr;
9242 int len = 0;
9243 QDF_STATUS ret;
9244 int loop = 0;
9245
9246 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9247 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9248 buf = wmi_buf_alloc(wmi_handle, len);
9249
9250 if (!buf) {
9251 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9252 return QDF_STATUS_E_NOMEM;
9253 }
9254
9255 buf_ptr = wmi_buf_data(buf);
9256 qdf_mem_zero(buf_ptr, len);
9257 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9258
9259 WMITLV_SET_HDR(&cmd->tlv_header,
9260 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9261 WMITLV_GET_STRUCT_TLVLEN(
9262 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9263
9264 cmd->pdev_id = param->pdev_id;
9265 cmd->enable = param->enable;
9266 cmd->mode = param->mode;
9267 cmd->rx_antenna = param->rx_antenna;
9268 cmd->tx_default_antenna = param->rx_antenna;
9269
9270 /* TLV indicating array of structures to follow */
9271 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9272 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9273 WMI_HAL_MAX_SANTENNA *
9274 sizeof(wmi_pdev_smart_ant_gpio_handle));
9275
9276 buf_ptr += WMI_TLV_HDR_SIZE;
9277 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9278
9279 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9280 WMITLV_SET_HDR(&gpio_param->tlv_header,
9281 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9282 WMITLV_GET_STRUCT_TLVLEN(
9283 wmi_pdev_smart_ant_gpio_handle));
9284 if (param->mode == SMART_ANT_MODE_SERIAL) {
9285 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
9286 gpio_param->gpio_pin = param->gpio_pin[loop];
9287 gpio_param->gpio_func = param->gpio_func[loop];
9288 } else {
9289 gpio_param->gpio_pin = 0;
9290 gpio_param->gpio_func = 0;
9291 }
9292 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
9293 gpio_param->gpio_pin = param->gpio_pin[loop];
9294 gpio_param->gpio_func = param->gpio_func[loop];
9295 }
9296 /* Setting it to 0 for now */
9297 gpio_param->pdev_id = param->pdev_id;
9298 gpio_param++;
9299 }
9300
9301 ret = wmi_unified_cmd_send(wmi_handle,
9302 buf,
9303 len,
9304 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
9305
9306 if (ret != 0) {
9307 WMI_LOGE(" %s :WMI Failed\n", __func__);
9308 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
9309 cmd->enable,
9310 cmd->mode,
9311 cmd->rx_antenna,
9312 param->gpio_pin[0], param->gpio_pin[1],
9313 param->gpio_pin[2], param->gpio_pin[3],
9314 param->gpio_func[0], param->gpio_func[1],
9315 param->gpio_func[2], param->gpio_func[3],
9316 ret);
9317 wmi_buf_free(buf);
9318 }
9319
9320 return ret;
9321}
9322
9323/**
9324 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
9325 *
9326 * @param wmi_handle : handle to WMI.
9327 * @param param : pointer to rx antenna param
9328 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9329 */
9330static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9331 struct smart_ant_rx_ant_params *param)
9332{
9333 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
9334 wmi_buf_t buf;
9335 uint8_t *buf_ptr;
9336 uint32_t len;
9337 QDF_STATUS ret;
9338
9339 len = sizeof(*cmd);
9340 buf = wmi_buf_alloc(wmi_handle, len);
9341 WMI_LOGD("%s:\n", __func__);
9342 if (!buf) {
9343 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9344 return QDF_STATUS_E_NOMEM;
9345 }
9346
9347 buf_ptr = wmi_buf_data(buf);
9348 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
9349 WMITLV_SET_HDR(&cmd->tlv_header,
9350 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
9351 WMITLV_GET_STRUCT_TLVLEN(
9352 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
9353 cmd->rx_antenna = param->antenna;
9354 cmd->pdev_id = param->pdev_id;
9355
9356 ret = wmi_unified_cmd_send(wmi_handle,
9357 buf,
9358 len,
9359 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
9360
9361 if (ret != 0) {
9362 WMI_LOGE(" %s :WMI Failed\n", __func__);
9363 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
9364 __func__,
9365 cmd->rx_antenna,
9366 ret);
9367 wmi_buf_free(buf);
9368 }
9369
9370 return ret;
9371}
9372
9373/**
9374 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
9375 * @wmi_handle: wmi handle
9376 * @param: pointer to hold ctl table param
9377 *
9378 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9379 */
9380static QDF_STATUS
9381send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
9382 struct ctl_table_params *param)
9383{
9384 uint16_t len, ctl_tlv_len;
9385 uint8_t *buf_ptr;
9386 wmi_buf_t buf;
9387 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
9388 uint32_t *ctl_array;
9389
9390 if (!param->ctl_array)
9391 return QDF_STATUS_E_FAILURE;
9392
9393 if (param->ctl_cmd_len !=
9394 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
9395 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
9396 qdf_print("CTL array len not correct\n");
9397 return QDF_STATUS_E_FAILURE;
9398 }
9399
9400 ctl_tlv_len = WMI_TLV_HDR_SIZE +
9401 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
9402 len = sizeof(*cmd) + ctl_tlv_len;
9403
9404 buf = wmi_buf_alloc(wmi_handle, len);
9405 if (!buf) {
9406 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9407 return QDF_STATUS_E_FAILURE;
9408 }
9409
9410 buf_ptr = wmi_buf_data(buf);
9411 qdf_mem_zero(buf_ptr, len);
9412
9413 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
9414
9415 WMITLV_SET_HDR(&cmd->tlv_header,
9416 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
9417 WMITLV_GET_STRUCT_TLVLEN(
9418 wmi_pdev_set_ctl_table_cmd_fixed_param));
9419 cmd->ctl_len = param->ctl_cmd_len;
9420 cmd->pdev_id = param->pdev_id;
9421
9422 buf_ptr += sizeof(*cmd);
9423 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9424 (cmd->ctl_len));
9425 buf_ptr += WMI_TLV_HDR_SIZE;
9426 ctl_array = (uint32_t *)buf_ptr;
9427
9428 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
9429 sizeof(param->ctl_band));
9430 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
9431 param->ctl_cmd_len -
9432 sizeof(param->ctl_band));
9433
9434 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9435 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
9436 WMI_LOGE("%s:Failed to send command\n", __func__);
9437 wmi_buf_free(buf);
9438 return QDF_STATUS_E_FAILURE;
9439 }
9440
9441 return QDF_STATUS_SUCCESS;
9442}
9443
9444/**
9445 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
9446 * @wmi_handle: wmi handle
9447 * @param: pointer to hold mimogain table param
9448 *
9449 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9450 */
9451static QDF_STATUS
9452send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
9453 struct mimogain_table_params *param)
9454{
9455 uint16_t len, table_tlv_len;
9456 wmi_buf_t buf;
9457 uint8_t *buf_ptr;
9458 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
9459 uint32_t *gain_table;
9460
9461 if (!param->array_gain)
9462 return QDF_STATUS_E_FAILURE;
9463
9464 /* len must be multiple of a single array gain table */
9465 if (param->tbl_len %
9466 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
9467 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
9468 WMI_LOGE("Array gain table len not correct\n");
9469 return QDF_STATUS_E_FAILURE;
9470 }
9471
9472 table_tlv_len = WMI_TLV_HDR_SIZE +
9473 roundup(param->tbl_len, sizeof(uint32_t));
9474 len = sizeof(*cmd) + table_tlv_len;
9475
9476 buf = wmi_buf_alloc(wmi_handle, len);
9477 if (!buf) {
9478 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9479 return QDF_STATUS_E_FAILURE;
9480 }
9481
9482 buf_ptr = wmi_buf_data(buf);
9483 qdf_mem_zero(buf_ptr, len);
9484
9485 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
9486
9487 WMITLV_SET_HDR(&cmd->tlv_header,
9488 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
9489 WMITLV_GET_STRUCT_TLVLEN(
9490 wmi_pdev_set_mimogain_table_cmd_fixed_param));
9491
9492 cmd->pdev_id = param->pdev_id;
9493 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
9494 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
9495 param->multichain_gain_bypass);
9496
9497 buf_ptr += sizeof(*cmd);
9498 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9499 (param->tbl_len));
9500 buf_ptr += WMI_TLV_HDR_SIZE;
9501 gain_table = (uint32_t *)buf_ptr;
9502
9503 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
9504 param->array_gain,
9505 param->tbl_len);
9506
9507 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9508 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
9509 return QDF_STATUS_E_FAILURE;
9510 }
9511
9512 return QDF_STATUS_SUCCESS;
9513}
9514
9515/**
9516 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
9517 * info to fw
9518 * @wmi_handle: wmi handle
9519 * @param: pointer to hold packet power info param
9520 *
9521 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9522 */
9523static QDF_STATUS
9524send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
9525 struct packet_power_info_params *param)
9526{
9527 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
9528 wmi_buf_t wmibuf;
9529 uint8_t *buf_ptr;
9530 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
9531
9532 wmibuf = wmi_buf_alloc(wmi_handle, len);
9533 if (wmibuf == NULL)
9534 return QDF_STATUS_E_NOMEM;
9535
9536 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
9537
9538 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
9539 WMITLV_SET_HDR(&cmd->tlv_header,
9540 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
9541 WMITLV_GET_STRUCT_TLVLEN(
9542 wmi_pdev_get_tpc_cmd_fixed_param));
9543 cmd->pdev_id = param->pdev_id;
9544 cmd->rate_flags = param->rate_flags;
9545 cmd->nss = param->nss;
9546 cmd->preamble = param->preamble;
9547 cmd->hw_rate = param->hw_rate;
9548 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
9549 __func__,
9550 __LINE__,
9551 WMI_PDEV_GET_TPC_CMDID,
9552 *((u_int32_t *)cmd));
9553 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
9554 WMI_PDEV_GET_TPC_CMDID)) {
9555 WMI_LOGE(FL("Failed to get tpc command\n"));
9556 wmi_buf_free(wmibuf);
9557 return QDF_STATUS_E_FAILURE;
9558 }
9559
9560 return QDF_STATUS_SUCCESS;
9561}
9562
9563/**
9564 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
9565 * @wmi_handle: wmi handle
9566 * @param: pointer to hold config ratemask params
9567 *
9568 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9569 */
9570static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
9571 struct config_ratemask_params *param)
9572{
9573 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
9574 wmi_buf_t buf;
9575 int32_t len = sizeof(*cmd);
9576
9577 buf = wmi_buf_alloc(wmi_handle, len);
9578 if (!buf) {
9579 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9580 return QDF_STATUS_E_FAILURE;
9581 }
9582 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
9583 WMITLV_SET_HDR(&cmd->tlv_header,
9584 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
9585 WMITLV_GET_STRUCT_TLVLEN(
9586 wmi_vdev_config_ratemask_cmd_fixed_param));
9587 cmd->vdev_id = param->vdev_id;
9588 cmd->type = param->type;
9589 cmd->mask_lower32 = param->lower32;
9590 cmd->mask_higher32 = param->higher32;
9591 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
9592 param->vdev_id, param->type, param->lower32, param->higher32);
9593
9594 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9595 WMI_VDEV_RATEMASK_CMDID)) {
9596 WMI_LOGE("Seting vdev ratemask failed\n");
9597 wmi_buf_free(buf);
9598 return QDF_STATUS_E_FAILURE;
9599 }
9600
9601 return QDF_STATUS_SUCCESS;
9602}
9603
9604/**
9605 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
9606 * @wmi_handle: wmi handle
9607 * @param: pointer to hold vap dscp tid map param
9608 *
9609 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9610 */
9611static QDF_STATUS
9612send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
9613 struct vap_dscp_tid_map_params *param)
9614{
9615 wmi_buf_t buf;
9616 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
9617 int32_t len = sizeof(*cmd);
9618
9619 buf = wmi_buf_alloc(wmi_handle, len);
9620 if (!buf) {
9621 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9622 return QDF_STATUS_E_FAILURE;
9623 }
9624
9625 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
9626 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
9627 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
9628
9629 cmd->vdev_id = param->vdev_id;
9630 cmd->enable_override = 0;
9631
9632 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
9633 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9634 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
9635 WMI_LOGE("Failed to set dscp cmd\n");
9636 wmi_buf_free(buf);
9637 return QDF_STATUS_E_FAILURE;
9638 }
9639
9640 return QDF_STATUS_SUCCESS;
9641}
9642
9643/**
9644 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
9645 * @wmi_handle: wmi handle
9646 * @macaddr: vdev mac address
9647 * @param: pointer to hold neigbour rx param
9648 *
9649 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9650 */
9651static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
9652 uint8_t macaddr[IEEE80211_ADDR_LEN],
9653 struct set_neighbour_rx_params *param)
9654{
9655 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
9656 wmi_buf_t buf;
9657 int32_t len = sizeof(*cmd);
9658
9659 buf = wmi_buf_alloc(wmi_handle, len);
9660 if (!buf) {
9661 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9662 return QDF_STATUS_E_FAILURE;
9663 }
9664 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
9665 WMITLV_SET_HDR(&cmd->tlv_header,
9666 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
9667 WMITLV_GET_STRUCT_TLVLEN(
9668 wmi_vdev_filter_nrp_config_cmd_fixed_param));
9669 cmd->vdev_id = param->vdev_id;
9670 cmd->bssid_idx = param->idx;
9671 cmd->action = param->action;
9672 cmd->type = param->type;
9673 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
9674 cmd->flag = 0;
9675
9676 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9677 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
9678 WMI_LOGE("Failed to set neighbour rx param\n");
9679 wmi_buf_free(buf);
9680 return QDF_STATUS_E_FAILURE;
9681 }
9682
9683 return QDF_STATUS_SUCCESS;
9684}
9685
9686/**
9687 * send_smart_ant_set_tx_ant_cmd_non_tlv() - WMI set tx antenna function
9688 * @param wmi_handle : handle to WMI.
9689 * @param macaddr : vdev mac address
9690 * @param param : pointer to tx antenna param
9691 *
9692 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9693 */
9694static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9695 uint8_t macaddr[IEEE80211_ADDR_LEN],
9696 struct smart_ant_tx_ant_params *param)
9697{
9698 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
9699 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
9700 wmi_buf_t buf;
9701 int32_t len = 0;
9702 int i;
9703 uint8_t *buf_ptr;
9704 QDF_STATUS ret;
9705
9706 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9707 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
9708 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
9709 buf = wmi_buf_alloc(wmi_handle, len);
9710
9711 if (!buf) {
9712 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9713 return QDF_STATUS_E_NOMEM;
9714 }
9715
9716 buf_ptr = (uint8_t *)wmi_buf_data(buf);
9717 qdf_mem_zero(buf_ptr, len);
9718 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
9719
9720 WMITLV_SET_HDR(&cmd->tlv_header,
9721 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
9722 WMITLV_GET_STRUCT_TLVLEN(
9723 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
9724
9725 cmd->vdev_id = param->vdev_id;
9726 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
9727
9728 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
9729 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9730 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
9731 buf_ptr += WMI_TLV_HDR_SIZE;
9732 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
9733
9734 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
9735 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
9736 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
9737 WMITLV_GET_STRUCT_TLVLEN(
9738 wmi_peer_smart_ant_set_tx_antenna_series));
9739 ant_tx_series->antenna_series = param->antenna_array[i];
9740 ant_tx_series++;
9741 }
9742
9743 ret = wmi_unified_cmd_send(wmi_handle,
9744 buf,
9745 len,
9746 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
9747
9748 if (ret != 0) {
9749 WMI_LOGE(" %s :WMI Failed\n", __func__);
9750 wmi_buf_free(buf);
9751 }
9752
9753 return ret;
9754}
9755
Jeff Johnson9366d7a2016-10-07 13:03:02 -07009756static
Govind Singh9ddd5162016-03-07 16:30:32 +05309757void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05309758 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05309759{
Govind Singhe7f2f342016-05-23 12:12:52 +05309760 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05309761 resource_cfg->num_peers = tgt_res_cfg->num_peers;
9762 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
9763 resource_cfg->num_offload_reorder_buffs =
9764 tgt_res_cfg->num_offload_reorder_buffs;
9765 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
9766 resource_cfg->num_tids = tgt_res_cfg->num_tids;
9767 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
9768 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
9769 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
9770 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
9771 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
9772 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
9773 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
9774 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
9775 resource_cfg->scan_max_pending_req =
9776 tgt_res_cfg->scan_max_pending_req;
9777 resource_cfg->bmiss_offload_max_vdev =
9778 tgt_res_cfg->bmiss_offload_max_vdev;
9779 resource_cfg->roam_offload_max_vdev =
9780 tgt_res_cfg->roam_offload_max_vdev;
9781 resource_cfg->roam_offload_max_ap_profiles =
9782 tgt_res_cfg->roam_offload_max_ap_profiles;
9783 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
9784 resource_cfg->num_mcast_table_elems =
9785 tgt_res_cfg->num_mcast_table_elems;
9786 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
9787 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
9788 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
9789 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
9790 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
9791 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
9792 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
9793 resource_cfg->vow_config = tgt_res_cfg->vow_config;
9794 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
9795 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
9796 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
9797 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
9798 resource_cfg->num_tdls_conn_table_entries =
9799 tgt_res_cfg->num_tdls_conn_table_entries;
9800 resource_cfg->beacon_tx_offload_max_vdev =
9801 tgt_res_cfg->beacon_tx_offload_max_vdev;
9802 resource_cfg->num_multicast_filter_entries =
9803 tgt_res_cfg->num_multicast_filter_entries;
9804 resource_cfg->num_wow_filters =
9805 tgt_res_cfg->num_wow_filters;
9806 resource_cfg->num_keep_alive_pattern =
9807 tgt_res_cfg->num_keep_alive_pattern;
9808 resource_cfg->keep_alive_pattern_size =
9809 tgt_res_cfg->keep_alive_pattern_size;
9810 resource_cfg->max_tdls_concurrent_sleep_sta =
9811 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
9812 resource_cfg->max_tdls_concurrent_buffer_sta =
9813 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
9814 resource_cfg->wmi_send_separate =
9815 tgt_res_cfg->wmi_send_separate;
9816 resource_cfg->num_ocb_vdevs =
9817 tgt_res_cfg->num_ocb_vdevs;
9818 resource_cfg->num_ocb_channels =
9819 tgt_res_cfg->num_ocb_channels;
9820 resource_cfg->num_ocb_schedules =
9821 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05309822 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
9823 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
9824 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Govind Singh9ddd5162016-03-07 16:30:32 +05309825}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309826#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309827/**
9828 * send_init_cmd_tlv() - wmi init command
9829 * @wmi_handle: pointer to wmi handle
9830 * @res_cfg: resource config
9831 * @num_mem_chunks: no of mem chunck
9832 * @mem_chunk: pointer to mem chunck structure
9833 *
9834 * This function sends IE information to firmware
9835 *
Govind Singhb53420c2016-03-09 14:32:57 +05309836 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309837 *
9838 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309839static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309840 wmi_resource_config *tgt_res_cfg,
9841 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
9842 bool action)
9843{
9844 wmi_buf_t buf;
9845 wmi_init_cmd_fixed_param *cmd;
9846 wmi_abi_version my_vers;
9847 int num_whitelist;
9848 uint8_t *buf_ptr;
9849 wmi_resource_config *resource_cfg;
9850 wlan_host_memory_chunk *host_mem_chunks;
9851 uint32_t mem_chunk_len = 0;
9852 uint16_t idx;
9853 int len;
9854 int ret;
9855
9856 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
9857 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
9858 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
9859 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309860 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
9861 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309862 }
9863
9864 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9865 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
9866 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
9867
9868 host_mem_chunks = (wlan_host_memory_chunk *)
9869 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
9870 + WMI_TLV_HDR_SIZE);
9871
9872 WMITLV_SET_HDR(&cmd->tlv_header,
9873 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
9874 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
9875
Govind Singhb53420c2016-03-09 14:32:57 +05309876 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +05309877 WMITLV_SET_HDR(&resource_cfg->tlv_header,
9878 WMITLV_TAG_STRUC_wmi_resource_config,
9879 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
9880
9881 for (idx = 0; idx < num_mem_chunks; ++idx) {
9882 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
9883 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
9884 WMITLV_GET_STRUCT_TLVLEN
9885 (wlan_host_memory_chunk));
9886 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
9887 host_mem_chunks[idx].size = mem_chunks[idx].len;
9888 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309889 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +05309890 idx, host_mem_chunks[idx].size,
9891 host_mem_chunks[idx].ptr);
9892 }
9893 cmd->num_host_mem_chunks = num_mem_chunks;
9894 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
9895 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
9896 WMITLV_TAG_ARRAY_STRUC,
9897 (sizeof(wlan_host_memory_chunk) *
9898 num_mem_chunks));
9899
9900 num_whitelist = sizeof(version_whitelist) /
9901 sizeof(wmi_whitelist_version_info);
9902 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
9903 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
9904 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
9905 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
9906 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
9907 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +05309908#ifdef CONFIG_MCL
9909 /* This needs to be enabled for WIN Lithium after removing dependency
9910 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +05309911 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
9912 &my_vers,
9913 &wmi_handle->fw_abi_version,
9914 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +05309915#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309916 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05309917 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
9918 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
9919 cmd->host_abi_vers.abi_version_ns_0,
9920 cmd->host_abi_vers.abi_version_ns_1,
9921 cmd->host_abi_vers.abi_version_ns_2,
9922 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +05309923#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309924 /* Save version sent from host -
9925 * Will be used to check ready event
9926 */
Govind Singhb53420c2016-03-09 14:32:57 +05309927 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309928 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309929#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309930 if (action) {
9931 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9932 WMI_INIT_CMDID);
9933 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309934 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +05309935 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309936 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309937 }
9938 } else {
9939 wmi_handle->saved_wmi_init_cmd.buf = buf;
9940 wmi_handle->saved_wmi_init_cmd.buf_len = len;
9941 }
9942
Govind Singhb53420c2016-03-09 14:32:57 +05309943 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309944
9945}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309946#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309947/**
9948 * send_saved_init_cmd_tlv() - wmi init command
9949 * @wmi_handle: pointer to wmi handle
9950 *
9951 * This function sends IE information to firmware
9952 *
Govind Singhb53420c2016-03-09 14:32:57 +05309953 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309954 *
9955 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309956static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +05309957{
9958 int status;
9959
9960 if (!wmi_handle->saved_wmi_init_cmd.buf ||
9961 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05309962 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
9963 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309964 }
9965 status = wmi_unified_cmd_send(wmi_handle,
9966 wmi_handle->saved_wmi_init_cmd.buf,
9967 wmi_handle->saved_wmi_init_cmd.buf_len,
9968 WMI_INIT_CMDID);
9969 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +05309970 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +05309971 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309972 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309973 }
9974 wmi_handle->saved_wmi_init_cmd.buf = NULL;
9975 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
9976
Govind Singhb53420c2016-03-09 14:32:57 +05309977 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309978}
9979
Sathish Kumarfd347372017-02-13 12:29:09 +05309980static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05309981{
9982 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
9983 wmi_service_ready_event_fixed_param *ev;
9984
9985
9986 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
9987
9988 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
9989 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05309990 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309991
Govind Singh87542482016-06-08 19:40:11 +05309992#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309993 /*Save fw version from service ready message */
9994 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05309995 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309996 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309997#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309998 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309999}
10000
10001/**
10002 * wmi_unified_save_fw_version_cmd() - save fw version
10003 * @wmi_handle: pointer to wmi handle
10004 * @res_cfg: resource config
10005 * @num_mem_chunks: no of mem chunck
10006 * @mem_chunk: pointer to mem chunck structure
10007 *
10008 * This function sends IE information to firmware
10009 *
Govind Singhb53420c2016-03-09 14:32:57 +053010010 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010011 *
10012 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010013static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053010014 void *evt_buf)
10015{
10016 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
10017 wmi_ready_event_fixed_param *ev = NULL;
10018
10019 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
10020 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053010021#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010022 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
10023 &ev->fw_abi_vers)) {
10024 /*
10025 * Error: Our host version and the given firmware version
10026 * are incompatible.
10027 **/
Govind Singhb53420c2016-03-09 14:32:57 +053010028 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053010029 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
10030 __func__,
10031 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
10032 abi_version_0),
10033 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
10034 abi_version_0),
10035 wmi_handle->final_abi_vers.abi_version_ns_0,
10036 wmi_handle->final_abi_vers.abi_version_ns_1,
10037 wmi_handle->final_abi_vers.abi_version_ns_2,
10038 wmi_handle->final_abi_vers.abi_version_ns_3,
10039 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
10040 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
10041 ev->fw_abi_vers.abi_version_ns_0,
10042 ev->fw_abi_vers.abi_version_ns_1,
10043 ev->fw_abi_vers.abi_version_ns_2,
10044 ev->fw_abi_vers.abi_version_ns_3);
10045
Govind Singhb53420c2016-03-09 14:32:57 +053010046 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010047 }
Govind Singhb53420c2016-03-09 14:32:57 +053010048 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010049 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053010050 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010051 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010052#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010053
Govind Singhb53420c2016-03-09 14:32:57 +053010054 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010055}
Govind Singha4836fd2016-03-07 16:45:38 +053010056
10057/**
10058 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
10059 * @wmi_handle: wmi handle
10060 * @custom_addr: base mac address
10061 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010062 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053010063 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010064static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010065 uint8_t *custom_addr)
10066{
10067 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
10068 wmi_buf_t buf;
10069 int err;
10070
10071 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10072 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010073 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010074 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010075 }
10076
10077 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010078 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053010079
10080 WMITLV_SET_HDR(&cmd->tlv_header,
10081 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
10082 WMITLV_GET_STRUCT_TLVLEN
10083 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
10084 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -070010085 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010086 err = wmi_unified_cmd_send(wmi_handle, buf,
10087 sizeof(*cmd),
10088 WMI_PDEV_SET_BASE_MACADDR_CMDID);
10089 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053010090 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053010091 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010092 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010093 }
10094
10095 return 0;
10096}
10097
10098/**
10099 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
10100 * @handle: wmi handle
10101 * @event: Event received from FW
10102 * @len: Length of the event
10103 *
10104 * Enables the low frequency events and disables the high frequency
10105 * events. Bit 17 indicates if the event if low/high frequency.
10106 * 1 - high frequency, 0 - low frequency
10107 *
10108 * Return: 0 on successfully enabling/disabling the events
10109 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010110static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010111 uint8_t *event,
10112 uint32_t len)
10113{
10114 uint32_t num_of_diag_events_logs;
10115 wmi_diag_event_log_config_fixed_param *cmd;
10116 wmi_buf_t buf;
10117 uint8_t *buf_ptr;
10118 uint32_t *cmd_args, *evt_args;
10119 uint32_t buf_len, i;
10120
10121 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
10122 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
10123
Govind Singhb53420c2016-03-09 14:32:57 +053010124 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053010125
10126 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
10127 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010128 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053010129 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010130 }
10131 wmi_event = param_buf->fixed_param;
10132 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
10133 evt_args = param_buf->diag_events_logs_list;
10134 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053010135 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010136 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053010137 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010138 }
10139
Govind Singhb53420c2016-03-09 14:32:57 +053010140 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010141 __func__, num_of_diag_events_logs);
10142
10143 /* Free any previous allocation */
10144 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053010145 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010146
10147 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053010148 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053010149 sizeof(uint32_t));
10150 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010151 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010152 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010153 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010154 }
10155 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
10156
10157 /* Prepare the send buffer */
10158 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10159 (num_of_diag_events_logs * sizeof(uint32_t));
10160
10161 buf = wmi_buf_alloc(wmi_handle, buf_len);
10162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010163 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10164 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010165 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010166 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010167 }
10168
10169 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10170 buf_ptr = (uint8_t *) cmd;
10171
10172 WMITLV_SET_HDR(&cmd->tlv_header,
10173 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10174 WMITLV_GET_STRUCT_TLVLEN(
10175 wmi_diag_event_log_config_fixed_param));
10176
10177 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
10178
10179 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10180
10181 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10182 (num_of_diag_events_logs * sizeof(uint32_t)));
10183
10184 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10185
10186 /* Populate the events */
10187 for (i = 0; i < num_of_diag_events_logs; i++) {
10188 /* Low freq (0) - Enable (1) the event
10189 * High freq (1) - Disable (0) the event
10190 */
10191 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
10192 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
10193 /* Set the event ID */
10194 WMI_DIAG_ID_SET(cmd_args[i],
10195 WMI_DIAG_ID_GET(evt_args[i]));
10196 /* Set the type */
10197 WMI_DIAG_TYPE_SET(cmd_args[i],
10198 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053010199 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053010200 wmi_handle->events_logs_list[i] = evt_args[i];
10201 }
10202
10203 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
10204 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010205 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010206 __func__);
10207 wmi_buf_free(buf);
10208 /* Not clearing events_logs_list, though wmi cmd failed.
10209 * Host can still have this list
10210 */
Govind Singh67922e82016-04-01 16:48:57 +053010211 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010212 }
10213
10214 return 0;
10215}
10216
10217/**
10218 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
10219 * @wmi_handle: wmi handle
10220 * @start_log: Start logging related parameters
10221 *
10222 * Send the command to the FW based on which specific logging of diag
10223 * event/log id can be started/stopped
10224 *
10225 * Return: None
10226 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010227static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010228 struct wmi_wifi_start_log *start_log)
10229{
10230 wmi_diag_event_log_config_fixed_param *cmd;
10231 wmi_buf_t buf;
10232 uint8_t *buf_ptr;
10233 uint32_t len, count, log_level, i;
10234 uint32_t *cmd_args;
10235 uint32_t total_len;
10236 count = 0;
10237
10238 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010239 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053010240 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010241 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010242 }
10243 /* total_len stores the number of events where BITS 17 and 18 are set.
10244 * i.e., events of high frequency (17) and for extended debugging (18)
10245 */
10246 total_len = 0;
10247 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10248 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
10249 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
10250 total_len++;
10251 }
10252
10253 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10254 (total_len * sizeof(uint32_t));
10255
10256 buf = wmi_buf_alloc(wmi_handle, len);
10257 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010258 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010259 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010260 }
10261 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10262 buf_ptr = (uint8_t *) cmd;
10263
10264 WMITLV_SET_HDR(&cmd->tlv_header,
10265 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10266 WMITLV_GET_STRUCT_TLVLEN(
10267 wmi_diag_event_log_config_fixed_param));
10268
10269 cmd->num_of_diag_events_logs = total_len;
10270
10271 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10272
10273 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10274 (total_len * sizeof(uint32_t)));
10275
10276 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10277
Govind Singh224a7312016-06-21 14:33:26 +053010278 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053010279 log_level = 1;
10280 else
10281 log_level = 0;
10282
Govind Singhb53420c2016-03-09 14:32:57 +053010283 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053010284 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10285 uint32_t val = wmi_handle->events_logs_list[i];
10286 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
10287 (WMI_DIAG_EXT_FEATURE_GET(val))) {
10288
10289 WMI_DIAG_ID_SET(cmd_args[count],
10290 WMI_DIAG_ID_GET(val));
10291 WMI_DIAG_TYPE_SET(cmd_args[count],
10292 WMI_DIAG_TYPE_GET(val));
10293 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
10294 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053010295 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053010296 count++;
10297 }
10298 }
10299
10300 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10301 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010302 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010303 __func__);
10304 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010305 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010306 }
10307
Govind Singhb53420c2016-03-09 14:32:57 +053010308 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010309}
10310
10311/**
10312 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
10313 * @wmi_handle: WMI handle
10314 *
10315 * This function is used to send the flush command to the FW,
10316 * that will flush the fw logs that are residue in the FW
10317 *
10318 * Return: None
10319 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010320static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053010321{
10322 wmi_debug_mesg_flush_fixed_param *cmd;
10323 wmi_buf_t buf;
10324 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053010325 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010326
10327 buf = wmi_buf_alloc(wmi_handle, len);
10328 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010329 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010330 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010331 }
10332
10333 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
10334 WMITLV_SET_HDR(&cmd->tlv_header,
10335 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
10336 WMITLV_GET_STRUCT_TLVLEN(
10337 wmi_debug_mesg_flush_fixed_param));
10338 cmd->reserved0 = 0;
10339
10340 ret = wmi_unified_cmd_send(wmi_handle,
10341 buf,
10342 len,
10343 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010344 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010345 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053010346 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010347 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010348 }
Govind Singhb53420c2016-03-09 14:32:57 +053010349 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053010350
Govind Singh67922e82016-04-01 16:48:57 +053010351 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010352}
10353
10354/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010355 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010356 * @wmi_handle: wmi handle
10357 * @msg: PCL structure containing the PCL and the number of channels
10358 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010359 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053010360 * firmware. The DBS Manager is the consumer of this information in the WLAN
10361 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
10362 * to migrate to a new channel without host driver involvement. An example of
10363 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
10364 * manage the channel selection without firmware involvement.
10365 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010366 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
10367 * channel list. The weights corresponds to the channels sent in
10368 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
10369 * weightage compared to the non PCL channels.
10370 *
Govind Singha4836fd2016-03-07 16:45:38 +053010371 * Return: Success if the cmd is sent successfully to the firmware
10372 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010373static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010374 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053010375{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010376 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010377 wmi_buf_t buf;
10378 uint8_t *buf_ptr;
10379 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010380 uint32_t chan_len;
10381
10382 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053010383
10384 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010385 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053010386
10387 buf = wmi_buf_alloc(wmi_handle, len);
10388 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010389 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10390 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010391 }
10392
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010393 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010394 buf_ptr = (uint8_t *) cmd;
10395 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010396 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
10397 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053010398
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010399 cmd->pdev_id = WMI_PDEV_ID_SOC;
10400 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053010401 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010402
10403 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053010404 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010405 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053010406 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010407 for (i = 0; i < chan_len ; i++) {
10408 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053010409 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010410 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010411 }
10412 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010413 WMI_PDEV_SET_PCL_CMDID)) {
10414 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010415 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010416 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010417 }
Govind Singhb53420c2016-03-09 14:32:57 +053010418 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010419}
10420
10421/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010422 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010423 * @wmi_handle: wmi handle
10424 * @msg: Structure containing the following parameters
10425 *
10426 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
10427 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
10428 *
10429 * Provides notification to the WLAN firmware that host driver is requesting a
10430 * HardWare (HW) Mode change. This command is needed to support iHelium in the
10431 * configurations that include the Dual Band Simultaneous (DBS) feature.
10432 *
10433 * Return: Success if the cmd is sent successfully to the firmware
10434 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010435static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010436 uint32_t hw_mode_index)
10437{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010438 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010439 wmi_buf_t buf;
10440 uint32_t len;
10441
10442 len = sizeof(*cmd);
10443
10444 buf = wmi_buf_alloc(wmi_handle, len);
10445 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010446 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10447 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010448 }
10449
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010450 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010451 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010452 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
10453 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
10454
10455 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010456 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053010457 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053010458
10459 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010460 WMI_PDEV_SET_HW_MODE_CMDID)) {
10461 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010462 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010463 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010464 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010465 }
10466
Govind Singhb53420c2016-03-09 14:32:57 +053010467 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010468}
10469
10470/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010471 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010472 * @wmi_handle: wmi handle
10473 * @msg: Dual MAC config parameters
10474 *
10475 * Configures WLAN firmware with the dual MAC features
10476 *
Govind Singhb53420c2016-03-09 14:32:57 +053010477 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053010478 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010479static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010480QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010481 struct wmi_dual_mac_config *msg)
10482{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010483 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010484 wmi_buf_t buf;
10485 uint32_t len;
10486
10487 len = sizeof(*cmd);
10488
10489 buf = wmi_buf_alloc(wmi_handle, len);
10490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010491 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10492 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010493 }
10494
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010495 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010496 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010497 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053010498 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010499 wmi_pdev_set_mac_config_cmd_fixed_param));
10500
10501 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010502 cmd->concurrent_scan_config_bits = msg->scan_config;
10503 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053010504 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053010505 __func__, msg->scan_config, msg->fw_mode_config);
10506
10507 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010508 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
10509 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010510 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010511 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010512 }
Govind Singhb53420c2016-03-09 14:32:57 +053010513 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010514}
10515
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053010516#ifdef BIG_ENDIAN_HOST
10517/**
10518* fips_conv_data_be() - LE to BE conversion of FIPS ev data
10519* @param data_len - data length
10520* @param data - pointer to data
10521*
10522* Return: QDF_STATUS - success or error status
10523*/
10524static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
10525 struct fips_params *param)
10526{
10527 unsigned char *key_unaligned, *data_unaligned;
10528 int c;
10529 u_int8_t *key_aligned = NULL;
10530 u_int8_t *data_aligned = NULL;
10531
10532 /* Assigning unaligned space to copy the key */
10533 key_unaligned = qdf_mem_malloc(
10534 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
10535 data_unaligned = qdf_mem_malloc(
10536 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
10537
10538 /* Checking if kmalloc is succesful to allocate space */
10539 if (key_unaligned == NULL)
10540 return QDF_STATUS_SUCCESS;
10541 /* Checking if space is aligned */
10542 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
10543 /* align to 4 */
10544 key_aligned =
10545 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
10546 FIPS_ALIGN);
10547 } else {
10548 key_aligned = (u_int8_t *)key_unaligned;
10549 }
10550
10551 /* memset and copy content from key to key aligned */
10552 OS_MEMSET(key_aligned, 0, param->key_len);
10553 OS_MEMCPY(key_aligned, param->key, param->key_len);
10554
10555 /* print a hexdump for host debug */
10556 print_hex_dump(KERN_DEBUG,
10557 "\t Aligned and Copied Key:@@@@ ",
10558 DUMP_PREFIX_NONE,
10559 16, 1, key_aligned, param->key_len, true);
10560
10561 /* Checking if kmalloc is succesful to allocate space */
10562 if (data_unaligned == NULL)
10563 return QDF_STATUS_SUCCESS;
10564 /* Checking of space is aligned */
10565 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
10566 /* align to 4 */
10567 data_aligned =
10568 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
10569 FIPS_ALIGN);
10570 } else {
10571 data_aligned = (u_int8_t *)data_unaligned;
10572 }
10573
10574 /* memset and copy content from data to data aligned */
10575 OS_MEMSET(data_aligned, 0, param->data_len);
10576 OS_MEMCPY(data_aligned, param->data, param->data_len);
10577
10578 /* print a hexdump for host debug */
10579 print_hex_dump(KERN_DEBUG,
10580 "\t Properly Aligned and Copied Data:@@@@ ",
10581 DUMP_PREFIX_NONE,
10582 16, 1, data_aligned, param->data_len, true);
10583
10584 /* converting to little Endian both key_aligned and
10585 * data_aligned*/
10586 for (c = 0; c < param->key_len/4; c++) {
10587 *((u_int32_t *)key_aligned+c) =
10588 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
10589 }
10590 for (c = 0; c < param->data_len/4; c++) {
10591 *((u_int32_t *)data_aligned+c) =
10592 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
10593 }
10594
10595 /* update endian data to key and data vectors */
10596 OS_MEMCPY(param->key, key_aligned, param->key_len);
10597 OS_MEMCPY(param->data, data_aligned, param->data_len);
10598
10599 /* clean up allocated spaces */
10600 qdf_mem_free(key_unaligned);
10601 key_unaligned = NULL;
10602 key_aligned = NULL;
10603
10604 qdf_mem_free(data_unaligned);
10605 data_unaligned = NULL;
10606 data_aligned = NULL;
10607
10608 return QDF_STATUS_SUCCESS;
10609}
10610#else
10611/**
10612* fips_align_data_be() - DUMMY for LE platform
10613*
10614* Return: QDF_STATUS - success
10615*/
10616static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
10617 struct fips_params *param)
10618{
10619 return QDF_STATUS_SUCCESS;
10620}
10621#endif
10622
10623
10624/**
10625 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
10626 * @wmi_handle: wmi handle
10627 * @param: pointer to hold pdev fips param
10628 *
10629 * Return: 0 for success or error code
10630 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010631static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053010632send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
10633 struct fips_params *param)
10634{
10635 wmi_pdev_fips_cmd_fixed_param *cmd;
10636 wmi_buf_t buf;
10637 uint8_t *buf_ptr;
10638 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
10639 QDF_STATUS retval = QDF_STATUS_SUCCESS;
10640
10641 /* Length TLV placeholder for array of bytes */
10642 len += WMI_TLV_HDR_SIZE;
10643 if (param->data_len)
10644 len += (param->data_len*sizeof(uint8_t));
10645
10646 /*
10647 * Data length must be multiples of 16 bytes - checked against 0xF -
10648 * and must be less than WMI_SVC_MSG_SIZE - static size of
10649 * wmi_pdev_fips_cmd structure
10650 */
10651
10652 /* do sanity on the input */
10653 if (!(((param->data_len & 0xF) == 0) &&
10654 ((param->data_len > 0) &&
10655 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
10656 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
10657 return QDF_STATUS_E_INVAL;
10658 }
10659
10660 buf = wmi_buf_alloc(wmi_handle, len);
10661 if (!buf) {
10662 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
10663 return QDF_STATUS_E_FAILURE;
10664 }
10665
10666 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10667 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
10668 WMITLV_SET_HDR(&cmd->tlv_header,
10669 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
10670 WMITLV_GET_STRUCT_TLVLEN
10671 (wmi_pdev_fips_cmd_fixed_param));
10672
10673 cmd->pdev_id = param->pdev_id;
10674 if (param->key != NULL && param->data != NULL) {
10675 cmd->key_len = param->key_len;
10676 cmd->data_len = param->data_len;
10677 cmd->fips_cmd = !!(param->op);
10678
10679 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
10680 return QDF_STATUS_E_FAILURE;
10681
10682 qdf_mem_copy(cmd->key, param->key, param->key_len);
10683
10684 if (param->mode == FIPS_ENGINE_AES_CTR ||
10685 param->mode == FIPS_ENGINE_AES_MIC) {
10686 cmd->mode = param->mode;
10687 } else {
10688 cmd->mode = FIPS_ENGINE_AES_CTR;
10689 }
10690 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
10691 cmd->key_len, cmd->data_len);
10692
10693 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
10694 cmd->key, cmd->key_len, true);
10695 buf_ptr += sizeof(*cmd);
10696
10697 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
10698
10699 buf_ptr += WMI_TLV_HDR_SIZE;
10700 if (param->data_len)
10701 qdf_mem_copy(buf_ptr,
10702 (uint8_t *) param->data, param->data_len);
10703
10704 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
10705 16, 1, buf_ptr, cmd->data_len, true);
10706
10707 buf_ptr += param->data_len;
10708
10709 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10710 WMI_PDEV_FIPS_CMDID);
10711 qdf_print("%s return value %d\n", __func__, retval);
10712 } else {
10713 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
10714 wmi_buf_free(buf);
10715 retval = -QDF_STATUS_E_BADMSG;
10716 }
10717
10718 return retval;
10719}
10720
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010721#ifdef WLAN_PMO_ENABLE
10722/**
10723 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
10724 * @wmi_handle: wmi handle
10725 * @vdev_id: vdev id
10726 * @bitmap: Event bitmap
10727 * @enable: enable/disable
10728 *
10729 * Return: CDF status
10730 */
10731static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
10732 uint32_t vdev_id,
10733 uint32_t bitmap,
10734 bool enable)
10735{
10736 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
10737 uint16_t len;
10738 wmi_buf_t buf;
10739 int ret;
10740
10741 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
10742 buf = wmi_buf_alloc(wmi_handle, len);
10743 if (!buf) {
10744 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10745 return QDF_STATUS_E_NOMEM;
10746 }
10747 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
10748 WMITLV_SET_HDR(&cmd->tlv_header,
10749 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
10750 WMITLV_GET_STRUCT_TLVLEN
10751 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
10752 cmd->vdev_id = vdev_id;
10753 cmd->is_add = enable;
10754 cmd->event_bitmap = bitmap;
10755
10756 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10757 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
10758 if (ret) {
10759 WMI_LOGE("Failed to config wow wakeup event");
10760 wmi_buf_free(buf);
10761 return QDF_STATUS_E_FAILURE;
10762 }
10763
10764 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
10765 enable ? "enabled" : "disabled");
10766
10767 return QDF_STATUS_SUCCESS;
10768}
10769
10770/**
10771 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
10772 * @wmi_handle: wmi handle
10773 * @vdev_id: vdev id
10774 * @ptrn_id: pattern id
10775 * @ptrn: pattern
10776 * @ptrn_len: pattern length
10777 * @ptrn_offset: pattern offset
10778 * @mask: mask
10779 * @mask_len: mask length
10780 * @user: true for user configured pattern and false for default pattern
10781 * @default_patterns: default patterns
10782 *
10783 * Return: CDF status
10784 */
10785static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
10786 uint8_t vdev_id, uint8_t ptrn_id,
10787 const uint8_t *ptrn, uint8_t ptrn_len,
10788 uint8_t ptrn_offset, const uint8_t *mask,
10789 uint8_t mask_len, bool user,
10790 uint8_t default_patterns)
10791{
10792 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
10793 WOW_BITMAP_PATTERN_T *bitmap_pattern;
10794 wmi_buf_t buf;
10795 uint8_t *buf_ptr;
10796 int32_t len;
10797 int ret;
10798
10799 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
10800 WMI_TLV_HDR_SIZE +
10801 1 * sizeof(WOW_BITMAP_PATTERN_T) +
10802 WMI_TLV_HDR_SIZE +
10803 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
10804 WMI_TLV_HDR_SIZE +
10805 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
10806 WMI_TLV_HDR_SIZE +
10807 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
10808 WMI_TLV_HDR_SIZE +
10809 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
10810
10811 buf = wmi_buf_alloc(wmi_handle, len);
10812 if (!buf) {
10813 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10814 return QDF_STATUS_E_NOMEM;
10815 }
10816
10817 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
10818 buf_ptr = (uint8_t *) cmd;
10819
10820 WMITLV_SET_HDR(&cmd->tlv_header,
10821 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
10822 WMITLV_GET_STRUCT_TLVLEN
10823 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
10824 cmd->vdev_id = vdev_id;
10825 cmd->pattern_id = ptrn_id;
10826
10827 cmd->pattern_type = WOW_BITMAP_PATTERN;
10828 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
10829
10830 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10831 sizeof(WOW_BITMAP_PATTERN_T));
10832 buf_ptr += WMI_TLV_HDR_SIZE;
10833 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
10834
10835 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
10836 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
10837 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
10838
10839 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
10840 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
10841
10842 bitmap_pattern->pattern_offset = ptrn_offset;
10843 bitmap_pattern->pattern_len = ptrn_len;
10844
10845 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
10846 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
10847
10848 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
10849 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
10850
10851 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
10852 bitmap_pattern->pattern_id = ptrn_id;
10853
10854 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
10855 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
10856 bitmap_pattern->pattern_offset, user);
10857 WMI_LOGI("Pattern : ");
10858 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
10859 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
10860
10861 WMI_LOGI("Mask : ");
10862 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
10863 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
10864
10865 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
10866
10867 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
10868 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
10869 buf_ptr += WMI_TLV_HDR_SIZE;
10870
10871 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
10872 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
10873 buf_ptr += WMI_TLV_HDR_SIZE;
10874
10875 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
10876 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
10877 buf_ptr += WMI_TLV_HDR_SIZE;
10878
10879 /* Fill TLV for pattern_info_timeout but no data. */
10880 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
10881 buf_ptr += WMI_TLV_HDR_SIZE;
10882
10883 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
10884 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
10885 buf_ptr += WMI_TLV_HDR_SIZE;
10886 *(A_UINT32 *) buf_ptr = 0;
10887
10888 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10889 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
10890 if (ret) {
10891 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
10892 wmi_buf_free(buf);
10893 return QDF_STATUS_E_FAILURE;
10894 }
10895
10896 return QDF_STATUS_SUCCESS;
10897}
10898
Govind Singha4836fd2016-03-07 16:45:38 +053010899/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010900 * fill_arp_offload_params_tlv() - Fill ARP offload data
10901 * @wmi_handle: wmi handle
10902 * @offload_req: offload request
10903 * @buf_ptr: buffer pointer
10904 *
10905 * To fill ARP offload data to firmware
10906 * when target goes to wow mode.
10907 *
10908 * Return: None
10909 */
10910static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010911 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010912{
10913
10914 int i;
10915 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010916 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010917
10918 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10919 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
10920 *buf_ptr += WMI_TLV_HDR_SIZE;
10921 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
10922 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
10923 WMITLV_SET_HDR(&arp_tuple->tlv_header,
10924 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
10925 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
10926
10927 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010928 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010929 /* Copy the target ip addr and flags */
10930 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
10931 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010932 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010933 WMI_IPV4_ADDR_LEN);
10934 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010935 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010936 }
10937 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
10938 }
10939}
10940
10941#ifdef WLAN_NS_OFFLOAD
10942/**
10943 * fill_ns_offload_params_tlv() - Fill NS offload data
10944 * @wmi|_handle: wmi handle
10945 * @offload_req: offload request
10946 * @buf_ptr: buffer pointer
10947 *
10948 * To fill NS offload data to firmware
10949 * when target goes to wow mode.
10950 *
10951 * Return: None
10952 */
10953static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010954 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010955{
10956
10957 int i;
10958 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010959
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010960 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10961 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10962 *buf_ptr += WMI_TLV_HDR_SIZE;
10963 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
10964 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10965 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10966 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10967 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
10968
10969 /*
10970 * Fill data only for NS offload in the first ARP tuple for LA
10971 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010972 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010973 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10974 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010975 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010976 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010977 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010978 sizeof(WMI_IPV6_ADDR));
10979 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010980 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010981 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010982 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010983 ns_tuple->flags |=
10984 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10985 }
10986 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010987 i, &ns_req->self_ipv6_addr[i],
10988 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010989
10990 /* target MAC is optional, check if it is valid,
10991 * if this is not valid, the target will use the known
10992 * local MAC address rather than the tuple
10993 */
10994 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010995 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010996 &ns_tuple->target_mac);
10997 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10998 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10999 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
11000 }
11001 }
11002 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
11003 }
11004}
11005
11006
11007/**
11008 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
11009 * @wmi: wmi handle
11010 * @offload_req: offload request
11011 * @buf_ptr: buffer pointer
11012 *
11013 * To fill extended NS offload extended data to firmware
11014 * when target goes to wow mode.
11015 *
11016 * Return: None
11017 */
11018static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011019 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011020{
11021 int i;
11022 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
11023 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011024
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011025 count = ns_req->num_ns_offload_count;
11026 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011027 WMI_MAX_NS_OFFLOADS;
11028
11029 /* Populate extended NS offload tuples */
11030 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11031 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
11032 *buf_ptr += WMI_TLV_HDR_SIZE;
11033 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
11034 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
11035 WMITLV_SET_HDR(&ns_tuple->tlv_header,
11036 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
11037 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
11038
11039 /*
11040 * Fill data only for NS offload in the first ARP tuple for LA
11041 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011042 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011043 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
11044 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011045 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011046 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011047 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011048 sizeof(WMI_IPV6_ADDR));
11049 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011050 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011051 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011052 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011053 ns_tuple->flags |=
11054 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
11055 }
11056 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011057 i, &ns_req->self_ipv6_addr[i],
11058 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011059
11060 /* target MAC is optional, check if it is valid,
11061 * if this is not valid, the target will use the
11062 * known local MAC address rather than the tuple
11063 */
11064 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011065 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011066 &ns_tuple->target_mac);
11067 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
11068 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
11069 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
11070 }
11071 }
11072 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
11073 }
11074}
11075#else
11076static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011077 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011078{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011079}
11080
11081static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011082 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011083{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011084}
11085#endif
11086
11087/**
Govind Singha4836fd2016-03-07 16:45:38 +053011088 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
11089 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011090 * @arp_offload_req: arp offload request
11091 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053011092 * @arp_only: flag
11093 *
11094 * To configure ARP NS off load data to firmware
11095 * when target goes to wow mode.
11096 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011097 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053011098 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011099static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011100 struct pmo_arp_offload_params *arp_offload_req,
11101 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053011102 uint8_t vdev_id)
11103{
Govind Singha4836fd2016-03-07 16:45:38 +053011104 int32_t res;
11105 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011106 A_UINT8 *buf_ptr;
11107 wmi_buf_t buf;
11108 int32_t len;
11109 uint32_t count = 0, num_ns_ext_tuples = 0;
11110
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011111 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053011112
Govind Singha4836fd2016-03-07 16:45:38 +053011113 /*
11114 * TLV place holder size for array of NS tuples
11115 * TLV place holder size for array of ARP tuples
11116 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011117 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
11118 WMI_TLV_HDR_SIZE +
11119 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
11120 WMI_TLV_HDR_SIZE +
11121 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053011122
11123 /*
11124 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
11125 * extra length for extended NS offload tuples which follows ARP offload
11126 * tuples. Host needs to fill this structure in following format:
11127 * 2 NS ofload tuples
11128 * 2 ARP offload tuples
11129 * N numbers of extended NS offload tuples if HDD has given more than
11130 * 2 NS offload addresses
11131 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011132 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053011133 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011134 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
11135 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053011136 }
11137
11138 buf = wmi_buf_alloc(wmi_handle, len);
11139 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011140 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053011141 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011142 }
11143
11144 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
11145 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
11146 WMITLV_SET_HDR(&cmd->tlv_header,
11147 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
11148 WMITLV_GET_STRUCT_TLVLEN
11149 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
11150 cmd->flags = 0;
11151 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011152 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053011153
Govind Singhb53420c2016-03-09 14:32:57 +053011154 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053011155
Govind Singha4836fd2016-03-07 16:45:38 +053011156 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011157 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
11158 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
11159 if (num_ns_ext_tuples)
11160 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053011161
11162 res = wmi_unified_cmd_send(wmi_handle, buf, len,
11163 WMI_SET_ARP_NS_OFFLOAD_CMDID);
11164 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053011165 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053011166 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011167 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011168 }
11169
Govind Singhb53420c2016-03-09 14:32:57 +053011170 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011171}
11172
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011173/**
11174 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
11175 * @wmi_handle: wmi handle
11176 * @vdev_id: vdev id
11177 * @action: true for enable else false
11178 *
11179 * To enable enhance multicast offload to firmware
11180 * when target goes to wow mode.
11181 *
11182 * Return: QDF Status
11183 */
11184
11185static
11186QDF_STATUS send_enable_enhance_multicast_offload_tlv(
11187 wmi_unified_t wmi_handle,
11188 uint8_t vdev_id, bool action)
11189{
11190 QDF_STATUS status;
11191 wmi_buf_t buf;
11192 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
11193
11194 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11195 if (!buf) {
11196 WMI_LOGE("Failed to allocate buffer to send set key cmd");
11197 return QDF_STATUS_E_NOMEM;
11198 }
11199
11200 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
11201 wmi_buf_data(buf);
11202
11203 WMITLV_SET_HDR(&cmd->tlv_header,
11204 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
11205 WMITLV_GET_STRUCT_TLVLEN(
11206 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
11207
11208 cmd->vdev_id = vdev_id;
11209 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
11210 ENHANCED_MCAST_FILTER_ENABLED);
11211 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
11212 __func__, action, vdev_id);
11213 status = wmi_unified_cmd_send(wmi_handle, buf,
11214 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
11215 if (status != QDF_STATUS_SUCCESS) {
11216 qdf_nbuf_free(buf);
11217 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
11218 __func__);
11219 }
11220
11221 return status;
11222}
11223
11224/**
11225 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
11226 * @wmi_handle: wmi handle
11227 * @param evt_buf: pointer to event buffer
11228 * @param hdr: Pointer to hold header
11229 * @param bufp: Pointer to hold pointer to rx param buffer
11230 *
11231 * Return: QDF_STATUS_SUCCESS for success or error code
11232 */
11233static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
11234 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
11235{
11236 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
11237 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
11238
11239 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
11240 if (!param_buf) {
11241 WMI_LOGE("gtk param_buf is NULL");
11242 return QDF_STATUS_E_INVAL;
11243 }
11244
11245 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
11246 WMI_LOGE("Invalid length for GTK status");
11247 return QDF_STATUS_E_INVAL;
11248 }
11249
11250 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
11251 param_buf->fixed_param;
11252 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
11253 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
11254 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
11255 qdf_mem_copy(&gtk_rsp_param->replay_counter,
11256 &fixed_param->replay_counter,
11257 GTK_REPLAY_COUNTER_BYTES);
11258
11259 return QDF_STATUS_SUCCESS;
11260
11261}
11262
11263#ifdef FEATURE_WLAN_RA_FILTERING
11264/**
11265 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
11266 * @wmi_handle: wmi handle
11267 * @vdev_id: vdev id
11268 *
11269 * Return: CDF status
11270 */
11271static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
11272 uint8_t vdev_id, uint8_t default_pattern,
11273 uint16_t rate_limit_interval)
11274{
11275
11276 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
11277 wmi_buf_t buf;
11278 uint8_t *buf_ptr;
11279 int32_t len;
11280 int ret;
11281
11282 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
11283 WMI_TLV_HDR_SIZE +
11284 0 * sizeof(WOW_BITMAP_PATTERN_T) +
11285 WMI_TLV_HDR_SIZE +
11286 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
11287 WMI_TLV_HDR_SIZE +
11288 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
11289 WMI_TLV_HDR_SIZE +
11290 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
11291 WMI_TLV_HDR_SIZE +
11292 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
11293
11294 buf = wmi_buf_alloc(wmi_handle, len);
11295 if (!buf) {
11296 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
11297 return QDF_STATUS_E_NOMEM;
11298 }
11299
11300 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
11301 buf_ptr = (uint8_t *) cmd;
11302
11303 WMITLV_SET_HDR(&cmd->tlv_header,
11304 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
11305 WMITLV_GET_STRUCT_TLVLEN
11306 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
11307 cmd->vdev_id = vdev_id;
11308 cmd->pattern_id = default_pattern,
11309 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
11310 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
11311
11312 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
11313 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11314 buf_ptr += WMI_TLV_HDR_SIZE;
11315
11316 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
11317 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11318 buf_ptr += WMI_TLV_HDR_SIZE;
11319
11320 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
11321 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11322 buf_ptr += WMI_TLV_HDR_SIZE;
11323
11324 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
11325 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11326 buf_ptr += WMI_TLV_HDR_SIZE;
11327
11328 /* Fill TLV for pattern_info_timeout but no data. */
11329 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
11330 buf_ptr += WMI_TLV_HDR_SIZE;
11331
11332 /* Fill TLV for ra_ratelimit_interval. */
11333 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
11334 buf_ptr += WMI_TLV_HDR_SIZE;
11335
11336 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
11337
11338 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
11339 rate_limit_interval, vdev_id);
11340
11341 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11342 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
11343 if (ret) {
11344 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
11345 wmi_buf_free(buf);
11346 return QDF_STATUS_E_FAILURE;
11347 }
11348
11349 return QDF_STATUS_SUCCESS;
11350
11351}
11352#endif /* FEATURE_WLAN_RA_FILTERING */
11353
11354/**
11355 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
11356 * @wmi_handle: wmi handle
11357 * @vdev_id: vdev id
11358 * @multicastAddr: mcast address
11359 * @clearList: clear list flag
11360 *
11361 * Return: QDF_STATUS_SUCCESS for success or error code
11362 */
11363static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
11364 uint8_t vdev_id,
11365 struct qdf_mac_addr multicast_addr,
11366 bool clearList)
11367{
11368 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
11369 wmi_buf_t buf;
11370 int err;
11371
11372 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11373 if (!buf) {
11374 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
11375 return QDF_STATUS_E_NOMEM;
11376 }
11377
11378 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
11379 qdf_mem_zero(cmd, sizeof(*cmd));
11380
11381 WMITLV_SET_HDR(&cmd->tlv_header,
11382 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
11383 WMITLV_GET_STRUCT_TLVLEN
11384 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
11385 cmd->action =
11386 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
11387 cmd->vdev_id = vdev_id;
11388 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
11389
11390 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
11391 cmd->action, vdev_id, clearList, multicast_addr.bytes);
11392
11393 err = wmi_unified_cmd_send(wmi_handle, buf,
11394 sizeof(*cmd),
11395 WMI_SET_MCASTBCAST_FILTER_CMDID);
11396 if (err) {
11397 WMI_LOGE("Failed to send set_param cmd");
11398 wmi_buf_free(buf);
11399 return QDF_STATUS_E_FAILURE;
11400 }
11401
11402 return QDF_STATUS_SUCCESS;
11403}
11404
11405/**
11406 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
11407 * @wmi_handle: wmi handle
11408 * @vdev_id: vdev id
11409 * @params: GTK offload parameters
11410 *
11411 * Return: CDF status
11412 */
11413static
11414QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
11415 struct pmo_gtk_req *params,
11416 bool enable_offload,
11417 uint32_t gtk_offload_opcode)
11418{
11419 int len;
11420 wmi_buf_t buf;
11421 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
11422 QDF_STATUS status = QDF_STATUS_SUCCESS;
11423
11424 WMI_LOGD("%s Enter", __func__);
11425
11426 len = sizeof(*cmd);
11427
11428 /* alloc wmi buffer */
11429 buf = wmi_buf_alloc(wmi_handle, len);
11430 if (!buf) {
11431 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
11432 status = QDF_STATUS_E_NOMEM;
11433 goto out;
11434 }
11435
11436 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
11437 WMITLV_SET_HDR(&cmd->tlv_header,
11438 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
11439 WMITLV_GET_STRUCT_TLVLEN
11440 (WMI_GTK_OFFLOAD_CMD_fixed_param));
11441
11442 cmd->vdev_id = vdev_id;
11443
11444 /* Request target to enable GTK offload */
11445 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
11446 cmd->flags = gtk_offload_opcode;
11447
11448 /* Copy the keys and replay counter */
11449 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
11450 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
11451 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
11452 GTK_REPLAY_COUNTER_BYTES);
11453 } else {
11454 cmd->flags = gtk_offload_opcode;
11455 }
11456
11457 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
11458
11459 /* send the wmi command */
11460 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11461 WMI_GTK_OFFLOAD_CMDID)) {
11462 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
11463 wmi_buf_free(buf);
11464 status = QDF_STATUS_E_FAILURE;
11465 }
11466
11467out:
11468 WMI_LOGD("%s Exit", __func__);
11469 return status;
11470}
11471
11472/**
11473 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
11474 * @wmi_handle: wmi handle
11475 * @params: GTK offload params
11476 *
11477 * Return: CDF status
11478 */
11479static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
11480 wmi_unified_t wmi_handle,
11481 uint8_t vdev_id,
11482 uint64_t offload_req_opcode)
11483{
11484 int len;
11485 wmi_buf_t buf;
11486 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
11487 QDF_STATUS status = QDF_STATUS_SUCCESS;
11488
11489 len = sizeof(*cmd);
11490
11491 /* alloc wmi buffer */
11492 buf = wmi_buf_alloc(wmi_handle, len);
11493 if (!buf) {
11494 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
11495 status = QDF_STATUS_E_NOMEM;
11496 goto out;
11497 }
11498
11499 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
11500 WMITLV_SET_HDR(&cmd->tlv_header,
11501 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
11502 WMITLV_GET_STRUCT_TLVLEN
11503 (WMI_GTK_OFFLOAD_CMD_fixed_param));
11504
11505 /* Request for GTK offload status */
11506 cmd->flags = offload_req_opcode;
11507 cmd->vdev_id = vdev_id;
11508
11509 /* send the wmi command */
11510 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11511 WMI_GTK_OFFLOAD_CMDID)) {
11512 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
11513 wmi_buf_free(buf);
11514 status = QDF_STATUS_E_FAILURE;
11515 }
11516
11517out:
11518 return status;
11519}
11520
11521/**
11522 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
11523 * @wmi_handle: wmi handler
11524 * @action_params: pointer to action_params
11525 *
11526 * Return: 0 for success, otherwise appropriate error code
11527 */
11528static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
11529 struct pmo_action_wakeup_set_params *action_params)
11530{
11531 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
11532 wmi_buf_t buf;
11533 int i;
11534 int32_t err;
11535
11536 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11537 if (!buf) {
11538 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
11539 return QDF_STATUS_E_NOMEM;
11540 }
11541 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
11542 WMITLV_SET_HDR(&cmd->tlv_header,
11543 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
11544 WMITLV_GET_STRUCT_TLVLEN(
11545 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
11546
11547 cmd->vdev_id = action_params->vdev_id;
11548 cmd->operation = action_params->operation;
11549
11550 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
11551 cmd->action_category_map[i] =
11552 action_params->action_category_map[i];
11553
11554 err = wmi_unified_cmd_send(wmi_handle, buf,
11555 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
11556 if (err) {
11557 WMI_LOGE("Failed to send ap_ps_egap cmd");
11558 wmi_buf_free(buf);
11559 return QDF_STATUS_E_FAILURE;
11560 }
11561
11562 return QDF_STATUS_SUCCESS;
11563}
11564
11565#ifdef FEATURE_WLAN_LPHB
11566
11567/**
11568 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
11569 * @wmi_handle: wmi handle
11570 * @lphb_conf_req: configuration info
11571 *
11572 * Return: CDF status
11573 */
11574static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
11575 wmi_hb_set_enable_cmd_fixed_param *params)
11576{
11577 QDF_STATUS status;
11578 wmi_buf_t buf = NULL;
11579 uint8_t *buf_ptr;
11580 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
11581 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
11582
11583
11584 buf = wmi_buf_alloc(wmi_handle, len);
11585 if (!buf) {
11586 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11587 return QDF_STATUS_E_NOMEM;
11588 }
11589
11590 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11591 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
11592 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
11593 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
11594 WMITLV_GET_STRUCT_TLVLEN
11595 (wmi_hb_set_enable_cmd_fixed_param));
11596
11597 /* fill in values */
11598 hb_enable_fp->vdev_id = params->session;
11599 hb_enable_fp->enable = params->enable;
11600 hb_enable_fp->item = params->item;
11601 hb_enable_fp->session = params->session;
11602
11603 status = wmi_unified_cmd_send(wmi_handle, buf,
11604 len, WMI_HB_SET_ENABLE_CMDID);
11605 if (QDF_IS_STATUS_ERROR(status)) {
11606 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
11607 status);
11608 wmi_buf_free(buf);
11609 }
11610
11611 return status;
11612}
11613
11614/**
11615 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
11616 * @wmi_handle: wmi handle
11617 * @lphb_conf_req: lphb config request
11618 *
11619 * Return: CDF status
11620 */
11621static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
11622 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
11623{
11624 QDF_STATUS status;
11625 wmi_buf_t buf = NULL;
11626 uint8_t *buf_ptr;
11627 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
11628 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
11629
11630 buf = wmi_buf_alloc(wmi_handle, len);
11631 if (!buf) {
11632 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11633 return QDF_STATUS_E_NOMEM;
11634 }
11635
11636 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11637 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
11638 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
11639 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
11640 WMITLV_GET_STRUCT_TLVLEN
11641 (wmi_hb_set_tcp_params_cmd_fixed_param));
11642
11643 /* fill in values */
11644 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
11645 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
11646 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
11647 hb_tcp_params_fp->seq = lphb_conf_req->seq;
11648 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
11649 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
11650 hb_tcp_params_fp->interval = lphb_conf_req->interval;
11651 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
11652 hb_tcp_params_fp->session = lphb_conf_req->session;
11653 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
11654 &lphb_conf_req->gateway_mac,
11655 sizeof(hb_tcp_params_fp->gateway_mac));
11656
11657 status = wmi_unified_cmd_send(wmi_handle, buf,
11658 len, WMI_HB_SET_TCP_PARAMS_CMDID);
11659 if (QDF_IS_STATUS_ERROR(status)) {
11660 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
11661 status);
11662 wmi_buf_free(buf);
11663 }
11664
11665 return status;
11666}
11667
11668/**
11669 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
11670 * @wmi_handle: wmi handle
11671 * @lphb_conf_req: lphb config request
11672 *
11673 * Return: CDF status
11674 */
11675static
11676QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
11677 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
11678{
11679 QDF_STATUS status;
11680 wmi_buf_t buf = NULL;
11681 uint8_t *buf_ptr;
11682 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
11683 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
11684
11685 buf = wmi_buf_alloc(wmi_handle, len);
11686 if (!buf) {
11687 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11688 return QDF_STATUS_E_NOMEM;
11689 }
11690
11691 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11692 hb_tcp_filter_fp =
11693 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
11694 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
11695 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
11696 WMITLV_GET_STRUCT_TLVLEN
11697 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
11698
11699 /* fill in values */
11700 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
11701 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
11702 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
11703 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
11704 memcpy((void *)&hb_tcp_filter_fp->filter,
11705 (void *)&g_hb_tcp_filter_fp->filter,
11706 WMI_WLAN_HB_MAX_FILTER_SIZE);
11707
11708 status = wmi_unified_cmd_send(wmi_handle, buf,
11709 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
11710 if (QDF_IS_STATUS_ERROR(status)) {
11711 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
11712 status);
11713 wmi_buf_free(buf);
11714 }
11715
11716 return status;
11717}
11718
11719/**
11720 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
11721 * @wmi_handle: wmi handle
11722 * @lphb_conf_req: lphb config request
11723 *
11724 * Return: CDF status
11725 */
11726static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
11727 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
11728{
11729 QDF_STATUS status;
11730 wmi_buf_t buf = NULL;
11731 uint8_t *buf_ptr;
11732 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
11733 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
11734
11735 buf = wmi_buf_alloc(wmi_handle, len);
11736 if (!buf) {
11737 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11738 return QDF_STATUS_E_NOMEM;
11739 }
11740
11741 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11742 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
11743 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
11744 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
11745 WMITLV_GET_STRUCT_TLVLEN
11746 (wmi_hb_set_udp_params_cmd_fixed_param));
11747
11748 /* fill in values */
11749 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
11750 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
11751 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
11752 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
11753 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
11754 hb_udp_params_fp->interval = lphb_conf_req->interval;
11755 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
11756 hb_udp_params_fp->session = lphb_conf_req->session;
11757 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
11758 &lphb_conf_req->gateway_mac,
11759 sizeof(lphb_conf_req->gateway_mac));
11760
11761 status = wmi_unified_cmd_send(wmi_handle, buf,
11762 len, WMI_HB_SET_UDP_PARAMS_CMDID);
11763 if (QDF_IS_STATUS_ERROR(status)) {
11764 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
11765 status);
11766 wmi_buf_free(buf);
11767 }
11768
11769 return status;
11770}
11771
11772/**
11773 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
11774 * @wmi_handle: wmi handle
11775 * @lphb_conf_req: lphb config request
11776 *
11777 * Return: CDF status
11778 */
11779static
11780QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
11781 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
11782{
11783 QDF_STATUS status;
11784 wmi_buf_t buf = NULL;
11785 uint8_t *buf_ptr;
11786 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
11787 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
11788
11789 buf = wmi_buf_alloc(wmi_handle, len);
11790 if (!buf) {
11791 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11792 return QDF_STATUS_E_NOMEM;
11793 }
11794
11795 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11796 hb_udp_filter_fp =
11797 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
11798 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
11799 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
11800 WMITLV_GET_STRUCT_TLVLEN
11801 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
11802
11803 /* fill in values */
11804 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
11805 hb_udp_filter_fp->length = lphb_conf_req->length;
11806 hb_udp_filter_fp->offset = lphb_conf_req->offset;
11807 hb_udp_filter_fp->session = lphb_conf_req->session;
11808 memcpy((void *)&hb_udp_filter_fp->filter,
11809 (void *)&lphb_conf_req->filter,
11810 WMI_WLAN_HB_MAX_FILTER_SIZE);
11811
11812 status = wmi_unified_cmd_send(wmi_handle, buf,
11813 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
11814 if (QDF_IS_STATUS_ERROR(status)) {
11815 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
11816 status);
11817 wmi_buf_free(buf);
11818 }
11819
11820 return status;
11821}
11822#endif /* FEATURE_WLAN_LPHB */
11823#endif /* End of WLAN_PMO_ENABLE */
11824
Sathish Kumarfd347372017-02-13 12:29:09 +053011825static QDF_STATUS send_enable_broadcast_filter_cmd_tlv(wmi_unified_t wmi_handle,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053011826 uint8_t vdev_id, bool enable)
11827{
11828 int32_t res;
11829 wmi_hw_data_filter_cmd_fixed_param *cmd;
11830 A_UINT8 *buf_ptr;
11831 wmi_buf_t buf;
11832 int32_t len;
11833
11834 /*
11835 * TLV place holder size for array of ARP tuples
11836 */
11837 len = sizeof(wmi_hw_data_filter_cmd_fixed_param);
11838
11839 buf = wmi_buf_alloc(wmi_handle, len);
11840 if (!buf) {
11841 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11842 return QDF_STATUS_E_NOMEM;
11843 }
11844
11845 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
11846 cmd = (wmi_hw_data_filter_cmd_fixed_param *) buf_ptr;
11847 WMITLV_SET_HDR(&cmd->tlv_header,
11848 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
11849 WMITLV_GET_STRUCT_TLVLEN
11850 (wmi_hw_data_filter_cmd_fixed_param));
11851 cmd->vdev_id = vdev_id;
11852 cmd->enable = enable;
11853 cmd->hw_filter_bitmap = WMI_HW_DATA_FILTER_DROP_NON_ARP_BC;
11854
11855 WMI_LOGD("HW Broadcast Filter vdev_id: %d", cmd->vdev_id);
11856
11857 res = wmi_unified_cmd_send(wmi_handle, buf, len,
11858 WMI_HW_DATA_FILTER_CMDID);
11859 if (res) {
11860 WMI_LOGE("Failed to enable ARP NDP/NSffload");
11861 wmi_buf_free(buf);
11862 return QDF_STATUS_E_FAILURE;
11863 }
11864
11865 return QDF_STATUS_SUCCESS;
11866}
11867
Govind Singha4836fd2016-03-07 16:45:38 +053011868/**
11869 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
11870 * @wmi_handle: wmi handle
11871 * @request: SSID hotlist set request
11872 *
Govind Singhb53420c2016-03-09 14:32:57 +053011873 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053011874 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011875static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053011876send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
11877 struct ssid_hotlist_request_params *request)
11878{
11879 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
11880 wmi_buf_t wmi_buf;
11881 uint32_t len;
11882 uint32_t array_size;
11883 uint8_t *buf_ptr;
11884
11885 /* length of fixed portion */
11886 len = sizeof(*cmd);
11887
11888 /* length of variable portion */
11889 array_size =
11890 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
11891 len += WMI_TLV_HDR_SIZE + array_size;
11892
11893 wmi_buf = wmi_buf_alloc(wmi_handle, len);
11894 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011895 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11896 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011897 }
11898
11899 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
11900 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
11901 buf_ptr;
11902 WMITLV_SET_HDR
11903 (&cmd->tlv_header,
11904 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
11905 WMITLV_GET_STRUCT_TLVLEN
11906 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
11907
11908 cmd->request_id = request->request_id;
11909 cmd->requestor_id = 0;
11910 cmd->vdev_id = request->session_id;
11911 cmd->table_id = 0;
11912 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
11913 cmd->total_entries = request->ssid_count;
11914 cmd->num_entries_in_page = request->ssid_count;
11915 cmd->first_entry_index = 0;
11916
11917 buf_ptr += sizeof(*cmd);
11918 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
11919
11920 if (request->ssid_count) {
11921 wmi_extscan_hotlist_ssid_entry *entry;
11922 int i;
11923
11924 buf_ptr += WMI_TLV_HDR_SIZE;
11925 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
11926 for (i = 0; i < request->ssid_count; i++) {
11927 WMITLV_SET_HDR
11928 (entry,
11929 WMITLV_TAG_ARRAY_STRUC,
11930 WMITLV_GET_STRUCT_TLVLEN
11931 (wmi_extscan_hotlist_ssid_entry));
11932 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053011933 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053011934 request->ssids[i].ssid.mac_ssid,
11935 request->ssids[i].ssid.length);
11936 entry->band = request->ssids[i].band;
11937 entry->min_rssi = request->ssids[i].rssi_low;
11938 entry->max_rssi = request->ssids[i].rssi_high;
11939 entry++;
11940 }
11941 cmd->mode = WMI_EXTSCAN_MODE_START;
11942 } else {
11943 cmd->mode = WMI_EXTSCAN_MODE_STOP;
11944 }
11945
11946 if (wmi_unified_cmd_send
11947 (wmi_handle, wmi_buf, len,
11948 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011949 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053011950 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011951 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011952 }
11953
Govind Singhb53420c2016-03-09 14:32:57 +053011954 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011955}
11956
11957/**
11958 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
11959 * @wmi_handle: wmi handle
11960 * @vdev_id: vdev id
11961 *
11962 * This function sends roam synch complete event to fw.
11963 *
11964 * Return: CDF STATUS
11965 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011966static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011967 uint8_t vdev_id)
11968{
11969 wmi_roam_synch_complete_fixed_param *cmd;
11970 wmi_buf_t wmi_buf;
11971 uint8_t *buf_ptr;
11972 uint16_t len;
11973 len = sizeof(wmi_roam_synch_complete_fixed_param);
11974
11975 wmi_buf = wmi_buf_alloc(wmi_handle, len);
11976 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011977 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11978 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011979 }
11980 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
11981 buf_ptr = (uint8_t *) cmd;
11982 WMITLV_SET_HDR(&cmd->tlv_header,
11983 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
11984 WMITLV_GET_STRUCT_TLVLEN
11985 (wmi_roam_synch_complete_fixed_param));
11986 cmd->vdev_id = vdev_id;
11987 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
11988 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011989 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053011990 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011991 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011992 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011993 }
11994
Govind Singhb53420c2016-03-09 14:32:57 +053011995 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011996}
11997
11998/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053011999 * send_fw_test_cmd_tlv() - send fw test command to fw.
12000 * @wmi_handle: wmi handle
12001 * @wmi_fwtest: fw test command
12002 *
12003 * This function sends fw test command to fw.
12004 *
12005 * Return: CDF STATUS
12006 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012007static
Anurag Chouhan459e0152016-07-22 20:19:54 +053012008QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
12009 struct set_fwtest_params *wmi_fwtest)
12010{
12011 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12012 wmi_buf_t wmi_buf;
12013 uint16_t len;
12014
12015 len = sizeof(*cmd);
12016
12017 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12018 if (!wmi_buf) {
12019 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12020 return QDF_STATUS_E_NOMEM;
12021 }
12022
12023 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
12024 WMITLV_SET_HDR(&cmd->tlv_header,
12025 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12026 WMITLV_GET_STRUCT_TLVLEN(
12027 wmi_fwtest_set_param_cmd_fixed_param));
12028 cmd->param_id = wmi_fwtest->arg;
12029 cmd->param_value = wmi_fwtest->value;
12030
12031 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12032 WMI_FWTEST_CMDID)) {
12033 WMI_LOGP("%s: failed to send fw test command", __func__);
12034 qdf_nbuf_free(wmi_buf);
12035 return QDF_STATUS_E_FAILURE;
12036 }
12037
12038 return QDF_STATUS_SUCCESS;
12039}
12040
12041/**
Govind Singha4836fd2016-03-07 16:45:38 +053012042 * send_unit_test_cmd_tlv() - send unit test command to fw.
12043 * @wmi_handle: wmi handle
12044 * @wmi_utest: unit test command
12045 *
12046 * This function send unit test command to fw.
12047 *
12048 * Return: CDF STATUS
12049 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012050static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012051 struct wmi_unit_test_cmd *wmi_utest)
12052{
12053 wmi_unit_test_cmd_fixed_param *cmd;
12054 wmi_buf_t wmi_buf;
12055 uint8_t *buf_ptr;
12056 int i;
12057 uint16_t len, args_tlv_len;
12058 A_UINT32 *unit_test_cmd_args;
12059
12060 args_tlv_len =
12061 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
12062 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
12063
12064 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12065 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012066 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12067 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012068 }
12069
12070 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
12071 buf_ptr = (uint8_t *) cmd;
12072 WMITLV_SET_HDR(&cmd->tlv_header,
12073 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
12074 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
12075 cmd->vdev_id = wmi_utest->vdev_id;
12076 cmd->module_id = wmi_utest->module_id;
12077 cmd->num_args = wmi_utest->num_args;
12078 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
12079 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12080 (wmi_utest->num_args * sizeof(uint32_t)));
12081 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053012082 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053012083 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
12084 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053012085 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012086 }
12087 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12088 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012089 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012090 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012091 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012092 }
12093
Govind Singhb53420c2016-03-09 14:32:57 +053012094 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012095}
12096
12097/**
12098 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
12099 * @wmi_handle: wma handle
12100 * @roaminvoke: roam invoke command
12101 *
12102 * Send roam invoke command to fw for fastreassoc.
12103 *
12104 * Return: CDF STATUS
12105 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012106static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012107 struct wmi_roam_invoke_cmd *roaminvoke,
12108 uint32_t ch_hz)
12109{
12110 wmi_roam_invoke_cmd_fixed_param *cmd;
12111 wmi_buf_t wmi_buf;
12112 u_int8_t *buf_ptr;
12113 u_int16_t len, args_tlv_len;
12114 A_UINT32 *channel_list;
12115 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080012116 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053012117
12118 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080012119 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
12120 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
12121 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012122 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
12123 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12124 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012125 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12126 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012127 }
12128
12129 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
12130 buf_ptr = (u_int8_t *) cmd;
12131 WMITLV_SET_HDR(&cmd->tlv_header,
12132 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
12133 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
12134 cmd->vdev_id = roaminvoke->vdev_id;
12135 cmd->flags = 0;
Naveen Rawat77797922017-01-20 17:00:07 -080012136
12137 if (roaminvoke->frame_len)
12138 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
12139 else
12140 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
12141
Govind Singha4836fd2016-03-07 16:45:38 +053012142 cmd->roam_ap_sel_mode = 0;
12143 cmd->roam_delay = 0;
12144 cmd->num_chan = 1;
12145 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080012146 /* packing 1 beacon/probe_rsp frame with WMI cmd */
12147 cmd->num_buf = 1;
12148
Govind Singha4836fd2016-03-07 16:45:38 +053012149 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
12150 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12151 (sizeof(u_int32_t)));
12152 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
12153 *channel_list = ch_hz;
12154 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
12155 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
12156 (sizeof(wmi_mac_addr)));
12157 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
12158 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080012159
12160 /* move to next tlv i.e. bcn_prb_buf_list */
12161 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
12162
12163 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
12164 sizeof(wmi_tlv_buf_len_param));
12165
12166 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
12167 buf_len_tlv->buf_len = roaminvoke->frame_len;
12168
12169 /* move to next tlv i.e. bcn_prb_frm */
12170 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
12171 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
12172 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
12173
12174 /* copy frame after the header */
12175 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
12176 roaminvoke->frame_buf,
12177 roaminvoke->frame_len);
12178
12179 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
12180 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
12181 buf_ptr + WMI_TLV_HDR_SIZE,
12182 roaminvoke->frame_len);
12183
Govind Singha4836fd2016-03-07 16:45:38 +053012184 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12185 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012186 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053012187 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012188 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012189 }
12190
Govind Singhb53420c2016-03-09 14:32:57 +053012191 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012192}
12193
12194/**
12195 * send_roam_scan_offload_cmd_tlv() - set roam offload command
12196 * @wmi_handle: wmi handle
12197 * @command: command
12198 * @vdev_id: vdev id
12199 *
12200 * This function set roam offload command to fw.
12201 *
12202 * Return: CDF status
12203 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012204static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012205 uint32_t command, uint32_t vdev_id)
12206{
Govind Singh67922e82016-04-01 16:48:57 +053012207 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012208 wmi_roam_scan_cmd_fixed_param *cmd_fp;
12209 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053012210 int len;
12211 uint8_t *buf_ptr;
12212
12213 len = sizeof(wmi_roam_scan_cmd_fixed_param);
12214 buf = wmi_buf_alloc(wmi_handle, len);
12215 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012216 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12217 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012218 }
12219
12220 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12221
12222 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
12223 WMITLV_SET_HDR(&cmd_fp->tlv_header,
12224 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
12225 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
12226 cmd_fp->vdev_id = vdev_id;
12227 cmd_fp->command_arg = command;
12228
12229 status = wmi_unified_cmd_send(wmi_handle, buf,
12230 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053012231 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012232 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012233 status);
Govind Singha4836fd2016-03-07 16:45:38 +053012234 goto error;
12235 }
12236
Govind Singhb53420c2016-03-09 14:32:57 +053012237 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
12238 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012239
12240error:
12241 wmi_buf_free(buf);
12242
Govind Singh67922e82016-04-01 16:48:57 +053012243 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012244}
12245
12246/**
12247 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
12248 * @wmi_handle: wmi handle
12249 * @ap_profile_p: ap profile
12250 * @vdev_id: vdev id
12251 *
12252 * Send WMI_ROAM_AP_PROFILE to firmware
12253 *
12254 * Return: CDF status
12255 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012256static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012257 wmi_ap_profile *ap_profile_p,
12258 uint32_t vdev_id)
12259{
Govind Singha4836fd2016-03-07 16:45:38 +053012260 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012261 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012262 int len;
12263 uint8_t *buf_ptr;
12264 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
12265
12266 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
12267
12268 buf = wmi_buf_alloc(wmi_handle, len);
12269 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012270 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12271 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012272 }
12273
12274 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12275 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
12276 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
12277 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
12278 WMITLV_GET_STRUCT_TLVLEN
12279 (wmi_roam_ap_profile_fixed_param));
12280 /* fill in threshold values */
12281 roam_ap_profile_fp->vdev_id = vdev_id;
12282 roam_ap_profile_fp->id = 0;
12283 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
12284
Govind Singhb53420c2016-03-09 14:32:57 +053012285 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053012286 WMITLV_SET_HDR(buf_ptr,
12287 WMITLV_TAG_STRUC_wmi_ap_profile,
12288 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
12289 status = wmi_unified_cmd_send(wmi_handle, buf,
12290 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053012291 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012292 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012293 status);
Govind Singh67922e82016-04-01 16:48:57 +053012294 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012295 }
12296
Govind Singhb53420c2016-03-09 14:32:57 +053012297 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053012298
Govind Singh67922e82016-04-01 16:48:57 +053012299 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012300}
12301
12302/**
12303 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
12304 * @wmi_handle: wmi handle
12305 * @scan_period: scan period
12306 * @scan_age: scan age
12307 * @vdev_id: vdev id
12308 *
12309 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
12310 *
12311 * Return: CDF status
12312 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012313static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012314 uint32_t scan_period,
12315 uint32_t scan_age,
12316 uint32_t vdev_id)
12317{
Govind Singh67922e82016-04-01 16:48:57 +053012318 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012319 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053012320 int len;
12321 uint8_t *buf_ptr;
12322 wmi_roam_scan_period_fixed_param *scan_period_fp;
12323
12324 /* Send scan period values */
12325 len = sizeof(wmi_roam_scan_period_fixed_param);
12326 buf = wmi_buf_alloc(wmi_handle, len);
12327 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012328 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12329 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012330 }
12331
12332 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12333 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
12334 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
12335 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
12336 WMITLV_GET_STRUCT_TLVLEN
12337 (wmi_roam_scan_period_fixed_param));
12338 /* fill in scan period values */
12339 scan_period_fp->vdev_id = vdev_id;
12340 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
12341 scan_period_fp->roam_scan_age = scan_age;
12342
12343 status = wmi_unified_cmd_send(wmi_handle, buf,
12344 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053012345 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012346 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012347 status);
Govind Singha4836fd2016-03-07 16:45:38 +053012348 goto error;
12349 }
12350
Govind Singhb53420c2016-03-09 14:32:57 +053012351 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012352 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053012353 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012354error:
12355 wmi_buf_free(buf);
12356
Govind Singh67922e82016-04-01 16:48:57 +053012357 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012358}
12359
12360/**
12361 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
12362 * @wmi_handle: wmi handle
12363 * @chan_count: channel count
12364 * @chan_list: channel list
12365 * @list_type: list type
12366 * @vdev_id: vdev id
12367 *
12368 * Set roam offload channel list.
12369 *
12370 * Return: CDF status
12371 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012372static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012373 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070012374 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053012375 uint8_t list_type, uint32_t vdev_id)
12376{
Govind Singha4836fd2016-03-07 16:45:38 +053012377 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012378 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012379 int len, list_tlv_len;
12380 int i;
12381 uint8_t *buf_ptr;
12382 wmi_roam_chan_list_fixed_param *chan_list_fp;
12383 A_UINT32 *roam_chan_list_array;
12384
12385 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053012386 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053012387 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053012388 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053012389 }
12390 /* Channel list is a table of 2 TLV's */
12391 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
12392 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
12393 buf = wmi_buf_alloc(wmi_handle, len);
12394 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012395 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12396 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012397 }
12398
12399 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12400 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
12401 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
12402 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
12403 WMITLV_GET_STRUCT_TLVLEN
12404 (wmi_roam_chan_list_fixed_param));
12405 chan_list_fp->vdev_id = vdev_id;
12406 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053012407 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053012408 /* external app is controlling channel list */
12409 chan_list_fp->chan_list_type =
12410 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
12411 } else {
12412 /* umac supplied occupied channel list in LFR */
12413 chan_list_fp->chan_list_type =
12414 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
12415 }
12416
12417 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
12418 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12419 (chan_list_fp->num_chan * sizeof(uint32_t)));
12420 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053012421 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053012422 for (i = 0; ((i < chan_list_fp->num_chan) &&
12423 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
12424 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053012425 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012426 }
12427
12428 status = wmi_unified_cmd_send(wmi_handle, buf,
12429 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053012430 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012431 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012432 status);
Govind Singha4836fd2016-03-07 16:45:38 +053012433 goto error;
12434 }
12435
Govind Singhb53420c2016-03-09 14:32:57 +053012436 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
12437 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012438error:
12439 wmi_buf_free(buf);
12440
Govind Singh67922e82016-04-01 16:48:57 +053012441 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012442}
12443
12444/**
12445 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
12446 * @wmi_handle: wmi handle
12447 * @rssi_change_thresh: RSSI Change threshold
12448 * @bcn_rssi_weight: beacon RSSI weight
12449 * @vdev_id: vdev id
12450 *
12451 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
12452 *
12453 * Return: CDF status
12454 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012455static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012456 uint32_t vdev_id,
12457 int32_t rssi_change_thresh,
12458 uint32_t bcn_rssi_weight,
12459 uint32_t hirssi_delay_btw_scans)
12460{
Govind Singha4836fd2016-03-07 16:45:38 +053012461 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012462 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012463 int len;
12464 uint8_t *buf_ptr;
12465 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
12466
12467 /* Send rssi change parameters */
12468 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
12469 buf = wmi_buf_alloc(wmi_handle, len);
12470 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012471 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12472 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012473 }
12474
12475 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12476 rssi_change_fp =
12477 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
12478 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
12479 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
12480 WMITLV_GET_STRUCT_TLVLEN
12481 (wmi_roam_scan_rssi_change_threshold_fixed_param));
12482 /* fill in rssi change threshold (hysteresis) values */
12483 rssi_change_fp->vdev_id = vdev_id;
12484 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
12485 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
12486 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
12487
12488 status = wmi_unified_cmd_send(wmi_handle, buf,
12489 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053012490 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012491 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012492 status);
Govind Singha4836fd2016-03-07 16:45:38 +053012493 goto error;
12494 }
12495
Govind Singhb53420c2016-03-09 14:32:57 +053012496 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053012497 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053012498 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
12499 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012500error:
12501 wmi_buf_free(buf);
12502
Govind Singh67922e82016-04-01 16:48:57 +053012503 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012504}
12505
12506/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
12507 * @wmi_handle: wmi handle.
12508 * @cmd: size of command structure.
12509 * @per_entry_size: per entry size.
12510 *
12511 * This utility function calculates how many hotlist entries can
12512 * fit in one page.
12513 *
12514 * Return: number of entries
12515 */
12516static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
12517 size_t cmd_size,
12518 size_t per_entry_size)
12519{
12520 uint32_t avail_space = 0;
12521 int num_entries = 0;
12522 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
12523
12524 /* Calculate number of hotlist entries that can
12525 * be passed in wma message request.
12526 */
12527 avail_space = max_msg_len - cmd_size;
12528 num_entries = avail_space / per_entry_size;
12529 return num_entries;
12530}
12531
12532/**
12533 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
12534 * @wmi_handle: wmi handle
12535 * @photlist: hotlist command params
12536 * @buf_len: buffer length
12537 *
12538 * This function fills individual elements for hotlist request and
12539 * TLV for bssid entries
12540 *
12541 * Return: CDF Status.
12542 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012543static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012544 struct ext_scan_setbssi_hotlist_params *
12545 photlist, int *buf_len)
12546{
12547 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
12548 wmi_extscan_hotlist_entry *dest_hotlist;
12549 struct ap_threshold_params *src_ap = photlist->ap;
12550 wmi_buf_t buf;
12551 uint8_t *buf_ptr;
12552
12553 int j, index = 0;
12554 int cmd_len = 0;
12555 int num_entries;
12556 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080012557 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053012558 int len = sizeof(*cmd);
12559
12560 len += WMI_TLV_HDR_SIZE;
12561 cmd_len = len;
12562
12563 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
12564 cmd_len,
12565 sizeof(*dest_hotlist));
12566 /* setbssid hotlist expects the bssid list
12567 * to be non zero value
12568 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080012569 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080012570 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053012571 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012572 }
12573
12574 /* Split the hot list entry pages and send multiple command
12575 * requests if the buffer reaches the maximum request size
12576 */
12577 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053012578 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053012579 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
12580 buf = wmi_buf_alloc(wmi_handle, len);
12581 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012582 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
12583 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012584 }
12585 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12586 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
12587 buf_ptr;
12588 WMITLV_SET_HDR(&cmd->tlv_header,
12589 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
12590 WMITLV_GET_STRUCT_TLVLEN
12591 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
12592
12593 /* Multiple requests are sent until the num_entries_in_page
12594 * matches the total_entries
12595 */
12596 cmd->request_id = photlist->requestId;
12597 cmd->vdev_id = photlist->sessionId;
12598 cmd->total_entries = numap;
12599 cmd->mode = 1;
12600 cmd->num_entries_in_page = min_entries;
12601 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
12602 cmd->first_entry_index = index;
12603
Govind Singhb53420c2016-03-09 14:32:57 +053012604 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012605 __func__, cmd->vdev_id, cmd->total_entries,
12606 cmd->num_entries_in_page,
12607 cmd->lost_ap_scan_count);
12608
12609 buf_ptr += sizeof(*cmd);
12610 WMITLV_SET_HDR(buf_ptr,
12611 WMITLV_TAG_ARRAY_STRUC,
12612 min_entries * sizeof(wmi_extscan_hotlist_entry));
12613 dest_hotlist = (wmi_extscan_hotlist_entry *)
12614 (buf_ptr + WMI_TLV_HDR_SIZE);
12615
12616 /* Populate bssid, channel info and rssi
12617 * for the bssid's that are sent as hotlists.
12618 */
12619 for (j = 0; j < min_entries; j++) {
12620 WMITLV_SET_HDR(dest_hotlist,
12621 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
12622 WMITLV_GET_STRUCT_TLVLEN
12623 (wmi_extscan_hotlist_entry));
12624
12625 dest_hotlist->min_rssi = src_ap->low;
12626 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
12627 &dest_hotlist->bssid);
12628
Govind Singhb53420c2016-03-09 14:32:57 +053012629 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012630 __func__, dest_hotlist->channel,
12631 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053012632 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053012633 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
12634 __func__, dest_hotlist->bssid.mac_addr31to0,
12635 dest_hotlist->bssid.mac_addr47to32);
12636 dest_hotlist++;
12637 src_ap++;
12638 }
12639 buf_ptr += WMI_TLV_HDR_SIZE +
12640 (min_entries * sizeof(wmi_extscan_hotlist_entry));
12641
12642 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12643 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012644 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012645 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012646 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012647 }
12648 index = index + min_entries;
12649 num_entries = numap - min_entries;
12650 len = cmd_len;
12651 }
Govind Singhb53420c2016-03-09 14:32:57 +053012652 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012653}
12654
Govind Singhbca3b1b2016-05-02 17:59:24 +053012655/**
12656 * send_power_dbg_cmd_tlv() - send power debug commands
12657 * @wmi_handle: wmi handle
12658 * @param: wmi power debug parameter
12659 *
12660 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
12661 *
12662 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
12663 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012664static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
12665 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053012666{
12667 wmi_buf_t buf = NULL;
12668 QDF_STATUS status;
12669 int len, args_tlv_len;
12670 uint8_t *buf_ptr;
12671 uint8_t i;
12672 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
12673 uint32_t *cmd_args;
12674
12675 /* Prepare and send power debug cmd parameters */
12676 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
12677 len = sizeof(*cmd) + args_tlv_len;
12678 buf = wmi_buf_alloc(wmi_handle, len);
12679 if (!buf) {
12680 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12681 return QDF_STATUS_E_NOMEM;
12682 }
12683
12684 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12685 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
12686 WMITLV_SET_HDR(&cmd->tlv_header,
12687 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
12688 WMITLV_GET_STRUCT_TLVLEN
12689 (wmi_pdev_wal_power_debug_cmd_fixed_param));
12690
12691 cmd->pdev_id = param->pdev_id;
12692 cmd->module_id = param->module_id;
12693 cmd->num_args = param->num_args;
12694 buf_ptr += sizeof(*cmd);
12695 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12696 (param->num_args * sizeof(uint32_t)));
12697 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12698 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
12699 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
12700 cmd_args[i] = param->args[i];
12701 WMI_LOGI("%d,", param->args[i]);
12702 }
12703
12704 status = wmi_unified_cmd_send(wmi_handle, buf,
12705 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
12706 if (QDF_IS_STATUS_ERROR(status)) {
12707 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
12708 status);
12709 goto error;
12710 }
12711
12712 return QDF_STATUS_SUCCESS;
12713error:
12714 wmi_buf_free(buf);
12715
12716 return status;
12717}
12718
Kiran Venkatappa26117052016-12-23 19:58:54 +053012719/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
12720 * @buf_ptr: pointer to current position in init command buffer
12721 * @len: pointer to length. This will be updated with current lenght of cmd
12722 * @param: point host parameters for init command
12723 *
12724 * Return: Updated pointer of buf_ptr.
12725 */
12726static inline uint8_t *copy_hw_mode_in_init_cmd(uint8_t *buf_ptr,
12727 int *len, struct wmi_init_cmd_param *param)
12728{
12729 uint16_t idx;
12730
12731 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
12732 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
12733 wmi_pdev_band_to_mac *band_to_mac;
12734
12735 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
12736 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
12737 sizeof(wmi_resource_config) +
12738 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
12739 sizeof(wlan_host_memory_chunk)));
12740
12741 WMITLV_SET_HDR(&hw_mode->tlv_header,
12742 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12743 (WMITLV_GET_STRUCT_TLVLEN
12744 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
12745
12746 hw_mode->hw_mode_index = param->hw_mode_id;
12747 hw_mode->num_band_to_mac = param->num_band_to_mac;
12748
12749 buf_ptr = (uint8_t *) (hw_mode + 1);
12750 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
12751 WMI_TLV_HDR_SIZE);
12752 for (idx = 0; idx < param->num_band_to_mac; idx++) {
12753 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
12754 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
12755 WMITLV_GET_STRUCT_TLVLEN
12756 (wmi_pdev_band_to_mac));
12757 band_to_mac[idx].pdev_id =
12758 param->band_to_mac[idx].pdev_id;
12759 band_to_mac[idx].start_freq =
12760 param->band_to_mac[idx].start_freq;
12761 band_to_mac[idx].end_freq =
12762 param->band_to_mac[idx].end_freq;
12763 }
12764 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12765 (param->num_band_to_mac *
12766 sizeof(wmi_pdev_band_to_mac)) +
12767 WMI_TLV_HDR_SIZE;
12768
12769 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12770 (param->num_band_to_mac *
12771 sizeof(wmi_pdev_band_to_mac)));
12772 }
12773
12774 return buf_ptr;
12775}
12776
Govind Singhe7f2f342016-05-23 12:12:52 +053012777/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053012778 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
12779 * @wmi_handle: wmi handle
12780 * @param: wmi multiple vdev restart req param
12781 *
12782 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
12783 *
12784 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
12785 */
12786static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
12787 wmi_unified_t wmi_handle,
12788 struct multiple_vdev_restart_params *param)
12789{
12790 wmi_buf_t buf;
12791 QDF_STATUS qdf_status;
12792 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
12793 int i;
12794 uint8_t *buf_ptr;
12795 uint32_t *vdev_ids;
12796 wmi_channel *chan_info;
12797 struct channel_param *tchan_info;
12798 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12799
12800 len += sizeof(wmi_channel);
12801 if (param->num_vdevs)
12802 len += sizeof(uint32_t) * param->num_vdevs;
12803
12804 buf = wmi_buf_alloc(wmi_handle, len);
12805 if (!buf) {
12806 WMI_LOGE("Failed to allocate memory\n");
12807 qdf_status = QDF_STATUS_E_NOMEM;
12808 goto end;
12809 }
12810
12811 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12812 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
12813 buf_ptr;
12814
12815 WMITLV_SET_HDR(&cmd->tlv_header,
12816 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
12817 WMITLV_GET_STRUCT_TLVLEN
12818 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
12819 cmd->pdev_id = param->pdev_id;
12820 cmd->requestor_id = param->requestor_id;
12821 cmd->disable_hw_ack = param->disable_hw_ack;
12822 cmd->cac_duration_ms = param->cac_duration_ms;
12823 cmd->num_vdevs = param->num_vdevs;
12824
12825 buf_ptr += sizeof(*cmd);
12826
12827 WMITLV_SET_HDR(buf_ptr,
12828 WMITLV_TAG_ARRAY_UINT32,
12829 sizeof(A_UINT32) * param->num_vdevs);
12830 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
12831 for (i = 0; i < param->num_vdevs; i++) {
12832 vdev_ids[i] = param->vdev_ids[i];
12833 }
12834
12835 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
12836
12837 WMITLV_SET_HDR(buf_ptr,
12838 WMITLV_TAG_STRUC_wmi_channel,
12839 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
12840 chan_info = (wmi_channel *)(buf_ptr + WMI_TLV_HDR_SIZE);
12841 tchan_info = &(param->ch_param);
12842 chan_info->mhz = tchan_info->mhz;
12843 chan_info->band_center_freq1 = tchan_info->cfreq1;
12844 chan_info->band_center_freq2 = tchan_info->cfreq2;
12845 if (tchan_info->is_chan_passive)
12846 WMI_SET_CHANNEL_FLAG(chan_info,
12847 WMI_CHAN_FLAG_PASSIVE);
12848 if (tchan_info->allow_vht)
12849 WMI_SET_CHANNEL_FLAG(chan_info,
12850 WMI_CHAN_FLAG_ALLOW_VHT);
12851 else if (tchan_info->allow_ht)
12852 WMI_SET_CHANNEL_FLAG(chan_info,
12853 WMI_CHAN_FLAG_ALLOW_HT);
12854 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
12855 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
12856 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
12857 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
12858 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
12859 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
12860
12861 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
12862 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
12863
12864 if (QDF_IS_STATUS_ERROR(qdf_status)) {
12865 WMI_LOGE("%s: Failed to send\n", __func__);
12866 wmi_buf_free(buf);
12867 }
12868
12869end:
12870 return qdf_status;
12871}
12872
12873/**
Govind Singhe7f2f342016-05-23 12:12:52 +053012874 * init_cmd_send_tlv() - send initialization cmd to fw
12875 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053012876 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053012877 *
12878 * Return: QDF_STATUS_SUCCESS for success or error code
12879 */
12880static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053012881 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053012882{
12883 wmi_buf_t buf;
12884 wmi_init_cmd_fixed_param *cmd;
12885 wmi_abi_version my_vers;
12886 int num_whitelist;
12887 uint8_t *buf_ptr;
12888 wmi_resource_config *resource_cfg;
12889 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053012890 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053012891 uint16_t idx;
12892 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053012893 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053012894
Kiran Venkatappa26117052016-12-23 19:58:54 +053012895 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
12896 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053012897 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053012898
12899 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
12900 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12901 WMI_TLV_HDR_SIZE +
12902 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
12903
12904 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053012905 if (!buf) {
12906 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
12907 return QDF_STATUS_E_FAILURE;
12908 }
12909
12910 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12911 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
12912 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
12913
12914 host_mem_chunks = (wlan_host_memory_chunk *)
12915 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
12916 + WMI_TLV_HDR_SIZE);
12917
12918 WMITLV_SET_HDR(&cmd->tlv_header,
12919 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
12920 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
12921
Kiran Venkatappa26117052016-12-23 19:58:54 +053012922 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053012923 WMITLV_SET_HDR(&resource_cfg->tlv_header,
12924 WMITLV_TAG_STRUC_wmi_resource_config,
12925 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
12926
Kiran Venkatappa26117052016-12-23 19:58:54 +053012927 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053012928 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
12929 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
12930 WMITLV_GET_STRUCT_TLVLEN
12931 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053012932 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
12933 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
12934 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053012935 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
12936 idx, host_mem_chunks[idx].size,
12937 host_mem_chunks[idx].ptr);
12938 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053012939 cmd->num_host_mem_chunks = param->num_mem_chunks;
12940 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
12941
Govind Singhe7f2f342016-05-23 12:12:52 +053012942 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
12943 WMITLV_TAG_ARRAY_STRUC,
12944 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053012945 param->num_mem_chunks));
12946
12947 /* Fill hw mode id config */
12948 buf_ptr = copy_hw_mode_in_init_cmd(buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053012949
12950 num_whitelist = sizeof(version_whitelist) /
12951 sizeof(wmi_whitelist_version_info);
12952 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12953 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12954 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12955 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12956 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12957 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
12958
Govind Singh87542482016-06-08 19:40:11 +053012959#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053012960 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12961 &my_vers,
12962 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
12963 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053012964#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053012965 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
12966 __func__,
12967 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
12968 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
12969 cmd->host_abi_vers.abi_version_ns_0,
12970 cmd->host_abi_vers.abi_version_ns_1,
12971 cmd->host_abi_vers.abi_version_ns_2,
12972 cmd->host_abi_vers.abi_version_ns_3);
12973
12974 /* Save version sent from host -
12975 * Will be used to check ready event
12976 */
Govind Singh87542482016-06-08 19:40:11 +053012977#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053012978 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
12979 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012980#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053012981 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
12982 if (QDF_IS_STATUS_ERROR(ret)) {
12983 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
12984 ret);
12985 wmi_buf_free(buf);
12986 }
12987 return ret;
12988
Govind Singhe7f2f342016-05-23 12:12:52 +053012989}
12990
12991/**
12992 * save_service_bitmap_tlv() - save service bitmap
12993 * @wmi_handle: wmi handle
12994 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080012995 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053012996 *
12997 * Return: None
12998 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053012999#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013000static
Rajeev Kumar77901472017-02-12 02:12:17 -080013001void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
13002 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053013003{
13004 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13005 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13006
13007 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
13008 param_buf->wmi_service_bitmap,
13009 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080013010
13011 if (bitmap_buf)
13012 qdf_mem_copy(bitmap_buf,
13013 param_buf->wmi_service_bitmap,
13014 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053013015}
13016#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013017static
Rajeev Kumar77901472017-02-12 02:12:17 -080013018void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
13019 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053013020{
Rajeev Kumar77901472017-02-12 02:12:17 -080013021 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13022 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053013023
Rajeev Kumar77901472017-02-12 02:12:17 -080013024 if (bitmap_buf)
13025 qdf_mem_copy(bitmap_buf,
13026 param_buf->wmi_service_bitmap,
13027 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
13028}
Govind Singhe7f2f342016-05-23 12:12:52 +053013029#endif
13030
13031/**
13032 * is_service_enabled_tlv() - Check if service enabled
13033 * @param wmi_handle: wmi handle
13034 * @param service_id: service identifier
13035 *
13036 * Return: 1 enabled, 0 disabled
13037 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013038#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013039static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
13040 uint32_t service_id)
13041{
13042 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
13043 service_id);
13044}
13045#else
13046static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
13047 uint32_t service_id)
13048{
13049 return false;
13050}
13051#endif
13052
13053/**
13054 * extract_service_ready_tlv() - extract service ready event
13055 * @wmi_handle: wmi handle
13056 * @param evt_buf: pointer to received event buffer
13057 * @param cap: pointer to hold target capability information extracted from even
13058 *
13059 * Return: QDF_STATUS_SUCCESS for success or error code
13060 */
13061static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080013062 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053013063{
13064 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13065 wmi_service_ready_event_fixed_param *ev;
13066
13067
13068 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13069
13070 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13071 if (!ev) {
13072 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13073 return QDF_STATUS_E_FAILURE;
13074 }
13075
13076 cap->phy_capability = ev->phy_capability;
13077 cap->max_frag_entry = ev->max_frag_entry;
13078 cap->num_rf_chains = ev->num_rf_chains;
13079 cap->ht_cap_info = ev->ht_cap_info;
13080 cap->vht_cap_info = ev->vht_cap_info;
13081 cap->vht_supp_mcs = ev->vht_supp_mcs;
13082 cap->hw_min_tx_power = ev->hw_min_tx_power;
13083 cap->hw_max_tx_power = ev->hw_max_tx_power;
13084 cap->sys_cap_info = ev->sys_cap_info;
13085 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
13086 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
13087 cap->max_num_scan_channels = ev->max_num_scan_channels;
13088 cap->max_supported_macs = ev->max_supported_macs;
13089 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
13090 cap->txrx_chainmask = ev->txrx_chainmask;
13091 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
13092 cap->num_msdu_desc = ev->num_msdu_desc;
13093
13094 return QDF_STATUS_SUCCESS;
13095}
13096
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053013097/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
13098 * to host internal WMI_HOST_REGDMN_MODE values.
13099 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
13100 * host currently. Add this in the future if required.
13101 * 11AX (Phase II) : 11ax related values are not currently
13102 * advertised separately by FW. As part of phase II regulatory bring-up,
13103 * finalize the advertisement mechanism.
13104 * @target_wireless_mode: target wireless mode received in message
13105 *
13106 * Return: returns the host internal wireless mode.
13107 */
13108static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
13109{
13110
13111 uint32_t wireless_modes = 0;
13112
13113 if (target_wireless_mode & REGDMN_MODE_11A)
13114 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
13115
13116 if (target_wireless_mode & REGDMN_MODE_TURBO)
13117 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
13118
13119 if (target_wireless_mode & REGDMN_MODE_11B)
13120 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
13121
13122 if (target_wireless_mode & REGDMN_MODE_PUREG)
13123 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
13124
13125 if (target_wireless_mode & REGDMN_MODE_11G)
13126 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
13127
13128 if (target_wireless_mode & REGDMN_MODE_108G)
13129 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
13130
13131 if (target_wireless_mode & REGDMN_MODE_108A)
13132 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
13133
13134 if (target_wireless_mode & REGDMN_MODE_XR)
13135 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
13136
13137 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
13138 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
13139
13140 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
13141 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
13142
13143 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
13144 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
13145
13146 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
13147 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
13148
13149 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
13150 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
13151
13152 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
13153 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
13154
13155 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
13156 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
13157
13158 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
13159 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
13160
13161 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
13162 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
13163
13164 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
13165 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
13166
13167 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
13168 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
13169
13170 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
13171 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
13172
13173 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
13174 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
13175
13176 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
13177 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
13178
13179 return wireless_modes;
13180}
13181
Govind Singhe7f2f342016-05-23 12:12:52 +053013182/**
13183 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
13184 * @wmi_handle: wmi handle
13185 * @param evt_buf: Pointer to event buffer
13186 * @param cap: pointer to hold HAL reg capabilities
13187 *
13188 * Return: QDF_STATUS_SUCCESS for success or error code
13189 */
13190static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080013191 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053013192{
13193 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13194
13195 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13196
13197 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
13198 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080013199 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053013200
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053013201 cap->wireless_modes = convert_wireless_modes_tlv(
13202 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053013203
Govind Singhe7f2f342016-05-23 12:12:52 +053013204 return QDF_STATUS_SUCCESS;
13205}
13206
13207/**
13208 * extract_host_mem_req_tlv() - Extract host memory request event
13209 * @wmi_handle: wmi handle
13210 * @param evt_buf: pointer to event buffer
13211 * @param num_entries: pointer to hold number of entries requested
13212 *
13213 * Return: Number of entries requested
13214 */
13215static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
13216 void *evt_buf, uint8_t *num_entries)
13217{
13218 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13219 wmi_service_ready_event_fixed_param *ev;
13220
13221 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13222
13223 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13224 if (!ev) {
13225 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13226 return NULL;
13227 }
13228
13229 *num_entries = ev->num_mem_reqs;
13230
13231 return (host_mem_req *)param_buf->mem_reqs;
13232}
13233
13234/**
13235 * save_fw_version_in_service_ready_tlv() - Save fw version in service
13236 * ready function
13237 * @wmi_handle: wmi handle
13238 * @param evt_buf: pointer to event buffer
13239 *
13240 * Return: QDF_STATUS_SUCCESS for success or error code
13241 */
13242static QDF_STATUS
13243save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
13244{
13245 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13246 wmi_service_ready_event_fixed_param *ev;
13247
13248
13249 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13250
13251 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13252 if (!ev) {
13253 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13254 return QDF_STATUS_E_FAILURE;
13255 }
13256
Govind Singh87542482016-06-08 19:40:11 +053013257#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013258 /*Save fw version from service ready message */
13259 /*This will be used while sending INIT message */
13260 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
13261 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053013262#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053013263 return QDF_STATUS_SUCCESS;
13264}
13265
13266/**
13267 * ready_extract_init_status_tlv() - Extract init status from ready event
13268 * @wmi_handle: wmi handle
13269 * @param evt_buf: Pointer to event buffer
13270 *
13271 * Return: ready status
13272 */
13273static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
13274 void *evt_buf)
13275{
13276 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13277 wmi_ready_event_fixed_param *ev = NULL;
13278
13279
13280 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13281 ev = param_buf->fixed_param;
13282
13283 qdf_print("%s:%d\n", __func__, ev->status);
13284
13285 return ev->status;
13286}
13287
13288/**
13289 * ready_extract_mac_addr_tlv() - extract mac address from ready event
13290 * @wmi_handle: wmi handle
13291 * @param evt_buf: pointer to event buffer
13292 * @param macaddr: Pointer to hold MAC address
13293 *
13294 * Return: QDF_STATUS_SUCCESS for success or error code
13295 */
13296static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
13297 void *evt_buf, uint8_t *macaddr)
13298{
13299 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13300 wmi_ready_event_fixed_param *ev = NULL;
13301
13302
13303 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13304 ev = param_buf->fixed_param;
13305
13306 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
13307
13308 return QDF_STATUS_SUCCESS;
13309}
13310
13311/**
13312 * extract_dbglog_data_len_tlv() - extract debuglog data length
13313 * @wmi_handle: wmi handle
13314 * @param evt_buf: pointer to event buffer
13315 *
13316 * Return: length
13317 */
13318static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080013319 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053013320{
13321 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
13322
13323 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
13324
13325 *len = param_buf->num_bufp;
13326
13327 return param_buf->bufp;
13328}
13329
13330/**
13331 * extract_vdev_start_resp_tlv() - extract vdev start response
13332 * @wmi_handle: wmi handle
13333 * @param evt_buf: pointer to event buffer
13334 * @param vdev_rsp: Pointer to hold vdev response
13335 *
13336 * Return: QDF_STATUS_SUCCESS for success or error code
13337 */
13338static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
13339 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
13340{
13341 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
13342 wmi_vdev_start_response_event_fixed_param *ev;
13343
13344 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
13345 if (!param_buf) {
13346 qdf_print("Invalid start response event buffer\n");
13347 return QDF_STATUS_E_INVAL;
13348 }
13349
13350 ev = param_buf->fixed_param;
13351 if (!ev) {
13352 qdf_print("Invalid start response event buffer\n");
13353 return QDF_STATUS_E_INVAL;
13354 }
13355
13356 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
13357
13358 vdev_rsp->vdev_id = ev->vdev_id;
13359 vdev_rsp->requestor_id = ev->requestor_id;
13360 vdev_rsp->resp_type = ev->resp_type;
13361 vdev_rsp->status = ev->status;
13362 vdev_rsp->chain_mask = ev->chain_mask;
13363 vdev_rsp->smps_mode = ev->smps_mode;
13364 vdev_rsp->mac_id = ev->mac_id;
13365 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
13366 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
13367
13368 return QDF_STATUS_SUCCESS;
13369}
13370
13371/**
13372 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
13373 * @wmi_handle: wmi handle
13374 * @param evt_buf: pointer to event buffer
13375 * @param vdev_map: Pointer to hold vdev map
13376 * @param tbttoffset_list: Pointer to tbtt offset list
13377 *
13378 * Return: QDF_STATUS_SUCCESS for success or error code
13379 */
13380static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
13381 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
13382{
13383 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
13384 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
13385
13386 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
13387 if (!param_buf) {
13388 qdf_print("Invalid tbtt update event buffer\n");
13389 return QDF_STATUS_E_INVAL;
13390 }
13391 tbtt_offset_event = param_buf->fixed_param;
13392
13393 *vdev_map = tbtt_offset_event->vdev_map;
13394 *tbttoffset_list = param_buf->tbttoffset_list;
13395
13396 return QDF_STATUS_SUCCESS;
13397}
13398
13399/**
13400 * extract_mgmt_rx_params_tlv() - extract management rx params from event
13401 * @wmi_handle: wmi handle
13402 * @param evt_buf: pointer to event buffer
13403 * @param hdr: Pointer to hold header
13404 * @param bufp: Pointer to hold pointer to rx param buffer
13405 *
13406 * Return: QDF_STATUS_SUCCESS for success or error code
13407 */
13408static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053013409 void *evt_buf, struct mgmt_rx_event_params *hdr,
13410 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053013411{
13412 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
13413 wmi_mgmt_rx_hdr *ev_hdr = NULL;
13414
13415 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
13416 if (!param_tlvs) {
13417 WMI_LOGE("Get NULL point message from FW");
13418 return QDF_STATUS_E_INVAL;
13419 }
13420
13421 ev_hdr = param_tlvs->hdr;
13422 if (!hdr) {
13423 WMI_LOGE("Rx event is NULL");
13424 return QDF_STATUS_E_INVAL;
13425 }
13426
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013427 hdr->pdev_id = ev_hdr->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053013428
13429 hdr->channel = ev_hdr->channel;
13430 hdr->snr = ev_hdr->snr;
13431 hdr->rate = ev_hdr->rate;
13432 hdr->phy_mode = ev_hdr->phy_mode;
13433 hdr->buf_len = ev_hdr->buf_len;
13434 hdr->status = ev_hdr->status;
13435 hdr->flags = ev_hdr->flags;
13436 hdr->rssi = ev_hdr->rssi;
13437 hdr->tsf_delta = ev_hdr->tsf_delta;
13438 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
13439
13440 *bufp = param_tlvs->bufp;
13441
13442 return QDF_STATUS_SUCCESS;
13443}
13444
13445/**
13446 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
13447 * @wmi_handle: wmi handle
13448 * @param evt_buf: pointer to event buffer
13449 * @param vdev_id: Pointer to hold vdev identifier
13450 *
13451 * Return: QDF_STATUS_SUCCESS for success or error code
13452 */
13453static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
13454 void *evt_buf, uint32_t *vdev_id)
13455{
13456 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
13457 wmi_vdev_stopped_event_fixed_param *resp_event;
13458
13459 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
13460 if (!param_buf) {
13461 WMI_LOGE("Invalid event buffer");
13462 return QDF_STATUS_E_INVAL;
13463 }
13464 resp_event = param_buf->fixed_param;
13465 *vdev_id = resp_event->vdev_id;
13466
13467 return QDF_STATUS_SUCCESS;
13468}
13469
13470/**
13471 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
13472 * @wmi_handle: wmi handle
13473 * @param evt_buf: pointer to event buffer
13474 * @param param: Pointer to hold roam param
13475 *
13476 * Return: QDF_STATUS_SUCCESS for success or error code
13477 */
13478static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
13479 void *evt_buf, wmi_host_roam_event *param)
13480{
13481 WMI_ROAM_EVENTID_param_tlvs *param_buf;
13482 wmi_roam_event_fixed_param *evt;
13483
13484 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
13485 if (!param_buf) {
13486 WMI_LOGE("Invalid roam event buffer");
13487 return QDF_STATUS_E_INVAL;
13488 }
13489
13490 evt = param_buf->fixed_param;
13491 qdf_mem_zero(param, sizeof(*param));
13492
13493 param->vdev_id = evt->vdev_id;
13494 param->reason = evt->reason;
13495 param->rssi = evt->rssi;
13496
13497 return QDF_STATUS_SUCCESS;
13498}
13499
13500/**
13501 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
13502 * @wmi_handle: wmi handle
13503 * @param evt_buf: pointer to event buffer
13504 * @param param: Pointer to hold vdev scan param
13505 *
13506 * Return: QDF_STATUS_SUCCESS for success or error code
13507 */
13508static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
13509 void *evt_buf, wmi_host_scan_event *param)
13510{
13511 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
13512 wmi_scan_event_fixed_param *evt = NULL;
13513
13514 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
13515 evt = param_buf->fixed_param;
13516
13517 qdf_mem_zero(param, sizeof(*param));
13518 switch (evt->event) {
13519 case WMI_SCAN_EVENT_STARTED:
13520 param->event = WMI_HOST_SCAN_EVENT_STARTED;
13521 break;
13522 case WMI_SCAN_EVENT_COMPLETED:
13523 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
13524 break;
13525 case WMI_SCAN_EVENT_BSS_CHANNEL:
13526 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
13527 break;
13528 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
13529 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
13530 break;
13531 case WMI_SCAN_EVENT_DEQUEUED:
13532 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
13533 break;
13534 case WMI_SCAN_EVENT_PREEMPTED:
13535 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
13536 break;
13537 case WMI_SCAN_EVENT_START_FAILED:
13538 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
13539 break;
13540 case WMI_SCAN_EVENT_RESTARTED:
13541 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
13542 break;
13543 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
13544 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
13545 break;
13546 case WMI_SCAN_EVENT_MAX:
13547 default:
13548 param->event = WMI_HOST_SCAN_EVENT_MAX;
13549 break;
13550 };
13551
13552 switch (evt->reason) {
13553 case WMI_SCAN_REASON_NONE:
13554 param->reason = WMI_HOST_SCAN_REASON_NONE;
13555 break;
13556 case WMI_SCAN_REASON_COMPLETED:
13557 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
13558 break;
13559 case WMI_SCAN_REASON_CANCELLED:
13560 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
13561 break;
13562 case WMI_SCAN_REASON_PREEMPTED:
13563 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
13564 break;
13565 case WMI_SCAN_REASON_TIMEDOUT:
13566 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
13567 break;
13568 case WMI_SCAN_REASON_INTERNAL_FAILURE:
13569 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
13570 break;
13571 case WMI_SCAN_REASON_MAX:
13572 default:
13573 param->reason = WMI_HOST_SCAN_REASON_MAX;
13574 break;
13575 };
13576
13577 param->channel_freq = evt->channel_freq;
13578 param->requestor = evt->requestor;
13579 param->scan_id = evt->scan_id;
13580 param->vdev_id = evt->vdev_id;
13581
13582 return QDF_STATUS_SUCCESS;
13583}
13584
13585/**
13586 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
13587 * @wmi_handle: wmi handle
13588 * @param evt_buf: pointer to event buffer
13589 * @param param: Pointer to hold MGMT TX completion params
13590 *
13591 * Return: QDF_STATUS_SUCCESS for success or error code
13592 */
13593static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
13594 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
13595{
13596 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
13597 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
13598
13599 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
13600 evt_buf;
13601 if (!param_buf) {
13602 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
13603 return QDF_STATUS_E_INVAL;
13604 }
13605 cmpl_params = param_buf->fixed_param;
13606
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013607 param->pdev_id = cmpl_params->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053013608 param->desc_id = cmpl_params->desc_id;
13609 param->status = cmpl_params->status;
13610
13611 return QDF_STATUS_SUCCESS;
13612}
13613
13614/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053013615 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
13616 * status tlv
13617 * @wmi_handle: wmi handle
13618 * @param evt_buf: pointer to event buffer
13619 * @param param: Pointer to hold csa switch count status event param
13620 *
13621 * Return: QDF_STATUS_SUCCESS for success or error code
13622 */
13623static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
13624 wmi_unified_t wmi_handle,
13625 void *evt_buf,
13626 struct pdev_csa_switch_count_status *param)
13627{
13628 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
13629 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
13630
13631 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
13632 evt_buf;
13633 if (!param_buf) {
13634 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
13635 return QDF_STATUS_E_INVAL;
13636 }
13637
13638 csa_status = param_buf->fixed_param;
13639
13640 param->pdev_id = csa_status->pdev_id;
13641 param->current_switch_count = csa_status->current_switch_count;
13642 param->num_vdevs = csa_status->num_vdevs;
13643 param->vdev_ids = param_buf->vdev_ids;
13644
13645 return QDF_STATUS_SUCCESS;
13646}
13647
13648/**
Govind Singhe7f2f342016-05-23 12:12:52 +053013649 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
13650 * @wmi_handle: wmi handle
13651 * @param evt_buf: pointer to event buffer
13652 * @param vdev_map: Pointer to hold vdev map
13653 *
13654 * Return: QDF_STATUS_SUCCESS for success or error code
13655 */
13656static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
13657 void *evt_buf, uint32_t *vdev_map)
13658{
13659 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
13660 wmi_host_swba_event_fixed_param *swba_event;
13661
13662 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
13663 if (!param_buf) {
13664 WMI_LOGE("Invalid swba event buffer");
13665 return QDF_STATUS_E_INVAL;
13666 }
13667 swba_event = param_buf->fixed_param;
13668 *vdev_map = swba_event->vdev_map;
13669
13670 return QDF_STATUS_SUCCESS;
13671}
13672
13673/**
13674 * extract_swba_tim_info_tlv() - extract swba tim info from event
13675 * @wmi_handle: wmi handle
13676 * @param evt_buf: pointer to event buffer
13677 * @param idx: Index to bcn info
13678 * @param tim_info: Pointer to hold tim info
13679 *
13680 * Return: QDF_STATUS_SUCCESS for success or error code
13681 */
13682static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
13683 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
13684{
13685 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
13686 wmi_tim_info *tim_info_ev;
13687
13688 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
13689 if (!param_buf) {
13690 WMI_LOGE("Invalid swba event buffer");
13691 return QDF_STATUS_E_INVAL;
13692 }
13693
13694 tim_info_ev = &param_buf->tim_info[idx];
13695
13696 tim_info->tim_len = tim_info_ev->tim_len;
13697 tim_info->tim_mcast = tim_info_ev->tim_mcast;
13698 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
13699 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
13700 tim_info->tim_changed = tim_info_ev->tim_changed;
13701 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
13702
13703 return QDF_STATUS_SUCCESS;
13704}
13705
13706/**
13707 * extract_swba_noa_info_tlv() - extract swba NoA information from event
13708 * @wmi_handle: wmi handle
13709 * @param evt_buf: pointer to event buffer
13710 * @param idx: Index to bcn info
13711 * @param p2p_desc: Pointer to hold p2p NoA info
13712 *
13713 * Return: QDF_STATUS_SUCCESS for success or error code
13714 */
13715static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
13716 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
13717{
13718 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
13719 wmi_p2p_noa_info *p2p_noa_info;
13720 uint8_t i = 0;
13721
13722 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
13723 if (!param_buf) {
13724 WMI_LOGE("Invalid swba event buffer");
13725 return QDF_STATUS_E_INVAL;
13726 }
13727
13728 p2p_noa_info = &param_buf->p2p_noa_info[idx];
13729
13730 p2p_desc->modified = false;
13731 p2p_desc->num_descriptors = 0;
13732 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
13733 p2p_desc->modified = true;
13734 p2p_desc->index =
13735 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
13736 p2p_desc->oppPS =
13737 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
13738 p2p_desc->ctwindow =
13739 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
13740 p2p_desc->num_descriptors =
13741 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
13742 (p2p_noa_info);
13743 for (i = 0; i < p2p_desc->num_descriptors; i++) {
13744 p2p_desc->noa_descriptors[i].type_count =
13745 (uint8_t) p2p_noa_info->noa_descriptors[i].
13746 type_count;
13747 p2p_desc->noa_descriptors[i].duration =
13748 p2p_noa_info->noa_descriptors[i].duration;
13749 p2p_desc->noa_descriptors[i].interval =
13750 p2p_noa_info->noa_descriptors[i].interval;
13751 p2p_desc->noa_descriptors[i].start_time =
13752 p2p_noa_info->noa_descriptors[i].start_time;
13753 }
13754 }
13755
13756 return QDF_STATUS_SUCCESS;
13757}
13758
13759/**
13760 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
13761 * @wmi_handle: wmi handle
13762 * @param evt_buf: pointer to event buffer
13763 * @param ev: Pointer to hold peer param
13764 *
13765 * Return: QDF_STATUS_SUCCESS for success or error code
13766 */
13767static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
13768 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
13769{
13770 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
13771 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
13772
13773 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
13774 kickout_event = param_buf->fixed_param;
13775
13776 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
13777 ev->peer_macaddr);
13778
13779 ev->reason = kickout_event->reason;
13780 ev->rssi = kickout_event->rssi;
13781
13782 return QDF_STATUS_SUCCESS;
13783}
13784
13785/**
13786 * extract_all_stats_counts_tlv() - extract all stats count from event
13787 * @wmi_handle: wmi handle
13788 * @param evt_buf: pointer to event buffer
13789 * @param stats_param: Pointer to hold stats count
13790 *
13791 * Return: QDF_STATUS_SUCCESS for success or error code
13792 */
13793static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
13794 void *evt_buf, wmi_host_stats_event *stats_param)
13795{
13796 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
13797 wmi_stats_event_fixed_param *ev;
13798
13799 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
13800
13801 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
13802 if (!ev) {
13803 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
13804 return QDF_STATUS_E_FAILURE;
13805 }
13806
13807 switch (ev->stats_id) {
13808 case WMI_REQUEST_PEER_STAT:
13809 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
13810 break;
13811
13812 case WMI_REQUEST_AP_STAT:
13813 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
13814 break;
13815
13816 case WMI_REQUEST_PDEV_STAT:
13817 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
13818 break;
13819
13820 case WMI_REQUEST_VDEV_STAT:
13821 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
13822 break;
13823
13824 case WMI_REQUEST_BCNFLT_STAT:
13825 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
13826 break;
13827
13828 case WMI_REQUEST_VDEV_RATE_STAT:
13829 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
13830 break;
13831
13832 default:
13833 stats_param->stats_id = 0;
13834 break;
13835
13836 }
13837
13838 stats_param->num_pdev_stats = ev->num_pdev_stats;
13839 stats_param->num_pdev_ext_stats = 0;
13840 stats_param->num_vdev_stats = ev->num_vdev_stats;
13841 stats_param->num_peer_stats = ev->num_peer_stats;
13842 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
13843 stats_param->num_chan_stats = ev->num_chan_stats;
13844
13845 return QDF_STATUS_SUCCESS;
13846}
13847
13848/**
13849 * extract_pdev_stats_tlv() - extract pdev stats from event
13850 * @wmi_handle: wmi handle
13851 * @param evt_buf: pointer to event buffer
13852 * @param index: Index into pdev stats
13853 * @param pdev_stats: Pointer to hold pdev stats
13854 *
13855 * Return: QDF_STATUS_SUCCESS for success or error code
13856 */
13857static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
13858 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
13859{
13860 return QDF_STATUS_SUCCESS;
13861}
13862
13863/**
13864 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
13865 * @wmi_handle: wmi handle
13866 * @param evt_buf: pointer to event buffer
13867 * @param index: Index into extended pdev stats
13868 * @param pdev_ext_stats: Pointer to hold extended pdev stats
13869 *
13870 * Return: QDF_STATUS_SUCCESS for success or error code
13871 */
13872static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
13873 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
13874{
13875 return QDF_STATUS_SUCCESS;
13876}
13877
13878/**
13879 * extract_vdev_stats_tlv() - extract vdev stats from event
13880 * @wmi_handle: wmi handle
13881 * @param evt_buf: pointer to event buffer
13882 * @param index: Index into vdev stats
13883 * @param vdev_stats: Pointer to hold vdev stats
13884 *
13885 * Return: QDF_STATUS_SUCCESS for success or error code
13886 */
13887static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
13888 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
13889{
13890 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
13891 wmi_stats_event_fixed_param *ev_param;
13892 uint8_t *data;
13893
13894 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
13895 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
13896 data = (uint8_t *) param_buf->data;
13897
13898 if (index < ev_param->num_vdev_stats) {
13899 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
13900 ((ev_param->num_pdev_stats) *
13901 sizeof(wmi_pdev_stats)) +
13902 (index * sizeof(wmi_vdev_stats)));
13903
13904 vdev_stats->vdev_id = ev->vdev_id;
13905 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
13906 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
13907
13908 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
13909 sizeof(ev->tx_frm_cnt));
13910 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
13911 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
13912 ev->multiple_retry_cnt,
13913 sizeof(ev->multiple_retry_cnt));
13914 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
13915 sizeof(ev->fail_cnt));
13916 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
13917 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
13918 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
13919 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
13920 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
13921 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
13922 sizeof(ev->tx_rate_history));
13923 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
13924 sizeof(ev->bcn_rssi_history));
13925
13926 }
13927
13928 return QDF_STATUS_SUCCESS;
13929}
13930
13931/**
13932 * extract_peer_stats_tlv() - extract peer stats from event
13933 * @wmi_handle: wmi handle
13934 * @param evt_buf: pointer to event buffer
13935 * @param index: Index into peer stats
13936 * @param peer_stats: Pointer to hold peer stats
13937 *
13938 * Return: QDF_STATUS_SUCCESS for success or error code
13939 */
13940static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
13941 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
13942{
13943 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
13944 wmi_stats_event_fixed_param *ev_param;
13945 uint8_t *data;
13946
13947 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
13948 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
13949 data = (uint8_t *) param_buf->data;
13950
13951 if (index < ev_param->num_peer_stats) {
13952 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
13953 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
13954 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
13955 (index * sizeof(wmi_peer_stats)));
13956
13957 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
13958
13959 OS_MEMCPY(&(peer_stats->peer_macaddr),
13960 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
13961
13962 peer_stats->peer_rssi = ev->peer_rssi;
13963 peer_stats->peer_tx_rate = ev->peer_tx_rate;
13964 peer_stats->peer_rx_rate = ev->peer_rx_rate;
13965 }
13966
13967 return QDF_STATUS_SUCCESS;
13968}
13969
13970/**
13971 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
13972 * @wmi_handle: wmi handle
13973 * @param evt_buf: pointer to event buffer
13974 * @param index: Index into bcn fault stats
13975 * @param bcnflt_stats: Pointer to hold bcn fault stats
13976 *
13977 * Return: QDF_STATUS_SUCCESS for success or error code
13978 */
13979static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
13980 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
13981{
13982 return QDF_STATUS_SUCCESS;
13983}
13984
13985/**
13986 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
13987 * @wmi_handle: wmi handle
13988 * @param evt_buf: pointer to event buffer
13989 * @param index: Index into extended peer stats
13990 * @param peer_extd_stats: Pointer to hold extended peer stats
13991 *
13992 * Return: QDF_STATUS_SUCCESS for success or error code
13993 */
13994static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
13995 void *evt_buf, uint32_t index,
13996 wmi_host_peer_extd_stats *peer_extd_stats)
13997{
13998 return QDF_STATUS_SUCCESS;
13999}
14000
14001/**
14002 * extract_chan_stats_tlv() - extract chan stats from event
14003 * @wmi_handle: wmi handle
14004 * @param evt_buf: pointer to event buffer
14005 * @param index: Index into chan stats
14006 * @param vdev_extd_stats: Pointer to hold chan stats
14007 *
14008 * Return: QDF_STATUS_SUCCESS for success or error code
14009 */
14010static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
14011 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
14012{
14013 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14014 wmi_stats_event_fixed_param *ev_param;
14015 uint8_t *data;
14016
14017 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14018 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14019 data = (uint8_t *) param_buf->data;
14020
14021 if (index < ev_param->num_chan_stats) {
14022 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
14023 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
14024 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
14025 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
14026 (index * sizeof(wmi_chan_stats)));
14027
14028
14029 /* Non-TLV doesnt have num_chan_stats */
14030 chan_stats->chan_mhz = ev->chan_mhz;
14031 chan_stats->sampling_period_us = ev->sampling_period_us;
14032 chan_stats->rx_clear_count = ev->rx_clear_count;
14033 chan_stats->tx_duration_us = ev->tx_duration_us;
14034 chan_stats->rx_duration_us = ev->rx_duration_us;
14035 }
14036
14037 return QDF_STATUS_SUCCESS;
14038}
14039
14040/**
14041 * extract_profile_ctx_tlv() - extract profile context from event
14042 * @wmi_handle: wmi handle
14043 * @param evt_buf: pointer to event buffer
14044 * @idx: profile stats index to extract
14045 * @param profile_ctx: Pointer to hold profile context
14046 *
14047 * Return: QDF_STATUS_SUCCESS for success or error code
14048 */
14049static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
14050 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
14051{
14052 return QDF_STATUS_SUCCESS;
14053}
14054
14055/**
14056 * extract_profile_data_tlv() - extract profile data from event
14057 * @wmi_handle: wmi handle
14058 * @param evt_buf: pointer to event buffer
14059 * @param profile_data: Pointer to hold profile data
14060 *
14061 * Return: QDF_STATUS_SUCCESS for success or error code
14062 */
14063static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
14064 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
14065{
14066
14067 return QDF_STATUS_SUCCESS;
14068}
14069
14070/**
14071 * extract_chan_info_event_tlv() - extract chan information from event
14072 * @wmi_handle: wmi handle
14073 * @param evt_buf: pointer to event buffer
14074 * @param chan_info: Pointer to hold chan information
14075 *
14076 * Return: QDF_STATUS_SUCCESS for success or error code
14077 */
14078static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
14079 void *evt_buf, wmi_host_chan_info_event *chan_info)
14080{
14081 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
14082 wmi_chan_info_event_fixed_param *ev;
14083
14084 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
14085
14086 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
14087 if (!ev) {
14088 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
14089 return QDF_STATUS_E_FAILURE;
14090 }
14091
14092 chan_info->err_code = ev->err_code;
14093 chan_info->freq = ev->freq;
14094 chan_info->cmd_flags = ev->cmd_flags;
14095 chan_info->noise_floor = ev->noise_floor;
14096 chan_info->rx_clear_count = ev->rx_clear_count;
14097 chan_info->cycle_count = ev->cycle_count;
14098
14099 return QDF_STATUS_SUCCESS;
14100}
14101
14102/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053014103 * extract_pdev_utf_event_tlv() - extract UTF data info from event
14104 * @wmi_handle: WMI handle
14105 * @param evt_buf: Pointer to event buffer
14106 * @param param: Pointer to hold data
14107 *
14108 * Return : QDF_STATUS_SUCCESS for success or error code
14109 */
14110static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
14111 uint8_t *evt_buf,
14112 struct wmi_host_pdev_utf_event *event)
14113{
14114 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
14115
14116 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
14117 event->data = param_buf->data;
14118 event->datalen = param_buf->num_data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053014119 /* Set pdev_id=1 until FW adds support to include pdev_id */
14120 event->pdev_id = 1;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053014121
14122 return QDF_STATUS_SUCCESS;
14123}
14124/**
Govind Singhe7f2f342016-05-23 12:12:52 +053014125 * extract_channel_hopping_event_tlv() - extract channel hopping param
14126 * from event
14127 * @wmi_handle: wmi handle
14128 * @param evt_buf: pointer to event buffer
14129 * @param ch_hopping: Pointer to hold channel hopping param
14130 *
14131 * Return: QDF_STATUS_SUCCESS for success or error code
14132 */
14133static QDF_STATUS extract_channel_hopping_event_tlv(wmi_unified_t wmi_handle,
14134 void *evt_buf, wmi_host_pdev_channel_hopping_event *chan_info)
14135{
14136 return QDF_STATUS_SUCCESS;
14137}
14138
Kiran Venkatappa06520822016-08-10 23:55:40 +053014139/**
14140 * extract_service_ready_ext_tlv() - extract basic extended service ready params
14141 * from event
14142 * @wmi_handle: wmi handle
14143 * @param evt_buf: pointer to event buffer
14144 * @param param: Pointer to hold evt buf
14145 *
14146 * Return: QDF_STATUS_SUCCESS for success or error code
14147 */
14148static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014149 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014150{
14151 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
14152 wmi_service_ready_ext_event_fixed_param *ev;
14153 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
14154 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
14155
14156 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14157 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014158 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014159
14160 ev = param_buf->fixed_param;
14161 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014162 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014163
14164 /* Move this to host based bitmap */
14165 param->default_conc_scan_config_bits =
14166 ev->default_conc_scan_config_bits;
14167 param->default_fw_config_bits = ev->default_fw_config_bits;
14168 param->he_cap_info = ev->he_cap_info;
14169 param->mpdu_density = ev->mpdu_density;
14170 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
14171 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
14172
14173 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014174 if (hw_caps)
14175 param->num_hw_modes = hw_caps->num_hw_modes;
14176 else
14177 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014178
14179 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014180 if (reg_caps)
14181 param->num_phy = reg_caps->num_phy;
14182 else
14183 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014184
14185 return QDF_STATUS_SUCCESS;
14186}
14187
14188/**
14189 * extract_hw_mode_cap_service_ready_ext_tlv() -
14190 * extract HW mode cap from service ready event
14191 * @wmi_handle: wmi handle
14192 * @param evt_buf: pointer to event buffer
14193 * @param param: Pointer to hold evt buf
14194 * @param hw_mode_idx: hw mode idx should be less than num_mode
14195 *
14196 * Return: QDF_STATUS_SUCCESS for success or error code
14197 */
14198static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
14199 wmi_unified_t wmi_handle,
14200 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014201 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014202{
14203 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
14204 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
14205
14206 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14207 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014208 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014209
14210 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014211 if (!hw_caps)
14212 return QDF_STATUS_E_INVAL;
14213
Kiran Venkatappa06520822016-08-10 23:55:40 +053014214 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014215 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014216
14217 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
14218 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
14219
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014220 param->hw_mode_config_type =
14221 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
14222
Kiran Venkatappa06520822016-08-10 23:55:40 +053014223 return QDF_STATUS_SUCCESS;
14224}
14225
14226/**
14227 * extract_mac_phy_cap_service_ready_ext_tlv() -
14228 * extract MAC phy cap from service ready event
14229 * @wmi_handle: wmi handle
14230 * @param evt_buf: pointer to event buffer
14231 * @param param: Pointer to hold evt buf
14232 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014233 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053014234 *
14235 * Return: QDF_STATUS_SUCCESS for success or error code
14236 */
14237static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
14238 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014239 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014240 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014241{
14242 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014243 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014244 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
14245 uint32_t phy_map;
14246 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014247
14248 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14249 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014250 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014251
14252 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014253 if (!hw_caps)
14254 return QDF_STATUS_E_INVAL;
14255
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014256 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
14257 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
14258 break;
14259
14260 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
14261 while (phy_map) {
14262 phy_map >>= 1;
14263 phy_idx++;
14264 }
14265 }
14266
14267 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014268 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014269
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014270 phy_idx += phy_id;
14271 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014272 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014273
14274 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053014275
14276 param->hw_mode_id = mac_phy_caps->hw_mode_id;
14277 param->pdev_id = mac_phy_caps->pdev_id;
14278 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014279 param->supports_11b =
14280 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
14281 param->supports_11g =
14282 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
14283 param->supports_11a =
14284 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
14285 param->supports_11n =
14286 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
14287 param->supports_11ac =
14288 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
14289 param->supports_11ax =
14290 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053014291
14292 param->supported_bands = mac_phy_caps->supported_bands;
14293 param->ampdu_density = mac_phy_caps->ampdu_density;
14294 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
14295 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
14296 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
14297 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
14298 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
14299 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
14300 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
14301 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
14302 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
14303 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
14304 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
14305 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
14306 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
14307 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
14308 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
14309 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080014310 qdf_mem_copy(&param->he_cap_phy_info_2G,
14311 &mac_phy_caps->he_cap_phy_info_2G,
14312 sizeof(param->he_cap_phy_info_2G));
14313 qdf_mem_copy(&param->he_cap_phy_info_5G,
14314 &mac_phy_caps->he_cap_phy_info_5G,
14315 sizeof(param->he_cap_phy_info_5G));
14316 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
14317 sizeof(param->he_ppet2G));
14318 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
14319 sizeof(param->he_ppet5G));
Kiran Venkatappa06520822016-08-10 23:55:40 +053014320
14321 return QDF_STATUS_SUCCESS;
14322}
14323
14324/**
14325 * extract_reg_cap_service_ready_ext_tlv() -
14326 * extract REG cap from service ready event
14327 * @wmi_handle: wmi handle
14328 * @param evt_buf: pointer to event buffer
14329 * @param param: Pointer to hold evt buf
14330 * @param phy_idx: phy idx should be less than num_mode
14331 *
14332 * Return: QDF_STATUS_SUCCESS for success or error code
14333 */
14334static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
14335 wmi_unified_t wmi_handle,
14336 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014337 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014338{
14339 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
14340 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
14341 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
14342
14343 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14344 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014345 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014346
14347 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014348 if (!reg_caps)
14349 return QDF_STATUS_E_INVAL;
14350
Kiran Venkatappa06520822016-08-10 23:55:40 +053014351 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014352 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014353
14354 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
14355
14356 param->phy_id = ext_reg_cap->phy_id;
14357 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
14358 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
14359 param->regcap1 = ext_reg_cap->regcap1;
14360 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053014361 param->wireless_modes = convert_wireless_modes_tlv(
14362 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053014363 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
14364 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
14365 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
14366 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
14367
14368 return QDF_STATUS_SUCCESS;
14369}
14370
Kiran Venkatappafea8a802016-12-29 18:09:32 +053014371/**
14372 * extract_dcs_interference_type_tlv() - extract dcs interference type
14373 * from event
14374 * @wmi_handle: wmi handle
14375 * @param evt_buf: pointer to event buffer
14376 * @param param: Pointer to hold dcs interference param
14377 *
14378 * Return: 0 for success or error code
14379 */
14380static QDF_STATUS extract_dcs_interference_type_tlv(
14381 wmi_unified_t wmi_handle,
14382 void *evt_buf, struct wmi_host_dcs_interference_param *param)
14383{
14384 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
14385
14386 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
14387 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014388 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053014389
14390 param->interference_type = param_buf->fixed_param->interference_type;
14391 param->pdev_id = param_buf->fixed_param->pdev_id;
14392
14393 return QDF_STATUS_SUCCESS;
14394}
14395
14396/*
14397 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
14398 * @wmi_handle: wmi handle
14399 * @param evt_buf: pointer to event buffer
14400 * @param cw_int: Pointer to hold cw interference
14401 *
14402 * Return: 0 for success or error code
14403 */
14404static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
14405 void *evt_buf,
14406 wmi_host_ath_dcs_cw_int *cw_int)
14407{
14408 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
14409 wlan_dcs_cw_int *ev;
14410
14411 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
14412 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014413 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053014414
14415 ev = param_buf->cw_int;
14416
14417 cw_int->channel = ev->channel;
14418
14419 return QDF_STATUS_SUCCESS;
14420}
14421
14422/**
14423 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
14424 * @wmi_handle: wmi handle
14425 * @param evt_buf: pointer to event buffer
14426 * @param wlan_stat: Pointer to hold wlan stats
14427 *
14428 * Return: 0 for success or error code
14429 */
14430static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
14431 void *evt_buf,
14432 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
14433{
14434 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
14435 wlan_dcs_im_tgt_stats_t *ev;
14436
14437 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
14438 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014439 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053014440
14441 ev = param_buf->wlan_stat;
14442 wlan_stat->reg_tsf32 = ev->reg_tsf32;
14443 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
14444 wlan_stat->tx_waste_time = ev->tx_waste_time;
14445 wlan_stat->rx_time = ev->rx_time;
14446 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
14447 wlan_stat->mib_stats.listen_time = ev->listen_time;
14448 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
14449 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
14450 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
14451 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
14452 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
14453 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
14454 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
14455 wlan_stat->chan_nf = ev->chan_nf;
14456 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
14457
14458 return QDF_STATUS_SUCCESS;
14459}
14460
Kiran Venkatappac813ec92016-12-29 22:07:14 +053014461#ifdef BIG_ENDIAN_HOST
14462/**
14463 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
14464 * @param data_len - data length
14465 * @param data - pointer to data
14466 *
14467 * Return: QDF_STATUS - success or error status
14468 */
14469static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
14470{
14471 uint8_t *data_aligned = NULL;
14472 int c;
14473 unsigned char *data_unaligned;
14474
14475 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
14476 FIPS_ALIGN));
14477 /* Assigning unaligned space to copy the data */
14478 /* Checking if kmalloc does succesful allocation */
14479 if (data_unaligned == NULL)
14480 return QDF_STATUS_E_FAILURE;
14481
14482 /* Checking if space is alligned */
14483 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
14484 /* align the data space */
14485 data_aligned =
14486 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
14487 } else {
14488 data_aligned = (u_int8_t *)data_unaligned;
14489 }
14490
14491 /* memset and copy content from data to data aligned */
14492 OS_MEMSET(data_aligned, 0, data_len);
14493 OS_MEMCPY(data_aligned, data, data_len);
14494 /* Endianness to LE */
14495 for (c = 0; c < data_len/4; c++) {
14496 *((u_int32_t *)data_aligned + c) =
14497 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
14498 }
14499
14500 /* Copy content to event->data */
14501 OS_MEMCPY(data, data_aligned, data_len);
14502
14503 /* clean up allocated space */
14504 qdf_mem_free(data_unaligned);
14505 data_aligned = NULL;
14506 data_unaligned = NULL;
14507
14508 /*************************************************************/
14509
14510 return QDF_STATUS_SUCCESS;
14511}
14512#else
14513/**
14514 * fips_conv_data_be() - DUMMY for LE platform
14515 *
14516 * Return: QDF_STATUS - success
14517 */
14518static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
14519{
14520 return QDF_STATUS_SUCCESS;
14521}
14522#endif
14523
14524/**
14525 * extract_fips_event_data_tlv() - extract fips event data
14526 * @wmi_handle: wmi handle
14527 * @param evt_buf: pointer to event buffer
14528 * @param param: pointer FIPS event params
14529 *
14530 * Return: 0 for success or error code
14531 */
14532static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
14533 void *evt_buf, struct wmi_host_fips_event_param *param)
14534{
14535 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
14536 wmi_pdev_fips_event_fixed_param *event;
14537
14538 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
14539 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
14540
14541 if (fips_conv_data_be(event->data_len, param_buf->data) !=
14542 QDF_STATUS_SUCCESS)
14543 return QDF_STATUS_E_FAILURE;
14544
14545 param->data = (uint32_t *)param_buf->data;
14546 param->data_len = event->data_len;
14547 param->error_status = event->error_status;
14548
14549 return QDF_STATUS_SUCCESS;
14550}
14551
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053014552/*
14553 * extract_peer_delete_response_event_tlv() - extract peer delete response event
14554 * @wmi_handle: wmi handle
14555 * @param evt_buf: pointer to event buffer
14556 * @param vdev_id: Pointer to hold vdev_id
14557 * @param mac_addr: Pointer to hold peer mac address
14558 *
14559 * Return: QDF_STATUS_SUCCESS for success or error code
14560 */
14561static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
14562 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
14563{
14564 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
14565 wmi_peer_delete_resp_event_fixed_param *ev;
14566
14567 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
14568
14569 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
14570 if (!ev) {
14571 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
14572 return QDF_STATUS_E_FAILURE;
14573 }
14574
14575 param->vdev_id = ev->vdev_id;
14576 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
14577 &param->mac_address.bytes[0]);
14578
14579 return QDF_STATUS_SUCCESS;
14580}
14581
Govind Singhecf03cd2016-05-12 12:45:51 +053014582static bool is_management_record_tlv(uint32_t cmd_id)
14583{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053014584 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053014585 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053014586
Govind Singhecf03cd2016-05-12 12:45:51 +053014587 return false;
14588}
14589
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053014590static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
14591{
14592 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
14593
14594 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
14595
14596 switch (set_cmd->param_id) {
14597 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
14598 case WMI_VDEV_PARAM_DTIM_POLICY:
14599 return HTC_TX_PACKET_TAG_AUTO_PM;
14600 default:
14601 break;
14602 }
14603
14604 return 0;
14605}
14606
14607static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
14608{
14609 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
14610
14611 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
14612
14613 switch (ps_cmd->param) {
14614 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
14615 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
14616 case WMI_STA_PS_ENABLE_QPOWER:
14617 return HTC_TX_PACKET_TAG_AUTO_PM;
14618 default:
14619 break;
14620 }
14621
14622 return 0;
14623}
14624
14625static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
14626 uint32_t cmd_id)
14627{
14628 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
14629 return 0;
14630
14631 switch (cmd_id) {
14632 case WMI_VDEV_SET_PARAM_CMDID:
14633 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
14634 case WMI_STA_POWERSAVE_PARAM_CMDID:
14635 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
14636 default:
14637 break;
14638 }
14639
14640 return 0;
14641}
14642
14643static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
14644{
14645 uint16_t tag = 0;
14646
14647 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
14648 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
14649 __func__);
14650 return tag;
14651 }
14652
14653 if (wmi_handle->tag_crash_inject)
14654 tag = HTC_TX_PACKET_TAG_AUTO_PM;
14655
14656 wmi_handle->tag_crash_inject = false;
14657 return tag;
14658}
14659
14660/**
14661 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
14662 * @wmi_handle: WMI handle
14663 * @buf: WMI buffer
14664 * @cmd_id: WMI command Id
14665 *
14666 * Return htc_tx_tag
14667 */
14668static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
14669 wmi_buf_t buf,
14670 uint32_t cmd_id)
14671{
14672 uint16_t htc_tx_tag = 0;
14673
14674 switch (cmd_id) {
14675 case WMI_WOW_ENABLE_CMDID:
14676 case WMI_PDEV_SUSPEND_CMDID:
14677 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
14678 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
14679 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
14680 case WMI_PDEV_RESUME_CMDID:
14681 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
14682 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
14683#ifdef FEATURE_WLAN_D0WOW
14684 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
14685#endif
14686 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
14687 break;
14688 case WMI_FORCE_FW_HANG_CMDID:
14689 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
14690 break;
14691 case WMI_VDEV_SET_PARAM_CMDID:
14692 case WMI_STA_POWERSAVE_PARAM_CMDID:
14693 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
14694 default:
14695 break;
14696 }
14697
14698 return htc_tx_tag;
14699}
14700
Govind Singh5eb51532016-03-09 11:34:12 +053014701struct wmi_ops tlv_ops = {
14702 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
14703 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
14704 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053014705 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
14706 .send_hidden_ssid_vdev_restart_cmd =
14707 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053014708 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
14709 .send_peer_param_cmd = send_peer_param_cmd_tlv,
14710 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053014711 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053014712 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053014713 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070014714 .send_peer_rx_reorder_queue_setup_cmd =
14715 send_peer_rx_reorder_queue_setup_cmd_tlv,
14716 .send_peer_rx_reorder_queue_remove_cmd =
14717 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053014718 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
14719 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
14720 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053014721 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
14722 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
14723 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
14724 .send_suspend_cmd = send_suspend_cmd_tlv,
14725 .send_resume_cmd = send_resume_cmd_tlv,
14726 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
14727 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
14728 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
14729 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
14730 .send_dbglog_cmd = send_dbglog_cmd_tlv,
14731 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
14732 .send_stats_request_cmd = send_stats_request_cmd_tlv,
14733 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
14734 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053014735#ifndef CONFIG_MCL
14736 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
14737#endif
Govind Singh5eb51532016-03-09 11:34:12 +053014738 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
14739 .send_scan_start_cmd = send_scan_start_cmd_tlv,
14740 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
14741 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053014742 .send_mgmt_cmd = send_mgmt_cmd_tlv,
14743 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
14744 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053014745 .send_set_sta_uapsd_auto_trig_cmd =
14746 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053014747 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
14748 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
14749 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
14750 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
14751 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053014752 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
14753 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
14754 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
14755 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
14756 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
14757 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
14758 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053014759 .send_ocb_start_timing_advert_cmd =
14760 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053014761 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
14762 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
14763 .send_set_mcc_channel_time_latency_cmd =
14764 send_set_mcc_channel_time_latency_cmd_tlv,
14765 .send_set_mcc_channel_time_quota_cmd =
14766 send_set_mcc_channel_time_quota_cmd_tlv,
14767 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
14768 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053014769 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053014770 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
14771 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
14772 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053014773 .send_probe_rsp_tmpl_send_cmd =
14774 send_probe_rsp_tmpl_send_cmd_tlv,
14775 .send_p2p_go_set_beacon_ie_cmd =
14776 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053014777 .send_setup_install_key_cmd =
14778 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053014779 .send_set_gateway_params_cmd =
14780 send_set_gateway_params_cmd_tlv,
14781 .send_set_rssi_monitoring_cmd =
14782 send_set_rssi_monitoring_cmd_tlv,
14783 .send_scan_probe_setoui_cmd =
14784 send_scan_probe_setoui_cmd_tlv,
14785 .send_reset_passpoint_network_list_cmd =
14786 send_reset_passpoint_network_list_cmd_tlv,
14787 .send_set_passpoint_network_list_cmd =
14788 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053014789 .send_roam_scan_offload_rssi_thresh_cmd =
14790 send_roam_scan_offload_rssi_thresh_cmd_tlv,
14791 .send_roam_scan_filter_cmd =
14792 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053014793 .send_set_epno_network_list_cmd =
14794 send_set_epno_network_list_cmd_tlv,
14795 .send_ipa_offload_control_cmd =
14796 send_ipa_offload_control_cmd_tlv,
14797 .send_extscan_get_capabilities_cmd =
14798 send_extscan_get_capabilities_cmd_tlv,
14799 .send_extscan_get_cached_results_cmd =
14800 send_extscan_get_cached_results_cmd_tlv,
14801 .send_extscan_stop_change_monitor_cmd =
14802 send_extscan_stop_change_monitor_cmd_tlv,
14803 .send_extscan_start_change_monitor_cmd =
14804 send_extscan_start_change_monitor_cmd_tlv,
14805 .send_extscan_stop_hotlist_monitor_cmd =
14806 send_extscan_stop_hotlist_monitor_cmd_tlv,
14807 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
14808 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
14809 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
14810 .send_plm_start_cmd = send_plm_start_cmd_tlv,
14811 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053014812#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053014813 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053014814#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053014815 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
14816 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
14817 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
14818 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
14819 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053014820 .send_snr_request_cmd = send_snr_request_cmd_tlv,
14821 .send_snr_cmd = send_snr_cmd_tlv,
14822 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014823#ifdef WLAN_PMO_ENABLE
14824 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
14825 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
14826 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
14827 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
14828 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
14829 .send_process_gtk_offload_getinfo_cmd =
14830 send_process_gtk_offload_getinfo_cmd_tlv,
14831 .send_enable_enhance_multicast_offload_cmd =
14832 send_enable_enhance_multicast_offload_tlv,
14833 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
14834#ifdef FEATURE_WLAN_RA_FILTERING
14835 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
14836#endif
14837 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053014838 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
14839 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014840 .send_lphb_config_tcp_pkt_filter_cmd =
14841 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053014842 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
14843 .send_lphb_config_udp_pkt_filter_cmd =
14844 send_lphb_config_udp_pkt_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014845#endif /* End of WLAN_PMO_ENABLE */
14846#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053014847 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
14848 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
14849 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053014850 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
14851 .send_process_update_edca_param_cmd =
14852 send_process_update_edca_param_cmd_tlv,
14853 .send_roam_scan_offload_mode_cmd =
14854 send_roam_scan_offload_mode_cmd_tlv,
14855 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
14856 .send_roam_scan_offload_ap_profile_cmd =
14857 send_roam_scan_offload_ap_profile_cmd_tlv,
14858#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053014859 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
14860 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053014861 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
14862 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
14863 .send_dfs_phyerr_filter_offload_en_cmd =
14864 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053014865 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
14866 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
14867 .send_del_ts_cmd = send_del_ts_cmd_tlv,
14868 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
14869 .send_add_ts_cmd = send_add_ts_cmd_tlv,
14870 .send_enable_disable_packet_filter_cmd =
14871 send_enable_disable_packet_filter_cmd_tlv,
14872 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053014873 .send_process_add_periodic_tx_ptrn_cmd =
14874 send_process_add_periodic_tx_ptrn_cmd_tlv,
14875 .send_process_del_periodic_tx_ptrn_cmd =
14876 send_process_del_periodic_tx_ptrn_cmd_tlv,
14877 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
14878 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
14879 .send_set_app_type2_params_in_fw_cmd =
14880 send_set_app_type2_params_in_fw_cmd_tlv,
14881 .send_set_auto_shutdown_timer_cmd =
14882 send_set_auto_shutdown_timer_cmd_tlv,
14883 .send_nan_req_cmd = send_nan_req_cmd_tlv,
14884 .send_process_dhcpserver_offload_cmd =
14885 send_process_dhcpserver_offload_cmd_tlv,
14886 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
14887 .send_process_ch_avoid_update_cmd =
14888 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053014889 .send_pdev_set_regdomain_cmd =
14890 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053014891 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
14892 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
14893 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
14894 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
14895 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
14896 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053014897#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053014898 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053014899#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053014900 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053014901 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053014902 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053014903 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053014904 .send_set_base_macaddr_indicate_cmd =
14905 send_set_base_macaddr_indicate_cmd_tlv,
14906 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
14907 .send_enable_specific_fw_logs_cmd =
14908 send_enable_specific_fw_logs_cmd_tlv,
14909 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053014910 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053014911 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053014912 .send_pdev_set_dual_mac_config_cmd =
14913 send_pdev_set_dual_mac_config_cmd_tlv,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014914 .send_enable_broadcast_filter_cmd =
14915 send_enable_broadcast_filter_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053014916 .send_app_type1_params_in_fw_cmd =
14917 send_app_type1_params_in_fw_cmd_tlv,
14918 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
14919 .send_process_roam_synch_complete_cmd =
14920 send_process_roam_synch_complete_cmd_tlv,
14921 .send_unit_test_cmd = send_unit_test_cmd_tlv,
14922 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
14923 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053014924 .send_roam_scan_offload_scan_period_cmd =
14925 send_roam_scan_offload_scan_period_cmd_tlv,
14926 .send_roam_scan_offload_chan_list_cmd =
14927 send_roam_scan_offload_chan_list_cmd_tlv,
14928 .send_roam_scan_offload_rssi_change_cmd =
14929 send_roam_scan_offload_rssi_change_cmd_tlv,
14930 .send_get_buf_extscan_hotlist_cmd =
14931 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053014932 .send_adapt_dwelltime_params_cmd =
14933 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053014934 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053014935 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
14936 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
14937 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
14938 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
14939 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
14940 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
14941 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
14942 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
14943 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053014944 .get_target_cap_from_service_ready = extract_service_ready_tlv,
14945 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
14946 .extract_host_mem_req = extract_host_mem_req_tlv,
14947 .save_service_bitmap = save_service_bitmap_tlv,
14948 .is_service_enabled = is_service_enabled_tlv,
14949 .save_fw_version = save_fw_version_in_service_ready_tlv,
14950 .ready_extract_init_status = ready_extract_init_status_tlv,
14951 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
14952 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
14953 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
14954 .extract_tbttoffset_update_params =
14955 extract_tbttoffset_update_params_tlv,
14956 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
14957 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
14958 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
14959 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
14960 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
14961 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
14962 .extract_swba_tim_info = extract_swba_tim_info_tlv,
14963 .extract_swba_noa_info = extract_swba_noa_info_tlv,
14964 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
14965 .extract_all_stats_count = extract_all_stats_counts_tlv,
14966 .extract_pdev_stats = extract_pdev_stats_tlv,
14967 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
14968 .extract_vdev_stats = extract_vdev_stats_tlv,
14969 .extract_peer_stats = extract_peer_stats_tlv,
14970 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
14971 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
14972 .extract_chan_stats = extract_chan_stats_tlv,
14973 .extract_profile_ctx = extract_profile_ctx_tlv,
14974 .extract_profile_data = extract_profile_data_tlv,
14975 .extract_chan_info_event = extract_chan_info_event_tlv,
14976 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053014977 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053014978 .send_encrypt_decrypt_send_cmd =
14979 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080014980 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053014981 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053014982 .send_multiple_vdev_restart_req_cmd =
14983 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053014984 .extract_service_ready_ext = extract_service_ready_ext_tlv,
14985 .extract_hw_mode_cap_service_ready_ext =
14986 extract_hw_mode_cap_service_ready_ext_tlv,
14987 .extract_mac_phy_cap_service_ready_ext =
14988 extract_mac_phy_cap_service_ready_ext_tlv,
14989 .extract_reg_cap_service_ready_ext =
14990 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053014991 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053014992 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053014993 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
14994 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
14995 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053014996 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014997 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053014998 .extract_peer_delete_response_event =
14999 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053015000 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053015001 .extract_pdev_csa_switch_count_status =
15002 extract_pdev_csa_switch_count_status_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053015003};
15004
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015005#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015006/**
15007 * populate_tlv_service() - populates wmi services
15008 *
15009 * @param wmi_service: Pointer to hold wmi_service
15010 * Return: None
15011 */
15012static void populate_tlv_service(uint32_t *wmi_service)
15013{
15014 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
15015 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
15016 wmi_service[wmi_service_roam_scan_offload] =
15017 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
15018 wmi_service[wmi_service_bcn_miss_offload] =
15019 WMI_SERVICE_BCN_MISS_OFFLOAD;
15020 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
15021 wmi_service[wmi_service_sta_advanced_pwrsave] =
15022 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
15023 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
15024 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
15025 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
15026 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
15027 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
15028 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
15029 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
15030 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
15031 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
15032 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
15033 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
15034 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
15035 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
15036 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
15037 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
15038 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
15039 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
15040 wmi_service[wmi_service_packet_power_save] =
15041 WMI_SERVICE_PACKET_POWER_SAVE;
15042 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
15043 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
15044 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
15045 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
15046 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
15047 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
15048 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
15049 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
15050 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
15051 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
15052 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
15053 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
15054 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
15055 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
15056 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
15057 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
15058 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
15059 wmi_service[wmi_service_mcc_bcn_interval_change] =
15060 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
15061 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
15062 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
15063 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
15064 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
15065 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
15066 wmi_service[wmi_service_lte_ant_share_support] =
15067 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
15068 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
15069 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
15070 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
15071 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
15072 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
15073 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
15074 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
15075 wmi_service[wmi_service_bcn_txrate_override] =
15076 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
15077 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
15078 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
15079 wmi_service[wmi_service_estimate_linkspeed] =
15080 WMI_SERVICE_ESTIMATE_LINKSPEED;
15081 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
15082 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
15083 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
15084 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
15085 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
15086 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
15087 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
15088 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
15089 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
15090 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
15091 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
15092 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
15093 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
15094 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
15095 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
15096 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
15097 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
15098 wmi_service[wmi_service_sap_auth_offload] =
15099 WMI_SERVICE_SAP_AUTH_OFFLOAD;
15100 wmi_service[wmi_service_dual_band_simultaneous_support] =
15101 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
15102 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
15103 wmi_service[wmi_service_ap_arpns_offload] =
15104 WMI_SERVICE_AP_ARPNS_OFFLOAD;
15105 wmi_service[wmi_service_per_band_chainmask_support] =
15106 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
15107 wmi_service[wmi_service_packet_filter_offload] =
15108 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
15109 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
15110 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
15111 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
15112 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015113 wmi_service[wmi_service_multiple_vdev_restart] =
15114 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
Govind Singhe7f2f342016-05-23 12:12:52 +053015115
15116 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
15117 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
15118 wmi_service[wmi_service_smart_antenna_sw_support] =
15119 WMI_SERVICE_UNAVAILABLE;
15120 wmi_service[wmi_service_smart_antenna_hw_support] =
15121 WMI_SERVICE_UNAVAILABLE;
15122 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
15123 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
15124 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
15125 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
15126 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
15127 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
15128 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
15129 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
15130 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
15131 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
15132 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
15133
15134 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
15135 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
15136 wmi_service[wmi_service_periodic_chan_stat_support] =
15137 WMI_SERVICE_UNAVAILABLE;
15138 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
15139 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
15140 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
Sathish Kumar699f6b52016-11-10 15:30:22 +053015141 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
Sathish Kumar58a9fb92017-01-19 14:57:37 +053015142 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053015143 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Govind Singhe7f2f342016-05-23 12:12:52 +053015144}
15145
15146/**
15147 * populate_tlv_event_id() - populates wmi event ids
15148 *
15149 * @param event_ids: Pointer to hold event ids
15150 * Return: None
15151 */
15152static void populate_tlv_events_id(uint32_t *event_ids)
15153{
15154 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
15155 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
15156 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
15157 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
15158 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
15159 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
15160 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
15161 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
15162 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
15163 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
15164 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
15165 event_ids[wmi_service_ready_ext_event_id] =
15166 WMI_SERVICE_READY_EXT_EVENTID;
15167 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
15168 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
15169 event_ids[wmi_vdev_install_key_complete_event_id] =
15170 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
15171 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
15172 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
15173
15174 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
15175 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
15176 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
15177 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
15178 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
15179 event_ids[wmi_peer_estimated_linkspeed_event_id] =
15180 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
15181 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053015182 event_ids[wmi_peer_delete_response_event_id] =
15183 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053015184 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
15185 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
15186 event_ids[wmi_tbttoffset_update_event_id] =
15187 WMI_TBTTOFFSET_UPDATE_EVENTID;
15188 event_ids[wmi_offload_bcn_tx_status_event_id] =
15189 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
15190 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
15191 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
15192 event_ids[wmi_mgmt_tx_completion_event_id] =
15193 WMI_MGMT_TX_COMPLETION_EVENTID;
15194
15195 event_ids[wmi_tx_delba_complete_event_id] =
15196 WMI_TX_DELBA_COMPLETE_EVENTID;
15197 event_ids[wmi_tx_addba_complete_event_id] =
15198 WMI_TX_ADDBA_COMPLETE_EVENTID;
15199 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
15200
15201 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
15202
15203 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
15204 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
15205
15206 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
15207
15208 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
15209
15210 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
15211
15212 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
15213 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
15214 event_ids[wmi_do_wow_disable_ack_event_id] =
15215 WMI_D0_WOW_DISABLE_ACK_EVENTID;
15216 event_ids[wmi_wow_initial_wakeup_event_id] =
15217 WMI_WOW_INITIAL_WAKEUP_EVENTID;
15218
15219 event_ids[wmi_rtt_meas_report_event_id] =
15220 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
15221 event_ids[wmi_tsf_meas_report_event_id] =
15222 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
15223 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
15224 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
15225 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
15226 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
15227 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
15228 event_ids[wmi_update_fw_mem_dump_event_id] =
15229 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
15230 event_ids[wmi_diag_event_id_log_supported_event_id] =
15231 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
15232 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
15233 event_ids[wmi_nlo_scan_complete_event_id] =
15234 WMI_NLO_SCAN_COMPLETE_EVENTID;
15235 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
15236 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
15237
15238 event_ids[wmi_gtk_offload_status_event_id] =
15239 WMI_GTK_OFFLOAD_STATUS_EVENTID;
15240 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
15241 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
15242 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
15243
15244 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
15245
15246 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
15247
15248 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
15249 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
15250 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
15251 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
15252 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
15253 event_ids[wmi_wlan_profile_data_event_id] =
15254 WMI_WLAN_PROFILE_DATA_EVENTID;
15255 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
15256 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
15257 event_ids[wmi_vdev_get_keepalive_event_id] =
15258 WMI_VDEV_GET_KEEPALIVE_EVENTID;
15259 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
15260
15261 event_ids[wmi_diag_container_event_id] =
15262 WMI_DIAG_DATA_CONTAINER_EVENTID;
15263
15264 event_ids[wmi_host_auto_shutdown_event_id] =
15265 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
15266
15267 event_ids[wmi_update_whal_mib_stats_event_id] =
15268 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
15269
15270 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
15271 event_ids[wmi_update_vdev_rate_stats_event_id] =
15272 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
15273
15274 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
15275
15276 /** Set OCB Sched Response, deprecated */
15277 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
15278
15279 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
15280 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
15281 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
15282
15283 /* GPIO Event */
15284 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
15285 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
15286
15287 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
15288 event_ids[wmi_rfkill_state_change_event_id] =
15289 WMI_RFKILL_STATE_CHANGE_EVENTID;
15290
15291 /* TDLS Event */
15292 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
15293
15294 event_ids[wmi_batch_scan_enabled_event_id] =
15295 WMI_BATCH_SCAN_ENABLED_EVENTID;
15296 event_ids[wmi_batch_scan_result_event_id] =
15297 WMI_BATCH_SCAN_RESULT_EVENTID;
15298 /* OEM Event */
15299 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
15300 event_ids[wmi_oem_meas_report_event_id] =
15301 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
15302 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
15303
15304 /* NAN Event */
15305 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
15306
15307 /* LPI Event */
15308 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
15309 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
15310 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
15311
15312 /* ExtScan events */
15313 event_ids[wmi_extscan_start_stop_event_id] =
15314 WMI_EXTSCAN_START_STOP_EVENTID;
15315 event_ids[wmi_extscan_operation_event_id] =
15316 WMI_EXTSCAN_OPERATION_EVENTID;
15317 event_ids[wmi_extscan_table_usage_event_id] =
15318 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
15319 event_ids[wmi_extscan_cached_results_event_id] =
15320 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
15321 event_ids[wmi_extscan_wlan_change_results_event_id] =
15322 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
15323 event_ids[wmi_extscan_hotlist_match_event_id] =
15324 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
15325 event_ids[wmi_extscan_capabilities_event_id] =
15326 WMI_EXTSCAN_CAPABILITIES_EVENTID;
15327 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
15328 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
15329
15330 /* mDNS offload events */
15331 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
15332
15333 /* SAP Authentication offload events */
15334 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
15335 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
15336
15337 /** Out-of-context-of-bss (OCB) events */
15338 event_ids[wmi_ocb_set_config_resp_event_id] =
15339 WMI_OCB_SET_CONFIG_RESP_EVENTID;
15340 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
15341 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
15342 event_ids[wmi_dcc_get_stats_resp_event_id] =
15343 WMI_DCC_GET_STATS_RESP_EVENTID;
15344 event_ids[wmi_dcc_update_ndl_resp_event_id] =
15345 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
15346 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
15347 /* System-On-Chip events */
15348 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
15349 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
15350 event_ids[wmi_soc_hw_mode_transition_event_id] =
15351 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
15352 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
15353 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053015354 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015355 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
15356 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053015357}
15358
15359/**
15360 * populate_pdev_param_tlv() - populates pdev params
15361 *
15362 * @param pdev_param: Pointer to hold pdev params
15363 * Return: None
15364 */
15365static void populate_pdev_param_tlv(uint32_t *pdev_param)
15366{
15367 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
15368 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
15369 pdev_param[wmi_pdev_param_txpower_limit2g] =
15370 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
15371 pdev_param[wmi_pdev_param_txpower_limit5g] =
15372 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
15373 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
15374 pdev_param[wmi_pdev_param_beacon_gen_mode] =
15375 WMI_PDEV_PARAM_BEACON_GEN_MODE;
15376 pdev_param[wmi_pdev_param_beacon_tx_mode] =
15377 WMI_PDEV_PARAM_BEACON_TX_MODE;
15378 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
15379 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
15380 pdev_param[wmi_pdev_param_protection_mode] =
15381 WMI_PDEV_PARAM_PROTECTION_MODE;
15382 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
15383 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
15384 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
15385 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
15386 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
15387 pdev_param[wmi_pdev_param_sta_kickout_th] =
15388 WMI_PDEV_PARAM_STA_KICKOUT_TH;
15389 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
15390 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
15391 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
15392 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
15393 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
15394 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
15395 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
15396 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
15397 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
15398 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
15399 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
15400 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
15401 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
15402 pdev_param[wmi_pdev_param_ltr_sleep_override] =
15403 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
15404 pdev_param[wmi_pdev_param_ltr_rx_override] =
15405 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
15406 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
15407 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
15408 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
15409 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
15410 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
15411 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
15412 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
15413 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
15414 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
15415 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
15416 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
15417 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
15418 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
15419 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
15420 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
15421 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
15422 pdev_param[wmi_pdev_param_peer_stats_update_period] =
15423 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
15424 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
15425 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
15426 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
15427 pdev_param[wmi_pdev_param_arp_ac_override] =
15428 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
15429 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
15430 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
15431 pdev_param[wmi_pdev_param_ani_poll_period] =
15432 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
15433 pdev_param[wmi_pdev_param_ani_listen_period] =
15434 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
15435 pdev_param[wmi_pdev_param_ani_ofdm_level] =
15436 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
15437 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
15438 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
15439 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
15440 pdev_param[wmi_pdev_param_idle_ps_config] =
15441 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
15442 pdev_param[wmi_pdev_param_power_gating_sleep] =
15443 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
15444 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
15445 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
15446 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
15447 pdev_param[wmi_pdev_param_hw_rfkill_config] =
15448 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
15449 pdev_param[wmi_pdev_param_low_power_rf_enable] =
15450 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
15451 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
15452 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
15453 pdev_param[wmi_pdev_param_power_collapse_enable] =
15454 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
15455 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
15456 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
15457 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
15458 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
15459 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
15460 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
15461 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
15462 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
15463 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
15464 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
15465 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
15466 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
15467 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
15468 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
15469 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
15470 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
15471 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
15472 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
15473 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
15474 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
15475 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
15476 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
15477 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
15478 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
15479 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
15480 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
15481 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
15482 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
15483 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
15484 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
15485 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
15486 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
15487 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
15488 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
15489 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
15490 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
15491 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
15492 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
15493 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
15494 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
15495 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
15496 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
15497 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
15498 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
15499 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
15500 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
15501 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
15502 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
15503 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
15504 WMI_UNAVAILABLE_PARAM;
15505 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
15506 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
15507 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
15508 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
15509 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
15510 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
15511 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
15512 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
15513 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
15514 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
15515 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
15516 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
15517 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
15518 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
15519 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
15520 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
15521 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
15522 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
15523 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
15524 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
15525 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
15526 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
15527 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
15528 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
15529 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
15530 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
15531 WMI_UNAVAILABLE_PARAM;
15532 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
15533 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
15534 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
15535 WMI_UNAVAILABLE_PARAM;
15536 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
15537 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
15538 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
15539 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
15540 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
15541 WMI_UNAVAILABLE_PARAM;
15542 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
15543 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
15544 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053015545 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
15546 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053015547 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053015548 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
15549 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015550}
15551
15552/**
15553 * populate_vdev_param_tlv() - populates vdev params
15554 *
15555 * @param vdev_param: Pointer to hold vdev params
15556 * Return: None
15557 */
15558static void populate_vdev_param_tlv(uint32_t *vdev_param)
15559{
15560 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
15561 vdev_param[wmi_vdev_param_fragmentation_threshold] =
15562 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
15563 vdev_param[wmi_vdev_param_beacon_interval] =
15564 WMI_VDEV_PARAM_BEACON_INTERVAL;
15565 vdev_param[wmi_vdev_param_listen_interval] =
15566 WMI_VDEV_PARAM_LISTEN_INTERVAL;
15567 vdev_param[wmi_vdev_param_multicast_rate] =
15568 WMI_VDEV_PARAM_MULTICAST_RATE;
15569 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
15570 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
15571 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
15572 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
15573 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
15574 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
15575 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
15576 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
15577 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
15578 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
15579 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
15580 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
15581 vdev_param[wmi_vdev_param_bmiss_count_max] =
15582 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
15583 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
15584 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
15585 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
15586 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
15587 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
15588 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
15589 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
15590 vdev_param[wmi_vdev_param_disable_htprotection] =
15591 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
15592 vdev_param[wmi_vdev_param_sta_quickkickout] =
15593 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
15594 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
15595 vdev_param[wmi_vdev_param_protection_mode] =
15596 WMI_VDEV_PARAM_PROTECTION_MODE;
15597 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
15598 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
15599 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
15600 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
15601 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
15602 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
15603 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
15604 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
15605 vdev_param[wmi_vdev_param_bcast_data_rate] =
15606 WMI_VDEV_PARAM_BCAST_DATA_RATE;
15607 vdev_param[wmi_vdev_param_mcast_data_rate] =
15608 WMI_VDEV_PARAM_MCAST_DATA_RATE;
15609 vdev_param[wmi_vdev_param_mcast_indicate] =
15610 WMI_VDEV_PARAM_MCAST_INDICATE;
15611 vdev_param[wmi_vdev_param_dhcp_indicate] =
15612 WMI_VDEV_PARAM_DHCP_INDICATE;
15613 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
15614 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
15615 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
15616 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
15617 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
15618 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
15619 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
15620 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
15621 vdev_param[wmi_vdev_param_ap_enable_nawds] =
15622 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
15623 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
15624 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
15625 vdev_param[wmi_vdev_param_packet_powersave] =
15626 WMI_VDEV_PARAM_PACKET_POWERSAVE;
15627 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
15628 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
15629 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
15630 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
15631 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
15632 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
15633 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
15634 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
15635 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
15636 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
15637 vdev_param[wmi_vdev_param_early_rx_slop_step] =
15638 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
15639 vdev_param[wmi_vdev_param_early_rx_init_slop] =
15640 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
15641 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
15642 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
15643 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
15644 vdev_param[wmi_vdev_param_snr_num_for_cal] =
15645 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
15646 vdev_param[wmi_vdev_param_roam_fw_offload] =
15647 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
15648 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
15649 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
15650 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
15651 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
15652 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
15653 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
15654 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
15655 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
15656 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
15657 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
15658 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
15659 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
15660 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
15661 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
15662 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
15663 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
15664 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
15665 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
15666 vdev_param[wmi_vdev_param_inactivity_cnt] =
15667 WMI_VDEV_PARAM_INACTIVITY_CNT;
15668 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
15669 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
15670 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
15671 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
15672 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
15673 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
15674 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
15675 vdev_param[wmi_vdev_param_rx_leak_window] =
15676 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
15677 vdev_param[wmi_vdev_param_stats_avg_factor] =
15678 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
15679 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
15680 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
15681 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
15682 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
15683 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
15684 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053015685 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
15686 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053015687 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080015688 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
15689 vdev_param[wmi_vdev_param_he_range_ext_enable] =
15690 WMI_VDEV_PARAM_HE_RANGE_EXT;
15691 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
15692 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
15693 vdev_param[wmi_vdev_param_tx_ofdma_cplen] =
15694 WMI_VDEV_PARAM_TX_OFDMA_CPLEN;
Govind Singhe7f2f342016-05-23 12:12:52 +053015695}
15696#endif
15697
Govind Singh5eb51532016-03-09 11:34:12 +053015698/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053015699 * populate_target_defines_tlv() - Populate target defines and params
15700 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053015701 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053015702 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053015703 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015704#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053015705static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053015706{
Govind Singhe7f2f342016-05-23 12:12:52 +053015707 populate_tlv_service(wmi_handle->services);
15708 populate_tlv_events_id(wmi_handle->wmi_events);
15709 populate_pdev_param_tlv(wmi_handle->pdev_param);
15710 populate_vdev_param_tlv(wmi_handle->vdev_param);
15711}
15712#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053015713static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
15714{ }
15715#endif
15716
15717/**
15718 * wmi_tlv_attach() - Attach TLV APIs
15719 *
15720 * Return: None
15721 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053015722void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053015723{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053015724 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053015725#ifdef WMI_INTERFACE_EVENT_LOGGING
15726 wmi_handle->log_info.buf_offset_command = 2;
15727 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053015728#endif
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053015729 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053015730}