blob: fe9b7011c868f344ee88b3b6699ed52b7f7ee7fa [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/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530874 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530875 * @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/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05309687 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +05309688 * @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
Sathish Kumar02c3b542017-02-22 17:24:45 +05309756/**
9757 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
9758 * @wmi_handle: wmi handle
9759 * @param: pointer to hold ant switch tbl param
9760 *
9761 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9762 */
9763static QDF_STATUS
9764send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
9765 struct ant_switch_tbl_params *param)
9766{
9767 uint8_t len;
9768 wmi_buf_t buf;
9769 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
9770 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
9771 uint8_t *buf_ptr;
9772
9773 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9774 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
9775 buf = wmi_buf_alloc(wmi_handle, len);
9776
9777 if (!buf) {
9778 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9779 return QDF_STATUS_E_NOMEM;
9780 }
9781
9782 buf_ptr = (uint8_t *)wmi_buf_data(buf);
9783 qdf_mem_zero(buf_ptr, len);
9784 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
9785
9786 WMITLV_SET_HDR(&cmd->tlv_header,
9787 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
9788 WMITLV_GET_STRUCT_TLVLEN(
9789 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
9790
9791 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
9792 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
9793 cmd->mac_id = param->pdev_id; /* Setting it to 0 for now */
9794
9795 /* TLV indicating array of structures to follow */
9796 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
9797 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9798 sizeof(wmi_pdev_set_ant_ctrl_chain));
9799 buf_ptr += WMI_TLV_HDR_SIZE;
9800 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
9801
9802 ctrl_chain->pdev_id = param->pdev_id;
9803 ctrl_chain->antCtrlChain = param->antCtrlChain;
9804
9805 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9806 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
9807 wmi_buf_free(buf);
9808 return QDF_STATUS_E_FAILURE;
9809 }
9810
9811 return QDF_STATUS_SUCCESS;
9812}
9813
9814/**
9815 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
9816 * training information function
9817 * @param wmi_handle : handle to WMI.
9818 * @macaddr : vdev mac address
9819 * @param param : pointer to tx antenna param
9820 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9821 */
9822static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
9823 wmi_unified_t wmi_handle,
9824 uint8_t macaddr[IEEE80211_ADDR_LEN],
9825 struct smart_ant_training_info_params *param)
9826{
9827 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
9828 wmi_peer_smart_ant_set_train_antenna_param *train_param;
9829 wmi_buf_t buf;
9830 uint8_t *buf_ptr;
9831 int32_t len = 0;
9832 QDF_STATUS ret;
9833 int loop;
9834
9835 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9836 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
9837 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
9838 buf = wmi_buf_alloc(wmi_handle, len);
9839
9840 if (!buf) {
9841 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9842 return QDF_STATUS_E_NOMEM;
9843 }
9844
9845 buf_ptr = (uint8_t *)wmi_buf_data(buf);
9846 qdf_mem_zero(buf_ptr, len);
9847 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
9848
9849 WMITLV_SET_HDR(&cmd->tlv_header,
9850 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
9851 WMITLV_GET_STRUCT_TLVLEN(
9852 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
9853
9854 cmd->vdev_id = param->vdev_id;
9855 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
9856 cmd->num_pkts = param->numpkts;
9857
9858 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
9859 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9860 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
9861 WMI_SMART_ANT_MAX_RATE_SERIES);
9862
9863 buf_ptr += WMI_TLV_HDR_SIZE;
9864 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
9865
9866 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
9867 WMITLV_SET_HDR(&train_param->tlv_header,
9868 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
9869 WMITLV_GET_STRUCT_TLVLEN(
9870 wmi_peer_smart_ant_set_train_antenna_param));
9871 train_param->train_rate_series = param->rate_array[loop];
9872 train_param->train_antenna_series = param->antenna_array[loop];
9873 train_param->rc_flags = 0;
9874 WMI_LOGI(FL("Series number:%d\n"), loop);
9875 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
9876 train_param->train_rate_series,
9877 train_param->train_antenna_series);
9878 train_param++;
9879 }
9880
9881 ret = wmi_unified_cmd_send(wmi_handle,
9882 buf,
9883 len,
9884 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
9885
9886 if (ret != 0) {
9887 WMI_LOGE(" %s :WMI Failed\n", __func__);
9888 wmi_buf_free(buf);
9889 return QDF_STATUS_E_FAILURE;
9890 }
9891
9892 return ret;
9893}
9894
9895/**
9896 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
9897 * configuration function
9898 * @param wmi_handle : handle to WMI.
9899 * @macaddr : vdev mad address
9900 * @param param : pointer to tx antenna param
9901 *
9902 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9903 */
9904static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
9905 wmi_unified_t wmi_handle,
9906 uint8_t macaddr[IEEE80211_ADDR_LEN],
9907 struct smart_ant_node_config_params *param)
9908{
9909 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
9910 wmi_buf_t buf;
9911 uint8_t *buf_ptr;
9912 int32_t len = 0, args_tlv_len;
9913 int ret;
9914 int i = 0;
9915 A_UINT32 *node_config_args;
9916
9917 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
9918 len = sizeof(*cmd) + args_tlv_len;
9919
9920 if ((param->args_count == 0)) {
9921 WMI_LOGE("%s: Can't send a command with %d arguments\n",
9922 __func__, param->args_count);
9923 return QDF_STATUS_E_FAILURE;
9924 }
9925
9926 buf = wmi_buf_alloc(wmi_handle, len);
9927 if (!buf) {
9928 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9929 return QDF_STATUS_E_NOMEM;
9930 }
9931
9932 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
9933 wmi_buf_data(buf);
9934 buf_ptr = (uint8_t *)cmd;
9935 WMITLV_SET_HDR(&cmd->tlv_header,
9936 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
9937 WMITLV_GET_STRUCT_TLVLEN(
9938 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
9939 cmd->vdev_id = param->vdev_id;
9940 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
9941 cmd->cmd_id = param->cmd_id;
9942 cmd->args_count = param->args_count;
9943 buf_ptr += sizeof(
9944 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
9945 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9946 (cmd->args_count * sizeof(A_UINT32)));
9947 buf_ptr += WMI_TLV_HDR_SIZE;
9948 node_config_args = (A_UINT32 *)buf_ptr;
9949
9950 for (i = 0; i < param->args_count; i++) {
9951 node_config_args[i] = param->args_arr[i];
9952 WMI_LOGI("%d", param->args_arr[i]);
9953 }
9954
9955 ret = wmi_unified_cmd_send(wmi_handle,
9956 buf,
9957 len,
9958 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
9959
9960 if (ret != 0) {
9961 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
9962 __func__, param->cmd_id, macaddr[0],
9963 macaddr[1], macaddr[2], macaddr[3],
9964 macaddr[4], macaddr[5], ret);
9965 wmi_buf_free(buf);
9966 }
9967
9968 return ret;
9969}
9970
9971/**
9972 * send_set_atf_cmd_tlv() - send set atf command to fw
9973 * @wmi_handle: wmi handle
9974 * @param: pointer to set atf param
9975 *
9976 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9977 */
9978static QDF_STATUS
9979send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
9980 struct set_atf_params *param)
9981{
9982 wmi_atf_peer_info *peer_info;
9983 wmi_peer_atf_request_fixed_param *cmd;
9984 wmi_buf_t buf;
9985 uint8_t *buf_ptr;
9986 int i;
9987 int32_t len = 0;
9988 QDF_STATUS retval;
9989
9990 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9991 len += param->num_peers * sizeof(wmi_atf_peer_info);
9992 buf = wmi_buf_alloc(wmi_handle, len);
9993 if (!buf) {
9994 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9995 return QDF_STATUS_E_FAILURE;
9996 }
9997 buf_ptr = (uint8_t *)wmi_buf_data(buf);
9998 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
9999 WMITLV_SET_HDR(&cmd->tlv_header,
10000 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10001 WMITLV_GET_STRUCT_TLVLEN(
10002 wmi_peer_atf_request_fixed_param));
10003 cmd->num_peers = param->num_peers;
10004
10005 buf_ptr += sizeof(*cmd);
10006 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10007 sizeof(wmi_atf_peer_info) *
10008 cmd->num_peers);
10009 buf_ptr += WMI_TLV_HDR_SIZE;
10010 peer_info = (wmi_atf_peer_info *)buf_ptr;
10011
10012 for (i = 0; i < cmd->num_peers; i++) {
10013 WMITLV_SET_HDR(&peer_info->tlv_header,
10014 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10015 WMITLV_GET_STRUCT_TLVLEN(
10016 wmi_atf_peer_info));
10017 peer_info->atf_units = param->peer_info[i].percentage_peer;
10018 /*
10019 * TLV definition for peer atf request fixed param combines
10020 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
10021 * stats and atf extension stats as two different
10022 * implementations.
10023 * Need to discuss with FW on this.
10024 *
10025 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
10026 * peer_info->atf_units_reserved =
10027 * param->peer_ext_info[i].atf_index_reserved;
10028 */
10029 peer_info++;
10030 }
10031
10032 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10033 WMI_PEER_ATF_REQUEST_CMDID);
10034
10035 if (retval != QDF_STATUS_SUCCESS) {
10036 WMI_LOGE("%s : WMI Failed\n", __func__);
10037 wmi_buf_free(buf);
10038 }
10039
10040 return retval;
10041}
10042
10043/**
10044 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
10045 * @wmi_handle: wmi handle
10046 * @param: pointer to hold fwtest param
10047 *
10048 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10049 */
10050static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
10051 struct set_fwtest_params *param)
10052{
10053 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10054 wmi_buf_t buf;
10055 int32_t len = sizeof(*cmd);
10056
10057 buf = wmi_buf_alloc(wmi_handle, len);
10058
10059 if (!buf) {
10060 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10061 return QDF_STATUS_E_FAILURE;
10062 }
10063
10064 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
10065 WMITLV_SET_HDR(&cmd->tlv_header,
10066 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10067 WMITLV_GET_STRUCT_TLVLEN(
10068 wmi_fwtest_set_param_cmd_fixed_param));
10069 cmd->param_id = param->arg;
10070 cmd->param_value = param->value;
10071
10072 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
10073 WMI_LOGE("Setting FW test param failed\n");
10074 wmi_buf_free(buf);
10075 return QDF_STATUS_E_FAILURE;
10076 }
10077
10078 return QDF_STATUS_SUCCESS;
10079}
10080
10081/**
10082 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
10083 * @wmi_handle: wmi handle
10084 * @param: pointer to qboost params
10085 * @macaddr: vdev mac address
10086 *
10087 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10088 */
10089static QDF_STATUS
10090send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
10091 uint8_t macaddr[IEEE80211_ADDR_LEN],
10092 struct set_qboost_params *param)
10093{
10094 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
10095 wmi_buf_t buf;
10096 int32_t len;
10097 QDF_STATUS ret;
10098
10099 len = sizeof(*cmd);
10100
10101 buf = wmi_buf_alloc(wmi_handle, len);
10102 if (!buf) {
10103 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10104 return QDF_STATUS_E_FAILURE;
10105 }
10106
10107 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
10108 WMITLV_SET_HDR(&cmd->tlv_header,
10109 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
10110 WMITLV_GET_STRUCT_TLVLEN(
10111 WMI_QBOOST_CFG_CMD_fixed_param));
10112 cmd->vdev_id = param->vdev_id;
10113 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10114 cmd->qb_enable = param->value;
10115
10116 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10117 WMI_QBOOST_CFG_CMDID);
10118
10119 if (ret != 0) {
10120 WMI_LOGE("Setting qboost cmd failed\n");
10121 wmi_buf_free(buf);
10122 }
10123
10124 return ret;
10125}
10126
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010127/**
10128 * send_gpio_config_cmd_tlv() - send gpio config to fw
10129 * @wmi_handle: wmi handle
10130 * @param: pointer to hold gpio config param
10131 *
10132 * Return: 0 for success or error code
10133 */
10134static QDF_STATUS
10135send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
10136 struct gpio_config_params *param)
10137{
10138 wmi_gpio_config_cmd_fixed_param *cmd;
10139 wmi_buf_t buf;
10140 int32_t len;
10141 QDF_STATUS ret;
10142
10143 len = sizeof(*cmd);
10144
10145 /* Sanity Checks */
10146 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
10147 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
10148 return QDF_STATUS_E_FAILURE;
10149 }
10150
10151 buf = wmi_buf_alloc(wmi_handle, len);
10152 if (!buf) {
10153 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10154 return QDF_STATUS_E_FAILURE;
10155 }
10156
10157 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
10158 WMITLV_SET_HDR(&cmd->tlv_header,
10159 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
10160 WMITLV_GET_STRUCT_TLVLEN(
10161 wmi_gpio_config_cmd_fixed_param));
10162 cmd->gpio_num = param->gpio_num;
10163 cmd->input = param->input;
10164 cmd->pull_type = param->pull_type;
10165 cmd->intr_mode = param->intr_mode;
10166
10167 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10168 WMI_GPIO_CONFIG_CMDID);
10169
10170 if (ret != 0) {
10171 WMI_LOGE("Sending GPIO config cmd failed\n");
10172 wmi_buf_free(buf);
10173 }
10174
10175 return ret;
10176}
10177
10178/**
10179 * send_gpio_output_cmd_tlv() - send gpio output to fw
10180 * @wmi_handle: wmi handle
10181 * @param: pointer to hold gpio output param
10182 *
10183 * Return: 0 for success or error code
10184 */
10185static QDF_STATUS
10186send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
10187 struct gpio_output_params *param)
10188{
10189 wmi_gpio_output_cmd_fixed_param *cmd;
10190 wmi_buf_t buf;
10191 int32_t len;
10192 QDF_STATUS ret;
10193
10194 len = sizeof(*cmd);
10195
10196 buf = wmi_buf_alloc(wmi_handle, len);
10197 if (!buf) {
10198 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10199 return QDF_STATUS_E_FAILURE;
10200 }
10201
10202 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
10203 WMITLV_SET_HDR(&cmd->tlv_header,
10204 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
10205 WMITLV_GET_STRUCT_TLVLEN(
10206 wmi_gpio_output_cmd_fixed_param));
10207 cmd->gpio_num = param->gpio_num;
10208 cmd->set = param->set;
10209
10210 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10211 WMI_GPIO_OUTPUT_CMDID);
10212
10213 if (ret != 0) {
10214 WMI_LOGE("Sending GPIO output cmd failed\n");
10215 wmi_buf_free(buf);
10216 }
10217
10218 return ret;
10219
10220}
10221
10222/**
10223 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
10224 *
10225 * @param wmi_handle : handle to WMI.
10226 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10227 */
10228static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
10229{
10230 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
10231 wmi_buf_t buf;
10232 QDF_STATUS ret;
10233 int32_t len;
10234
10235 len = sizeof(*cmd);
10236
10237 buf = wmi_buf_alloc(wmi_handle, len);
10238 if (!buf) {
10239 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10240 return QDF_STATUS_E_FAILURE;
10241 }
10242
10243 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
10244 WMITLV_SET_HDR(&cmd->tlv_header,
10245 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
10246 WMITLV_GET_STRUCT_TLVLEN(
10247 wmi_pdev_dfs_disable_cmd_fixed_param));
10248 /* Filling it with WMI_PDEV_ID_SOC for now */
10249 cmd->pdev_id = WMI_PDEV_ID_SOC;
10250
10251 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10252 WMI_PDEV_DFS_DISABLE_CMDID);
10253
10254 if (ret != 0) {
10255 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
10256 wmi_buf_free(buf);
10257 }
10258
10259 return ret;
10260}
10261
10262/**
10263 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
10264 *
10265 * @param wmi_handle : handle to WMI.
10266 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10267 */
10268static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
10269{
10270 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
10271 wmi_buf_t buf;
10272 QDF_STATUS ret;
10273 int32_t len;
10274
10275 len = sizeof(*cmd);
10276
10277 buf = wmi_buf_alloc(wmi_handle, len);
10278 if (!buf) {
10279 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10280 return QDF_STATUS_E_FAILURE;
10281 }
10282
10283 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
10284 WMITLV_SET_HDR(&cmd->tlv_header,
10285 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
10286 WMITLV_GET_STRUCT_TLVLEN(
10287 wmi_pdev_dfs_enable_cmd_fixed_param));
10288 /* Reserved for future use */
10289 cmd->reserved0 = 0;
10290
10291 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10292 WMI_PDEV_DFS_ENABLE_CMDID);
10293
10294 if (ret != 0) {
10295 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
10296 wmi_buf_free(buf);
10297 }
10298
10299 return ret;
10300}
10301
10302/**
10303 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
10304 * @wmi_handle: wmi handle
10305 *
10306 * Return: 0 for success or error code
10307 */
10308static QDF_STATUS
10309send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
10310{
10311 wmi_buf_t buf;
10312 QDF_STATUS ret;
10313
10314 buf = wmi_buf_alloc(wmi_handle, 0);
10315 if (buf == NULL)
10316 return QDF_STATUS_E_NOMEM;
10317
10318 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
10319 WMI_PDEV_GET_NFCAL_POWER_CMDID);
10320 if (ret != 0) {
10321 WMI_LOGE("Sending get nfcal power cmd failed\n");
10322 wmi_buf_free(buf);
10323 }
10324
10325 return ret;
10326}
10327
10328/**
10329 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
10330 * @wmi_handle: wmi handle
10331 * @param: pointer to ht ie param
10332 *
10333 * Return: 0 for success or error code
10334 */
10335static QDF_STATUS
10336send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10337 struct ht_ie_params *param)
10338{
10339 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
10340 wmi_buf_t buf;
10341 QDF_STATUS ret;
10342 int32_t len;
10343 uint8_t *buf_ptr;
10344
10345 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10346 roundup(param->ie_len, sizeof(uint32_t));
10347
10348 buf = wmi_buf_alloc(wmi_handle, len);
10349 if (!buf) {
10350 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10351 return QDF_STATUS_E_FAILURE;
10352 }
10353
10354 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10355 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
10356 WMITLV_SET_HDR(&cmd->tlv_header,
10357 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
10358 WMITLV_GET_STRUCT_TLVLEN(
10359 wmi_pdev_set_ht_ie_cmd_fixed_param));
10360 cmd->reserved0 = 0;
10361 cmd->ie_len = param->ie_len;
10362 cmd->tx_streams = param->tx_streams;
10363 cmd->rx_streams = param->rx_streams;
10364
10365 buf_ptr += sizeof(*cmd);
10366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10367 buf_ptr += WMI_TLV_HDR_SIZE;
10368 if (param->ie_len)
10369 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10370 cmd->ie_len);
10371
10372 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10373 WMI_PDEV_SET_HT_CAP_IE_CMDID);
10374
10375 if (ret != 0) {
10376 WMI_LOGE("Sending set ht ie cmd failed\n");
10377 wmi_buf_free(buf);
10378 }
10379
10380 return ret;
10381}
10382
10383/**
10384 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
10385 * @wmi_handle: wmi handle
10386 * @param: pointer to vht ie param
10387 *
10388 * Return: 0 for success or error code
10389 */
10390static QDF_STATUS
10391send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10392 struct vht_ie_params *param)
10393{
10394 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
10395 wmi_buf_t buf;
10396 QDF_STATUS ret;
10397 int32_t len;
10398 uint8_t *buf_ptr;
10399
10400 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10401 roundup(param->ie_len, sizeof(uint32_t));
10402
10403 buf = wmi_buf_alloc(wmi_handle, len);
10404 if (!buf) {
10405 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10406 return QDF_STATUS_E_FAILURE;
10407 }
10408
10409 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10410 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
10411 WMITLV_SET_HDR(&cmd->tlv_header,
10412 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
10413 WMITLV_GET_STRUCT_TLVLEN(
10414 wmi_pdev_set_vht_ie_cmd_fixed_param));
10415 cmd->reserved0 = 0;
10416 cmd->ie_len = param->ie_len;
10417 cmd->tx_streams = param->tx_streams;
10418 cmd->rx_streams = param->rx_streams;
10419
10420 buf_ptr += sizeof(*cmd);
10421 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10422 buf_ptr += WMI_TLV_HDR_SIZE;
10423 if (param->ie_len)
10424 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10425 cmd->ie_len);
10426
10427 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10428 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
10429
10430 if (ret != 0) {
10431 WMI_LOGE("Sending set vht ie cmd failed\n");
10432 wmi_buf_free(buf);
10433 }
10434
10435 return ret;
10436}
10437
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010438static
Govind Singh9ddd5162016-03-07 16:30:32 +053010439void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053010440 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053010441{
Govind Singhe7f2f342016-05-23 12:12:52 +053010442 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053010443 resource_cfg->num_peers = tgt_res_cfg->num_peers;
10444 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
10445 resource_cfg->num_offload_reorder_buffs =
10446 tgt_res_cfg->num_offload_reorder_buffs;
10447 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
10448 resource_cfg->num_tids = tgt_res_cfg->num_tids;
10449 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
10450 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
10451 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
10452 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
10453 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
10454 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
10455 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
10456 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
10457 resource_cfg->scan_max_pending_req =
10458 tgt_res_cfg->scan_max_pending_req;
10459 resource_cfg->bmiss_offload_max_vdev =
10460 tgt_res_cfg->bmiss_offload_max_vdev;
10461 resource_cfg->roam_offload_max_vdev =
10462 tgt_res_cfg->roam_offload_max_vdev;
10463 resource_cfg->roam_offload_max_ap_profiles =
10464 tgt_res_cfg->roam_offload_max_ap_profiles;
10465 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
10466 resource_cfg->num_mcast_table_elems =
10467 tgt_res_cfg->num_mcast_table_elems;
10468 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
10469 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
10470 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
10471 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
10472 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
10473 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
10474 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
10475 resource_cfg->vow_config = tgt_res_cfg->vow_config;
10476 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
10477 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
10478 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
10479 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
10480 resource_cfg->num_tdls_conn_table_entries =
10481 tgt_res_cfg->num_tdls_conn_table_entries;
10482 resource_cfg->beacon_tx_offload_max_vdev =
10483 tgt_res_cfg->beacon_tx_offload_max_vdev;
10484 resource_cfg->num_multicast_filter_entries =
10485 tgt_res_cfg->num_multicast_filter_entries;
10486 resource_cfg->num_wow_filters =
10487 tgt_res_cfg->num_wow_filters;
10488 resource_cfg->num_keep_alive_pattern =
10489 tgt_res_cfg->num_keep_alive_pattern;
10490 resource_cfg->keep_alive_pattern_size =
10491 tgt_res_cfg->keep_alive_pattern_size;
10492 resource_cfg->max_tdls_concurrent_sleep_sta =
10493 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
10494 resource_cfg->max_tdls_concurrent_buffer_sta =
10495 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
10496 resource_cfg->wmi_send_separate =
10497 tgt_res_cfg->wmi_send_separate;
10498 resource_cfg->num_ocb_vdevs =
10499 tgt_res_cfg->num_ocb_vdevs;
10500 resource_cfg->num_ocb_channels =
10501 tgt_res_cfg->num_ocb_channels;
10502 resource_cfg->num_ocb_schedules =
10503 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053010504 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
10505 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
10506 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Govind Singh9ddd5162016-03-07 16:30:32 +053010507}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053010508#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010509/**
10510 * send_init_cmd_tlv() - wmi init command
10511 * @wmi_handle: pointer to wmi handle
10512 * @res_cfg: resource config
10513 * @num_mem_chunks: no of mem chunck
10514 * @mem_chunk: pointer to mem chunck structure
10515 *
10516 * This function sends IE information to firmware
10517 *
Govind Singhb53420c2016-03-09 14:32:57 +053010518 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010519 *
10520 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010521static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053010522 wmi_resource_config *tgt_res_cfg,
10523 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
10524 bool action)
10525{
10526 wmi_buf_t buf;
10527 wmi_init_cmd_fixed_param *cmd;
10528 wmi_abi_version my_vers;
10529 int num_whitelist;
10530 uint8_t *buf_ptr;
10531 wmi_resource_config *resource_cfg;
10532 wlan_host_memory_chunk *host_mem_chunks;
10533 uint32_t mem_chunk_len = 0;
10534 uint16_t idx;
10535 int len;
10536 int ret;
10537
10538 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
10539 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
10540 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
10541 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010542 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
10543 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010544 }
10545
10546 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10547 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
10548 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
10549
10550 host_mem_chunks = (wlan_host_memory_chunk *)
10551 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
10552 + WMI_TLV_HDR_SIZE);
10553
10554 WMITLV_SET_HDR(&cmd->tlv_header,
10555 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
10556 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
10557
Govind Singhb53420c2016-03-09 14:32:57 +053010558 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053010559 WMITLV_SET_HDR(&resource_cfg->tlv_header,
10560 WMITLV_TAG_STRUC_wmi_resource_config,
10561 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
10562
10563 for (idx = 0; idx < num_mem_chunks; ++idx) {
10564 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
10565 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
10566 WMITLV_GET_STRUCT_TLVLEN
10567 (wlan_host_memory_chunk));
10568 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
10569 host_mem_chunks[idx].size = mem_chunks[idx].len;
10570 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053010571 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053010572 idx, host_mem_chunks[idx].size,
10573 host_mem_chunks[idx].ptr);
10574 }
10575 cmd->num_host_mem_chunks = num_mem_chunks;
10576 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
10577 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
10578 WMITLV_TAG_ARRAY_STRUC,
10579 (sizeof(wlan_host_memory_chunk) *
10580 num_mem_chunks));
10581
10582 num_whitelist = sizeof(version_whitelist) /
10583 sizeof(wmi_whitelist_version_info);
10584 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
10585 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
10586 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
10587 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
10588 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
10589 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053010590#ifdef CONFIG_MCL
10591 /* This needs to be enabled for WIN Lithium after removing dependency
10592 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053010593 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
10594 &my_vers,
10595 &wmi_handle->fw_abi_version,
10596 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053010597#endif
Govind Singhb53420c2016-03-09 14:32:57 +053010598 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053010599 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
10600 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
10601 cmd->host_abi_vers.abi_version_ns_0,
10602 cmd->host_abi_vers.abi_version_ns_1,
10603 cmd->host_abi_vers.abi_version_ns_2,
10604 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053010605#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010606 /* Save version sent from host -
10607 * Will be used to check ready event
10608 */
Govind Singhb53420c2016-03-09 14:32:57 +053010609 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010610 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010611#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010612 if (action) {
10613 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10614 WMI_INIT_CMDID);
10615 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010616 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053010617 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010618 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010619 }
10620 } else {
10621 wmi_handle->saved_wmi_init_cmd.buf = buf;
10622 wmi_handle->saved_wmi_init_cmd.buf_len = len;
10623 }
10624
Govind Singhb53420c2016-03-09 14:32:57 +053010625 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010626
10627}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053010628#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010629/**
10630 * send_saved_init_cmd_tlv() - wmi init command
10631 * @wmi_handle: pointer to wmi handle
10632 *
10633 * This function sends IE information to firmware
10634 *
Govind Singhb53420c2016-03-09 14:32:57 +053010635 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010636 *
10637 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010638static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053010639{
10640 int status;
10641
10642 if (!wmi_handle->saved_wmi_init_cmd.buf ||
10643 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053010644 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
10645 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010646 }
10647 status = wmi_unified_cmd_send(wmi_handle,
10648 wmi_handle->saved_wmi_init_cmd.buf,
10649 wmi_handle->saved_wmi_init_cmd.buf_len,
10650 WMI_INIT_CMDID);
10651 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053010652 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053010653 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010654 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010655 }
10656 wmi_handle->saved_wmi_init_cmd.buf = NULL;
10657 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
10658
Govind Singhb53420c2016-03-09 14:32:57 +053010659 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010660}
10661
Sathish Kumarfd347372017-02-13 12:29:09 +053010662static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053010663{
10664 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
10665 wmi_service_ready_event_fixed_param *ev;
10666
10667
10668 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
10669
10670 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
10671 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053010672 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010673
Govind Singh87542482016-06-08 19:40:11 +053010674#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010675 /*Save fw version from service ready message */
10676 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053010677 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010678 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010679#endif
Govind Singhb53420c2016-03-09 14:32:57 +053010680 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010681}
10682
10683/**
10684 * wmi_unified_save_fw_version_cmd() - save fw version
10685 * @wmi_handle: pointer to wmi handle
10686 * @res_cfg: resource config
10687 * @num_mem_chunks: no of mem chunck
10688 * @mem_chunk: pointer to mem chunck structure
10689 *
10690 * This function sends IE information to firmware
10691 *
Govind Singhb53420c2016-03-09 14:32:57 +053010692 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010693 *
10694 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010695static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053010696 void *evt_buf)
10697{
10698 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
10699 wmi_ready_event_fixed_param *ev = NULL;
10700
10701 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
10702 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053010703#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010704 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
10705 &ev->fw_abi_vers)) {
10706 /*
10707 * Error: Our host version and the given firmware version
10708 * are incompatible.
10709 **/
Govind Singhb53420c2016-03-09 14:32:57 +053010710 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053010711 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
10712 __func__,
10713 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
10714 abi_version_0),
10715 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
10716 abi_version_0),
10717 wmi_handle->final_abi_vers.abi_version_ns_0,
10718 wmi_handle->final_abi_vers.abi_version_ns_1,
10719 wmi_handle->final_abi_vers.abi_version_ns_2,
10720 wmi_handle->final_abi_vers.abi_version_ns_3,
10721 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
10722 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
10723 ev->fw_abi_vers.abi_version_ns_0,
10724 ev->fw_abi_vers.abi_version_ns_1,
10725 ev->fw_abi_vers.abi_version_ns_2,
10726 ev->fw_abi_vers.abi_version_ns_3);
10727
Govind Singhb53420c2016-03-09 14:32:57 +053010728 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010729 }
Govind Singhb53420c2016-03-09 14:32:57 +053010730 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010731 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053010732 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010733 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010734#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010735
Govind Singhb53420c2016-03-09 14:32:57 +053010736 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010737}
Govind Singha4836fd2016-03-07 16:45:38 +053010738
10739/**
10740 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
10741 * @wmi_handle: wmi handle
10742 * @custom_addr: base mac address
10743 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010744 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053010745 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010746static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010747 uint8_t *custom_addr)
10748{
10749 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
10750 wmi_buf_t buf;
10751 int err;
10752
10753 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10754 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010755 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010756 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010757 }
10758
10759 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010760 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053010761
10762 WMITLV_SET_HDR(&cmd->tlv_header,
10763 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
10764 WMITLV_GET_STRUCT_TLVLEN
10765 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
10766 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -070010767 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010768 err = wmi_unified_cmd_send(wmi_handle, buf,
10769 sizeof(*cmd),
10770 WMI_PDEV_SET_BASE_MACADDR_CMDID);
10771 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053010772 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053010773 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010774 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010775 }
10776
10777 return 0;
10778}
10779
10780/**
10781 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
10782 * @handle: wmi handle
10783 * @event: Event received from FW
10784 * @len: Length of the event
10785 *
10786 * Enables the low frequency events and disables the high frequency
10787 * events. Bit 17 indicates if the event if low/high frequency.
10788 * 1 - high frequency, 0 - low frequency
10789 *
10790 * Return: 0 on successfully enabling/disabling the events
10791 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010792static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010793 uint8_t *event,
10794 uint32_t len)
10795{
10796 uint32_t num_of_diag_events_logs;
10797 wmi_diag_event_log_config_fixed_param *cmd;
10798 wmi_buf_t buf;
10799 uint8_t *buf_ptr;
10800 uint32_t *cmd_args, *evt_args;
10801 uint32_t buf_len, i;
10802
10803 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
10804 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
10805
Govind Singhb53420c2016-03-09 14:32:57 +053010806 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053010807
10808 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
10809 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010810 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053010811 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010812 }
10813 wmi_event = param_buf->fixed_param;
10814 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
10815 evt_args = param_buf->diag_events_logs_list;
10816 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053010817 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010818 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053010819 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010820 }
10821
Govind Singhb53420c2016-03-09 14:32:57 +053010822 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010823 __func__, num_of_diag_events_logs);
10824
10825 /* Free any previous allocation */
10826 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053010827 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010828
10829 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053010830 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053010831 sizeof(uint32_t));
10832 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010833 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010834 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010835 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010836 }
10837 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
10838
10839 /* Prepare the send buffer */
10840 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10841 (num_of_diag_events_logs * sizeof(uint32_t));
10842
10843 buf = wmi_buf_alloc(wmi_handle, buf_len);
10844 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010845 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10846 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010847 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010848 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010849 }
10850
10851 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10852 buf_ptr = (uint8_t *) cmd;
10853
10854 WMITLV_SET_HDR(&cmd->tlv_header,
10855 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10856 WMITLV_GET_STRUCT_TLVLEN(
10857 wmi_diag_event_log_config_fixed_param));
10858
10859 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
10860
10861 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10862
10863 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10864 (num_of_diag_events_logs * sizeof(uint32_t)));
10865
10866 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10867
10868 /* Populate the events */
10869 for (i = 0; i < num_of_diag_events_logs; i++) {
10870 /* Low freq (0) - Enable (1) the event
10871 * High freq (1) - Disable (0) the event
10872 */
10873 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
10874 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
10875 /* Set the event ID */
10876 WMI_DIAG_ID_SET(cmd_args[i],
10877 WMI_DIAG_ID_GET(evt_args[i]));
10878 /* Set the type */
10879 WMI_DIAG_TYPE_SET(cmd_args[i],
10880 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053010881 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053010882 wmi_handle->events_logs_list[i] = evt_args[i];
10883 }
10884
10885 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
10886 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010887 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010888 __func__);
10889 wmi_buf_free(buf);
10890 /* Not clearing events_logs_list, though wmi cmd failed.
10891 * Host can still have this list
10892 */
Govind Singh67922e82016-04-01 16:48:57 +053010893 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010894 }
10895
10896 return 0;
10897}
10898
10899/**
10900 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
10901 * @wmi_handle: wmi handle
10902 * @start_log: Start logging related parameters
10903 *
10904 * Send the command to the FW based on which specific logging of diag
10905 * event/log id can be started/stopped
10906 *
10907 * Return: None
10908 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010909static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010910 struct wmi_wifi_start_log *start_log)
10911{
10912 wmi_diag_event_log_config_fixed_param *cmd;
10913 wmi_buf_t buf;
10914 uint8_t *buf_ptr;
10915 uint32_t len, count, log_level, i;
10916 uint32_t *cmd_args;
10917 uint32_t total_len;
10918 count = 0;
10919
10920 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010921 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053010922 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010923 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010924 }
10925 /* total_len stores the number of events where BITS 17 and 18 are set.
10926 * i.e., events of high frequency (17) and for extended debugging (18)
10927 */
10928 total_len = 0;
10929 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10930 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
10931 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
10932 total_len++;
10933 }
10934
10935 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10936 (total_len * sizeof(uint32_t));
10937
10938 buf = wmi_buf_alloc(wmi_handle, len);
10939 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010940 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010941 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010942 }
10943 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10944 buf_ptr = (uint8_t *) cmd;
10945
10946 WMITLV_SET_HDR(&cmd->tlv_header,
10947 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10948 WMITLV_GET_STRUCT_TLVLEN(
10949 wmi_diag_event_log_config_fixed_param));
10950
10951 cmd->num_of_diag_events_logs = total_len;
10952
10953 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10954
10955 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10956 (total_len * sizeof(uint32_t)));
10957
10958 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10959
Govind Singh224a7312016-06-21 14:33:26 +053010960 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053010961 log_level = 1;
10962 else
10963 log_level = 0;
10964
Govind Singhb53420c2016-03-09 14:32:57 +053010965 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053010966 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10967 uint32_t val = wmi_handle->events_logs_list[i];
10968 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
10969 (WMI_DIAG_EXT_FEATURE_GET(val))) {
10970
10971 WMI_DIAG_ID_SET(cmd_args[count],
10972 WMI_DIAG_ID_GET(val));
10973 WMI_DIAG_TYPE_SET(cmd_args[count],
10974 WMI_DIAG_TYPE_GET(val));
10975 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
10976 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053010977 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053010978 count++;
10979 }
10980 }
10981
10982 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10983 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010984 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010985 __func__);
10986 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010987 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010988 }
10989
Govind Singhb53420c2016-03-09 14:32:57 +053010990 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010991}
10992
10993/**
10994 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
10995 * @wmi_handle: WMI handle
10996 *
10997 * This function is used to send the flush command to the FW,
10998 * that will flush the fw logs that are residue in the FW
10999 *
11000 * Return: None
11001 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011002static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053011003{
11004 wmi_debug_mesg_flush_fixed_param *cmd;
11005 wmi_buf_t buf;
11006 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053011007 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053011008
11009 buf = wmi_buf_alloc(wmi_handle, len);
11010 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011011 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011012 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011013 }
11014
11015 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
11016 WMITLV_SET_HDR(&cmd->tlv_header,
11017 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
11018 WMITLV_GET_STRUCT_TLVLEN(
11019 wmi_debug_mesg_flush_fixed_param));
11020 cmd->reserved0 = 0;
11021
11022 ret = wmi_unified_cmd_send(wmi_handle,
11023 buf,
11024 len,
11025 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011026 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011027 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053011028 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011029 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011030 }
Govind Singhb53420c2016-03-09 14:32:57 +053011031 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053011032
Govind Singh67922e82016-04-01 16:48:57 +053011033 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053011034}
11035
11036/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011037 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011038 * @wmi_handle: wmi handle
11039 * @msg: PCL structure containing the PCL and the number of channels
11040 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011041 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053011042 * firmware. The DBS Manager is the consumer of this information in the WLAN
11043 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
11044 * to migrate to a new channel without host driver involvement. An example of
11045 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
11046 * manage the channel selection without firmware involvement.
11047 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011048 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
11049 * channel list. The weights corresponds to the channels sent in
11050 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
11051 * weightage compared to the non PCL channels.
11052 *
Govind Singha4836fd2016-03-07 16:45:38 +053011053 * Return: Success if the cmd is sent successfully to the firmware
11054 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011055static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011056 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053011057{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011058 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011059 wmi_buf_t buf;
11060 uint8_t *buf_ptr;
11061 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011062 uint32_t chan_len;
11063
11064 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053011065
11066 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011067 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053011068
11069 buf = wmi_buf_alloc(wmi_handle, len);
11070 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011071 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11072 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011073 }
11074
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011075 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011076 buf_ptr = (uint8_t *) cmd;
11077 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011078 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
11079 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053011080
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011081 cmd->pdev_id = WMI_PDEV_ID_SOC;
11082 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053011083 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011084
11085 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053011086 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011087 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053011088 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011089 for (i = 0; i < chan_len ; i++) {
11090 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053011091 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011092 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011093 }
11094 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011095 WMI_PDEV_SET_PCL_CMDID)) {
11096 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011097 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011098 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011099 }
Govind Singhb53420c2016-03-09 14:32:57 +053011100 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011101}
11102
11103/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011104 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011105 * @wmi_handle: wmi handle
11106 * @msg: Structure containing the following parameters
11107 *
11108 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
11109 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
11110 *
11111 * Provides notification to the WLAN firmware that host driver is requesting a
11112 * HardWare (HW) Mode change. This command is needed to support iHelium in the
11113 * configurations that include the Dual Band Simultaneous (DBS) feature.
11114 *
11115 * Return: Success if the cmd is sent successfully to the firmware
11116 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011117static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011118 uint32_t hw_mode_index)
11119{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011120 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011121 wmi_buf_t buf;
11122 uint32_t len;
11123
11124 len = sizeof(*cmd);
11125
11126 buf = wmi_buf_alloc(wmi_handle, len);
11127 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011128 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11129 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011130 }
11131
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011132 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011133 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011134 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
11135 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
11136
11137 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053011138 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053011139 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053011140
11141 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011142 WMI_PDEV_SET_HW_MODE_CMDID)) {
11143 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053011144 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011145 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011146 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011147 }
11148
Govind Singhb53420c2016-03-09 14:32:57 +053011149 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011150}
11151
11152/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011153 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011154 * @wmi_handle: wmi handle
11155 * @msg: Dual MAC config parameters
11156 *
11157 * Configures WLAN firmware with the dual MAC features
11158 *
Govind Singhb53420c2016-03-09 14:32:57 +053011159 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053011160 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011161static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011162QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011163 struct wmi_dual_mac_config *msg)
11164{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011165 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011166 wmi_buf_t buf;
11167 uint32_t len;
11168
11169 len = sizeof(*cmd);
11170
11171 buf = wmi_buf_alloc(wmi_handle, len);
11172 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011173 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11174 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011175 }
11176
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011177 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011178 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011179 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053011180 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011181 wmi_pdev_set_mac_config_cmd_fixed_param));
11182
11183 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053011184 cmd->concurrent_scan_config_bits = msg->scan_config;
11185 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053011186 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053011187 __func__, msg->scan_config, msg->fw_mode_config);
11188
11189 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011190 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
11191 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053011192 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011193 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011194 }
Govind Singhb53420c2016-03-09 14:32:57 +053011195 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011196}
11197
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011198#ifdef BIG_ENDIAN_HOST
11199/**
11200* fips_conv_data_be() - LE to BE conversion of FIPS ev data
11201* @param data_len - data length
11202* @param data - pointer to data
11203*
11204* Return: QDF_STATUS - success or error status
11205*/
11206static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
11207 struct fips_params *param)
11208{
11209 unsigned char *key_unaligned, *data_unaligned;
11210 int c;
11211 u_int8_t *key_aligned = NULL;
11212 u_int8_t *data_aligned = NULL;
11213
11214 /* Assigning unaligned space to copy the key */
11215 key_unaligned = qdf_mem_malloc(
11216 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
11217 data_unaligned = qdf_mem_malloc(
11218 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
11219
11220 /* Checking if kmalloc is succesful to allocate space */
11221 if (key_unaligned == NULL)
11222 return QDF_STATUS_SUCCESS;
11223 /* Checking if space is aligned */
11224 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
11225 /* align to 4 */
11226 key_aligned =
11227 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
11228 FIPS_ALIGN);
11229 } else {
11230 key_aligned = (u_int8_t *)key_unaligned;
11231 }
11232
11233 /* memset and copy content from key to key aligned */
11234 OS_MEMSET(key_aligned, 0, param->key_len);
11235 OS_MEMCPY(key_aligned, param->key, param->key_len);
11236
11237 /* print a hexdump for host debug */
11238 print_hex_dump(KERN_DEBUG,
11239 "\t Aligned and Copied Key:@@@@ ",
11240 DUMP_PREFIX_NONE,
11241 16, 1, key_aligned, param->key_len, true);
11242
11243 /* Checking if kmalloc is succesful to allocate space */
11244 if (data_unaligned == NULL)
11245 return QDF_STATUS_SUCCESS;
11246 /* Checking of space is aligned */
11247 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
11248 /* align to 4 */
11249 data_aligned =
11250 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
11251 FIPS_ALIGN);
11252 } else {
11253 data_aligned = (u_int8_t *)data_unaligned;
11254 }
11255
11256 /* memset and copy content from data to data aligned */
11257 OS_MEMSET(data_aligned, 0, param->data_len);
11258 OS_MEMCPY(data_aligned, param->data, param->data_len);
11259
11260 /* print a hexdump for host debug */
11261 print_hex_dump(KERN_DEBUG,
11262 "\t Properly Aligned and Copied Data:@@@@ ",
11263 DUMP_PREFIX_NONE,
11264 16, 1, data_aligned, param->data_len, true);
11265
11266 /* converting to little Endian both key_aligned and
11267 * data_aligned*/
11268 for (c = 0; c < param->key_len/4; c++) {
11269 *((u_int32_t *)key_aligned+c) =
11270 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
11271 }
11272 for (c = 0; c < param->data_len/4; c++) {
11273 *((u_int32_t *)data_aligned+c) =
11274 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
11275 }
11276
11277 /* update endian data to key and data vectors */
11278 OS_MEMCPY(param->key, key_aligned, param->key_len);
11279 OS_MEMCPY(param->data, data_aligned, param->data_len);
11280
11281 /* clean up allocated spaces */
11282 qdf_mem_free(key_unaligned);
11283 key_unaligned = NULL;
11284 key_aligned = NULL;
11285
11286 qdf_mem_free(data_unaligned);
11287 data_unaligned = NULL;
11288 data_aligned = NULL;
11289
11290 return QDF_STATUS_SUCCESS;
11291}
11292#else
11293/**
11294* fips_align_data_be() - DUMMY for LE platform
11295*
11296* Return: QDF_STATUS - success
11297*/
11298static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
11299 struct fips_params *param)
11300{
11301 return QDF_STATUS_SUCCESS;
11302}
11303#endif
11304
11305
11306/**
11307 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
11308 * @wmi_handle: wmi handle
11309 * @param: pointer to hold pdev fips param
11310 *
11311 * Return: 0 for success or error code
11312 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011313static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011314send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
11315 struct fips_params *param)
11316{
11317 wmi_pdev_fips_cmd_fixed_param *cmd;
11318 wmi_buf_t buf;
11319 uint8_t *buf_ptr;
11320 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
11321 QDF_STATUS retval = QDF_STATUS_SUCCESS;
11322
11323 /* Length TLV placeholder for array of bytes */
11324 len += WMI_TLV_HDR_SIZE;
11325 if (param->data_len)
11326 len += (param->data_len*sizeof(uint8_t));
11327
11328 /*
11329 * Data length must be multiples of 16 bytes - checked against 0xF -
11330 * and must be less than WMI_SVC_MSG_SIZE - static size of
11331 * wmi_pdev_fips_cmd structure
11332 */
11333
11334 /* do sanity on the input */
11335 if (!(((param->data_len & 0xF) == 0) &&
11336 ((param->data_len > 0) &&
11337 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
11338 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
11339 return QDF_STATUS_E_INVAL;
11340 }
11341
11342 buf = wmi_buf_alloc(wmi_handle, len);
11343 if (!buf) {
11344 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
11345 return QDF_STATUS_E_FAILURE;
11346 }
11347
11348 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11349 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
11350 WMITLV_SET_HDR(&cmd->tlv_header,
11351 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
11352 WMITLV_GET_STRUCT_TLVLEN
11353 (wmi_pdev_fips_cmd_fixed_param));
11354
11355 cmd->pdev_id = param->pdev_id;
11356 if (param->key != NULL && param->data != NULL) {
11357 cmd->key_len = param->key_len;
11358 cmd->data_len = param->data_len;
11359 cmd->fips_cmd = !!(param->op);
11360
11361 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
11362 return QDF_STATUS_E_FAILURE;
11363
11364 qdf_mem_copy(cmd->key, param->key, param->key_len);
11365
11366 if (param->mode == FIPS_ENGINE_AES_CTR ||
11367 param->mode == FIPS_ENGINE_AES_MIC) {
11368 cmd->mode = param->mode;
11369 } else {
11370 cmd->mode = FIPS_ENGINE_AES_CTR;
11371 }
11372 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
11373 cmd->key_len, cmd->data_len);
11374
11375 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
11376 cmd->key, cmd->key_len, true);
11377 buf_ptr += sizeof(*cmd);
11378
11379 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
11380
11381 buf_ptr += WMI_TLV_HDR_SIZE;
11382 if (param->data_len)
11383 qdf_mem_copy(buf_ptr,
11384 (uint8_t *) param->data, param->data_len);
11385
11386 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
11387 16, 1, buf_ptr, cmd->data_len, true);
11388
11389 buf_ptr += param->data_len;
11390
11391 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11392 WMI_PDEV_FIPS_CMDID);
11393 qdf_print("%s return value %d\n", __func__, retval);
11394 } else {
11395 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
11396 wmi_buf_free(buf);
11397 retval = -QDF_STATUS_E_BADMSG;
11398 }
11399
11400 return retval;
11401}
11402
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011403#ifdef WLAN_PMO_ENABLE
11404/**
11405 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
11406 * @wmi_handle: wmi handle
11407 * @vdev_id: vdev id
11408 * @bitmap: Event bitmap
11409 * @enable: enable/disable
11410 *
11411 * Return: CDF status
11412 */
11413static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
11414 uint32_t vdev_id,
11415 uint32_t bitmap,
11416 bool enable)
11417{
11418 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
11419 uint16_t len;
11420 wmi_buf_t buf;
11421 int ret;
11422
11423 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
11424 buf = wmi_buf_alloc(wmi_handle, len);
11425 if (!buf) {
11426 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
11427 return QDF_STATUS_E_NOMEM;
11428 }
11429 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
11430 WMITLV_SET_HDR(&cmd->tlv_header,
11431 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
11432 WMITLV_GET_STRUCT_TLVLEN
11433 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
11434 cmd->vdev_id = vdev_id;
11435 cmd->is_add = enable;
11436 cmd->event_bitmap = bitmap;
11437
11438 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11439 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
11440 if (ret) {
11441 WMI_LOGE("Failed to config wow wakeup event");
11442 wmi_buf_free(buf);
11443 return QDF_STATUS_E_FAILURE;
11444 }
11445
11446 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
11447 enable ? "enabled" : "disabled");
11448
11449 return QDF_STATUS_SUCCESS;
11450}
11451
11452/**
11453 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
11454 * @wmi_handle: wmi handle
11455 * @vdev_id: vdev id
11456 * @ptrn_id: pattern id
11457 * @ptrn: pattern
11458 * @ptrn_len: pattern length
11459 * @ptrn_offset: pattern offset
11460 * @mask: mask
11461 * @mask_len: mask length
11462 * @user: true for user configured pattern and false for default pattern
11463 * @default_patterns: default patterns
11464 *
11465 * Return: CDF status
11466 */
11467static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
11468 uint8_t vdev_id, uint8_t ptrn_id,
11469 const uint8_t *ptrn, uint8_t ptrn_len,
11470 uint8_t ptrn_offset, const uint8_t *mask,
11471 uint8_t mask_len, bool user,
11472 uint8_t default_patterns)
11473{
11474 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
11475 WOW_BITMAP_PATTERN_T *bitmap_pattern;
11476 wmi_buf_t buf;
11477 uint8_t *buf_ptr;
11478 int32_t len;
11479 int ret;
11480
11481 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
11482 WMI_TLV_HDR_SIZE +
11483 1 * sizeof(WOW_BITMAP_PATTERN_T) +
11484 WMI_TLV_HDR_SIZE +
11485 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
11486 WMI_TLV_HDR_SIZE +
11487 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
11488 WMI_TLV_HDR_SIZE +
11489 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
11490 WMI_TLV_HDR_SIZE +
11491 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
11492
11493 buf = wmi_buf_alloc(wmi_handle, len);
11494 if (!buf) {
11495 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
11496 return QDF_STATUS_E_NOMEM;
11497 }
11498
11499 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
11500 buf_ptr = (uint8_t *) cmd;
11501
11502 WMITLV_SET_HDR(&cmd->tlv_header,
11503 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
11504 WMITLV_GET_STRUCT_TLVLEN
11505 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
11506 cmd->vdev_id = vdev_id;
11507 cmd->pattern_id = ptrn_id;
11508
11509 cmd->pattern_type = WOW_BITMAP_PATTERN;
11510 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
11511
11512 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11513 sizeof(WOW_BITMAP_PATTERN_T));
11514 buf_ptr += WMI_TLV_HDR_SIZE;
11515 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
11516
11517 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
11518 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
11519 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
11520
11521 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
11522 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
11523
11524 bitmap_pattern->pattern_offset = ptrn_offset;
11525 bitmap_pattern->pattern_len = ptrn_len;
11526
11527 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
11528 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
11529
11530 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
11531 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
11532
11533 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
11534 bitmap_pattern->pattern_id = ptrn_id;
11535
11536 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
11537 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
11538 bitmap_pattern->pattern_offset, user);
11539 WMI_LOGI("Pattern : ");
11540 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
11541 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
11542
11543 WMI_LOGI("Mask : ");
11544 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
11545 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
11546
11547 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
11548
11549 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
11550 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11551 buf_ptr += WMI_TLV_HDR_SIZE;
11552
11553 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
11554 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11555 buf_ptr += WMI_TLV_HDR_SIZE;
11556
11557 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
11558 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11559 buf_ptr += WMI_TLV_HDR_SIZE;
11560
11561 /* Fill TLV for pattern_info_timeout but no data. */
11562 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
11563 buf_ptr += WMI_TLV_HDR_SIZE;
11564
11565 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
11566 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
11567 buf_ptr += WMI_TLV_HDR_SIZE;
11568 *(A_UINT32 *) buf_ptr = 0;
11569
11570 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11571 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
11572 if (ret) {
11573 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
11574 wmi_buf_free(buf);
11575 return QDF_STATUS_E_FAILURE;
11576 }
11577
11578 return QDF_STATUS_SUCCESS;
11579}
11580
Govind Singha4836fd2016-03-07 16:45:38 +053011581/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011582 * fill_arp_offload_params_tlv() - Fill ARP offload data
11583 * @wmi_handle: wmi handle
11584 * @offload_req: offload request
11585 * @buf_ptr: buffer pointer
11586 *
11587 * To fill ARP offload data to firmware
11588 * when target goes to wow mode.
11589 *
11590 * Return: None
11591 */
11592static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011593 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011594{
11595
11596 int i;
11597 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011598 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011599
11600 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11601 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
11602 *buf_ptr += WMI_TLV_HDR_SIZE;
11603 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
11604 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
11605 WMITLV_SET_HDR(&arp_tuple->tlv_header,
11606 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
11607 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
11608
11609 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011610 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011611 /* Copy the target ip addr and flags */
11612 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
11613 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011614 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011615 WMI_IPV4_ADDR_LEN);
11616 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011617 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011618 }
11619 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
11620 }
11621}
11622
11623#ifdef WLAN_NS_OFFLOAD
11624/**
11625 * fill_ns_offload_params_tlv() - Fill NS offload data
11626 * @wmi|_handle: wmi handle
11627 * @offload_req: offload request
11628 * @buf_ptr: buffer pointer
11629 *
11630 * To fill NS offload data to firmware
11631 * when target goes to wow mode.
11632 *
11633 * Return: None
11634 */
11635static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011636 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011637{
11638
11639 int i;
11640 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011641
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011642 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11643 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
11644 *buf_ptr += WMI_TLV_HDR_SIZE;
11645 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
11646 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
11647 WMITLV_SET_HDR(&ns_tuple->tlv_header,
11648 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
11649 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
11650
11651 /*
11652 * Fill data only for NS offload in the first ARP tuple for LA
11653 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011654 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011655 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
11656 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011657 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011658 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011659 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011660 sizeof(WMI_IPV6_ADDR));
11661 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011662 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011663 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011664 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011665 ns_tuple->flags |=
11666 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
11667 }
11668 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011669 i, &ns_req->self_ipv6_addr[i],
11670 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011671
11672 /* target MAC is optional, check if it is valid,
11673 * if this is not valid, the target will use the known
11674 * local MAC address rather than the tuple
11675 */
11676 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011677 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011678 &ns_tuple->target_mac);
11679 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
11680 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
11681 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
11682 }
11683 }
11684 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
11685 }
11686}
11687
11688
11689/**
11690 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
11691 * @wmi: wmi handle
11692 * @offload_req: offload request
11693 * @buf_ptr: buffer pointer
11694 *
11695 * To fill extended NS offload extended data to firmware
11696 * when target goes to wow mode.
11697 *
11698 * Return: None
11699 */
11700static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011701 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011702{
11703 int i;
11704 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
11705 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011706
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011707 count = ns_req->num_ns_offload_count;
11708 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011709 WMI_MAX_NS_OFFLOADS;
11710
11711 /* Populate extended NS offload tuples */
11712 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11713 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
11714 *buf_ptr += WMI_TLV_HDR_SIZE;
11715 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
11716 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
11717 WMITLV_SET_HDR(&ns_tuple->tlv_header,
11718 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
11719 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
11720
11721 /*
11722 * Fill data only for NS offload in the first ARP tuple for LA
11723 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011724 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011725 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
11726 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011727 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011728 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011729 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011730 sizeof(WMI_IPV6_ADDR));
11731 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011732 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011733 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011734 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011735 ns_tuple->flags |=
11736 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
11737 }
11738 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011739 i, &ns_req->self_ipv6_addr[i],
11740 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011741
11742 /* target MAC is optional, check if it is valid,
11743 * if this is not valid, the target will use the
11744 * known local MAC address rather than the tuple
11745 */
11746 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011747 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011748 &ns_tuple->target_mac);
11749 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
11750 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
11751 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
11752 }
11753 }
11754 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
11755 }
11756}
11757#else
11758static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011759 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011760{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011761}
11762
11763static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011764 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011765{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011766}
11767#endif
11768
11769/**
Govind Singha4836fd2016-03-07 16:45:38 +053011770 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
11771 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011772 * @arp_offload_req: arp offload request
11773 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053011774 * @arp_only: flag
11775 *
11776 * To configure ARP NS off load data to firmware
11777 * when target goes to wow mode.
11778 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011779 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053011780 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011781static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011782 struct pmo_arp_offload_params *arp_offload_req,
11783 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053011784 uint8_t vdev_id)
11785{
Govind Singha4836fd2016-03-07 16:45:38 +053011786 int32_t res;
11787 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011788 A_UINT8 *buf_ptr;
11789 wmi_buf_t buf;
11790 int32_t len;
11791 uint32_t count = 0, num_ns_ext_tuples = 0;
11792
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011793 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053011794
Govind Singha4836fd2016-03-07 16:45:38 +053011795 /*
11796 * TLV place holder size for array of NS tuples
11797 * TLV place holder size for array of ARP tuples
11798 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011799 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
11800 WMI_TLV_HDR_SIZE +
11801 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
11802 WMI_TLV_HDR_SIZE +
11803 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053011804
11805 /*
11806 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
11807 * extra length for extended NS offload tuples which follows ARP offload
11808 * tuples. Host needs to fill this structure in following format:
11809 * 2 NS ofload tuples
11810 * 2 ARP offload tuples
11811 * N numbers of extended NS offload tuples if HDD has given more than
11812 * 2 NS offload addresses
11813 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011814 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053011815 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011816 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
11817 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053011818 }
11819
11820 buf = wmi_buf_alloc(wmi_handle, len);
11821 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011822 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053011823 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011824 }
11825
11826 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
11827 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
11828 WMITLV_SET_HDR(&cmd->tlv_header,
11829 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
11830 WMITLV_GET_STRUCT_TLVLEN
11831 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
11832 cmd->flags = 0;
11833 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011834 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053011835
Govind Singhb53420c2016-03-09 14:32:57 +053011836 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053011837
Govind Singha4836fd2016-03-07 16:45:38 +053011838 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011839 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
11840 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
11841 if (num_ns_ext_tuples)
11842 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053011843
11844 res = wmi_unified_cmd_send(wmi_handle, buf, len,
11845 WMI_SET_ARP_NS_OFFLOAD_CMDID);
11846 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053011847 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053011848 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011849 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011850 }
11851
Govind Singhb53420c2016-03-09 14:32:57 +053011852 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011853}
11854
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011855/**
11856 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
11857 * @wmi_handle: wmi handle
11858 * @vdev_id: vdev id
11859 * @action: true for enable else false
11860 *
11861 * To enable enhance multicast offload to firmware
11862 * when target goes to wow mode.
11863 *
11864 * Return: QDF Status
11865 */
11866
11867static
11868QDF_STATUS send_enable_enhance_multicast_offload_tlv(
11869 wmi_unified_t wmi_handle,
11870 uint8_t vdev_id, bool action)
11871{
11872 QDF_STATUS status;
11873 wmi_buf_t buf;
11874 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
11875
11876 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11877 if (!buf) {
11878 WMI_LOGE("Failed to allocate buffer to send set key cmd");
11879 return QDF_STATUS_E_NOMEM;
11880 }
11881
11882 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
11883 wmi_buf_data(buf);
11884
11885 WMITLV_SET_HDR(&cmd->tlv_header,
11886 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
11887 WMITLV_GET_STRUCT_TLVLEN(
11888 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
11889
11890 cmd->vdev_id = vdev_id;
11891 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
11892 ENHANCED_MCAST_FILTER_ENABLED);
11893 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
11894 __func__, action, vdev_id);
11895 status = wmi_unified_cmd_send(wmi_handle, buf,
11896 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
11897 if (status != QDF_STATUS_SUCCESS) {
11898 qdf_nbuf_free(buf);
11899 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
11900 __func__);
11901 }
11902
11903 return status;
11904}
11905
11906/**
11907 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
11908 * @wmi_handle: wmi handle
11909 * @param evt_buf: pointer to event buffer
11910 * @param hdr: Pointer to hold header
11911 * @param bufp: Pointer to hold pointer to rx param buffer
11912 *
11913 * Return: QDF_STATUS_SUCCESS for success or error code
11914 */
11915static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
11916 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
11917{
11918 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
11919 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
11920
11921 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
11922 if (!param_buf) {
11923 WMI_LOGE("gtk param_buf is NULL");
11924 return QDF_STATUS_E_INVAL;
11925 }
11926
11927 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
11928 WMI_LOGE("Invalid length for GTK status");
11929 return QDF_STATUS_E_INVAL;
11930 }
11931
11932 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
11933 param_buf->fixed_param;
11934 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
11935 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
11936 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
11937 qdf_mem_copy(&gtk_rsp_param->replay_counter,
11938 &fixed_param->replay_counter,
11939 GTK_REPLAY_COUNTER_BYTES);
11940
11941 return QDF_STATUS_SUCCESS;
11942
11943}
11944
11945#ifdef FEATURE_WLAN_RA_FILTERING
11946/**
11947 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
11948 * @wmi_handle: wmi handle
11949 * @vdev_id: vdev id
11950 *
11951 * Return: CDF status
11952 */
11953static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
11954 uint8_t vdev_id, uint8_t default_pattern,
11955 uint16_t rate_limit_interval)
11956{
11957
11958 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
11959 wmi_buf_t buf;
11960 uint8_t *buf_ptr;
11961 int32_t len;
11962 int ret;
11963
11964 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
11965 WMI_TLV_HDR_SIZE +
11966 0 * sizeof(WOW_BITMAP_PATTERN_T) +
11967 WMI_TLV_HDR_SIZE +
11968 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
11969 WMI_TLV_HDR_SIZE +
11970 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
11971 WMI_TLV_HDR_SIZE +
11972 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
11973 WMI_TLV_HDR_SIZE +
11974 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
11975
11976 buf = wmi_buf_alloc(wmi_handle, len);
11977 if (!buf) {
11978 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
11979 return QDF_STATUS_E_NOMEM;
11980 }
11981
11982 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
11983 buf_ptr = (uint8_t *) cmd;
11984
11985 WMITLV_SET_HDR(&cmd->tlv_header,
11986 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
11987 WMITLV_GET_STRUCT_TLVLEN
11988 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
11989 cmd->vdev_id = vdev_id;
11990 cmd->pattern_id = default_pattern,
11991 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
11992 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
11993
11994 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
11995 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11996 buf_ptr += WMI_TLV_HDR_SIZE;
11997
11998 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
11999 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12000 buf_ptr += WMI_TLV_HDR_SIZE;
12001
12002 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12003 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12004 buf_ptr += WMI_TLV_HDR_SIZE;
12005
12006 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12007 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12008 buf_ptr += WMI_TLV_HDR_SIZE;
12009
12010 /* Fill TLV for pattern_info_timeout but no data. */
12011 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12012 buf_ptr += WMI_TLV_HDR_SIZE;
12013
12014 /* Fill TLV for ra_ratelimit_interval. */
12015 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
12016 buf_ptr += WMI_TLV_HDR_SIZE;
12017
12018 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
12019
12020 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
12021 rate_limit_interval, vdev_id);
12022
12023 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12024 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12025 if (ret) {
12026 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
12027 wmi_buf_free(buf);
12028 return QDF_STATUS_E_FAILURE;
12029 }
12030
12031 return QDF_STATUS_SUCCESS;
12032
12033}
12034#endif /* FEATURE_WLAN_RA_FILTERING */
12035
12036/**
12037 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
12038 * @wmi_handle: wmi handle
12039 * @vdev_id: vdev id
12040 * @multicastAddr: mcast address
12041 * @clearList: clear list flag
12042 *
12043 * Return: QDF_STATUS_SUCCESS for success or error code
12044 */
12045static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
12046 uint8_t vdev_id,
12047 struct qdf_mac_addr multicast_addr,
12048 bool clearList)
12049{
12050 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
12051 wmi_buf_t buf;
12052 int err;
12053
12054 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12055 if (!buf) {
12056 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
12057 return QDF_STATUS_E_NOMEM;
12058 }
12059
12060 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
12061 qdf_mem_zero(cmd, sizeof(*cmd));
12062
12063 WMITLV_SET_HDR(&cmd->tlv_header,
12064 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
12065 WMITLV_GET_STRUCT_TLVLEN
12066 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
12067 cmd->action =
12068 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
12069 cmd->vdev_id = vdev_id;
12070 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
12071
12072 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
12073 cmd->action, vdev_id, clearList, multicast_addr.bytes);
12074
12075 err = wmi_unified_cmd_send(wmi_handle, buf,
12076 sizeof(*cmd),
12077 WMI_SET_MCASTBCAST_FILTER_CMDID);
12078 if (err) {
12079 WMI_LOGE("Failed to send set_param cmd");
12080 wmi_buf_free(buf);
12081 return QDF_STATUS_E_FAILURE;
12082 }
12083
12084 return QDF_STATUS_SUCCESS;
12085}
12086
12087/**
12088 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
12089 * @wmi_handle: wmi handle
12090 * @vdev_id: vdev id
12091 * @params: GTK offload parameters
12092 *
12093 * Return: CDF status
12094 */
12095static
12096QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
12097 struct pmo_gtk_req *params,
12098 bool enable_offload,
12099 uint32_t gtk_offload_opcode)
12100{
12101 int len;
12102 wmi_buf_t buf;
12103 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
12104 QDF_STATUS status = QDF_STATUS_SUCCESS;
12105
12106 WMI_LOGD("%s Enter", __func__);
12107
12108 len = sizeof(*cmd);
12109
12110 /* alloc wmi buffer */
12111 buf = wmi_buf_alloc(wmi_handle, len);
12112 if (!buf) {
12113 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
12114 status = QDF_STATUS_E_NOMEM;
12115 goto out;
12116 }
12117
12118 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
12119 WMITLV_SET_HDR(&cmd->tlv_header,
12120 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
12121 WMITLV_GET_STRUCT_TLVLEN
12122 (WMI_GTK_OFFLOAD_CMD_fixed_param));
12123
12124 cmd->vdev_id = vdev_id;
12125
12126 /* Request target to enable GTK offload */
12127 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
12128 cmd->flags = gtk_offload_opcode;
12129
12130 /* Copy the keys and replay counter */
12131 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
12132 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
12133 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
12134 GTK_REPLAY_COUNTER_BYTES);
12135 } else {
12136 cmd->flags = gtk_offload_opcode;
12137 }
12138
12139 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
12140
12141 /* send the wmi command */
12142 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12143 WMI_GTK_OFFLOAD_CMDID)) {
12144 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
12145 wmi_buf_free(buf);
12146 status = QDF_STATUS_E_FAILURE;
12147 }
12148
12149out:
12150 WMI_LOGD("%s Exit", __func__);
12151 return status;
12152}
12153
12154/**
12155 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
12156 * @wmi_handle: wmi handle
12157 * @params: GTK offload params
12158 *
12159 * Return: CDF status
12160 */
12161static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
12162 wmi_unified_t wmi_handle,
12163 uint8_t vdev_id,
12164 uint64_t offload_req_opcode)
12165{
12166 int len;
12167 wmi_buf_t buf;
12168 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
12169 QDF_STATUS status = QDF_STATUS_SUCCESS;
12170
12171 len = sizeof(*cmd);
12172
12173 /* alloc wmi buffer */
12174 buf = wmi_buf_alloc(wmi_handle, len);
12175 if (!buf) {
12176 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
12177 status = QDF_STATUS_E_NOMEM;
12178 goto out;
12179 }
12180
12181 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
12182 WMITLV_SET_HDR(&cmd->tlv_header,
12183 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
12184 WMITLV_GET_STRUCT_TLVLEN
12185 (WMI_GTK_OFFLOAD_CMD_fixed_param));
12186
12187 /* Request for GTK offload status */
12188 cmd->flags = offload_req_opcode;
12189 cmd->vdev_id = vdev_id;
12190
12191 /* send the wmi command */
12192 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12193 WMI_GTK_OFFLOAD_CMDID)) {
12194 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
12195 wmi_buf_free(buf);
12196 status = QDF_STATUS_E_FAILURE;
12197 }
12198
12199out:
12200 return status;
12201}
12202
12203/**
12204 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
12205 * @wmi_handle: wmi handler
12206 * @action_params: pointer to action_params
12207 *
12208 * Return: 0 for success, otherwise appropriate error code
12209 */
12210static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
12211 struct pmo_action_wakeup_set_params *action_params)
12212{
12213 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
12214 wmi_buf_t buf;
12215 int i;
12216 int32_t err;
12217
12218 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12219 if (!buf) {
12220 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
12221 return QDF_STATUS_E_NOMEM;
12222 }
12223 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
12224 WMITLV_SET_HDR(&cmd->tlv_header,
12225 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
12226 WMITLV_GET_STRUCT_TLVLEN(
12227 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
12228
12229 cmd->vdev_id = action_params->vdev_id;
12230 cmd->operation = action_params->operation;
12231
12232 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
12233 cmd->action_category_map[i] =
12234 action_params->action_category_map[i];
12235
12236 err = wmi_unified_cmd_send(wmi_handle, buf,
12237 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
12238 if (err) {
12239 WMI_LOGE("Failed to send ap_ps_egap cmd");
12240 wmi_buf_free(buf);
12241 return QDF_STATUS_E_FAILURE;
12242 }
12243
12244 return QDF_STATUS_SUCCESS;
12245}
12246
12247#ifdef FEATURE_WLAN_LPHB
12248
12249/**
12250 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
12251 * @wmi_handle: wmi handle
12252 * @lphb_conf_req: configuration info
12253 *
12254 * Return: CDF status
12255 */
12256static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
12257 wmi_hb_set_enable_cmd_fixed_param *params)
12258{
12259 QDF_STATUS status;
12260 wmi_buf_t buf = NULL;
12261 uint8_t *buf_ptr;
12262 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
12263 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
12264
12265
12266 buf = wmi_buf_alloc(wmi_handle, len);
12267 if (!buf) {
12268 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12269 return QDF_STATUS_E_NOMEM;
12270 }
12271
12272 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12273 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
12274 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
12275 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
12276 WMITLV_GET_STRUCT_TLVLEN
12277 (wmi_hb_set_enable_cmd_fixed_param));
12278
12279 /* fill in values */
12280 hb_enable_fp->vdev_id = params->session;
12281 hb_enable_fp->enable = params->enable;
12282 hb_enable_fp->item = params->item;
12283 hb_enable_fp->session = params->session;
12284
12285 status = wmi_unified_cmd_send(wmi_handle, buf,
12286 len, WMI_HB_SET_ENABLE_CMDID);
12287 if (QDF_IS_STATUS_ERROR(status)) {
12288 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
12289 status);
12290 wmi_buf_free(buf);
12291 }
12292
12293 return status;
12294}
12295
12296/**
12297 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
12298 * @wmi_handle: wmi handle
12299 * @lphb_conf_req: lphb config request
12300 *
12301 * Return: CDF status
12302 */
12303static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
12304 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
12305{
12306 QDF_STATUS status;
12307 wmi_buf_t buf = NULL;
12308 uint8_t *buf_ptr;
12309 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
12310 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
12311
12312 buf = wmi_buf_alloc(wmi_handle, len);
12313 if (!buf) {
12314 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12315 return QDF_STATUS_E_NOMEM;
12316 }
12317
12318 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12319 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
12320 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
12321 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
12322 WMITLV_GET_STRUCT_TLVLEN
12323 (wmi_hb_set_tcp_params_cmd_fixed_param));
12324
12325 /* fill in values */
12326 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
12327 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
12328 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
12329 hb_tcp_params_fp->seq = lphb_conf_req->seq;
12330 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
12331 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
12332 hb_tcp_params_fp->interval = lphb_conf_req->interval;
12333 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
12334 hb_tcp_params_fp->session = lphb_conf_req->session;
12335 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
12336 &lphb_conf_req->gateway_mac,
12337 sizeof(hb_tcp_params_fp->gateway_mac));
12338
12339 status = wmi_unified_cmd_send(wmi_handle, buf,
12340 len, WMI_HB_SET_TCP_PARAMS_CMDID);
12341 if (QDF_IS_STATUS_ERROR(status)) {
12342 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
12343 status);
12344 wmi_buf_free(buf);
12345 }
12346
12347 return status;
12348}
12349
12350/**
12351 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
12352 * @wmi_handle: wmi handle
12353 * @lphb_conf_req: lphb config request
12354 *
12355 * Return: CDF status
12356 */
12357static
12358QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
12359 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
12360{
12361 QDF_STATUS status;
12362 wmi_buf_t buf = NULL;
12363 uint8_t *buf_ptr;
12364 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
12365 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
12366
12367 buf = wmi_buf_alloc(wmi_handle, len);
12368 if (!buf) {
12369 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12370 return QDF_STATUS_E_NOMEM;
12371 }
12372
12373 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12374 hb_tcp_filter_fp =
12375 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
12376 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
12377 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
12378 WMITLV_GET_STRUCT_TLVLEN
12379 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
12380
12381 /* fill in values */
12382 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
12383 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
12384 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
12385 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
12386 memcpy((void *)&hb_tcp_filter_fp->filter,
12387 (void *)&g_hb_tcp_filter_fp->filter,
12388 WMI_WLAN_HB_MAX_FILTER_SIZE);
12389
12390 status = wmi_unified_cmd_send(wmi_handle, buf,
12391 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
12392 if (QDF_IS_STATUS_ERROR(status)) {
12393 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
12394 status);
12395 wmi_buf_free(buf);
12396 }
12397
12398 return status;
12399}
12400
12401/**
12402 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
12403 * @wmi_handle: wmi handle
12404 * @lphb_conf_req: lphb config request
12405 *
12406 * Return: CDF status
12407 */
12408static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
12409 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
12410{
12411 QDF_STATUS status;
12412 wmi_buf_t buf = NULL;
12413 uint8_t *buf_ptr;
12414 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
12415 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
12416
12417 buf = wmi_buf_alloc(wmi_handle, len);
12418 if (!buf) {
12419 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12420 return QDF_STATUS_E_NOMEM;
12421 }
12422
12423 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12424 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
12425 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
12426 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
12427 WMITLV_GET_STRUCT_TLVLEN
12428 (wmi_hb_set_udp_params_cmd_fixed_param));
12429
12430 /* fill in values */
12431 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
12432 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
12433 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
12434 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
12435 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
12436 hb_udp_params_fp->interval = lphb_conf_req->interval;
12437 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
12438 hb_udp_params_fp->session = lphb_conf_req->session;
12439 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
12440 &lphb_conf_req->gateway_mac,
12441 sizeof(lphb_conf_req->gateway_mac));
12442
12443 status = wmi_unified_cmd_send(wmi_handle, buf,
12444 len, WMI_HB_SET_UDP_PARAMS_CMDID);
12445 if (QDF_IS_STATUS_ERROR(status)) {
12446 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
12447 status);
12448 wmi_buf_free(buf);
12449 }
12450
12451 return status;
12452}
12453
12454/**
12455 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
12456 * @wmi_handle: wmi handle
12457 * @lphb_conf_req: lphb config request
12458 *
12459 * Return: CDF status
12460 */
12461static
12462QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
12463 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
12464{
12465 QDF_STATUS status;
12466 wmi_buf_t buf = NULL;
12467 uint8_t *buf_ptr;
12468 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
12469 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
12470
12471 buf = wmi_buf_alloc(wmi_handle, len);
12472 if (!buf) {
12473 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12474 return QDF_STATUS_E_NOMEM;
12475 }
12476
12477 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12478 hb_udp_filter_fp =
12479 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
12480 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
12481 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
12482 WMITLV_GET_STRUCT_TLVLEN
12483 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
12484
12485 /* fill in values */
12486 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
12487 hb_udp_filter_fp->length = lphb_conf_req->length;
12488 hb_udp_filter_fp->offset = lphb_conf_req->offset;
12489 hb_udp_filter_fp->session = lphb_conf_req->session;
12490 memcpy((void *)&hb_udp_filter_fp->filter,
12491 (void *)&lphb_conf_req->filter,
12492 WMI_WLAN_HB_MAX_FILTER_SIZE);
12493
12494 status = wmi_unified_cmd_send(wmi_handle, buf,
12495 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
12496 if (QDF_IS_STATUS_ERROR(status)) {
12497 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
12498 status);
12499 wmi_buf_free(buf);
12500 }
12501
12502 return status;
12503}
12504#endif /* FEATURE_WLAN_LPHB */
12505#endif /* End of WLAN_PMO_ENABLE */
12506
Sathish Kumarfd347372017-02-13 12:29:09 +053012507static QDF_STATUS send_enable_broadcast_filter_cmd_tlv(wmi_unified_t wmi_handle,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053012508 uint8_t vdev_id, bool enable)
12509{
12510 int32_t res;
12511 wmi_hw_data_filter_cmd_fixed_param *cmd;
12512 A_UINT8 *buf_ptr;
12513 wmi_buf_t buf;
12514 int32_t len;
12515
12516 /*
12517 * TLV place holder size for array of ARP tuples
12518 */
12519 len = sizeof(wmi_hw_data_filter_cmd_fixed_param);
12520
12521 buf = wmi_buf_alloc(wmi_handle, len);
12522 if (!buf) {
12523 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12524 return QDF_STATUS_E_NOMEM;
12525 }
12526
12527 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
12528 cmd = (wmi_hw_data_filter_cmd_fixed_param *) buf_ptr;
12529 WMITLV_SET_HDR(&cmd->tlv_header,
12530 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
12531 WMITLV_GET_STRUCT_TLVLEN
12532 (wmi_hw_data_filter_cmd_fixed_param));
12533 cmd->vdev_id = vdev_id;
12534 cmd->enable = enable;
12535 cmd->hw_filter_bitmap = WMI_HW_DATA_FILTER_DROP_NON_ARP_BC;
12536
12537 WMI_LOGD("HW Broadcast Filter vdev_id: %d", cmd->vdev_id);
12538
12539 res = wmi_unified_cmd_send(wmi_handle, buf, len,
12540 WMI_HW_DATA_FILTER_CMDID);
12541 if (res) {
12542 WMI_LOGE("Failed to enable ARP NDP/NSffload");
12543 wmi_buf_free(buf);
12544 return QDF_STATUS_E_FAILURE;
12545 }
12546
12547 return QDF_STATUS_SUCCESS;
12548}
12549
Govind Singha4836fd2016-03-07 16:45:38 +053012550/**
12551 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
12552 * @wmi_handle: wmi handle
12553 * @request: SSID hotlist set request
12554 *
Govind Singhb53420c2016-03-09 14:32:57 +053012555 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053012556 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012557static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053012558send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
12559 struct ssid_hotlist_request_params *request)
12560{
12561 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
12562 wmi_buf_t wmi_buf;
12563 uint32_t len;
12564 uint32_t array_size;
12565 uint8_t *buf_ptr;
12566
12567 /* length of fixed portion */
12568 len = sizeof(*cmd);
12569
12570 /* length of variable portion */
12571 array_size =
12572 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
12573 len += WMI_TLV_HDR_SIZE + array_size;
12574
12575 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12576 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012577 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12578 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012579 }
12580
12581 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
12582 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
12583 buf_ptr;
12584 WMITLV_SET_HDR
12585 (&cmd->tlv_header,
12586 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
12587 WMITLV_GET_STRUCT_TLVLEN
12588 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
12589
12590 cmd->request_id = request->request_id;
12591 cmd->requestor_id = 0;
12592 cmd->vdev_id = request->session_id;
12593 cmd->table_id = 0;
12594 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
12595 cmd->total_entries = request->ssid_count;
12596 cmd->num_entries_in_page = request->ssid_count;
12597 cmd->first_entry_index = 0;
12598
12599 buf_ptr += sizeof(*cmd);
12600 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
12601
12602 if (request->ssid_count) {
12603 wmi_extscan_hotlist_ssid_entry *entry;
12604 int i;
12605
12606 buf_ptr += WMI_TLV_HDR_SIZE;
12607 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
12608 for (i = 0; i < request->ssid_count; i++) {
12609 WMITLV_SET_HDR
12610 (entry,
12611 WMITLV_TAG_ARRAY_STRUC,
12612 WMITLV_GET_STRUCT_TLVLEN
12613 (wmi_extscan_hotlist_ssid_entry));
12614 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053012615 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053012616 request->ssids[i].ssid.mac_ssid,
12617 request->ssids[i].ssid.length);
12618 entry->band = request->ssids[i].band;
12619 entry->min_rssi = request->ssids[i].rssi_low;
12620 entry->max_rssi = request->ssids[i].rssi_high;
12621 entry++;
12622 }
12623 cmd->mode = WMI_EXTSCAN_MODE_START;
12624 } else {
12625 cmd->mode = WMI_EXTSCAN_MODE_STOP;
12626 }
12627
12628 if (wmi_unified_cmd_send
12629 (wmi_handle, wmi_buf, len,
12630 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012631 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053012632 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012633 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012634 }
12635
Govind Singhb53420c2016-03-09 14:32:57 +053012636 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012637}
12638
12639/**
12640 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
12641 * @wmi_handle: wmi handle
12642 * @vdev_id: vdev id
12643 *
12644 * This function sends roam synch complete event to fw.
12645 *
12646 * Return: CDF STATUS
12647 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012648static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012649 uint8_t vdev_id)
12650{
12651 wmi_roam_synch_complete_fixed_param *cmd;
12652 wmi_buf_t wmi_buf;
12653 uint8_t *buf_ptr;
12654 uint16_t len;
12655 len = sizeof(wmi_roam_synch_complete_fixed_param);
12656
12657 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12658 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012659 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12660 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012661 }
12662 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
12663 buf_ptr = (uint8_t *) cmd;
12664 WMITLV_SET_HDR(&cmd->tlv_header,
12665 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
12666 WMITLV_GET_STRUCT_TLVLEN
12667 (wmi_roam_synch_complete_fixed_param));
12668 cmd->vdev_id = vdev_id;
12669 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12670 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012671 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053012672 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012673 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012674 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012675 }
12676
Govind Singhb53420c2016-03-09 14:32:57 +053012677 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012678}
12679
12680/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053012681 * send_fw_test_cmd_tlv() - send fw test command to fw.
12682 * @wmi_handle: wmi handle
12683 * @wmi_fwtest: fw test command
12684 *
12685 * This function sends fw test command to fw.
12686 *
12687 * Return: CDF STATUS
12688 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012689static
Anurag Chouhan459e0152016-07-22 20:19:54 +053012690QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
12691 struct set_fwtest_params *wmi_fwtest)
12692{
12693 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12694 wmi_buf_t wmi_buf;
12695 uint16_t len;
12696
12697 len = sizeof(*cmd);
12698
12699 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12700 if (!wmi_buf) {
12701 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12702 return QDF_STATUS_E_NOMEM;
12703 }
12704
12705 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
12706 WMITLV_SET_HDR(&cmd->tlv_header,
12707 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12708 WMITLV_GET_STRUCT_TLVLEN(
12709 wmi_fwtest_set_param_cmd_fixed_param));
12710 cmd->param_id = wmi_fwtest->arg;
12711 cmd->param_value = wmi_fwtest->value;
12712
12713 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12714 WMI_FWTEST_CMDID)) {
12715 WMI_LOGP("%s: failed to send fw test command", __func__);
12716 qdf_nbuf_free(wmi_buf);
12717 return QDF_STATUS_E_FAILURE;
12718 }
12719
12720 return QDF_STATUS_SUCCESS;
12721}
12722
12723/**
Govind Singha4836fd2016-03-07 16:45:38 +053012724 * send_unit_test_cmd_tlv() - send unit test command to fw.
12725 * @wmi_handle: wmi handle
12726 * @wmi_utest: unit test command
12727 *
12728 * This function send unit test command to fw.
12729 *
12730 * Return: CDF STATUS
12731 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012732static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012733 struct wmi_unit_test_cmd *wmi_utest)
12734{
12735 wmi_unit_test_cmd_fixed_param *cmd;
12736 wmi_buf_t wmi_buf;
12737 uint8_t *buf_ptr;
12738 int i;
12739 uint16_t len, args_tlv_len;
12740 A_UINT32 *unit_test_cmd_args;
12741
12742 args_tlv_len =
12743 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
12744 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
12745
12746 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12747 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012748 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12749 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012750 }
12751
12752 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
12753 buf_ptr = (uint8_t *) cmd;
12754 WMITLV_SET_HDR(&cmd->tlv_header,
12755 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
12756 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
12757 cmd->vdev_id = wmi_utest->vdev_id;
12758 cmd->module_id = wmi_utest->module_id;
12759 cmd->num_args = wmi_utest->num_args;
12760 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
12761 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12762 (wmi_utest->num_args * sizeof(uint32_t)));
12763 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053012764 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053012765 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
12766 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053012767 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012768 }
12769 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12770 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012771 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012772 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012773 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012774 }
12775
Govind Singhb53420c2016-03-09 14:32:57 +053012776 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012777}
12778
12779/**
12780 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
12781 * @wmi_handle: wma handle
12782 * @roaminvoke: roam invoke command
12783 *
12784 * Send roam invoke command to fw for fastreassoc.
12785 *
12786 * Return: CDF STATUS
12787 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012788static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012789 struct wmi_roam_invoke_cmd *roaminvoke,
12790 uint32_t ch_hz)
12791{
12792 wmi_roam_invoke_cmd_fixed_param *cmd;
12793 wmi_buf_t wmi_buf;
12794 u_int8_t *buf_ptr;
12795 u_int16_t len, args_tlv_len;
12796 A_UINT32 *channel_list;
12797 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080012798 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053012799
12800 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080012801 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
12802 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
12803 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012804 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
12805 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12806 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012807 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12808 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012809 }
12810
12811 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
12812 buf_ptr = (u_int8_t *) cmd;
12813 WMITLV_SET_HDR(&cmd->tlv_header,
12814 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
12815 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
12816 cmd->vdev_id = roaminvoke->vdev_id;
12817 cmd->flags = 0;
Naveen Rawat77797922017-01-20 17:00:07 -080012818
12819 if (roaminvoke->frame_len)
12820 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
12821 else
12822 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
12823
Govind Singha4836fd2016-03-07 16:45:38 +053012824 cmd->roam_ap_sel_mode = 0;
12825 cmd->roam_delay = 0;
12826 cmd->num_chan = 1;
12827 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080012828 /* packing 1 beacon/probe_rsp frame with WMI cmd */
12829 cmd->num_buf = 1;
12830
Govind Singha4836fd2016-03-07 16:45:38 +053012831 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
12832 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12833 (sizeof(u_int32_t)));
12834 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
12835 *channel_list = ch_hz;
12836 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
12837 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
12838 (sizeof(wmi_mac_addr)));
12839 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
12840 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080012841
12842 /* move to next tlv i.e. bcn_prb_buf_list */
12843 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
12844
12845 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
12846 sizeof(wmi_tlv_buf_len_param));
12847
12848 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
12849 buf_len_tlv->buf_len = roaminvoke->frame_len;
12850
12851 /* move to next tlv i.e. bcn_prb_frm */
12852 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
12853 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
12854 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
12855
12856 /* copy frame after the header */
12857 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
12858 roaminvoke->frame_buf,
12859 roaminvoke->frame_len);
12860
12861 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
12862 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
12863 buf_ptr + WMI_TLV_HDR_SIZE,
12864 roaminvoke->frame_len);
12865
Govind Singha4836fd2016-03-07 16:45:38 +053012866 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12867 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012868 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053012869 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012870 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012871 }
12872
Govind Singhb53420c2016-03-09 14:32:57 +053012873 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012874}
12875
12876/**
12877 * send_roam_scan_offload_cmd_tlv() - set roam offload command
12878 * @wmi_handle: wmi handle
12879 * @command: command
12880 * @vdev_id: vdev id
12881 *
12882 * This function set roam offload command to fw.
12883 *
12884 * Return: CDF status
12885 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012886static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012887 uint32_t command, uint32_t vdev_id)
12888{
Govind Singh67922e82016-04-01 16:48:57 +053012889 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012890 wmi_roam_scan_cmd_fixed_param *cmd_fp;
12891 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053012892 int len;
12893 uint8_t *buf_ptr;
12894
12895 len = sizeof(wmi_roam_scan_cmd_fixed_param);
12896 buf = wmi_buf_alloc(wmi_handle, len);
12897 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012898 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12899 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012900 }
12901
12902 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12903
12904 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
12905 WMITLV_SET_HDR(&cmd_fp->tlv_header,
12906 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
12907 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
12908 cmd_fp->vdev_id = vdev_id;
12909 cmd_fp->command_arg = command;
12910
12911 status = wmi_unified_cmd_send(wmi_handle, buf,
12912 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053012913 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012914 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012915 status);
Govind Singha4836fd2016-03-07 16:45:38 +053012916 goto error;
12917 }
12918
Govind Singhb53420c2016-03-09 14:32:57 +053012919 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
12920 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012921
12922error:
12923 wmi_buf_free(buf);
12924
Govind Singh67922e82016-04-01 16:48:57 +053012925 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012926}
12927
12928/**
12929 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
12930 * @wmi_handle: wmi handle
12931 * @ap_profile_p: ap profile
12932 * @vdev_id: vdev id
12933 *
12934 * Send WMI_ROAM_AP_PROFILE to firmware
12935 *
12936 * Return: CDF status
12937 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012938static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012939 wmi_ap_profile *ap_profile_p,
12940 uint32_t vdev_id)
12941{
Govind Singha4836fd2016-03-07 16:45:38 +053012942 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012943 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012944 int len;
12945 uint8_t *buf_ptr;
12946 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
12947
12948 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
12949
12950 buf = wmi_buf_alloc(wmi_handle, len);
12951 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012952 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12953 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012954 }
12955
12956 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12957 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
12958 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
12959 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
12960 WMITLV_GET_STRUCT_TLVLEN
12961 (wmi_roam_ap_profile_fixed_param));
12962 /* fill in threshold values */
12963 roam_ap_profile_fp->vdev_id = vdev_id;
12964 roam_ap_profile_fp->id = 0;
12965 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
12966
Govind Singhb53420c2016-03-09 14:32:57 +053012967 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053012968 WMITLV_SET_HDR(buf_ptr,
12969 WMITLV_TAG_STRUC_wmi_ap_profile,
12970 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
12971 status = wmi_unified_cmd_send(wmi_handle, buf,
12972 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053012973 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012974 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012975 status);
Govind Singh67922e82016-04-01 16:48:57 +053012976 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012977 }
12978
Govind Singhb53420c2016-03-09 14:32:57 +053012979 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053012980
Govind Singh67922e82016-04-01 16:48:57 +053012981 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012982}
12983
12984/**
12985 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
12986 * @wmi_handle: wmi handle
12987 * @scan_period: scan period
12988 * @scan_age: scan age
12989 * @vdev_id: vdev id
12990 *
12991 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
12992 *
12993 * Return: CDF status
12994 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012995static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012996 uint32_t scan_period,
12997 uint32_t scan_age,
12998 uint32_t vdev_id)
12999{
Govind Singh67922e82016-04-01 16:48:57 +053013000 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013001 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053013002 int len;
13003 uint8_t *buf_ptr;
13004 wmi_roam_scan_period_fixed_param *scan_period_fp;
13005
13006 /* Send scan period values */
13007 len = sizeof(wmi_roam_scan_period_fixed_param);
13008 buf = wmi_buf_alloc(wmi_handle, len);
13009 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013010 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13011 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013012 }
13013
13014 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13015 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
13016 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
13017 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
13018 WMITLV_GET_STRUCT_TLVLEN
13019 (wmi_roam_scan_period_fixed_param));
13020 /* fill in scan period values */
13021 scan_period_fp->vdev_id = vdev_id;
13022 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
13023 scan_period_fp->roam_scan_age = scan_age;
13024
13025 status = wmi_unified_cmd_send(wmi_handle, buf,
13026 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053013027 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013028 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013029 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013030 goto error;
13031 }
13032
Govind Singhb53420c2016-03-09 14:32:57 +053013033 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013034 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053013035 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013036error:
13037 wmi_buf_free(buf);
13038
Govind Singh67922e82016-04-01 16:48:57 +053013039 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013040}
13041
13042/**
13043 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
13044 * @wmi_handle: wmi handle
13045 * @chan_count: channel count
13046 * @chan_list: channel list
13047 * @list_type: list type
13048 * @vdev_id: vdev id
13049 *
13050 * Set roam offload channel list.
13051 *
13052 * Return: CDF status
13053 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013054static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013055 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070013056 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053013057 uint8_t list_type, uint32_t vdev_id)
13058{
Govind Singha4836fd2016-03-07 16:45:38 +053013059 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013060 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013061 int len, list_tlv_len;
13062 int i;
13063 uint8_t *buf_ptr;
13064 wmi_roam_chan_list_fixed_param *chan_list_fp;
13065 A_UINT32 *roam_chan_list_array;
13066
13067 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053013068 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053013069 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053013070 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053013071 }
13072 /* Channel list is a table of 2 TLV's */
13073 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
13074 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
13075 buf = wmi_buf_alloc(wmi_handle, len);
13076 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013077 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13078 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013079 }
13080
13081 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13082 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
13083 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
13084 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
13085 WMITLV_GET_STRUCT_TLVLEN
13086 (wmi_roam_chan_list_fixed_param));
13087 chan_list_fp->vdev_id = vdev_id;
13088 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053013089 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053013090 /* external app is controlling channel list */
13091 chan_list_fp->chan_list_type =
13092 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
13093 } else {
13094 /* umac supplied occupied channel list in LFR */
13095 chan_list_fp->chan_list_type =
13096 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
13097 }
13098
13099 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
13100 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13101 (chan_list_fp->num_chan * sizeof(uint32_t)));
13102 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053013103 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053013104 for (i = 0; ((i < chan_list_fp->num_chan) &&
13105 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
13106 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053013107 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013108 }
13109
13110 status = wmi_unified_cmd_send(wmi_handle, buf,
13111 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053013112 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013113 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013114 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013115 goto error;
13116 }
13117
Govind Singhb53420c2016-03-09 14:32:57 +053013118 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
13119 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013120error:
13121 wmi_buf_free(buf);
13122
Govind Singh67922e82016-04-01 16:48:57 +053013123 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013124}
13125
13126/**
13127 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
13128 * @wmi_handle: wmi handle
13129 * @rssi_change_thresh: RSSI Change threshold
13130 * @bcn_rssi_weight: beacon RSSI weight
13131 * @vdev_id: vdev id
13132 *
13133 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
13134 *
13135 * Return: CDF status
13136 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013137static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013138 uint32_t vdev_id,
13139 int32_t rssi_change_thresh,
13140 uint32_t bcn_rssi_weight,
13141 uint32_t hirssi_delay_btw_scans)
13142{
Govind Singha4836fd2016-03-07 16:45:38 +053013143 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013144 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013145 int len;
13146 uint8_t *buf_ptr;
13147 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
13148
13149 /* Send rssi change parameters */
13150 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
13151 buf = wmi_buf_alloc(wmi_handle, len);
13152 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013153 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13154 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013155 }
13156
13157 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13158 rssi_change_fp =
13159 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
13160 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
13161 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
13162 WMITLV_GET_STRUCT_TLVLEN
13163 (wmi_roam_scan_rssi_change_threshold_fixed_param));
13164 /* fill in rssi change threshold (hysteresis) values */
13165 rssi_change_fp->vdev_id = vdev_id;
13166 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
13167 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
13168 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
13169
13170 status = wmi_unified_cmd_send(wmi_handle, buf,
13171 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053013172 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013173 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013174 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013175 goto error;
13176 }
13177
Govind Singhb53420c2016-03-09 14:32:57 +053013178 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053013179 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053013180 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
13181 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013182error:
13183 wmi_buf_free(buf);
13184
Govind Singh67922e82016-04-01 16:48:57 +053013185 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013186}
13187
13188/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
13189 * @wmi_handle: wmi handle.
13190 * @cmd: size of command structure.
13191 * @per_entry_size: per entry size.
13192 *
13193 * This utility function calculates how many hotlist entries can
13194 * fit in one page.
13195 *
13196 * Return: number of entries
13197 */
13198static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
13199 size_t cmd_size,
13200 size_t per_entry_size)
13201{
13202 uint32_t avail_space = 0;
13203 int num_entries = 0;
13204 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
13205
13206 /* Calculate number of hotlist entries that can
13207 * be passed in wma message request.
13208 */
13209 avail_space = max_msg_len - cmd_size;
13210 num_entries = avail_space / per_entry_size;
13211 return num_entries;
13212}
13213
13214/**
13215 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
13216 * @wmi_handle: wmi handle
13217 * @photlist: hotlist command params
13218 * @buf_len: buffer length
13219 *
13220 * This function fills individual elements for hotlist request and
13221 * TLV for bssid entries
13222 *
13223 * Return: CDF Status.
13224 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013225static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013226 struct ext_scan_setbssi_hotlist_params *
13227 photlist, int *buf_len)
13228{
13229 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
13230 wmi_extscan_hotlist_entry *dest_hotlist;
13231 struct ap_threshold_params *src_ap = photlist->ap;
13232 wmi_buf_t buf;
13233 uint8_t *buf_ptr;
13234
13235 int j, index = 0;
13236 int cmd_len = 0;
13237 int num_entries;
13238 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080013239 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053013240 int len = sizeof(*cmd);
13241
13242 len += WMI_TLV_HDR_SIZE;
13243 cmd_len = len;
13244
13245 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
13246 cmd_len,
13247 sizeof(*dest_hotlist));
13248 /* setbssid hotlist expects the bssid list
13249 * to be non zero value
13250 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080013251 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080013252 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053013253 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013254 }
13255
13256 /* Split the hot list entry pages and send multiple command
13257 * requests if the buffer reaches the maximum request size
13258 */
13259 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053013260 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053013261 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
13262 buf = wmi_buf_alloc(wmi_handle, len);
13263 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013264 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
13265 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013266 }
13267 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13268 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
13269 buf_ptr;
13270 WMITLV_SET_HDR(&cmd->tlv_header,
13271 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
13272 WMITLV_GET_STRUCT_TLVLEN
13273 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
13274
13275 /* Multiple requests are sent until the num_entries_in_page
13276 * matches the total_entries
13277 */
13278 cmd->request_id = photlist->requestId;
13279 cmd->vdev_id = photlist->sessionId;
13280 cmd->total_entries = numap;
13281 cmd->mode = 1;
13282 cmd->num_entries_in_page = min_entries;
13283 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
13284 cmd->first_entry_index = index;
13285
Govind Singhb53420c2016-03-09 14:32:57 +053013286 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013287 __func__, cmd->vdev_id, cmd->total_entries,
13288 cmd->num_entries_in_page,
13289 cmd->lost_ap_scan_count);
13290
13291 buf_ptr += sizeof(*cmd);
13292 WMITLV_SET_HDR(buf_ptr,
13293 WMITLV_TAG_ARRAY_STRUC,
13294 min_entries * sizeof(wmi_extscan_hotlist_entry));
13295 dest_hotlist = (wmi_extscan_hotlist_entry *)
13296 (buf_ptr + WMI_TLV_HDR_SIZE);
13297
13298 /* Populate bssid, channel info and rssi
13299 * for the bssid's that are sent as hotlists.
13300 */
13301 for (j = 0; j < min_entries; j++) {
13302 WMITLV_SET_HDR(dest_hotlist,
13303 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
13304 WMITLV_GET_STRUCT_TLVLEN
13305 (wmi_extscan_hotlist_entry));
13306
13307 dest_hotlist->min_rssi = src_ap->low;
13308 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
13309 &dest_hotlist->bssid);
13310
Govind Singhb53420c2016-03-09 14:32:57 +053013311 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013312 __func__, dest_hotlist->channel,
13313 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053013314 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053013315 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
13316 __func__, dest_hotlist->bssid.mac_addr31to0,
13317 dest_hotlist->bssid.mac_addr47to32);
13318 dest_hotlist++;
13319 src_ap++;
13320 }
13321 buf_ptr += WMI_TLV_HDR_SIZE +
13322 (min_entries * sizeof(wmi_extscan_hotlist_entry));
13323
13324 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13325 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013326 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013327 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013328 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013329 }
13330 index = index + min_entries;
13331 num_entries = numap - min_entries;
13332 len = cmd_len;
13333 }
Govind Singhb53420c2016-03-09 14:32:57 +053013334 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013335}
13336
Govind Singhbca3b1b2016-05-02 17:59:24 +053013337/**
13338 * send_power_dbg_cmd_tlv() - send power debug commands
13339 * @wmi_handle: wmi handle
13340 * @param: wmi power debug parameter
13341 *
13342 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
13343 *
13344 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
13345 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013346static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
13347 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053013348{
13349 wmi_buf_t buf = NULL;
13350 QDF_STATUS status;
13351 int len, args_tlv_len;
13352 uint8_t *buf_ptr;
13353 uint8_t i;
13354 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
13355 uint32_t *cmd_args;
13356
13357 /* Prepare and send power debug cmd parameters */
13358 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
13359 len = sizeof(*cmd) + args_tlv_len;
13360 buf = wmi_buf_alloc(wmi_handle, len);
13361 if (!buf) {
13362 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13363 return QDF_STATUS_E_NOMEM;
13364 }
13365
13366 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13367 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
13368 WMITLV_SET_HDR(&cmd->tlv_header,
13369 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
13370 WMITLV_GET_STRUCT_TLVLEN
13371 (wmi_pdev_wal_power_debug_cmd_fixed_param));
13372
13373 cmd->pdev_id = param->pdev_id;
13374 cmd->module_id = param->module_id;
13375 cmd->num_args = param->num_args;
13376 buf_ptr += sizeof(*cmd);
13377 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13378 (param->num_args * sizeof(uint32_t)));
13379 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13380 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
13381 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
13382 cmd_args[i] = param->args[i];
13383 WMI_LOGI("%d,", param->args[i]);
13384 }
13385
13386 status = wmi_unified_cmd_send(wmi_handle, buf,
13387 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
13388 if (QDF_IS_STATUS_ERROR(status)) {
13389 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
13390 status);
13391 goto error;
13392 }
13393
13394 return QDF_STATUS_SUCCESS;
13395error:
13396 wmi_buf_free(buf);
13397
13398 return status;
13399}
13400
Kiran Venkatappa26117052016-12-23 19:58:54 +053013401/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13402 * @buf_ptr: pointer to current position in init command buffer
13403 * @len: pointer to length. This will be updated with current lenght of cmd
13404 * @param: point host parameters for init command
13405 *
13406 * Return: Updated pointer of buf_ptr.
13407 */
13408static inline uint8_t *copy_hw_mode_in_init_cmd(uint8_t *buf_ptr,
13409 int *len, struct wmi_init_cmd_param *param)
13410{
13411 uint16_t idx;
13412
13413 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13414 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13415 wmi_pdev_band_to_mac *band_to_mac;
13416
13417 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13418 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13419 sizeof(wmi_resource_config) +
13420 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13421 sizeof(wlan_host_memory_chunk)));
13422
13423 WMITLV_SET_HDR(&hw_mode->tlv_header,
13424 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13425 (WMITLV_GET_STRUCT_TLVLEN
13426 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13427
13428 hw_mode->hw_mode_index = param->hw_mode_id;
13429 hw_mode->num_band_to_mac = param->num_band_to_mac;
13430
13431 buf_ptr = (uint8_t *) (hw_mode + 1);
13432 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13433 WMI_TLV_HDR_SIZE);
13434 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13435 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13436 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13437 WMITLV_GET_STRUCT_TLVLEN
13438 (wmi_pdev_band_to_mac));
13439 band_to_mac[idx].pdev_id =
13440 param->band_to_mac[idx].pdev_id;
13441 band_to_mac[idx].start_freq =
13442 param->band_to_mac[idx].start_freq;
13443 band_to_mac[idx].end_freq =
13444 param->band_to_mac[idx].end_freq;
13445 }
13446 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13447 (param->num_band_to_mac *
13448 sizeof(wmi_pdev_band_to_mac)) +
13449 WMI_TLV_HDR_SIZE;
13450
13451 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13452 (param->num_band_to_mac *
13453 sizeof(wmi_pdev_band_to_mac)));
13454 }
13455
13456 return buf_ptr;
13457}
13458
Govind Singhe7f2f342016-05-23 12:12:52 +053013459/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053013460 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
13461 * @wmi_handle: wmi handle
13462 * @param: wmi multiple vdev restart req param
13463 *
13464 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
13465 *
13466 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
13467 */
13468static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
13469 wmi_unified_t wmi_handle,
13470 struct multiple_vdev_restart_params *param)
13471{
13472 wmi_buf_t buf;
13473 QDF_STATUS qdf_status;
13474 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
13475 int i;
13476 uint8_t *buf_ptr;
13477 uint32_t *vdev_ids;
13478 wmi_channel *chan_info;
13479 struct channel_param *tchan_info;
13480 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
13481
13482 len += sizeof(wmi_channel);
13483 if (param->num_vdevs)
13484 len += sizeof(uint32_t) * param->num_vdevs;
13485
13486 buf = wmi_buf_alloc(wmi_handle, len);
13487 if (!buf) {
13488 WMI_LOGE("Failed to allocate memory\n");
13489 qdf_status = QDF_STATUS_E_NOMEM;
13490 goto end;
13491 }
13492
13493 buf_ptr = (uint8_t *)wmi_buf_data(buf);
13494 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
13495 buf_ptr;
13496
13497 WMITLV_SET_HDR(&cmd->tlv_header,
13498 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
13499 WMITLV_GET_STRUCT_TLVLEN
13500 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
13501 cmd->pdev_id = param->pdev_id;
13502 cmd->requestor_id = param->requestor_id;
13503 cmd->disable_hw_ack = param->disable_hw_ack;
13504 cmd->cac_duration_ms = param->cac_duration_ms;
13505 cmd->num_vdevs = param->num_vdevs;
13506
13507 buf_ptr += sizeof(*cmd);
13508
13509 WMITLV_SET_HDR(buf_ptr,
13510 WMITLV_TAG_ARRAY_UINT32,
13511 sizeof(A_UINT32) * param->num_vdevs);
13512 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
13513 for (i = 0; i < param->num_vdevs; i++) {
13514 vdev_ids[i] = param->vdev_ids[i];
13515 }
13516
13517 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
13518
13519 WMITLV_SET_HDR(buf_ptr,
13520 WMITLV_TAG_STRUC_wmi_channel,
13521 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
13522 chan_info = (wmi_channel *)(buf_ptr + WMI_TLV_HDR_SIZE);
13523 tchan_info = &(param->ch_param);
13524 chan_info->mhz = tchan_info->mhz;
13525 chan_info->band_center_freq1 = tchan_info->cfreq1;
13526 chan_info->band_center_freq2 = tchan_info->cfreq2;
13527 if (tchan_info->is_chan_passive)
13528 WMI_SET_CHANNEL_FLAG(chan_info,
13529 WMI_CHAN_FLAG_PASSIVE);
13530 if (tchan_info->allow_vht)
13531 WMI_SET_CHANNEL_FLAG(chan_info,
13532 WMI_CHAN_FLAG_ALLOW_VHT);
13533 else if (tchan_info->allow_ht)
13534 WMI_SET_CHANNEL_FLAG(chan_info,
13535 WMI_CHAN_FLAG_ALLOW_HT);
13536 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
13537 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
13538 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
13539 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
13540 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
13541 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
13542
13543 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
13544 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
13545
13546 if (QDF_IS_STATUS_ERROR(qdf_status)) {
13547 WMI_LOGE("%s: Failed to send\n", __func__);
13548 wmi_buf_free(buf);
13549 }
13550
13551end:
13552 return qdf_status;
13553}
13554
13555/**
Govind Singhe7f2f342016-05-23 12:12:52 +053013556 * init_cmd_send_tlv() - send initialization cmd to fw
13557 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053013558 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053013559 *
13560 * Return: QDF_STATUS_SUCCESS for success or error code
13561 */
13562static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053013563 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053013564{
13565 wmi_buf_t buf;
13566 wmi_init_cmd_fixed_param *cmd;
13567 wmi_abi_version my_vers;
13568 int num_whitelist;
13569 uint8_t *buf_ptr;
13570 wmi_resource_config *resource_cfg;
13571 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053013572 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053013573 uint16_t idx;
13574 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053013575 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053013576
Kiran Venkatappa26117052016-12-23 19:58:54 +053013577 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
13578 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053013579 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053013580
13581 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
13582 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13583 WMI_TLV_HDR_SIZE +
13584 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
13585
13586 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053013587 if (!buf) {
13588 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13589 return QDF_STATUS_E_FAILURE;
13590 }
13591
13592 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13593 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
13594 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
13595
13596 host_mem_chunks = (wlan_host_memory_chunk *)
13597 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
13598 + WMI_TLV_HDR_SIZE);
13599
13600 WMITLV_SET_HDR(&cmd->tlv_header,
13601 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
13602 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
13603
Kiran Venkatappa26117052016-12-23 19:58:54 +053013604 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053013605 WMITLV_SET_HDR(&resource_cfg->tlv_header,
13606 WMITLV_TAG_STRUC_wmi_resource_config,
13607 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
13608
Kiran Venkatappa26117052016-12-23 19:58:54 +053013609 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053013610 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
13611 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
13612 WMITLV_GET_STRUCT_TLVLEN
13613 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053013614 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
13615 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
13616 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053013617 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
13618 idx, host_mem_chunks[idx].size,
13619 host_mem_chunks[idx].ptr);
13620 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053013621 cmd->num_host_mem_chunks = param->num_mem_chunks;
13622 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
13623
Govind Singhe7f2f342016-05-23 12:12:52 +053013624 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
13625 WMITLV_TAG_ARRAY_STRUC,
13626 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053013627 param->num_mem_chunks));
13628
13629 /* Fill hw mode id config */
13630 buf_ptr = copy_hw_mode_in_init_cmd(buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053013631
13632 num_whitelist = sizeof(version_whitelist) /
13633 sizeof(wmi_whitelist_version_info);
13634 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13635 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13636 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13637 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13638 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13639 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13640
Govind Singh87542482016-06-08 19:40:11 +053013641#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013642 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13643 &my_vers,
13644 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13645 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053013646#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053013647 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13648 __func__,
13649 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13650 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13651 cmd->host_abi_vers.abi_version_ns_0,
13652 cmd->host_abi_vers.abi_version_ns_1,
13653 cmd->host_abi_vers.abi_version_ns_2,
13654 cmd->host_abi_vers.abi_version_ns_3);
13655
13656 /* Save version sent from host -
13657 * Will be used to check ready event
13658 */
Govind Singh87542482016-06-08 19:40:11 +053013659#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013660 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13661 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053013662#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053013663 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
13664 if (QDF_IS_STATUS_ERROR(ret)) {
13665 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
13666 ret);
13667 wmi_buf_free(buf);
13668 }
13669 return ret;
13670
Govind Singhe7f2f342016-05-23 12:12:52 +053013671}
13672
13673/**
13674 * save_service_bitmap_tlv() - save service bitmap
13675 * @wmi_handle: wmi handle
13676 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080013677 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053013678 *
13679 * Return: None
13680 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013681#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013682static
Rajeev Kumar77901472017-02-12 02:12:17 -080013683void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
13684 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053013685{
13686 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13687 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13688
13689 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
13690 param_buf->wmi_service_bitmap,
13691 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080013692
13693 if (bitmap_buf)
13694 qdf_mem_copy(bitmap_buf,
13695 param_buf->wmi_service_bitmap,
13696 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053013697}
13698#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013699static
Rajeev Kumar77901472017-02-12 02:12:17 -080013700void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
13701 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053013702{
Rajeev Kumar77901472017-02-12 02:12:17 -080013703 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13704 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053013705
Rajeev Kumar77901472017-02-12 02:12:17 -080013706 if (bitmap_buf)
13707 qdf_mem_copy(bitmap_buf,
13708 param_buf->wmi_service_bitmap,
13709 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
13710}
Govind Singhe7f2f342016-05-23 12:12:52 +053013711#endif
13712
13713/**
13714 * is_service_enabled_tlv() - Check if service enabled
13715 * @param wmi_handle: wmi handle
13716 * @param service_id: service identifier
13717 *
13718 * Return: 1 enabled, 0 disabled
13719 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013720#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013721static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
13722 uint32_t service_id)
13723{
13724 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
13725 service_id);
13726}
13727#else
13728static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
13729 uint32_t service_id)
13730{
13731 return false;
13732}
13733#endif
13734
13735/**
13736 * extract_service_ready_tlv() - extract service ready event
13737 * @wmi_handle: wmi handle
13738 * @param evt_buf: pointer to received event buffer
13739 * @param cap: pointer to hold target capability information extracted from even
13740 *
13741 * Return: QDF_STATUS_SUCCESS for success or error code
13742 */
13743static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080013744 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053013745{
13746 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13747 wmi_service_ready_event_fixed_param *ev;
13748
13749
13750 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13751
13752 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13753 if (!ev) {
13754 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13755 return QDF_STATUS_E_FAILURE;
13756 }
13757
13758 cap->phy_capability = ev->phy_capability;
13759 cap->max_frag_entry = ev->max_frag_entry;
13760 cap->num_rf_chains = ev->num_rf_chains;
13761 cap->ht_cap_info = ev->ht_cap_info;
13762 cap->vht_cap_info = ev->vht_cap_info;
13763 cap->vht_supp_mcs = ev->vht_supp_mcs;
13764 cap->hw_min_tx_power = ev->hw_min_tx_power;
13765 cap->hw_max_tx_power = ev->hw_max_tx_power;
13766 cap->sys_cap_info = ev->sys_cap_info;
13767 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
13768 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
13769 cap->max_num_scan_channels = ev->max_num_scan_channels;
13770 cap->max_supported_macs = ev->max_supported_macs;
13771 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
13772 cap->txrx_chainmask = ev->txrx_chainmask;
13773 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
13774 cap->num_msdu_desc = ev->num_msdu_desc;
13775
13776 return QDF_STATUS_SUCCESS;
13777}
13778
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053013779/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
13780 * to host internal WMI_HOST_REGDMN_MODE values.
13781 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
13782 * host currently. Add this in the future if required.
13783 * 11AX (Phase II) : 11ax related values are not currently
13784 * advertised separately by FW. As part of phase II regulatory bring-up,
13785 * finalize the advertisement mechanism.
13786 * @target_wireless_mode: target wireless mode received in message
13787 *
13788 * Return: returns the host internal wireless mode.
13789 */
13790static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
13791{
13792
13793 uint32_t wireless_modes = 0;
13794
13795 if (target_wireless_mode & REGDMN_MODE_11A)
13796 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
13797
13798 if (target_wireless_mode & REGDMN_MODE_TURBO)
13799 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
13800
13801 if (target_wireless_mode & REGDMN_MODE_11B)
13802 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
13803
13804 if (target_wireless_mode & REGDMN_MODE_PUREG)
13805 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
13806
13807 if (target_wireless_mode & REGDMN_MODE_11G)
13808 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
13809
13810 if (target_wireless_mode & REGDMN_MODE_108G)
13811 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
13812
13813 if (target_wireless_mode & REGDMN_MODE_108A)
13814 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
13815
13816 if (target_wireless_mode & REGDMN_MODE_XR)
13817 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
13818
13819 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
13820 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
13821
13822 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
13823 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
13824
13825 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
13826 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
13827
13828 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
13829 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
13830
13831 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
13832 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
13833
13834 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
13835 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
13836
13837 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
13838 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
13839
13840 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
13841 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
13842
13843 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
13844 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
13845
13846 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
13847 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
13848
13849 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
13850 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
13851
13852 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
13853 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
13854
13855 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
13856 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
13857
13858 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
13859 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
13860
13861 return wireless_modes;
13862}
13863
Govind Singhe7f2f342016-05-23 12:12:52 +053013864/**
13865 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
13866 * @wmi_handle: wmi handle
13867 * @param evt_buf: Pointer to event buffer
13868 * @param cap: pointer to hold HAL reg capabilities
13869 *
13870 * Return: QDF_STATUS_SUCCESS for success or error code
13871 */
13872static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080013873 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053013874{
13875 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13876
13877 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13878
13879 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
13880 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080013881 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053013882
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053013883 cap->wireless_modes = convert_wireless_modes_tlv(
13884 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053013885
Govind Singhe7f2f342016-05-23 12:12:52 +053013886 return QDF_STATUS_SUCCESS;
13887}
13888
13889/**
13890 * extract_host_mem_req_tlv() - Extract host memory request event
13891 * @wmi_handle: wmi handle
13892 * @param evt_buf: pointer to event buffer
13893 * @param num_entries: pointer to hold number of entries requested
13894 *
13895 * Return: Number of entries requested
13896 */
13897static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
13898 void *evt_buf, uint8_t *num_entries)
13899{
13900 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13901 wmi_service_ready_event_fixed_param *ev;
13902
13903 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13904
13905 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13906 if (!ev) {
13907 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13908 return NULL;
13909 }
13910
13911 *num_entries = ev->num_mem_reqs;
13912
13913 return (host_mem_req *)param_buf->mem_reqs;
13914}
13915
13916/**
13917 * save_fw_version_in_service_ready_tlv() - Save fw version in service
13918 * ready function
13919 * @wmi_handle: wmi handle
13920 * @param evt_buf: pointer to event buffer
13921 *
13922 * Return: QDF_STATUS_SUCCESS for success or error code
13923 */
13924static QDF_STATUS
13925save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
13926{
13927 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13928 wmi_service_ready_event_fixed_param *ev;
13929
13930
13931 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13932
13933 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13934 if (!ev) {
13935 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13936 return QDF_STATUS_E_FAILURE;
13937 }
13938
Govind Singh87542482016-06-08 19:40:11 +053013939#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013940 /*Save fw version from service ready message */
13941 /*This will be used while sending INIT message */
13942 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
13943 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053013944#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053013945 return QDF_STATUS_SUCCESS;
13946}
13947
13948/**
13949 * ready_extract_init_status_tlv() - Extract init status from ready event
13950 * @wmi_handle: wmi handle
13951 * @param evt_buf: Pointer to event buffer
13952 *
13953 * Return: ready status
13954 */
13955static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
13956 void *evt_buf)
13957{
13958 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13959 wmi_ready_event_fixed_param *ev = NULL;
13960
13961
13962 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13963 ev = param_buf->fixed_param;
13964
13965 qdf_print("%s:%d\n", __func__, ev->status);
13966
13967 return ev->status;
13968}
13969
13970/**
13971 * ready_extract_mac_addr_tlv() - extract mac address from ready event
13972 * @wmi_handle: wmi handle
13973 * @param evt_buf: pointer to event buffer
13974 * @param macaddr: Pointer to hold MAC address
13975 *
13976 * Return: QDF_STATUS_SUCCESS for success or error code
13977 */
13978static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
13979 void *evt_buf, uint8_t *macaddr)
13980{
13981 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13982 wmi_ready_event_fixed_param *ev = NULL;
13983
13984
13985 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13986 ev = param_buf->fixed_param;
13987
13988 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
13989
13990 return QDF_STATUS_SUCCESS;
13991}
13992
13993/**
13994 * extract_dbglog_data_len_tlv() - extract debuglog data length
13995 * @wmi_handle: wmi handle
13996 * @param evt_buf: pointer to event buffer
13997 *
13998 * Return: length
13999 */
14000static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080014001 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053014002{
14003 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
14004
14005 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
14006
14007 *len = param_buf->num_bufp;
14008
14009 return param_buf->bufp;
14010}
14011
14012/**
14013 * extract_vdev_start_resp_tlv() - extract vdev start response
14014 * @wmi_handle: wmi handle
14015 * @param evt_buf: pointer to event buffer
14016 * @param vdev_rsp: Pointer to hold vdev response
14017 *
14018 * Return: QDF_STATUS_SUCCESS for success or error code
14019 */
14020static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
14021 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
14022{
14023 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
14024 wmi_vdev_start_response_event_fixed_param *ev;
14025
14026 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
14027 if (!param_buf) {
14028 qdf_print("Invalid start response event buffer\n");
14029 return QDF_STATUS_E_INVAL;
14030 }
14031
14032 ev = param_buf->fixed_param;
14033 if (!ev) {
14034 qdf_print("Invalid start response event buffer\n");
14035 return QDF_STATUS_E_INVAL;
14036 }
14037
14038 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
14039
14040 vdev_rsp->vdev_id = ev->vdev_id;
14041 vdev_rsp->requestor_id = ev->requestor_id;
14042 vdev_rsp->resp_type = ev->resp_type;
14043 vdev_rsp->status = ev->status;
14044 vdev_rsp->chain_mask = ev->chain_mask;
14045 vdev_rsp->smps_mode = ev->smps_mode;
14046 vdev_rsp->mac_id = ev->mac_id;
14047 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
14048 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
14049
14050 return QDF_STATUS_SUCCESS;
14051}
14052
14053/**
14054 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
14055 * @wmi_handle: wmi handle
14056 * @param evt_buf: pointer to event buffer
14057 * @param vdev_map: Pointer to hold vdev map
14058 * @param tbttoffset_list: Pointer to tbtt offset list
14059 *
14060 * Return: QDF_STATUS_SUCCESS for success or error code
14061 */
14062static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
14063 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
14064{
14065 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
14066 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
14067
14068 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
14069 if (!param_buf) {
14070 qdf_print("Invalid tbtt update event buffer\n");
14071 return QDF_STATUS_E_INVAL;
14072 }
14073 tbtt_offset_event = param_buf->fixed_param;
14074
14075 *vdev_map = tbtt_offset_event->vdev_map;
14076 *tbttoffset_list = param_buf->tbttoffset_list;
14077
14078 return QDF_STATUS_SUCCESS;
14079}
14080
14081/**
14082 * extract_mgmt_rx_params_tlv() - extract management rx params from event
14083 * @wmi_handle: wmi handle
14084 * @param evt_buf: pointer to event buffer
14085 * @param hdr: Pointer to hold header
14086 * @param bufp: Pointer to hold pointer to rx param buffer
14087 *
14088 * Return: QDF_STATUS_SUCCESS for success or error code
14089 */
14090static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053014091 void *evt_buf, struct mgmt_rx_event_params *hdr,
14092 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053014093{
14094 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
14095 wmi_mgmt_rx_hdr *ev_hdr = NULL;
14096
14097 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
14098 if (!param_tlvs) {
14099 WMI_LOGE("Get NULL point message from FW");
14100 return QDF_STATUS_E_INVAL;
14101 }
14102
14103 ev_hdr = param_tlvs->hdr;
14104 if (!hdr) {
14105 WMI_LOGE("Rx event is NULL");
14106 return QDF_STATUS_E_INVAL;
14107 }
14108
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053014109 hdr->pdev_id = ev_hdr->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053014110
14111 hdr->channel = ev_hdr->channel;
14112 hdr->snr = ev_hdr->snr;
14113 hdr->rate = ev_hdr->rate;
14114 hdr->phy_mode = ev_hdr->phy_mode;
14115 hdr->buf_len = ev_hdr->buf_len;
14116 hdr->status = ev_hdr->status;
14117 hdr->flags = ev_hdr->flags;
14118 hdr->rssi = ev_hdr->rssi;
14119 hdr->tsf_delta = ev_hdr->tsf_delta;
14120 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
14121
14122 *bufp = param_tlvs->bufp;
14123
14124 return QDF_STATUS_SUCCESS;
14125}
14126
14127/**
14128 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
14129 * @wmi_handle: wmi handle
14130 * @param evt_buf: pointer to event buffer
14131 * @param vdev_id: Pointer to hold vdev identifier
14132 *
14133 * Return: QDF_STATUS_SUCCESS for success or error code
14134 */
14135static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
14136 void *evt_buf, uint32_t *vdev_id)
14137{
14138 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
14139 wmi_vdev_stopped_event_fixed_param *resp_event;
14140
14141 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
14142 if (!param_buf) {
14143 WMI_LOGE("Invalid event buffer");
14144 return QDF_STATUS_E_INVAL;
14145 }
14146 resp_event = param_buf->fixed_param;
14147 *vdev_id = resp_event->vdev_id;
14148
14149 return QDF_STATUS_SUCCESS;
14150}
14151
14152/**
14153 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
14154 * @wmi_handle: wmi handle
14155 * @param evt_buf: pointer to event buffer
14156 * @param param: Pointer to hold roam param
14157 *
14158 * Return: QDF_STATUS_SUCCESS for success or error code
14159 */
14160static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
14161 void *evt_buf, wmi_host_roam_event *param)
14162{
14163 WMI_ROAM_EVENTID_param_tlvs *param_buf;
14164 wmi_roam_event_fixed_param *evt;
14165
14166 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
14167 if (!param_buf) {
14168 WMI_LOGE("Invalid roam event buffer");
14169 return QDF_STATUS_E_INVAL;
14170 }
14171
14172 evt = param_buf->fixed_param;
14173 qdf_mem_zero(param, sizeof(*param));
14174
14175 param->vdev_id = evt->vdev_id;
14176 param->reason = evt->reason;
14177 param->rssi = evt->rssi;
14178
14179 return QDF_STATUS_SUCCESS;
14180}
14181
14182/**
14183 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
14184 * @wmi_handle: wmi handle
14185 * @param evt_buf: pointer to event buffer
14186 * @param param: Pointer to hold vdev scan param
14187 *
14188 * Return: QDF_STATUS_SUCCESS for success or error code
14189 */
14190static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
14191 void *evt_buf, wmi_host_scan_event *param)
14192{
14193 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
14194 wmi_scan_event_fixed_param *evt = NULL;
14195
14196 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
14197 evt = param_buf->fixed_param;
14198
14199 qdf_mem_zero(param, sizeof(*param));
14200 switch (evt->event) {
14201 case WMI_SCAN_EVENT_STARTED:
14202 param->event = WMI_HOST_SCAN_EVENT_STARTED;
14203 break;
14204 case WMI_SCAN_EVENT_COMPLETED:
14205 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
14206 break;
14207 case WMI_SCAN_EVENT_BSS_CHANNEL:
14208 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
14209 break;
14210 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
14211 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
14212 break;
14213 case WMI_SCAN_EVENT_DEQUEUED:
14214 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
14215 break;
14216 case WMI_SCAN_EVENT_PREEMPTED:
14217 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
14218 break;
14219 case WMI_SCAN_EVENT_START_FAILED:
14220 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
14221 break;
14222 case WMI_SCAN_EVENT_RESTARTED:
14223 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
14224 break;
14225 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
14226 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
14227 break;
14228 case WMI_SCAN_EVENT_MAX:
14229 default:
14230 param->event = WMI_HOST_SCAN_EVENT_MAX;
14231 break;
14232 };
14233
14234 switch (evt->reason) {
14235 case WMI_SCAN_REASON_NONE:
14236 param->reason = WMI_HOST_SCAN_REASON_NONE;
14237 break;
14238 case WMI_SCAN_REASON_COMPLETED:
14239 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
14240 break;
14241 case WMI_SCAN_REASON_CANCELLED:
14242 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
14243 break;
14244 case WMI_SCAN_REASON_PREEMPTED:
14245 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
14246 break;
14247 case WMI_SCAN_REASON_TIMEDOUT:
14248 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
14249 break;
14250 case WMI_SCAN_REASON_INTERNAL_FAILURE:
14251 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
14252 break;
14253 case WMI_SCAN_REASON_MAX:
14254 default:
14255 param->reason = WMI_HOST_SCAN_REASON_MAX;
14256 break;
14257 };
14258
14259 param->channel_freq = evt->channel_freq;
14260 param->requestor = evt->requestor;
14261 param->scan_id = evt->scan_id;
14262 param->vdev_id = evt->vdev_id;
14263
14264 return QDF_STATUS_SUCCESS;
14265}
14266
14267/**
14268 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
14269 * @wmi_handle: wmi handle
14270 * @param evt_buf: pointer to event buffer
14271 * @param param: Pointer to hold MGMT TX completion params
14272 *
14273 * Return: QDF_STATUS_SUCCESS for success or error code
14274 */
14275static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
14276 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
14277{
14278 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
14279 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
14280
14281 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
14282 evt_buf;
14283 if (!param_buf) {
14284 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
14285 return QDF_STATUS_E_INVAL;
14286 }
14287 cmpl_params = param_buf->fixed_param;
14288
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053014289 param->pdev_id = cmpl_params->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053014290 param->desc_id = cmpl_params->desc_id;
14291 param->status = cmpl_params->status;
14292
14293 return QDF_STATUS_SUCCESS;
14294}
14295
14296/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053014297 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
14298 * status tlv
14299 * @wmi_handle: wmi handle
14300 * @param evt_buf: pointer to event buffer
14301 * @param param: Pointer to hold csa switch count status event param
14302 *
14303 * Return: QDF_STATUS_SUCCESS for success or error code
14304 */
14305static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
14306 wmi_unified_t wmi_handle,
14307 void *evt_buf,
14308 struct pdev_csa_switch_count_status *param)
14309{
14310 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
14311 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
14312
14313 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
14314 evt_buf;
14315 if (!param_buf) {
14316 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
14317 return QDF_STATUS_E_INVAL;
14318 }
14319
14320 csa_status = param_buf->fixed_param;
14321
14322 param->pdev_id = csa_status->pdev_id;
14323 param->current_switch_count = csa_status->current_switch_count;
14324 param->num_vdevs = csa_status->num_vdevs;
14325 param->vdev_ids = param_buf->vdev_ids;
14326
14327 return QDF_STATUS_SUCCESS;
14328}
14329
14330/**
Govind Singhe7f2f342016-05-23 12:12:52 +053014331 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
14332 * @wmi_handle: wmi handle
14333 * @param evt_buf: pointer to event buffer
14334 * @param vdev_map: Pointer to hold vdev map
14335 *
14336 * Return: QDF_STATUS_SUCCESS for success or error code
14337 */
14338static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
14339 void *evt_buf, uint32_t *vdev_map)
14340{
14341 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
14342 wmi_host_swba_event_fixed_param *swba_event;
14343
14344 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
14345 if (!param_buf) {
14346 WMI_LOGE("Invalid swba event buffer");
14347 return QDF_STATUS_E_INVAL;
14348 }
14349 swba_event = param_buf->fixed_param;
14350 *vdev_map = swba_event->vdev_map;
14351
14352 return QDF_STATUS_SUCCESS;
14353}
14354
14355/**
14356 * extract_swba_tim_info_tlv() - extract swba tim info from event
14357 * @wmi_handle: wmi handle
14358 * @param evt_buf: pointer to event buffer
14359 * @param idx: Index to bcn info
14360 * @param tim_info: Pointer to hold tim info
14361 *
14362 * Return: QDF_STATUS_SUCCESS for success or error code
14363 */
14364static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
14365 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
14366{
14367 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
14368 wmi_tim_info *tim_info_ev;
14369
14370 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
14371 if (!param_buf) {
14372 WMI_LOGE("Invalid swba event buffer");
14373 return QDF_STATUS_E_INVAL;
14374 }
14375
14376 tim_info_ev = &param_buf->tim_info[idx];
14377
14378 tim_info->tim_len = tim_info_ev->tim_len;
14379 tim_info->tim_mcast = tim_info_ev->tim_mcast;
14380 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
14381 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
14382 tim_info->tim_changed = tim_info_ev->tim_changed;
14383 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
14384
14385 return QDF_STATUS_SUCCESS;
14386}
14387
14388/**
14389 * extract_swba_noa_info_tlv() - extract swba NoA information from event
14390 * @wmi_handle: wmi handle
14391 * @param evt_buf: pointer to event buffer
14392 * @param idx: Index to bcn info
14393 * @param p2p_desc: Pointer to hold p2p NoA info
14394 *
14395 * Return: QDF_STATUS_SUCCESS for success or error code
14396 */
14397static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
14398 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
14399{
14400 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
14401 wmi_p2p_noa_info *p2p_noa_info;
14402 uint8_t i = 0;
14403
14404 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
14405 if (!param_buf) {
14406 WMI_LOGE("Invalid swba event buffer");
14407 return QDF_STATUS_E_INVAL;
14408 }
14409
14410 p2p_noa_info = &param_buf->p2p_noa_info[idx];
14411
14412 p2p_desc->modified = false;
14413 p2p_desc->num_descriptors = 0;
14414 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
14415 p2p_desc->modified = true;
14416 p2p_desc->index =
14417 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
14418 p2p_desc->oppPS =
14419 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
14420 p2p_desc->ctwindow =
14421 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
14422 p2p_desc->num_descriptors =
14423 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
14424 (p2p_noa_info);
14425 for (i = 0; i < p2p_desc->num_descriptors; i++) {
14426 p2p_desc->noa_descriptors[i].type_count =
14427 (uint8_t) p2p_noa_info->noa_descriptors[i].
14428 type_count;
14429 p2p_desc->noa_descriptors[i].duration =
14430 p2p_noa_info->noa_descriptors[i].duration;
14431 p2p_desc->noa_descriptors[i].interval =
14432 p2p_noa_info->noa_descriptors[i].interval;
14433 p2p_desc->noa_descriptors[i].start_time =
14434 p2p_noa_info->noa_descriptors[i].start_time;
14435 }
14436 }
14437
14438 return QDF_STATUS_SUCCESS;
14439}
14440
14441/**
14442 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
14443 * @wmi_handle: wmi handle
14444 * @param evt_buf: pointer to event buffer
14445 * @param ev: Pointer to hold peer param
14446 *
14447 * Return: QDF_STATUS_SUCCESS for success or error code
14448 */
14449static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
14450 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
14451{
14452 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
14453 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
14454
14455 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
14456 kickout_event = param_buf->fixed_param;
14457
14458 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
14459 ev->peer_macaddr);
14460
14461 ev->reason = kickout_event->reason;
14462 ev->rssi = kickout_event->rssi;
14463
14464 return QDF_STATUS_SUCCESS;
14465}
14466
14467/**
14468 * extract_all_stats_counts_tlv() - extract all stats count from event
14469 * @wmi_handle: wmi handle
14470 * @param evt_buf: pointer to event buffer
14471 * @param stats_param: Pointer to hold stats count
14472 *
14473 * Return: QDF_STATUS_SUCCESS for success or error code
14474 */
14475static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
14476 void *evt_buf, wmi_host_stats_event *stats_param)
14477{
14478 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14479 wmi_stats_event_fixed_param *ev;
14480
14481 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14482
14483 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14484 if (!ev) {
14485 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
14486 return QDF_STATUS_E_FAILURE;
14487 }
14488
14489 switch (ev->stats_id) {
14490 case WMI_REQUEST_PEER_STAT:
14491 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
14492 break;
14493
14494 case WMI_REQUEST_AP_STAT:
14495 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
14496 break;
14497
14498 case WMI_REQUEST_PDEV_STAT:
14499 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
14500 break;
14501
14502 case WMI_REQUEST_VDEV_STAT:
14503 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
14504 break;
14505
14506 case WMI_REQUEST_BCNFLT_STAT:
14507 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
14508 break;
14509
14510 case WMI_REQUEST_VDEV_RATE_STAT:
14511 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
14512 break;
14513
14514 default:
14515 stats_param->stats_id = 0;
14516 break;
14517
14518 }
14519
14520 stats_param->num_pdev_stats = ev->num_pdev_stats;
14521 stats_param->num_pdev_ext_stats = 0;
14522 stats_param->num_vdev_stats = ev->num_vdev_stats;
14523 stats_param->num_peer_stats = ev->num_peer_stats;
14524 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
14525 stats_param->num_chan_stats = ev->num_chan_stats;
14526
14527 return QDF_STATUS_SUCCESS;
14528}
14529
14530/**
14531 * extract_pdev_stats_tlv() - extract pdev stats from event
14532 * @wmi_handle: wmi handle
14533 * @param evt_buf: pointer to event buffer
14534 * @param index: Index into pdev stats
14535 * @param pdev_stats: Pointer to hold pdev stats
14536 *
14537 * Return: QDF_STATUS_SUCCESS for success or error code
14538 */
14539static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
14540 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
14541{
14542 return QDF_STATUS_SUCCESS;
14543}
14544
14545/**
14546 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
14547 * @wmi_handle: wmi handle
14548 * @param evt_buf: pointer to event buffer
14549 * @param index: Index into extended pdev stats
14550 * @param pdev_ext_stats: Pointer to hold extended pdev stats
14551 *
14552 * Return: QDF_STATUS_SUCCESS for success or error code
14553 */
14554static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
14555 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
14556{
14557 return QDF_STATUS_SUCCESS;
14558}
14559
14560/**
14561 * extract_vdev_stats_tlv() - extract vdev stats from event
14562 * @wmi_handle: wmi handle
14563 * @param evt_buf: pointer to event buffer
14564 * @param index: Index into vdev stats
14565 * @param vdev_stats: Pointer to hold vdev stats
14566 *
14567 * Return: QDF_STATUS_SUCCESS for success or error code
14568 */
14569static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
14570 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
14571{
14572 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14573 wmi_stats_event_fixed_param *ev_param;
14574 uint8_t *data;
14575
14576 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14577 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14578 data = (uint8_t *) param_buf->data;
14579
14580 if (index < ev_param->num_vdev_stats) {
14581 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
14582 ((ev_param->num_pdev_stats) *
14583 sizeof(wmi_pdev_stats)) +
14584 (index * sizeof(wmi_vdev_stats)));
14585
14586 vdev_stats->vdev_id = ev->vdev_id;
14587 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
14588 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
14589
14590 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
14591 sizeof(ev->tx_frm_cnt));
14592 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
14593 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
14594 ev->multiple_retry_cnt,
14595 sizeof(ev->multiple_retry_cnt));
14596 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
14597 sizeof(ev->fail_cnt));
14598 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
14599 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
14600 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
14601 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
14602 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
14603 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
14604 sizeof(ev->tx_rate_history));
14605 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
14606 sizeof(ev->bcn_rssi_history));
14607
14608 }
14609
14610 return QDF_STATUS_SUCCESS;
14611}
14612
14613/**
14614 * extract_peer_stats_tlv() - extract peer stats from event
14615 * @wmi_handle: wmi handle
14616 * @param evt_buf: pointer to event buffer
14617 * @param index: Index into peer stats
14618 * @param peer_stats: Pointer to hold peer stats
14619 *
14620 * Return: QDF_STATUS_SUCCESS for success or error code
14621 */
14622static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
14623 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
14624{
14625 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14626 wmi_stats_event_fixed_param *ev_param;
14627 uint8_t *data;
14628
14629 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14630 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14631 data = (uint8_t *) param_buf->data;
14632
14633 if (index < ev_param->num_peer_stats) {
14634 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
14635 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
14636 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
14637 (index * sizeof(wmi_peer_stats)));
14638
14639 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
14640
14641 OS_MEMCPY(&(peer_stats->peer_macaddr),
14642 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
14643
14644 peer_stats->peer_rssi = ev->peer_rssi;
14645 peer_stats->peer_tx_rate = ev->peer_tx_rate;
14646 peer_stats->peer_rx_rate = ev->peer_rx_rate;
14647 }
14648
14649 return QDF_STATUS_SUCCESS;
14650}
14651
14652/**
14653 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
14654 * @wmi_handle: wmi handle
14655 * @param evt_buf: pointer to event buffer
14656 * @param index: Index into bcn fault stats
14657 * @param bcnflt_stats: Pointer to hold bcn fault stats
14658 *
14659 * Return: QDF_STATUS_SUCCESS for success or error code
14660 */
14661static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
14662 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
14663{
14664 return QDF_STATUS_SUCCESS;
14665}
14666
14667/**
14668 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
14669 * @wmi_handle: wmi handle
14670 * @param evt_buf: pointer to event buffer
14671 * @param index: Index into extended peer stats
14672 * @param peer_extd_stats: Pointer to hold extended peer stats
14673 *
14674 * Return: QDF_STATUS_SUCCESS for success or error code
14675 */
14676static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
14677 void *evt_buf, uint32_t index,
14678 wmi_host_peer_extd_stats *peer_extd_stats)
14679{
14680 return QDF_STATUS_SUCCESS;
14681}
14682
14683/**
14684 * extract_chan_stats_tlv() - extract chan stats from event
14685 * @wmi_handle: wmi handle
14686 * @param evt_buf: pointer to event buffer
14687 * @param index: Index into chan stats
14688 * @param vdev_extd_stats: Pointer to hold chan stats
14689 *
14690 * Return: QDF_STATUS_SUCCESS for success or error code
14691 */
14692static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
14693 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
14694{
14695 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14696 wmi_stats_event_fixed_param *ev_param;
14697 uint8_t *data;
14698
14699 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14700 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14701 data = (uint8_t *) param_buf->data;
14702
14703 if (index < ev_param->num_chan_stats) {
14704 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
14705 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
14706 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
14707 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
14708 (index * sizeof(wmi_chan_stats)));
14709
14710
14711 /* Non-TLV doesnt have num_chan_stats */
14712 chan_stats->chan_mhz = ev->chan_mhz;
14713 chan_stats->sampling_period_us = ev->sampling_period_us;
14714 chan_stats->rx_clear_count = ev->rx_clear_count;
14715 chan_stats->tx_duration_us = ev->tx_duration_us;
14716 chan_stats->rx_duration_us = ev->rx_duration_us;
14717 }
14718
14719 return QDF_STATUS_SUCCESS;
14720}
14721
14722/**
14723 * extract_profile_ctx_tlv() - extract profile context from event
14724 * @wmi_handle: wmi handle
14725 * @param evt_buf: pointer to event buffer
14726 * @idx: profile stats index to extract
14727 * @param profile_ctx: Pointer to hold profile context
14728 *
14729 * Return: QDF_STATUS_SUCCESS for success or error code
14730 */
14731static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
14732 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
14733{
14734 return QDF_STATUS_SUCCESS;
14735}
14736
14737/**
14738 * extract_profile_data_tlv() - extract profile data from event
14739 * @wmi_handle: wmi handle
14740 * @param evt_buf: pointer to event buffer
14741 * @param profile_data: Pointer to hold profile data
14742 *
14743 * Return: QDF_STATUS_SUCCESS for success or error code
14744 */
14745static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
14746 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
14747{
14748
14749 return QDF_STATUS_SUCCESS;
14750}
14751
14752/**
14753 * extract_chan_info_event_tlv() - extract chan information from event
14754 * @wmi_handle: wmi handle
14755 * @param evt_buf: pointer to event buffer
14756 * @param chan_info: Pointer to hold chan information
14757 *
14758 * Return: QDF_STATUS_SUCCESS for success or error code
14759 */
14760static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
14761 void *evt_buf, wmi_host_chan_info_event *chan_info)
14762{
14763 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
14764 wmi_chan_info_event_fixed_param *ev;
14765
14766 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
14767
14768 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
14769 if (!ev) {
14770 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
14771 return QDF_STATUS_E_FAILURE;
14772 }
14773
14774 chan_info->err_code = ev->err_code;
14775 chan_info->freq = ev->freq;
14776 chan_info->cmd_flags = ev->cmd_flags;
14777 chan_info->noise_floor = ev->noise_floor;
14778 chan_info->rx_clear_count = ev->rx_clear_count;
14779 chan_info->cycle_count = ev->cycle_count;
14780
14781 return QDF_STATUS_SUCCESS;
14782}
14783
14784/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053014785 * extract_pdev_utf_event_tlv() - extract UTF data info from event
14786 * @wmi_handle: WMI handle
14787 * @param evt_buf: Pointer to event buffer
14788 * @param param: Pointer to hold data
14789 *
14790 * Return : QDF_STATUS_SUCCESS for success or error code
14791 */
14792static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
14793 uint8_t *evt_buf,
14794 struct wmi_host_pdev_utf_event *event)
14795{
14796 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
14797
14798 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
14799 event->data = param_buf->data;
14800 event->datalen = param_buf->num_data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053014801 /* Set pdev_id=1 until FW adds support to include pdev_id */
14802 event->pdev_id = 1;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053014803
14804 return QDF_STATUS_SUCCESS;
14805}
Govind Singhe7f2f342016-05-23 12:12:52 +053014806
Kiran Venkatappa06520822016-08-10 23:55:40 +053014807/**
14808 * extract_service_ready_ext_tlv() - extract basic extended service ready params
14809 * from event
14810 * @wmi_handle: wmi handle
14811 * @param evt_buf: pointer to event buffer
14812 * @param param: Pointer to hold evt buf
14813 *
14814 * Return: QDF_STATUS_SUCCESS for success or error code
14815 */
14816static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014817 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014818{
14819 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
14820 wmi_service_ready_ext_event_fixed_param *ev;
14821 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
14822 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
14823
14824 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14825 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014826 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014827
14828 ev = param_buf->fixed_param;
14829 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014830 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014831
14832 /* Move this to host based bitmap */
14833 param->default_conc_scan_config_bits =
14834 ev->default_conc_scan_config_bits;
14835 param->default_fw_config_bits = ev->default_fw_config_bits;
14836 param->he_cap_info = ev->he_cap_info;
14837 param->mpdu_density = ev->mpdu_density;
14838 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
14839 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
14840
14841 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014842 if (hw_caps)
14843 param->num_hw_modes = hw_caps->num_hw_modes;
14844 else
14845 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014846
14847 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014848 if (reg_caps)
14849 param->num_phy = reg_caps->num_phy;
14850 else
14851 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014852
14853 return QDF_STATUS_SUCCESS;
14854}
14855
14856/**
14857 * extract_hw_mode_cap_service_ready_ext_tlv() -
14858 * extract HW mode cap from service ready event
14859 * @wmi_handle: wmi handle
14860 * @param evt_buf: pointer to event buffer
14861 * @param param: Pointer to hold evt buf
14862 * @param hw_mode_idx: hw mode idx should be less than num_mode
14863 *
14864 * Return: QDF_STATUS_SUCCESS for success or error code
14865 */
14866static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
14867 wmi_unified_t wmi_handle,
14868 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014869 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014870{
14871 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
14872 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
14873
14874 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14875 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014876 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014877
14878 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014879 if (!hw_caps)
14880 return QDF_STATUS_E_INVAL;
14881
Kiran Venkatappa06520822016-08-10 23:55:40 +053014882 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014883 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014884
14885 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
14886 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
14887
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014888 param->hw_mode_config_type =
14889 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
14890
Kiran Venkatappa06520822016-08-10 23:55:40 +053014891 return QDF_STATUS_SUCCESS;
14892}
14893
14894/**
14895 * extract_mac_phy_cap_service_ready_ext_tlv() -
14896 * extract MAC phy cap from service ready event
14897 * @wmi_handle: wmi handle
14898 * @param evt_buf: pointer to event buffer
14899 * @param param: Pointer to hold evt buf
14900 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014901 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053014902 *
14903 * Return: QDF_STATUS_SUCCESS for success or error code
14904 */
14905static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
14906 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014907 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014908 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014909{
14910 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014911 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014912 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
14913 uint32_t phy_map;
14914 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014915
14916 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14917 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014918 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014919
14920 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014921 if (!hw_caps)
14922 return QDF_STATUS_E_INVAL;
14923
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014924 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
14925 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
14926 break;
14927
14928 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
14929 while (phy_map) {
14930 phy_map >>= 1;
14931 phy_idx++;
14932 }
14933 }
14934
14935 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014936 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014937
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014938 phy_idx += phy_id;
14939 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014940 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014941
14942 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053014943
14944 param->hw_mode_id = mac_phy_caps->hw_mode_id;
14945 param->pdev_id = mac_phy_caps->pdev_id;
14946 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014947 param->supports_11b =
14948 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
14949 param->supports_11g =
14950 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
14951 param->supports_11a =
14952 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
14953 param->supports_11n =
14954 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
14955 param->supports_11ac =
14956 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
14957 param->supports_11ax =
14958 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053014959
14960 param->supported_bands = mac_phy_caps->supported_bands;
14961 param->ampdu_density = mac_phy_caps->ampdu_density;
14962 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
14963 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
14964 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
14965 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
14966 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
14967 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
14968 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
14969 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
14970 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
14971 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
14972 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
14973 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
14974 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
14975 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
14976 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
14977 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080014978 qdf_mem_copy(&param->he_cap_phy_info_2G,
14979 &mac_phy_caps->he_cap_phy_info_2G,
14980 sizeof(param->he_cap_phy_info_2G));
14981 qdf_mem_copy(&param->he_cap_phy_info_5G,
14982 &mac_phy_caps->he_cap_phy_info_5G,
14983 sizeof(param->he_cap_phy_info_5G));
14984 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
14985 sizeof(param->he_ppet2G));
14986 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
14987 sizeof(param->he_ppet5G));
Kiran Venkatappa06520822016-08-10 23:55:40 +053014988
14989 return QDF_STATUS_SUCCESS;
14990}
14991
14992/**
14993 * extract_reg_cap_service_ready_ext_tlv() -
14994 * extract REG cap from service ready event
14995 * @wmi_handle: wmi handle
14996 * @param evt_buf: pointer to event buffer
14997 * @param param: Pointer to hold evt buf
14998 * @param phy_idx: phy idx should be less than num_mode
14999 *
15000 * Return: QDF_STATUS_SUCCESS for success or error code
15001 */
15002static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
15003 wmi_unified_t wmi_handle,
15004 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015005 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053015006{
15007 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
15008 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
15009 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
15010
15011 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
15012 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015013 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015014
15015 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015016 if (!reg_caps)
15017 return QDF_STATUS_E_INVAL;
15018
Kiran Venkatappa06520822016-08-10 23:55:40 +053015019 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015020 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015021
15022 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
15023
15024 param->phy_id = ext_reg_cap->phy_id;
15025 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
15026 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
15027 param->regcap1 = ext_reg_cap->regcap1;
15028 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015029 param->wireless_modes = convert_wireless_modes_tlv(
15030 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053015031 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
15032 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
15033 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
15034 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
15035
15036 return QDF_STATUS_SUCCESS;
15037}
15038
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015039/**
15040 * extract_dcs_interference_type_tlv() - extract dcs interference type
15041 * from event
15042 * @wmi_handle: wmi handle
15043 * @param evt_buf: pointer to event buffer
15044 * @param param: Pointer to hold dcs interference param
15045 *
15046 * Return: 0 for success or error code
15047 */
15048static QDF_STATUS extract_dcs_interference_type_tlv(
15049 wmi_unified_t wmi_handle,
15050 void *evt_buf, struct wmi_host_dcs_interference_param *param)
15051{
15052 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
15053
15054 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
15055 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015056 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015057
15058 param->interference_type = param_buf->fixed_param->interference_type;
15059 param->pdev_id = param_buf->fixed_param->pdev_id;
15060
15061 return QDF_STATUS_SUCCESS;
15062}
15063
15064/*
15065 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
15066 * @wmi_handle: wmi handle
15067 * @param evt_buf: pointer to event buffer
15068 * @param cw_int: Pointer to hold cw interference
15069 *
15070 * Return: 0 for success or error code
15071 */
15072static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
15073 void *evt_buf,
15074 wmi_host_ath_dcs_cw_int *cw_int)
15075{
15076 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
15077 wlan_dcs_cw_int *ev;
15078
15079 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
15080 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015081 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015082
15083 ev = param_buf->cw_int;
15084
15085 cw_int->channel = ev->channel;
15086
15087 return QDF_STATUS_SUCCESS;
15088}
15089
15090/**
15091 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
15092 * @wmi_handle: wmi handle
15093 * @param evt_buf: pointer to event buffer
15094 * @param wlan_stat: Pointer to hold wlan stats
15095 *
15096 * Return: 0 for success or error code
15097 */
15098static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
15099 void *evt_buf,
15100 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
15101{
15102 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
15103 wlan_dcs_im_tgt_stats_t *ev;
15104
15105 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
15106 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015107 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015108
15109 ev = param_buf->wlan_stat;
15110 wlan_stat->reg_tsf32 = ev->reg_tsf32;
15111 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
15112 wlan_stat->tx_waste_time = ev->tx_waste_time;
15113 wlan_stat->rx_time = ev->rx_time;
15114 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
15115 wlan_stat->mib_stats.listen_time = ev->listen_time;
15116 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
15117 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
15118 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
15119 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
15120 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
15121 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
15122 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
15123 wlan_stat->chan_nf = ev->chan_nf;
15124 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
15125
15126 return QDF_STATUS_SUCCESS;
15127}
15128
Kiran Venkatappac813ec92016-12-29 22:07:14 +053015129#ifdef BIG_ENDIAN_HOST
15130/**
15131 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
15132 * @param data_len - data length
15133 * @param data - pointer to data
15134 *
15135 * Return: QDF_STATUS - success or error status
15136 */
15137static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
15138{
15139 uint8_t *data_aligned = NULL;
15140 int c;
15141 unsigned char *data_unaligned;
15142
15143 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
15144 FIPS_ALIGN));
15145 /* Assigning unaligned space to copy the data */
15146 /* Checking if kmalloc does succesful allocation */
15147 if (data_unaligned == NULL)
15148 return QDF_STATUS_E_FAILURE;
15149
15150 /* Checking if space is alligned */
15151 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
15152 /* align the data space */
15153 data_aligned =
15154 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
15155 } else {
15156 data_aligned = (u_int8_t *)data_unaligned;
15157 }
15158
15159 /* memset and copy content from data to data aligned */
15160 OS_MEMSET(data_aligned, 0, data_len);
15161 OS_MEMCPY(data_aligned, data, data_len);
15162 /* Endianness to LE */
15163 for (c = 0; c < data_len/4; c++) {
15164 *((u_int32_t *)data_aligned + c) =
15165 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
15166 }
15167
15168 /* Copy content to event->data */
15169 OS_MEMCPY(data, data_aligned, data_len);
15170
15171 /* clean up allocated space */
15172 qdf_mem_free(data_unaligned);
15173 data_aligned = NULL;
15174 data_unaligned = NULL;
15175
15176 /*************************************************************/
15177
15178 return QDF_STATUS_SUCCESS;
15179}
15180#else
15181/**
15182 * fips_conv_data_be() - DUMMY for LE platform
15183 *
15184 * Return: QDF_STATUS - success
15185 */
15186static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
15187{
15188 return QDF_STATUS_SUCCESS;
15189}
15190#endif
15191
15192/**
15193 * extract_fips_event_data_tlv() - extract fips event data
15194 * @wmi_handle: wmi handle
15195 * @param evt_buf: pointer to event buffer
15196 * @param param: pointer FIPS event params
15197 *
15198 * Return: 0 for success or error code
15199 */
15200static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
15201 void *evt_buf, struct wmi_host_fips_event_param *param)
15202{
15203 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
15204 wmi_pdev_fips_event_fixed_param *event;
15205
15206 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
15207 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
15208
15209 if (fips_conv_data_be(event->data_len, param_buf->data) !=
15210 QDF_STATUS_SUCCESS)
15211 return QDF_STATUS_E_FAILURE;
15212
15213 param->data = (uint32_t *)param_buf->data;
15214 param->data_len = event->data_len;
15215 param->error_status = event->error_status;
15216
15217 return QDF_STATUS_SUCCESS;
15218}
15219
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053015220/*
15221 * extract_peer_delete_response_event_tlv() - extract peer delete response event
15222 * @wmi_handle: wmi handle
15223 * @param evt_buf: pointer to event buffer
15224 * @param vdev_id: Pointer to hold vdev_id
15225 * @param mac_addr: Pointer to hold peer mac address
15226 *
15227 * Return: QDF_STATUS_SUCCESS for success or error code
15228 */
15229static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
15230 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
15231{
15232 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
15233 wmi_peer_delete_resp_event_fixed_param *ev;
15234
15235 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
15236
15237 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
15238 if (!ev) {
15239 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
15240 return QDF_STATUS_E_FAILURE;
15241 }
15242
15243 param->vdev_id = ev->vdev_id;
15244 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
15245 &param->mac_address.bytes[0]);
15246
15247 return QDF_STATUS_SUCCESS;
15248}
15249
Govind Singhecf03cd2016-05-12 12:45:51 +053015250static bool is_management_record_tlv(uint32_t cmd_id)
15251{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053015252 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053015253 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053015254
Govind Singhecf03cd2016-05-12 12:45:51 +053015255 return false;
15256}
15257
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053015258static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
15259{
15260 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
15261
15262 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
15263
15264 switch (set_cmd->param_id) {
15265 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
15266 case WMI_VDEV_PARAM_DTIM_POLICY:
15267 return HTC_TX_PACKET_TAG_AUTO_PM;
15268 default:
15269 break;
15270 }
15271
15272 return 0;
15273}
15274
15275static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
15276{
15277 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
15278
15279 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
15280
15281 switch (ps_cmd->param) {
15282 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
15283 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
15284 case WMI_STA_PS_ENABLE_QPOWER:
15285 return HTC_TX_PACKET_TAG_AUTO_PM;
15286 default:
15287 break;
15288 }
15289
15290 return 0;
15291}
15292
15293static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
15294 uint32_t cmd_id)
15295{
15296 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
15297 return 0;
15298
15299 switch (cmd_id) {
15300 case WMI_VDEV_SET_PARAM_CMDID:
15301 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
15302 case WMI_STA_POWERSAVE_PARAM_CMDID:
15303 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
15304 default:
15305 break;
15306 }
15307
15308 return 0;
15309}
15310
15311static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
15312{
15313 uint16_t tag = 0;
15314
15315 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
15316 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
15317 __func__);
15318 return tag;
15319 }
15320
15321 if (wmi_handle->tag_crash_inject)
15322 tag = HTC_TX_PACKET_TAG_AUTO_PM;
15323
15324 wmi_handle->tag_crash_inject = false;
15325 return tag;
15326}
15327
15328/**
15329 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
15330 * @wmi_handle: WMI handle
15331 * @buf: WMI buffer
15332 * @cmd_id: WMI command Id
15333 *
15334 * Return htc_tx_tag
15335 */
15336static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
15337 wmi_buf_t buf,
15338 uint32_t cmd_id)
15339{
15340 uint16_t htc_tx_tag = 0;
15341
15342 switch (cmd_id) {
15343 case WMI_WOW_ENABLE_CMDID:
15344 case WMI_PDEV_SUSPEND_CMDID:
15345 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
15346 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
15347 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
15348 case WMI_PDEV_RESUME_CMDID:
15349 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
15350 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
15351#ifdef FEATURE_WLAN_D0WOW
15352 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
15353#endif
15354 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
15355 break;
15356 case WMI_FORCE_FW_HANG_CMDID:
15357 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
15358 break;
15359 case WMI_VDEV_SET_PARAM_CMDID:
15360 case WMI_STA_POWERSAVE_PARAM_CMDID:
15361 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
15362 default:
15363 break;
15364 }
15365
15366 return htc_tx_tag;
15367}
15368
Sathish Kumard3ab1002017-02-07 17:10:59 +053015369/**
15370 * extract_channel_hopping_event_tlv() - extract channel hopping param
15371 * from event
15372 * @wmi_handle: wmi handle
15373 * @param evt_buf: pointer to event buffer
15374 * @param ch_hopping: Pointer to hold channel hopping param
15375 *
15376 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
15377 */
15378static QDF_STATUS extract_channel_hopping_event_tlv(
15379 wmi_unified_t wmi_handle, void *evt_buf,
15380 wmi_host_pdev_channel_hopping_event *ch_hopping)
15381{
15382 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
15383 wmi_pdev_channel_hopping_event_fixed_param *event;
15384
15385 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
15386 event = (wmi_pdev_channel_hopping_event_fixed_param *)
15387 param_buf->fixed_param;
15388
15389 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
15390 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
15391
15392 return QDF_STATUS_SUCCESS;
15393}
15394
15395/**
15396 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
15397 * @wmi_handle: wmi handle
15398 * @param evt_buf: pointer to event buffer
15399 * @param param: Pointer to hold tpc param
15400 *
15401 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
15402 */
15403static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
15404 void *evt_buf,
15405 wmi_host_pdev_tpc_event *param)
15406{
15407 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
15408 wmi_pdev_tpc_event_fixed_param *event;
15409
15410 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
15411 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
15412
15413 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
15414
15415 return QDF_STATUS_SUCCESS;
15416}
15417
15418
15419#ifdef BIG_ENDIAN_HOST
15420/**
15421 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
15422 * @param data_len - data length
15423 * @param data - pointer to data
15424 *
15425 * Return: QDF_STATUS - success or error status
15426 */
15427static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
15428{
15429 uint8_t *datap = (uint8_t *)ev;
15430 /* Skip swapping the first word */
15431 datap += sizeof(uint32_t);
15432 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
15433 i++, datap += sizeof(uint32_t)) {
15434 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
15435 }
15436
15437 return QDF_STATUS_SUCCESS;
15438}
15439#else
15440/**
15441 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
15442 * @param data_len - data length
15443 * @param data - pointer to data
15444 *
15445 * Return: QDF_STATUS - success or error status
15446 */
15447static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
15448{
15449 return QDF_STATUS_SUCCESS;
15450}
15451#endif
15452
15453/**
15454 * extract_wds_addr_event_tlv() - extract wds address from event
15455 * @wmi_handle: wmi handle
15456 * @param evt_buf: pointer to event buffer
15457 * @param wds_ev: Pointer to hold wds address
15458 *
15459 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
15460 */
15461static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
15462 void *evt_buf,
15463 uint16_t len, wds_addr_event_t *wds_ev)
15464{
15465 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
15466 wmi_wds_addr_event_fixed_param *ev;
15467 int i;
15468
15469 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
15470 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
15471
15472 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
15473 return QDF_STATUS_E_FAILURE;
15474
15475 qdf_mem_copy(wds_ev->event_type, ev->event_type,
15476 sizeof(wds_ev->event_type));
15477 for (i = 0; i < 4; i++) {
15478 wds_ev->peer_mac[i] =
15479 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
15480 wds_ev->dest_mac[i] =
15481 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
15482 }
15483 for (i = 0; i < 2; i++) {
15484 wds_ev->peer_mac[4+i] =
15485 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
15486 wds_ev->dest_mac[4+i] =
15487 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
15488 }
15489 return QDF_STATUS_SUCCESS;
15490}
15491
15492/**
15493 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
15494 * from event
15495 * @wmi_handle: wmi handle
15496 * @param evt_buf: pointer to event buffer
15497 * @param ev: Pointer to hold peer param and ps state
15498 *
15499 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
15500 */
15501static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
15502 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
15503{
15504 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
15505 wmi_peer_sta_ps_statechange_event_fixed_param *event;
15506
15507 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
15508 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
15509 param_buf->fixed_param;
15510
15511 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
15512 ev->peer_ps_state = event->peer_ps_state;
15513
15514 return QDF_STATUS_SUCCESS;
15515}
15516
15517/**
15518 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
15519 * @wmi_handle: wmi handle
15520 * @param evt_buf: pointer to event buffer
15521 * @param inst_rssi_resp: Pointer to hold inst rssi response
15522 *
15523 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
15524 */
15525static QDF_STATUS extract_inst_rssi_stats_event_tlv(
15526 wmi_unified_t wmi_handle, void *evt_buf,
15527 wmi_host_inst_stats_resp *inst_rssi_resp)
15528{
15529 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
15530 wmi_inst_rssi_stats_resp_fixed_param *event;
15531
15532 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
15533 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
15534
15535 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
15536 &(event->peer_macaddr), sizeof(wmi_mac_addr));
15537 inst_rssi_resp->iRSSI = event->iRSSI;
15538
15539 return QDF_STATUS_SUCCESS;
15540}
15541
Govind Singh5eb51532016-03-09 11:34:12 +053015542struct wmi_ops tlv_ops = {
15543 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
15544 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
15545 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053015546 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
15547 .send_hidden_ssid_vdev_restart_cmd =
15548 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053015549 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
15550 .send_peer_param_cmd = send_peer_param_cmd_tlv,
15551 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053015552 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053015553 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053015554 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070015555 .send_peer_rx_reorder_queue_setup_cmd =
15556 send_peer_rx_reorder_queue_setup_cmd_tlv,
15557 .send_peer_rx_reorder_queue_remove_cmd =
15558 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053015559 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
15560 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
15561 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053015562 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
15563 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
15564 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
15565 .send_suspend_cmd = send_suspend_cmd_tlv,
15566 .send_resume_cmd = send_resume_cmd_tlv,
15567 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
15568 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
15569 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
15570 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
15571 .send_dbglog_cmd = send_dbglog_cmd_tlv,
15572 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
15573 .send_stats_request_cmd = send_stats_request_cmd_tlv,
15574 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
15575 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053015576#ifndef CONFIG_MCL
15577 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
15578#endif
Govind Singh5eb51532016-03-09 11:34:12 +053015579 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
15580 .send_scan_start_cmd = send_scan_start_cmd_tlv,
15581 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
15582 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053015583 .send_mgmt_cmd = send_mgmt_cmd_tlv,
15584 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
15585 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015586 .send_set_sta_uapsd_auto_trig_cmd =
15587 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053015588 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
15589 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
15590 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
15591 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
15592 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053015593 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
15594 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
15595 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
15596 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
15597 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
15598 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
15599 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015600 .send_ocb_start_timing_advert_cmd =
15601 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053015602 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
15603 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
15604 .send_set_mcc_channel_time_latency_cmd =
15605 send_set_mcc_channel_time_latency_cmd_tlv,
15606 .send_set_mcc_channel_time_quota_cmd =
15607 send_set_mcc_channel_time_quota_cmd_tlv,
15608 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
15609 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053015610 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015611 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
15612 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
15613 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015614 .send_probe_rsp_tmpl_send_cmd =
15615 send_probe_rsp_tmpl_send_cmd_tlv,
15616 .send_p2p_go_set_beacon_ie_cmd =
15617 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053015618 .send_setup_install_key_cmd =
15619 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015620 .send_set_gateway_params_cmd =
15621 send_set_gateway_params_cmd_tlv,
15622 .send_set_rssi_monitoring_cmd =
15623 send_set_rssi_monitoring_cmd_tlv,
15624 .send_scan_probe_setoui_cmd =
15625 send_scan_probe_setoui_cmd_tlv,
15626 .send_reset_passpoint_network_list_cmd =
15627 send_reset_passpoint_network_list_cmd_tlv,
15628 .send_set_passpoint_network_list_cmd =
15629 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053015630 .send_roam_scan_offload_rssi_thresh_cmd =
15631 send_roam_scan_offload_rssi_thresh_cmd_tlv,
15632 .send_roam_scan_filter_cmd =
15633 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015634 .send_set_epno_network_list_cmd =
15635 send_set_epno_network_list_cmd_tlv,
15636 .send_ipa_offload_control_cmd =
15637 send_ipa_offload_control_cmd_tlv,
15638 .send_extscan_get_capabilities_cmd =
15639 send_extscan_get_capabilities_cmd_tlv,
15640 .send_extscan_get_cached_results_cmd =
15641 send_extscan_get_cached_results_cmd_tlv,
15642 .send_extscan_stop_change_monitor_cmd =
15643 send_extscan_stop_change_monitor_cmd_tlv,
15644 .send_extscan_start_change_monitor_cmd =
15645 send_extscan_start_change_monitor_cmd_tlv,
15646 .send_extscan_stop_hotlist_monitor_cmd =
15647 send_extscan_stop_hotlist_monitor_cmd_tlv,
15648 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
15649 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
15650 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
15651 .send_plm_start_cmd = send_plm_start_cmd_tlv,
15652 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053015653#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053015654 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053015655#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053015656 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
15657 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
15658 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
15659 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
15660 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015661 .send_snr_request_cmd = send_snr_request_cmd_tlv,
15662 .send_snr_cmd = send_snr_cmd_tlv,
15663 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015664#ifdef WLAN_PMO_ENABLE
15665 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
15666 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
15667 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
15668 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
15669 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
15670 .send_process_gtk_offload_getinfo_cmd =
15671 send_process_gtk_offload_getinfo_cmd_tlv,
15672 .send_enable_enhance_multicast_offload_cmd =
15673 send_enable_enhance_multicast_offload_tlv,
15674 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
15675#ifdef FEATURE_WLAN_RA_FILTERING
15676 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
15677#endif
15678 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015679 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
15680 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015681 .send_lphb_config_tcp_pkt_filter_cmd =
15682 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015683 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
15684 .send_lphb_config_udp_pkt_filter_cmd =
15685 send_lphb_config_udp_pkt_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015686#endif /* End of WLAN_PMO_ENABLE */
15687#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053015688 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
15689 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
15690 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053015691 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
15692 .send_process_update_edca_param_cmd =
15693 send_process_update_edca_param_cmd_tlv,
15694 .send_roam_scan_offload_mode_cmd =
15695 send_roam_scan_offload_mode_cmd_tlv,
15696 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
15697 .send_roam_scan_offload_ap_profile_cmd =
15698 send_roam_scan_offload_ap_profile_cmd_tlv,
15699#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053015700 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
15701 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015702 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
15703 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
15704 .send_dfs_phyerr_filter_offload_en_cmd =
15705 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015706 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
15707 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
15708 .send_del_ts_cmd = send_del_ts_cmd_tlv,
15709 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
15710 .send_add_ts_cmd = send_add_ts_cmd_tlv,
15711 .send_enable_disable_packet_filter_cmd =
15712 send_enable_disable_packet_filter_cmd_tlv,
15713 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015714 .send_process_add_periodic_tx_ptrn_cmd =
15715 send_process_add_periodic_tx_ptrn_cmd_tlv,
15716 .send_process_del_periodic_tx_ptrn_cmd =
15717 send_process_del_periodic_tx_ptrn_cmd_tlv,
15718 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
15719 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
15720 .send_set_app_type2_params_in_fw_cmd =
15721 send_set_app_type2_params_in_fw_cmd_tlv,
15722 .send_set_auto_shutdown_timer_cmd =
15723 send_set_auto_shutdown_timer_cmd_tlv,
15724 .send_nan_req_cmd = send_nan_req_cmd_tlv,
15725 .send_process_dhcpserver_offload_cmd =
15726 send_process_dhcpserver_offload_cmd_tlv,
15727 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
15728 .send_process_ch_avoid_update_cmd =
15729 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053015730 .send_pdev_set_regdomain_cmd =
15731 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015732 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
15733 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
15734 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
15735 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
15736 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
15737 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053015738#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053015739 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053015740#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053015741 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053015742 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053015743 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053015744 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053015745 .send_set_base_macaddr_indicate_cmd =
15746 send_set_base_macaddr_indicate_cmd_tlv,
15747 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
15748 .send_enable_specific_fw_logs_cmd =
15749 send_enable_specific_fw_logs_cmd_tlv,
15750 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053015751 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053015752 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053015753 .send_pdev_set_dual_mac_config_cmd =
15754 send_pdev_set_dual_mac_config_cmd_tlv,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015755 .send_enable_broadcast_filter_cmd =
15756 send_enable_broadcast_filter_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053015757 .send_app_type1_params_in_fw_cmd =
15758 send_app_type1_params_in_fw_cmd_tlv,
15759 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
15760 .send_process_roam_synch_complete_cmd =
15761 send_process_roam_synch_complete_cmd_tlv,
15762 .send_unit_test_cmd = send_unit_test_cmd_tlv,
15763 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
15764 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053015765 .send_roam_scan_offload_scan_period_cmd =
15766 send_roam_scan_offload_scan_period_cmd_tlv,
15767 .send_roam_scan_offload_chan_list_cmd =
15768 send_roam_scan_offload_chan_list_cmd_tlv,
15769 .send_roam_scan_offload_rssi_change_cmd =
15770 send_roam_scan_offload_rssi_change_cmd_tlv,
15771 .send_get_buf_extscan_hotlist_cmd =
15772 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053015773 .send_adapt_dwelltime_params_cmd =
15774 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053015775 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053015776 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
15777 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
15778 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
15779 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
15780 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
15781 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
15782 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
15783 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
15784 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053015785 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
15786 .send_smart_ant_set_training_info_cmd =
15787 send_smart_ant_set_training_info_cmd_tlv,
15788 .send_smart_ant_set_node_config_cmd =
15789 send_smart_ant_set_node_config_cmd_tlv,
15790 .send_set_atf_cmd = send_set_atf_cmd_tlv,
15791 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
15792 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053015793 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
15794 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
15795 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
15796 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
15797 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
15798 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
15799 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053015800 .get_target_cap_from_service_ready = extract_service_ready_tlv,
15801 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
15802 .extract_host_mem_req = extract_host_mem_req_tlv,
15803 .save_service_bitmap = save_service_bitmap_tlv,
15804 .is_service_enabled = is_service_enabled_tlv,
15805 .save_fw_version = save_fw_version_in_service_ready_tlv,
15806 .ready_extract_init_status = ready_extract_init_status_tlv,
15807 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
15808 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
15809 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
15810 .extract_tbttoffset_update_params =
15811 extract_tbttoffset_update_params_tlv,
15812 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
15813 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
15814 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
15815 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
15816 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
15817 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
15818 .extract_swba_tim_info = extract_swba_tim_info_tlv,
15819 .extract_swba_noa_info = extract_swba_noa_info_tlv,
15820 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
15821 .extract_all_stats_count = extract_all_stats_counts_tlv,
15822 .extract_pdev_stats = extract_pdev_stats_tlv,
15823 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
15824 .extract_vdev_stats = extract_vdev_stats_tlv,
15825 .extract_peer_stats = extract_peer_stats_tlv,
15826 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
15827 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
15828 .extract_chan_stats = extract_chan_stats_tlv,
15829 .extract_profile_ctx = extract_profile_ctx_tlv,
15830 .extract_profile_data = extract_profile_data_tlv,
15831 .extract_chan_info_event = extract_chan_info_event_tlv,
15832 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053015833 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053015834 .send_encrypt_decrypt_send_cmd =
15835 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080015836 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053015837 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053015838 .send_multiple_vdev_restart_req_cmd =
15839 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053015840 .extract_service_ready_ext = extract_service_ready_ext_tlv,
15841 .extract_hw_mode_cap_service_ready_ext =
15842 extract_hw_mode_cap_service_ready_ext_tlv,
15843 .extract_mac_phy_cap_service_ready_ext =
15844 extract_mac_phy_cap_service_ready_ext_tlv,
15845 .extract_reg_cap_service_ready_ext =
15846 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053015847 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053015848 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015849 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
15850 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
15851 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053015852 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053015853 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053015854 .extract_peer_delete_response_event =
15855 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053015856 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053015857 .extract_pdev_csa_switch_count_status =
15858 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053015859 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
15860 .extract_wds_addr_event = extract_wds_addr_event_tlv,
15861 .extract_peer_sta_ps_statechange_ev =
15862 extract_peer_sta_ps_statechange_ev_tlv,
15863 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053015864};
15865
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015866#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015867/**
15868 * populate_tlv_service() - populates wmi services
15869 *
15870 * @param wmi_service: Pointer to hold wmi_service
15871 * Return: None
15872 */
15873static void populate_tlv_service(uint32_t *wmi_service)
15874{
15875 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
15876 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
15877 wmi_service[wmi_service_roam_scan_offload] =
15878 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
15879 wmi_service[wmi_service_bcn_miss_offload] =
15880 WMI_SERVICE_BCN_MISS_OFFLOAD;
15881 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
15882 wmi_service[wmi_service_sta_advanced_pwrsave] =
15883 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
15884 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
15885 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
15886 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
15887 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
15888 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
15889 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
15890 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
15891 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
15892 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
15893 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
15894 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
15895 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
15896 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
15897 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
15898 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
15899 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
15900 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
15901 wmi_service[wmi_service_packet_power_save] =
15902 WMI_SERVICE_PACKET_POWER_SAVE;
15903 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
15904 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
15905 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
15906 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
15907 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
15908 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
15909 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
15910 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
15911 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
15912 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
15913 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
15914 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
15915 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
15916 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
15917 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
15918 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
15919 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
15920 wmi_service[wmi_service_mcc_bcn_interval_change] =
15921 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
15922 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
15923 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
15924 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
15925 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
15926 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
15927 wmi_service[wmi_service_lte_ant_share_support] =
15928 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
15929 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
15930 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
15931 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
15932 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
15933 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
15934 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
15935 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
15936 wmi_service[wmi_service_bcn_txrate_override] =
15937 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
15938 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
15939 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
15940 wmi_service[wmi_service_estimate_linkspeed] =
15941 WMI_SERVICE_ESTIMATE_LINKSPEED;
15942 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
15943 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
15944 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
15945 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
15946 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
15947 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
15948 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
15949 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
15950 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
15951 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
15952 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
15953 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
15954 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
15955 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
15956 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
15957 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
15958 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
15959 wmi_service[wmi_service_sap_auth_offload] =
15960 WMI_SERVICE_SAP_AUTH_OFFLOAD;
15961 wmi_service[wmi_service_dual_band_simultaneous_support] =
15962 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
15963 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
15964 wmi_service[wmi_service_ap_arpns_offload] =
15965 WMI_SERVICE_AP_ARPNS_OFFLOAD;
15966 wmi_service[wmi_service_per_band_chainmask_support] =
15967 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
15968 wmi_service[wmi_service_packet_filter_offload] =
15969 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
15970 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
15971 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
15972 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
15973 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015974 wmi_service[wmi_service_multiple_vdev_restart] =
15975 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
Govind Singhe7f2f342016-05-23 12:12:52 +053015976
15977 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
15978 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
15979 wmi_service[wmi_service_smart_antenna_sw_support] =
15980 WMI_SERVICE_UNAVAILABLE;
15981 wmi_service[wmi_service_smart_antenna_hw_support] =
15982 WMI_SERVICE_UNAVAILABLE;
15983 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
15984 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
15985 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
15986 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
15987 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
15988 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
15989 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
15990 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
15991 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
15992 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
15993 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
15994
15995 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
15996 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
15997 wmi_service[wmi_service_periodic_chan_stat_support] =
15998 WMI_SERVICE_UNAVAILABLE;
15999 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
16000 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
16001 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
Sathish Kumar699f6b52016-11-10 15:30:22 +053016002 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
Sathish Kumar58a9fb92017-01-19 14:57:37 +053016003 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053016004 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Govind Singhe7f2f342016-05-23 12:12:52 +053016005}
16006
16007/**
16008 * populate_tlv_event_id() - populates wmi event ids
16009 *
16010 * @param event_ids: Pointer to hold event ids
16011 * Return: None
16012 */
16013static void populate_tlv_events_id(uint32_t *event_ids)
16014{
16015 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
16016 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
16017 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
16018 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
16019 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
16020 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
16021 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
16022 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
16023 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
16024 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
16025 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
16026 event_ids[wmi_service_ready_ext_event_id] =
16027 WMI_SERVICE_READY_EXT_EVENTID;
16028 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
16029 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
16030 event_ids[wmi_vdev_install_key_complete_event_id] =
16031 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
16032 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
16033 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
16034
16035 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
16036 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
16037 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
16038 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
16039 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
16040 event_ids[wmi_peer_estimated_linkspeed_event_id] =
16041 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
16042 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053016043 event_ids[wmi_peer_delete_response_event_id] =
16044 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053016045 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
16046 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
16047 event_ids[wmi_tbttoffset_update_event_id] =
16048 WMI_TBTTOFFSET_UPDATE_EVENTID;
16049 event_ids[wmi_offload_bcn_tx_status_event_id] =
16050 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
16051 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
16052 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
16053 event_ids[wmi_mgmt_tx_completion_event_id] =
16054 WMI_MGMT_TX_COMPLETION_EVENTID;
16055
16056 event_ids[wmi_tx_delba_complete_event_id] =
16057 WMI_TX_DELBA_COMPLETE_EVENTID;
16058 event_ids[wmi_tx_addba_complete_event_id] =
16059 WMI_TX_ADDBA_COMPLETE_EVENTID;
16060 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
16061
16062 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
16063
16064 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
16065 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
16066
16067 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
16068
16069 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
16070
16071 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
16072
16073 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
16074 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
16075 event_ids[wmi_do_wow_disable_ack_event_id] =
16076 WMI_D0_WOW_DISABLE_ACK_EVENTID;
16077 event_ids[wmi_wow_initial_wakeup_event_id] =
16078 WMI_WOW_INITIAL_WAKEUP_EVENTID;
16079
16080 event_ids[wmi_rtt_meas_report_event_id] =
16081 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
16082 event_ids[wmi_tsf_meas_report_event_id] =
16083 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
16084 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
16085 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
16086 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
16087 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
16088 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
16089 event_ids[wmi_update_fw_mem_dump_event_id] =
16090 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
16091 event_ids[wmi_diag_event_id_log_supported_event_id] =
16092 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
16093 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
16094 event_ids[wmi_nlo_scan_complete_event_id] =
16095 WMI_NLO_SCAN_COMPLETE_EVENTID;
16096 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
16097 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
16098
16099 event_ids[wmi_gtk_offload_status_event_id] =
16100 WMI_GTK_OFFLOAD_STATUS_EVENTID;
16101 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
16102 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
16103 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
16104
16105 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
16106
16107 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
16108
16109 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
16110 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
16111 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
16112 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
16113 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
16114 event_ids[wmi_wlan_profile_data_event_id] =
16115 WMI_WLAN_PROFILE_DATA_EVENTID;
16116 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
16117 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
16118 event_ids[wmi_vdev_get_keepalive_event_id] =
16119 WMI_VDEV_GET_KEEPALIVE_EVENTID;
16120 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
16121
16122 event_ids[wmi_diag_container_event_id] =
16123 WMI_DIAG_DATA_CONTAINER_EVENTID;
16124
16125 event_ids[wmi_host_auto_shutdown_event_id] =
16126 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
16127
16128 event_ids[wmi_update_whal_mib_stats_event_id] =
16129 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
16130
16131 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
16132 event_ids[wmi_update_vdev_rate_stats_event_id] =
16133 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
16134
16135 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
16136
16137 /** Set OCB Sched Response, deprecated */
16138 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
16139
16140 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
16141 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
16142 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
16143
16144 /* GPIO Event */
16145 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
16146 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
16147
16148 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
16149 event_ids[wmi_rfkill_state_change_event_id] =
16150 WMI_RFKILL_STATE_CHANGE_EVENTID;
16151
16152 /* TDLS Event */
16153 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
16154
16155 event_ids[wmi_batch_scan_enabled_event_id] =
16156 WMI_BATCH_SCAN_ENABLED_EVENTID;
16157 event_ids[wmi_batch_scan_result_event_id] =
16158 WMI_BATCH_SCAN_RESULT_EVENTID;
16159 /* OEM Event */
16160 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
16161 event_ids[wmi_oem_meas_report_event_id] =
16162 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
16163 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
16164
16165 /* NAN Event */
16166 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
16167
16168 /* LPI Event */
16169 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
16170 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
16171 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
16172
16173 /* ExtScan events */
16174 event_ids[wmi_extscan_start_stop_event_id] =
16175 WMI_EXTSCAN_START_STOP_EVENTID;
16176 event_ids[wmi_extscan_operation_event_id] =
16177 WMI_EXTSCAN_OPERATION_EVENTID;
16178 event_ids[wmi_extscan_table_usage_event_id] =
16179 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
16180 event_ids[wmi_extscan_cached_results_event_id] =
16181 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
16182 event_ids[wmi_extscan_wlan_change_results_event_id] =
16183 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
16184 event_ids[wmi_extscan_hotlist_match_event_id] =
16185 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
16186 event_ids[wmi_extscan_capabilities_event_id] =
16187 WMI_EXTSCAN_CAPABILITIES_EVENTID;
16188 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
16189 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
16190
16191 /* mDNS offload events */
16192 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
16193
16194 /* SAP Authentication offload events */
16195 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
16196 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
16197
16198 /** Out-of-context-of-bss (OCB) events */
16199 event_ids[wmi_ocb_set_config_resp_event_id] =
16200 WMI_OCB_SET_CONFIG_RESP_EVENTID;
16201 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
16202 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
16203 event_ids[wmi_dcc_get_stats_resp_event_id] =
16204 WMI_DCC_GET_STATS_RESP_EVENTID;
16205 event_ids[wmi_dcc_update_ndl_resp_event_id] =
16206 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
16207 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
16208 /* System-On-Chip events */
16209 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
16210 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
16211 event_ids[wmi_soc_hw_mode_transition_event_id] =
16212 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
16213 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
16214 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053016215 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016216 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
16217 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053016218}
16219
16220/**
16221 * populate_pdev_param_tlv() - populates pdev params
16222 *
16223 * @param pdev_param: Pointer to hold pdev params
16224 * Return: None
16225 */
16226static void populate_pdev_param_tlv(uint32_t *pdev_param)
16227{
16228 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
16229 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
16230 pdev_param[wmi_pdev_param_txpower_limit2g] =
16231 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
16232 pdev_param[wmi_pdev_param_txpower_limit5g] =
16233 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
16234 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
16235 pdev_param[wmi_pdev_param_beacon_gen_mode] =
16236 WMI_PDEV_PARAM_BEACON_GEN_MODE;
16237 pdev_param[wmi_pdev_param_beacon_tx_mode] =
16238 WMI_PDEV_PARAM_BEACON_TX_MODE;
16239 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
16240 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
16241 pdev_param[wmi_pdev_param_protection_mode] =
16242 WMI_PDEV_PARAM_PROTECTION_MODE;
16243 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
16244 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
16245 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
16246 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
16247 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
16248 pdev_param[wmi_pdev_param_sta_kickout_th] =
16249 WMI_PDEV_PARAM_STA_KICKOUT_TH;
16250 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
16251 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
16252 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
16253 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
16254 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
16255 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
16256 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
16257 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
16258 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
16259 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
16260 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
16261 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
16262 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
16263 pdev_param[wmi_pdev_param_ltr_sleep_override] =
16264 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
16265 pdev_param[wmi_pdev_param_ltr_rx_override] =
16266 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
16267 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
16268 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
16269 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
16270 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
16271 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
16272 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
16273 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
16274 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
16275 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
16276 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
16277 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
16278 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
16279 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
16280 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
16281 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
16282 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
16283 pdev_param[wmi_pdev_param_peer_stats_update_period] =
16284 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
16285 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
16286 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
16287 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
16288 pdev_param[wmi_pdev_param_arp_ac_override] =
16289 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
16290 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
16291 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
16292 pdev_param[wmi_pdev_param_ani_poll_period] =
16293 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
16294 pdev_param[wmi_pdev_param_ani_listen_period] =
16295 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
16296 pdev_param[wmi_pdev_param_ani_ofdm_level] =
16297 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
16298 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
16299 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
16300 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
16301 pdev_param[wmi_pdev_param_idle_ps_config] =
16302 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
16303 pdev_param[wmi_pdev_param_power_gating_sleep] =
16304 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
16305 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
16306 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
16307 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
16308 pdev_param[wmi_pdev_param_hw_rfkill_config] =
16309 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
16310 pdev_param[wmi_pdev_param_low_power_rf_enable] =
16311 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
16312 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
16313 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
16314 pdev_param[wmi_pdev_param_power_collapse_enable] =
16315 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
16316 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
16317 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
16318 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
16319 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
16320 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
16321 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
16322 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
16323 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
16324 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
16325 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
16326 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
16327 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
16328 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
16329 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
16330 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
16331 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
16332 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
16333 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
16334 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
16335 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
16336 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
16337 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
16338 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
16339 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
16340 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
16341 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
16342 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
16343 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
16344 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
16345 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
16346 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
16347 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
16348 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
16349 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
16350 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
16351 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
16352 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
16353 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
16354 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
16355 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
16356 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
16357 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
16358 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
16359 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
16360 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
16361 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
16362 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
16363 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
16364 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
16365 WMI_UNAVAILABLE_PARAM;
16366 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
16367 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
16368 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
16369 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
16370 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
16371 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
16372 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
16373 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
16374 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
16375 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
16376 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
16377 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
16378 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
16379 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
16380 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
16381 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
16382 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
16383 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
16384 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
16385 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
16386 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
16387 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
16388 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
16389 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
16390 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
16391 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
16392 WMI_UNAVAILABLE_PARAM;
16393 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
16394 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
16395 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
16396 WMI_UNAVAILABLE_PARAM;
16397 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
16398 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
16399 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
16400 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
16401 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
16402 WMI_UNAVAILABLE_PARAM;
16403 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
16404 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
16405 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053016406 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
16407 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053016408 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053016409 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
16410 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016411}
16412
16413/**
16414 * populate_vdev_param_tlv() - populates vdev params
16415 *
16416 * @param vdev_param: Pointer to hold vdev params
16417 * Return: None
16418 */
16419static void populate_vdev_param_tlv(uint32_t *vdev_param)
16420{
16421 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
16422 vdev_param[wmi_vdev_param_fragmentation_threshold] =
16423 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
16424 vdev_param[wmi_vdev_param_beacon_interval] =
16425 WMI_VDEV_PARAM_BEACON_INTERVAL;
16426 vdev_param[wmi_vdev_param_listen_interval] =
16427 WMI_VDEV_PARAM_LISTEN_INTERVAL;
16428 vdev_param[wmi_vdev_param_multicast_rate] =
16429 WMI_VDEV_PARAM_MULTICAST_RATE;
16430 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
16431 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
16432 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
16433 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
16434 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
16435 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
16436 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
16437 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
16438 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
16439 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
16440 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
16441 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
16442 vdev_param[wmi_vdev_param_bmiss_count_max] =
16443 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
16444 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
16445 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
16446 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
16447 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
16448 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
16449 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
16450 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
16451 vdev_param[wmi_vdev_param_disable_htprotection] =
16452 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
16453 vdev_param[wmi_vdev_param_sta_quickkickout] =
16454 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
16455 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
16456 vdev_param[wmi_vdev_param_protection_mode] =
16457 WMI_VDEV_PARAM_PROTECTION_MODE;
16458 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
16459 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
16460 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
16461 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
16462 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
16463 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
16464 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
16465 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
16466 vdev_param[wmi_vdev_param_bcast_data_rate] =
16467 WMI_VDEV_PARAM_BCAST_DATA_RATE;
16468 vdev_param[wmi_vdev_param_mcast_data_rate] =
16469 WMI_VDEV_PARAM_MCAST_DATA_RATE;
16470 vdev_param[wmi_vdev_param_mcast_indicate] =
16471 WMI_VDEV_PARAM_MCAST_INDICATE;
16472 vdev_param[wmi_vdev_param_dhcp_indicate] =
16473 WMI_VDEV_PARAM_DHCP_INDICATE;
16474 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
16475 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
16476 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
16477 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
16478 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
16479 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
16480 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
16481 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
16482 vdev_param[wmi_vdev_param_ap_enable_nawds] =
16483 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
16484 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
16485 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
16486 vdev_param[wmi_vdev_param_packet_powersave] =
16487 WMI_VDEV_PARAM_PACKET_POWERSAVE;
16488 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
16489 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
16490 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
16491 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
16492 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
16493 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
16494 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
16495 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
16496 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
16497 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
16498 vdev_param[wmi_vdev_param_early_rx_slop_step] =
16499 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
16500 vdev_param[wmi_vdev_param_early_rx_init_slop] =
16501 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
16502 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
16503 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
16504 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
16505 vdev_param[wmi_vdev_param_snr_num_for_cal] =
16506 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
16507 vdev_param[wmi_vdev_param_roam_fw_offload] =
16508 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
16509 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
16510 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
16511 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
16512 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
16513 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
16514 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
16515 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
16516 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
16517 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
16518 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
16519 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
16520 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
16521 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
16522 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
16523 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
16524 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
16525 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
16526 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
16527 vdev_param[wmi_vdev_param_inactivity_cnt] =
16528 WMI_VDEV_PARAM_INACTIVITY_CNT;
16529 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
16530 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
16531 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
16532 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
16533 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
16534 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
16535 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
16536 vdev_param[wmi_vdev_param_rx_leak_window] =
16537 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
16538 vdev_param[wmi_vdev_param_stats_avg_factor] =
16539 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
16540 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
16541 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
16542 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
16543 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
16544 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
16545 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053016546 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
16547 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053016548 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080016549 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
16550 vdev_param[wmi_vdev_param_he_range_ext_enable] =
16551 WMI_VDEV_PARAM_HE_RANGE_EXT;
16552 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
16553 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
16554 vdev_param[wmi_vdev_param_tx_ofdma_cplen] =
16555 WMI_VDEV_PARAM_TX_OFDMA_CPLEN;
Govind Singhe7f2f342016-05-23 12:12:52 +053016556}
16557#endif
16558
Govind Singh5eb51532016-03-09 11:34:12 +053016559/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053016560 * populate_target_defines_tlv() - Populate target defines and params
16561 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053016562 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053016563 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053016564 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053016565#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053016566static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053016567{
Govind Singhe7f2f342016-05-23 12:12:52 +053016568 populate_tlv_service(wmi_handle->services);
16569 populate_tlv_events_id(wmi_handle->wmi_events);
16570 populate_pdev_param_tlv(wmi_handle->pdev_param);
16571 populate_vdev_param_tlv(wmi_handle->vdev_param);
16572}
16573#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053016574static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
16575{ }
16576#endif
16577
16578/**
16579 * wmi_tlv_attach() - Attach TLV APIs
16580 *
16581 * Return: None
16582 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053016583void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053016584{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053016585 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053016586#ifdef WMI_INTERFACE_EVENT_LOGGING
16587 wmi_handle->log_info.buf_offset_command = 2;
16588 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053016589#endif
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053016590 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053016591}