blob: cb1f17c9f8eca00a888c88ddaf4cfabab1545380 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Paul Zhangd19abd82017-01-04 16:45:42 +08002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Govind Singh5eb51532016-03-09 11:34:12 +053028#include "wmi_unified_api.h"
29#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053030#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053031#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053032#include "wmi_version_whitelist.h"
Govind Singh5eb51532016-03-09 11:34:12 +053033
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053034
35/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
36 * buffer.
37 * @cmd: pointer target vdev create command buffer
38 * @param: pointer host params for vdev create
39 *
40 * Return: None
41 */
42#ifdef CONFIG_MCL
43static inline void copy_vdev_create_pdev_id(
44 wmi_vdev_create_cmd_fixed_param * cmd,
45 struct vdev_create_params *param)
46{
47 cmd->pdev_id = WMI_PDEV_ID_SOC;
48}
49#else
50static inline void copy_vdev_create_pdev_id(
51 wmi_vdev_create_cmd_fixed_param * cmd,
52 struct vdev_create_params *param)
53{
54 cmd->pdev_id = param->pdev_id;
55}
56#endif
57
Govind Singh5eb51532016-03-09 11:34:12 +053058/**
59 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
60 * @wmi_handle: wmi handle
61 * @param: pointer to hold vdev create parameter
62 * @macaddr: vdev mac address
63 *
Govind Singhe7f2f342016-05-23 12:12:52 +053064 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053065 */
Sathish Kumarfd347372017-02-13 12:29:09 +053066static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053067 uint8_t macaddr[IEEE80211_ADDR_LEN],
68 struct vdev_create_params *param)
69{
70 wmi_vdev_create_cmd_fixed_param *cmd;
71 wmi_buf_t buf;
72 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053073 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070074 int num_bands = 2;
75 uint8_t *buf_ptr;
76 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053077
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070078 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053079 buf = wmi_buf_alloc(wmi_handle, len);
80 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053081 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053082 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053083 }
84 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
85 WMITLV_SET_HDR(&cmd->tlv_header,
86 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
87 WMITLV_GET_STRUCT_TLVLEN
88 (wmi_vdev_create_cmd_fixed_param));
89 cmd->vdev_id = param->if_id;
90 cmd->vdev_type = param->type;
91 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070092 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053093 copy_vdev_create_pdev_id(cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +053094 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +053095 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +053096 __func__, param->if_id,
97 macaddr[0], macaddr[1], macaddr[2],
98 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070099 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
100 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
101 (num_bands * sizeof(wmi_vdev_txrx_streams)));
102 buf_ptr += WMI_TLV_HDR_SIZE;
103
Govind Singh224a7312016-06-21 14:33:26 +0530104 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700105 param->type, param->subtype,
106 param->nss_2g, param->nss_5g);
107 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
108 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
109 txrx_streams->supported_tx_streams = param->nss_2g;
110 txrx_streams->supported_rx_streams = param->nss_2g;
111 WMITLV_SET_HDR(&txrx_streams->tlv_header,
112 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
113 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
114
115 txrx_streams++;
116 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
117 txrx_streams->supported_tx_streams = param->nss_5g;
118 txrx_streams->supported_rx_streams = param->nss_5g;
119 WMITLV_SET_HDR(&txrx_streams->tlv_header,
120 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
121 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530122 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530123 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530124 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530125 wmi_buf_free(buf);
126 }
127
128 return ret;
129}
130
131/**
132 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
133 * @wmi_handle: wmi handle
134 * @if_id: vdev id
135 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530136 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530137 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530138static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530139 uint8_t if_id)
140{
141 wmi_vdev_delete_cmd_fixed_param *cmd;
142 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530143 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530144
145 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
146 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530147 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530148 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530149 }
150
151 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
152 WMITLV_SET_HDR(&cmd->tlv_header,
153 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
154 WMITLV_GET_STRUCT_TLVLEN
155 (wmi_vdev_delete_cmd_fixed_param));
156 cmd->vdev_id = if_id;
157 ret = wmi_unified_cmd_send(wmi_handle, buf,
158 sizeof(wmi_vdev_delete_cmd_fixed_param),
159 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530160 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530161 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530162 wmi_buf_free(buf);
163 }
Govind Singhb53420c2016-03-09 14:32:57 +0530164 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530165
166 return ret;
167}
168
169/**
170 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
171 * @wmi: wmi handle
172 * @vdev_id: vdev id
173 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530174 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530175 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530176static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530177 uint8_t vdev_id)
178{
179 wmi_vdev_stop_cmd_fixed_param *cmd;
180 wmi_buf_t buf;
181 int32_t len = sizeof(*cmd);
182
183 buf = wmi_buf_alloc(wmi, len);
184 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530185 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530186 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530187 }
188 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
189 WMITLV_SET_HDR(&cmd->tlv_header,
190 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
191 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
192 cmd->vdev_id = vdev_id;
193 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530194 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530195 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530196 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530197 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530198 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530199
200 return 0;
201}
202
203/**
204 * send_vdev_down_cmd_tlv() - send vdev down command to fw
205 * @wmi: wmi handle
206 * @vdev_id: vdev id
207 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530208 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530209 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530210static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530211{
212 wmi_vdev_down_cmd_fixed_param *cmd;
213 wmi_buf_t buf;
214 int32_t len = sizeof(*cmd);
215
216 buf = wmi_buf_alloc(wmi, len);
217 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530218 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530219 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530220 }
221 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
222 WMITLV_SET_HDR(&cmd->tlv_header,
223 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
224 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
225 cmd->vdev_id = vdev_id;
226 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530227 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530228 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530229 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530230 }
Govind Singhb53420c2016-03-09 14:32:57 +0530231 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530232
233 return 0;
234}
235
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530236#ifdef CONFIG_MCL
237static inline void copy_channel_info(
238 wmi_vdev_start_request_cmd_fixed_param * cmd,
239 wmi_channel *chan,
240 struct vdev_start_params *req)
241{
242 chan->mhz = req->chan_freq;
243
244 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
245
246 chan->band_center_freq1 = req->band_center_freq1;
247 chan->band_center_freq2 = req->band_center_freq2;
248
249 if (req->is_half_rate)
250 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
251 else if (req->is_quarter_rate)
252 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
253
Naveen Rawat44f2f432016-12-01 12:58:57 -0800254 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530255 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
256 cmd->disable_hw_ack = req->dis_hw_ack;
257 }
258
259 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
260 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
261
262}
263#else
264static inline void copy_channel_info(
265 wmi_vdev_start_request_cmd_fixed_param * cmd,
266 wmi_channel *chan,
267 struct vdev_start_params *req)
268{
269 chan->mhz = req->channel.mhz;
270
271 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
272
273 chan->band_center_freq1 = req->channel.cfreq1;
274 chan->band_center_freq2 = req->channel.cfreq2;
275
276 if (req->channel.half_rate)
277 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
278 else if (req->channel.quarter_rate)
279 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
280
281 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530282 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530283 cmd->disable_hw_ack = req->disable_hw_ack;
284 }
285
286 /* FIXME: Find out min, max and regulatory power levels */
287 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
288 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
289
290}
291#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530292/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530293 * send_vdev_start_cmd_tlv() - send vdev start request to fw
294 * @wmi_handle: wmi handle
295 * @req: vdev start params
296 *
297 * Return: QDF status
298 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530299static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530300 struct vdev_start_params *req)
301{
302 wmi_vdev_start_request_cmd_fixed_param *cmd;
303 wmi_buf_t buf;
304 wmi_channel *chan;
305 int32_t len, ret;
306 uint8_t *buf_ptr;
307
308 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
309 buf = wmi_buf_alloc(wmi_handle, len);
310 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530311 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530312 return QDF_STATUS_E_NOMEM;
313 }
314 buf_ptr = (uint8_t *) wmi_buf_data(buf);
315 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
316 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
317 WMITLV_SET_HDR(&cmd->tlv_header,
318 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
319 WMITLV_GET_STRUCT_TLVLEN
320 (wmi_vdev_start_request_cmd_fixed_param));
321 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
322 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
323 cmd->vdev_id = req->vdev_id;
324
325 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530326 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530327
328 cmd->beacon_interval = req->beacon_intval;
329 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530330
331 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530332 cmd->beacon_interval = req->beacon_intval;
333 cmd->dtim_period = req->dtim_period;
334
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530335 /* Copy the SSID */
336 if (req->ssid.length) {
337 if (req->ssid.length < sizeof(cmd->ssid.ssid))
338 cmd->ssid.ssid_len = req->ssid.length;
339 else
340 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
341 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
342 cmd->ssid.ssid_len);
343 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530344
345 if (req->hidden_ssid)
346 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
347
348 if (req->pmf_enabled)
349 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530350 }
351
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530352 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530353 cmd->preferred_rx_streams = req->preferred_rx_streams;
354 cmd->preferred_tx_streams = req->preferred_tx_streams;
355
356 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
357 sizeof(wmi_channel));
358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
359 cmd->num_noa_descriptors *
360 sizeof(wmi_p2p_noa_descriptor));
Naveen Rawat44f2f432016-12-01 12:58:57 -0800361 WMI_LOGA("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530362 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
363 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
364 "Tx SS %d, Rx SS %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800365 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530366 req->is_dfs, req->beacon_intval, cmd->dtim_period,
367 chan->band_center_freq1, chan->band_center_freq2,
368 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
369 req->preferred_tx_streams, req->preferred_rx_streams);
370
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530371 if (req->is_restart)
372 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
373 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530374 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530375 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
376 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530377 if (ret) {
378 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530379 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530380 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530381 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530382
383 return QDF_STATUS_SUCCESS;
384}
385
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530386/**
387 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
388 * @wmi_handle: wmi handle
389 * @restart_params: vdev restart params
390 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530391 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530392 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530393static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530394 struct hidden_ssid_vdev_restart_params *restart_params)
395{
396 wmi_vdev_start_request_cmd_fixed_param *cmd;
397 wmi_buf_t buf;
398 wmi_channel *chan;
399 int32_t len;
400 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530401 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530402
403 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
404 buf = wmi_buf_alloc(wmi_handle, len);
405 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530406 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530407 return QDF_STATUS_E_NOMEM;
408 }
409 buf_ptr = (uint8_t *) wmi_buf_data(buf);
410 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
411 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
412
413 WMITLV_SET_HDR(&cmd->tlv_header,
414 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
415 WMITLV_GET_STRUCT_TLVLEN
416 (wmi_vdev_start_request_cmd_fixed_param));
417
418 WMITLV_SET_HDR(&chan->tlv_header,
419 WMITLV_TAG_STRUC_wmi_channel,
420 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
421
422 cmd->vdev_id = restart_params->session_id;
423 cmd->ssid.ssid_len = restart_params->ssid_len;
424 qdf_mem_copy(cmd->ssid.ssid,
425 restart_params->ssid,
426 cmd->ssid.ssid_len);
427 cmd->flags = restart_params->flags;
428 cmd->requestor_id = restart_params->requestor_id;
429 cmd->disable_hw_ack = restart_params->disable_hw_ack;
430
431 chan->mhz = restart_params->mhz;
432 chan->band_center_freq1 =
433 restart_params->band_center_freq1;
434 chan->band_center_freq2 =
435 restart_params->band_center_freq2;
436 chan->info = restart_params->info;
437 chan->reg_info_1 = restart_params->reg_info_1;
438 chan->reg_info_2 = restart_params->reg_info_2;
439
440 cmd->num_noa_descriptors = 0;
441 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
442 sizeof(wmi_channel));
443 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
444 cmd->num_noa_descriptors *
445 sizeof(wmi_p2p_noa_descriptor));
446
447 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
448 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530449 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530450 wmi_buf_free(buf);
451 return QDF_STATUS_E_FAILURE;
452 }
453 return QDF_STATUS_SUCCESS;
454}
455
456
457/**
Govind Singh5eb51532016-03-09 11:34:12 +0530458 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
459 * @wmi: wmi handle
460 * @peer_addr: peer mac address
461 * @param: pointer to hold peer flush tid parameter
462 *
463 * Return: 0 for sucess or error code
464 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530465static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530466 uint8_t peer_addr[IEEE80211_ADDR_LEN],
467 struct peer_flush_params *param)
468{
469 wmi_peer_flush_tids_cmd_fixed_param *cmd;
470 wmi_buf_t buf;
471 int32_t len = sizeof(*cmd);
472
473 buf = wmi_buf_alloc(wmi, len);
474 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530475 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530476 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530477 }
478 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
479 WMITLV_SET_HDR(&cmd->tlv_header,
480 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
481 WMITLV_GET_STRUCT_TLVLEN
482 (wmi_peer_flush_tids_cmd_fixed_param));
483 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
484 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
485 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530486 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530487 peer_addr, param->vdev_id,
488 param->peer_tid_bitmap);
489 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530490 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530491 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530492 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530493 }
494
495 return 0;
496}
497
498/**
499 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
500 * @wmi: wmi handle
501 * @peer_addr: peer mac addr
502 * @vdev_id: vdev id
503 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530504 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530505 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530506static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530507 uint8_t peer_addr[IEEE80211_ADDR_LEN],
508 uint8_t vdev_id)
509{
510 wmi_peer_delete_cmd_fixed_param *cmd;
511 wmi_buf_t buf;
512 int32_t len = sizeof(*cmd);
513 buf = wmi_buf_alloc(wmi, len);
514 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530515 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530516 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530517 }
518 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
519 WMITLV_SET_HDR(&cmd->tlv_header,
520 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
521 WMITLV_GET_STRUCT_TLVLEN
522 (wmi_peer_delete_cmd_fixed_param));
523 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
524 cmd->vdev_id = vdev_id;
525
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800526 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530527 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530528 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530529 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530530 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530531 }
Govind Singh5eb51532016-03-09 11:34:12 +0530532
533 return 0;
534}
535
536/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530537 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
538 * to target id.
539 * @targ_paramid: Target parameter id to hold the result.
540 * @peer_param_id: host param id.
541 *
542 * Return: QDF_STATUS_SUCCESS for success
543 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
544 */
545#ifdef CONFIG_MCL
546static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
547 uint32_t *targ_paramid,
548 uint32_t peer_param_id)
549{
550 *targ_paramid = peer_param_id;
551 return QDF_STATUS_SUCCESS;
552}
553#else
554static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
555 uint32_t *targ_paramid,
556 uint32_t peer_param_id)
557{
558 switch (peer_param_id) {
559 case WMI_HOST_PEER_MIMO_PS_STATE:
560 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
561 break;
562 case WMI_HOST_PEER_AMPDU:
563 *targ_paramid = WMI_PEER_AMPDU;
564 break;
565 case WMI_HOST_PEER_AUTHORIZE:
566 *targ_paramid = WMI_PEER_AUTHORIZE;
567 break;
568 case WMI_HOST_PEER_CHWIDTH:
569 *targ_paramid = WMI_PEER_CHWIDTH;
570 break;
571 case WMI_HOST_PEER_NSS:
572 *targ_paramid = WMI_PEER_NSS;
573 break;
574 case WMI_HOST_PEER_USE_4ADDR:
575 *targ_paramid = WMI_PEER_USE_4ADDR;
576 break;
577 case WMI_HOST_PEER_MEMBERSHIP:
578 *targ_paramid = WMI_PEER_MEMBERSHIP;
579 break;
580 case WMI_HOST_PEER_USERPOS:
581 *targ_paramid = WMI_PEER_USERPOS;
582 break;
583 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
584 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
585 break;
586 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
587 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
588 break;
589 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
590 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
591 break;
592 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
593 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
594 break;
595 case WMI_HOST_PEER_PHYMODE:
596 *targ_paramid = WMI_PEER_PHYMODE;
597 break;
598 case WMI_HOST_PEER_USE_FIXED_PWR:
599 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
600 break;
601 case WMI_HOST_PEER_PARAM_FIXED_RATE:
602 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
603 break;
604 case WMI_HOST_PEER_SET_MU_WHITELIST:
605 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
606 break;
607 case WMI_HOST_PEER_SET_MAC_TX_RATE:
608 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
609 break;
610 case WMI_HOST_PEER_SET_MIN_TX_RATE:
611 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
612 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530613 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
614 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
615 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530616 default:
617 return QDF_STATUS_E_NOSUPPORT;
618 }
619
620 return QDF_STATUS_SUCCESS;
621}
622#endif
623/**
Govind Singh5eb51532016-03-09 11:34:12 +0530624 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530625 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530626 * @peer_addr: peer mac address
627 * @param : pointer to hold peer set parameter
628 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530629 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530630 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530631static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530632 uint8_t peer_addr[IEEE80211_ADDR_LEN],
633 struct peer_set_params *param)
634{
635 wmi_peer_set_param_cmd_fixed_param *cmd;
636 wmi_buf_t buf;
637 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530638 uint32_t param_id;
639
640 if (convert_host_peer_id_to_target_id_tlv(&param_id,
641 param->param_id) != QDF_STATUS_SUCCESS)
642 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530643
644 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
645 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530646 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530647 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530648 }
649 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
650 WMITLV_SET_HDR(&cmd->tlv_header,
651 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
652 WMITLV_GET_STRUCT_TLVLEN
653 (wmi_peer_set_param_cmd_fixed_param));
654 cmd->vdev_id = param->vdev_id;
655 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530656 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530657 cmd->param_value = param->param_value;
658 err = wmi_unified_cmd_send(wmi, buf,
659 sizeof(wmi_peer_set_param_cmd_fixed_param),
660 WMI_PEER_SET_PARAM_CMDID);
661 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530662 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530663 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530664 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530665 }
666
667 return 0;
668}
669
670/**
671 * send_vdev_up_cmd_tlv() - send vdev up command in fw
672 * @wmi: wmi handle
673 * @bssid: bssid
674 * @vdev_up_params: pointer to hold vdev up parameter
675 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530676 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530677 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530678static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530679 uint8_t bssid[IEEE80211_ADDR_LEN],
680 struct vdev_up_params *params)
681{
682 wmi_vdev_up_cmd_fixed_param *cmd;
683 wmi_buf_t buf;
684 int32_t len = sizeof(*cmd);
685
Govind Singhb53420c2016-03-09 14:32:57 +0530686 WMI_LOGD("%s: VDEV_UP", __func__);
687 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530688 params->vdev_id, params->assoc_id, bssid);
689 buf = wmi_buf_alloc(wmi, len);
690 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530691 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530692 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530693 }
694 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
695 WMITLV_SET_HDR(&cmd->tlv_header,
696 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
697 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
698 cmd->vdev_id = params->vdev_id;
699 cmd->vdev_assoc_id = params->assoc_id;
700 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
701 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530702 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530703 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530704 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530705 }
706
707 return 0;
708}
709
710/**
711 * send_peer_create_cmd_tlv() - send peer create command to fw
712 * @wmi: wmi handle
713 * @peer_addr: peer mac address
714 * @peer_type: peer type
715 * @vdev_id: vdev id
716 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530717 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530718 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530719static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530720 struct peer_create_params *param)
721{
722 wmi_peer_create_cmd_fixed_param *cmd;
723 wmi_buf_t buf;
724 int32_t len = sizeof(*cmd);
725
726 buf = wmi_buf_alloc(wmi, len);
727 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530728 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530729 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530730 }
731 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
732 WMITLV_SET_HDR(&cmd->tlv_header,
733 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
734 WMITLV_GET_STRUCT_TLVLEN
735 (wmi_peer_create_cmd_fixed_param));
736 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
737 cmd->peer_type = param->peer_type;
738 cmd->vdev_id = param->vdev_id;
739
740 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530741 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530742 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530743 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530744 }
Govind Singhb53420c2016-03-09 14:32:57 +0530745 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530746 param->vdev_id);
747
748 return 0;
749}
750
751/**
Leo Changeee40872016-09-28 13:43:36 -0700752 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
753 * command to fw
754 * @wmi: wmi handle
755 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
756 *
757 * Return: 0 for success or error code
758 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700759static
Leo Changeee40872016-09-28 13:43:36 -0700760QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
761 struct rx_reorder_queue_setup_params *param)
762{
763 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
764 wmi_buf_t buf;
765 int32_t len = sizeof(*cmd);
766
767 buf = wmi_buf_alloc(wmi, len);
768 if (!buf) {
769 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
770 return QDF_STATUS_E_NOMEM;
771 }
772 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
773 WMITLV_SET_HDR(&cmd->tlv_header,
774 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
775 WMITLV_GET_STRUCT_TLVLEN
776 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
777 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
778 cmd->vdev_id = param->vdev_id;
779 cmd->tid = param->tid;
780 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
781 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
782 cmd->queue_no = param->queue_no;
783
784 if (wmi_unified_cmd_send(wmi, buf, len,
785 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
786 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
787 __func__);
788 qdf_nbuf_free(buf);
789 return QDF_STATUS_E_FAILURE;
790 }
791 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
792 param->peer_macaddr, param->vdev_id, param->tid);
793
794 return QDF_STATUS_SUCCESS;
795}
796
797/**
798 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
799 * command to fw
800 * @wmi: wmi handle
801 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
802 *
803 * Return: 0 for success or error code
804 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700805static
Leo Changeee40872016-09-28 13:43:36 -0700806QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
807 struct rx_reorder_queue_remove_params *param)
808{
809 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
810 wmi_buf_t buf;
811 int32_t len = sizeof(*cmd);
812
813 buf = wmi_buf_alloc(wmi, len);
814 if (!buf) {
815 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
816 return QDF_STATUS_E_NOMEM;
817 }
818 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
819 wmi_buf_data(buf);
820 WMITLV_SET_HDR(&cmd->tlv_header,
821 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
822 WMITLV_GET_STRUCT_TLVLEN
823 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
824 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
825 cmd->vdev_id = param->vdev_id;
826 cmd->tid_mask = param->peer_tid_bitmap;
827
828 if (wmi_unified_cmd_send(wmi, buf, len,
829 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
830 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
831 __func__);
832 qdf_nbuf_free(buf);
833 return QDF_STATUS_E_FAILURE;
834 }
835 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
836 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
837
838 return QDF_STATUS_SUCCESS;
839}
840
841/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530842 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
843 * @wmi_handle: wmi handle
844 * @param: pointer holding peer details
845 *
846 * Return: 0 for success or error code
847 */
848static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
849 struct peer_add_wds_entry_params *param)
850{
851 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
852 wmi_buf_t buf;
853 int len = sizeof(*cmd);
854
855 buf = wmi_buf_alloc(wmi_handle, len);
856 if (!buf) {
857 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
858 return QDF_STATUS_E_FAILURE;
859 }
860 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
861 WMITLV_SET_HDR(&cmd->tlv_header,
862 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
863 WMITLV_GET_STRUCT_TLVLEN
864 (wmi_peer_add_wds_entry_cmd_fixed_param));
865 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
866 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
867 cmd->flags = param->flags;
868
869 return wmi_unified_cmd_send(wmi_handle, buf, len,
870 WMI_PEER_ADD_WDS_ENTRY_CMDID);
871}
872
873/**
874 * send_peer_del_wds_entry_cmd_non_tlv() - send peer delete command to fw
875 * @wmi_handle: wmi handle
876 * @param: pointer holding peer details
877 *
878 * Return: 0 for success or error code
879 */
880static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
881 struct peer_del_wds_entry_params *param)
882{
883 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
884 wmi_buf_t buf;
885 int len = sizeof(*cmd);
886
887 buf = wmi_buf_alloc(wmi_handle, len);
888 if (!buf) {
889 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
890 return QDF_STATUS_E_NOMEM;
891 }
892 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
893 WMITLV_SET_HDR(&cmd->tlv_header,
894 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
895 WMITLV_GET_STRUCT_TLVLEN
896 (wmi_peer_remove_wds_entry_cmd_fixed_param));
897 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
898 return wmi_unified_cmd_send(wmi_handle, buf, len,
899 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
900}
901
902/**
903 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
904 * @wmi_handle: wmi handle
905 * @param: pointer holding peer details
906 *
907 * Return: 0 for success or error code
908 */
909static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
910 struct peer_update_wds_entry_params *param)
911{
912 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
913 wmi_buf_t buf;
914 int len = sizeof(*cmd);
915
916 buf = wmi_buf_alloc(wmi_handle, len);
917 if (!buf) {
918 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
919 return QDF_STATUS_E_NOMEM;
920 }
921
922 /* wmi_buf_alloc returns zeroed command buffer */
923 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
924 WMITLV_SET_HDR(&cmd->tlv_header,
925 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
926 WMITLV_GET_STRUCT_TLVLEN
927 (wmi_peer_update_wds_entry_cmd_fixed_param));
928 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
929 if (param->wds_macaddr)
930 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
931 &cmd->wds_macaddr);
932 if (param->peer_macaddr)
933 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
934 &cmd->peer_macaddr);
935 return wmi_unified_cmd_send(wmi_handle, buf, len,
936 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
937}
938
939
940
941/**
Govind Singh5eb51532016-03-09 11:34:12 +0530942 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
943 * @wmi_handle: wmi handle
944 * @value: value
945 * @mac_id: mac id to have radio context
946 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530947 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530948 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530949static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530950 uint32_t value, uint8_t mac_id)
951{
952 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
953 wmi_buf_t buf;
954 int32_t len = sizeof(*cmd);
955
Govind Singhb53420c2016-03-09 14:32:57 +0530956 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530957
958 buf = wmi_buf_alloc(wmi_handle, len);
959 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530960 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530961 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530962 }
963
964 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
965 WMITLV_SET_HDR(&cmd->tlv_header,
966 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
967 WMITLV_GET_STRUCT_TLVLEN
968 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530969 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530970 cmd->enable = value;
971
972 if (wmi_unified_cmd_send(wmi_handle, buf, len,
973 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530974 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530975 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530976 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530977 }
978
979 return 0;
980}
981
982/**
983 * send_pdev_utf_cmd_tlv() - send utf command to fw
984 * @wmi_handle: wmi handle
985 * @param: pointer to pdev_utf_params
986 * @mac_id: mac id to have radio context
987 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530988 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530989 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530990static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530991send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
992 struct pdev_utf_params *param,
993 uint8_t mac_id)
994{
995 wmi_buf_t buf;
996 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -0700997 /* if param->len is 0 no data is sent, return error */
998 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +0530999 static uint8_t msgref = 1;
1000 uint8_t segNumber = 0, segInfo, numSegments;
1001 uint16_t chunk_len, total_bytes;
1002 uint8_t *bufpos;
1003 struct seg_hdr_info segHdrInfo;
1004
1005 bufpos = param->utf_payload;
1006 total_bytes = param->len;
1007 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1008 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1009 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1010
1011 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1012 numSegments++;
1013
1014 while (param->len) {
1015 if (param->len > MAX_WMI_UTF_LEN)
1016 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1017 else
1018 chunk_len = param->len;
1019
1020 buf = wmi_buf_alloc(wmi_handle,
1021 (chunk_len + sizeof(segHdrInfo) +
1022 WMI_TLV_HDR_SIZE));
1023 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301024 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301025 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301026 }
1027
1028 cmd = (uint8_t *) wmi_buf_data(buf);
1029
1030 segHdrInfo.len = total_bytes;
1031 segHdrInfo.msgref = msgref;
1032 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1033 segHdrInfo.segmentInfo = segInfo;
1034 segHdrInfo.pad = 0;
1035
Govind Singhb53420c2016-03-09 14:32:57 +05301036 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301037 " segHdrInfo.segmentInfo = %d",
1038 __func__, segHdrInfo.len, segHdrInfo.msgref,
1039 segHdrInfo.segmentInfo);
1040
Govind Singhb53420c2016-03-09 14:32:57 +05301041 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301042 "chunk len %d", __func__, total_bytes, segNumber,
1043 numSegments, chunk_len);
1044
1045 segNumber++;
1046
1047 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1048 (chunk_len + sizeof(segHdrInfo)));
1049 cmd += WMI_TLV_HDR_SIZE;
1050 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1051 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1052
1053 ret = wmi_unified_cmd_send(wmi_handle, buf,
1054 (chunk_len + sizeof(segHdrInfo) +
1055 WMI_TLV_HDR_SIZE),
1056 WMI_PDEV_UTF_CMDID);
1057
Govind Singh67922e82016-04-01 16:48:57 +05301058 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301059 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301060 wmi_buf_free(buf);
1061 break;
1062 }
1063
1064 param->len -= chunk_len;
1065 bufpos += chunk_len;
1066 }
1067
1068 msgref++;
1069
1070 return ret;
1071}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301072#ifdef CONFIG_MCL
1073static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1074 uint32_t host_param)
1075{
1076 return host_param;
1077}
1078#else
1079static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1080 uint32_t host_param)
1081{
1082 if (host_param < wmi_pdev_param_max)
1083 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301084
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301085 return WMI_UNAVAILABLE_PARAM;
1086}
1087#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301088/**
1089 * send_pdev_param_cmd_tlv() - set pdev parameters
1090 * @wmi_handle: wmi handle
1091 * @param: pointer to pdev parameter
1092 * @mac_id: radio context
1093 *
1094 * Return: 0 on success, errno on failure
1095 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301096static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301097send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1098 struct pdev_params *param,
1099 uint8_t mac_id)
1100{
Govind Singh67922e82016-04-01 16:48:57 +05301101 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301102 wmi_pdev_set_param_cmd_fixed_param *cmd;
1103 wmi_buf_t buf;
1104 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301105 uint32_t pdev_param;
1106
1107 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1108 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1109 WMI_LOGW("%s: Unavailable param %d\n",
1110 __func__, param->param_id);
1111 return QDF_STATUS_E_INVAL;
1112 }
Govind Singh5eb51532016-03-09 11:34:12 +05301113
1114 buf = wmi_buf_alloc(wmi_handle, len);
1115 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301116 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301117 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301118 }
1119 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1120 WMITLV_SET_HDR(&cmd->tlv_header,
1121 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1122 WMITLV_GET_STRUCT_TLVLEN
1123 (wmi_pdev_set_param_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +05301124 cmd->pdev_id = 0;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301125 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301126 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301127 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301128 param->param_value);
1129 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1130 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301131 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301132 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301133 wmi_buf_free(buf);
1134 }
1135 return ret;
1136}
1137
1138/**
1139 * send_suspend_cmd_tlv() - WMI suspend function
1140 * @param wmi_handle : handle to WMI.
1141 * @param param : pointer to hold suspend parameter
1142 * @mac_id: radio context
1143 *
1144 * Return 0 on success and -ve on failure.
1145 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301146static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301147 struct suspend_params *param,
1148 uint8_t mac_id)
1149{
1150 wmi_pdev_suspend_cmd_fixed_param *cmd;
1151 wmi_buf_t wmibuf;
1152 uint32_t len = sizeof(*cmd);
1153 int32_t ret;
1154
1155 /*
1156 * send the comand to Target to ignore the
1157 * PCIE reset so as to ensure that Host and target
1158 * states are in sync
1159 */
1160 wmibuf = wmi_buf_alloc(wmi_handle, len);
1161 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301162 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301163
1164 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1165 WMITLV_SET_HDR(&cmd->tlv_header,
1166 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1167 WMITLV_GET_STRUCT_TLVLEN
1168 (wmi_pdev_suspend_cmd_fixed_param));
1169 if (param->disable_target_intr)
1170 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1171 else
1172 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1173 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1174 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301175 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301176 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301177 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301178 }
1179
1180 return ret;
1181}
1182
1183/**
1184 * send_resume_cmd_tlv() - WMI resume function
1185 * @param wmi_handle : handle to WMI.
1186 * @mac_id: radio context
1187 *
1188 * Return: 0 on success and -ve on failure.
1189 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301190static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301191 uint8_t mac_id)
1192{
1193 wmi_buf_t wmibuf;
1194 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301195 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301196
1197 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1198 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301199 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301200 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1201 WMITLV_SET_HDR(&cmd->tlv_header,
1202 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1203 WMITLV_GET_STRUCT_TLVLEN
1204 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07001205 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +05301206 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1207 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301208 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301209 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301210 wmi_buf_free(wmibuf);
1211 }
1212
1213 return ret;
1214}
1215
1216/**
1217 * send_wow_enable_cmd_tlv() - WMI wow enable function
1218 * @param wmi_handle : handle to WMI.
1219 * @param param : pointer to hold wow enable parameter
1220 * @mac_id: radio context
1221 *
1222 * Return: 0 on success and -ve on failure.
1223 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301224static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301225 struct wow_cmd_params *param,
1226 uint8_t mac_id)
1227{
1228 wmi_wow_enable_cmd_fixed_param *cmd;
1229 wmi_buf_t buf;
1230 int32_t len;
1231 int32_t ret;
1232
1233 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1234
1235 buf = wmi_buf_alloc(wmi_handle, len);
1236 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301237 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1238 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301239 }
1240 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1241 WMITLV_SET_HDR(&cmd->tlv_header,
1242 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1243 WMITLV_GET_STRUCT_TLVLEN
1244 (wmi_wow_enable_cmd_fixed_param));
1245 cmd->enable = param->enable;
1246 if (param->can_suspend_link)
1247 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1248 else
1249 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001250 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301251
Govind Singhb53420c2016-03-09 14:32:57 +05301252 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301253 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1254 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1255
1256 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1257 WMI_WOW_ENABLE_CMDID);
1258 if (ret)
1259 wmi_buf_free(buf);
1260
1261 return ret;
1262}
1263
1264/**
1265 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301266 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301267 * @peer_addr: peer mac address
1268 * @param: pointer to ap_ps parameter structure
1269 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301270 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301271 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301272static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301273 uint8_t *peer_addr,
1274 struct ap_ps_params *param)
1275{
1276 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1277 wmi_buf_t buf;
1278 int32_t err;
1279
1280 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1281 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301282 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301283 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301284 }
1285 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1286 WMITLV_SET_HDR(&cmd->tlv_header,
1287 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1288 WMITLV_GET_STRUCT_TLVLEN
1289 (wmi_ap_ps_peer_cmd_fixed_param));
1290 cmd->vdev_id = param->vdev_id;
1291 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1292 cmd->param = param->param;
1293 cmd->value = param->value;
1294 err = wmi_unified_cmd_send(wmi_handle, buf,
1295 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1296 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301297 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301298 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301299 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301300 }
1301
1302 return 0;
1303}
1304
1305/**
1306 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301307 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301308 * @peer_addr: peer mac address
1309 * @param: pointer to sta_ps parameter structure
1310 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301311 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301312 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301313static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301314 struct sta_ps_params *param)
1315{
1316 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1317 wmi_buf_t buf;
1318 int32_t len = sizeof(*cmd);
1319
1320 buf = wmi_buf_alloc(wmi_handle, len);
1321 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301322 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301323 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301324 }
1325
1326 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1327 WMITLV_SET_HDR(&cmd->tlv_header,
1328 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1329 WMITLV_GET_STRUCT_TLVLEN
1330 (wmi_sta_powersave_param_cmd_fixed_param));
1331 cmd->vdev_id = param->vdev_id;
1332 cmd->param = param->param;
1333 cmd->value = param->value;
1334
1335 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1336 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301337 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301338 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301339 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301340 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301341 }
1342
1343 return 0;
1344}
1345
1346/**
1347 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301348 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301349 * @param: ponirt to crash inject paramter structure
1350 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301351 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301352 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301353static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301354 struct crash_inject *param)
1355{
1356 int32_t ret = 0;
1357 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1358 uint16_t len = sizeof(*cmd);
1359 wmi_buf_t buf;
1360
1361 buf = wmi_buf_alloc(wmi_handle, len);
1362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301363 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301364 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301365 }
1366
1367 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1368 WMITLV_SET_HDR(&cmd->tlv_header,
1369 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1370 WMITLV_GET_STRUCT_TLVLEN
1371 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1372 cmd->type = param->type;
1373 cmd->delay_time_ms = param->delay_time_ms;
1374
1375 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1376 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301377 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301378 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301379 __func__, ret);
1380 wmi_buf_free(buf);
1381 }
1382
1383 return ret;
1384}
1385
1386/**
1387 * send_dbglog_cmd_tlv() - set debug log level
1388 * @param wmi_handle : handle to WMI.
1389 * @param param : pointer to hold dbglog level parameter
1390 *
1391 * Return: 0 on success and -ve on failure.
1392 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301393 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301394send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1395 struct dbglog_params *dbglog_param)
1396{
1397 wmi_buf_t buf;
1398 wmi_debug_log_config_cmd_fixed_param *configmsg;
1399 A_STATUS status = A_OK;
1400 int32_t i;
1401 int32_t len;
1402 int8_t *buf_ptr;
1403 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1404
1405 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1406
1407 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1408 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1409 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1410 buf = wmi_buf_alloc(wmi_handle, len);
1411 if (buf == NULL)
1412 return A_NO_MEMORY;
1413
1414 configmsg =
1415 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1416 buf_ptr = (int8_t *) configmsg;
1417 WMITLV_SET_HDR(&configmsg->tlv_header,
1418 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1419 WMITLV_GET_STRUCT_TLVLEN
1420 (wmi_debug_log_config_cmd_fixed_param));
1421 configmsg->dbg_log_param = dbglog_param->param;
1422 configmsg->value = dbglog_param->val;
1423 /* Filling in the data part of second tlv -- should
1424 * follow first tlv _ WMI_TLV_HDR_SIZE */
1425 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1426 sizeof
1427 (wmi_debug_log_config_cmd_fixed_param)
1428 + WMI_TLV_HDR_SIZE);
1429 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1430 WMITLV_TAG_ARRAY_UINT32,
1431 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1432 if (dbglog_param->module_id_bitmap) {
1433 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1434 module_id_bitmap_array[i] =
1435 dbglog_param->module_id_bitmap[i];
1436 }
1437 }
1438
1439 status = wmi_unified_cmd_send(wmi_handle, buf,
1440 len, WMI_DBGLOG_CFG_CMDID);
1441
1442 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301443 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301444
1445 return status;
1446}
1447
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301448#ifdef CONFIG_MCL
1449static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1450 uint32_t host_param)
1451{
1452 return host_param;
1453}
1454#else
1455static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1456 uint32_t host_param)
1457{
1458 if (host_param < wmi_vdev_param_max)
1459 return wmi_handle->vdev_param[host_param];
1460
1461 return WMI_UNAVAILABLE_PARAM;
1462}
1463#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301464/**
1465 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1466 * @param wmi_handle : handle to WMI.
1467 * @param macaddr : MAC address
1468 * @param param : pointer to hold vdev set parameter
1469 *
1470 * Return: 0 on success and -ve on failure.
1471 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301472static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301473 struct vdev_set_params *param)
1474{
Govind Singh67922e82016-04-01 16:48:57 +05301475 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301476 wmi_vdev_set_param_cmd_fixed_param *cmd;
1477 wmi_buf_t buf;
1478 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301479 uint32_t vdev_param;
1480
1481 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1482 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1483 WMI_LOGW("%s:Vdev param %d not available", __func__,
1484 param->param_id);
1485 return QDF_STATUS_E_INVAL;
1486
1487 }
Govind Singh5eb51532016-03-09 11:34:12 +05301488
1489 buf = wmi_buf_alloc(wmi_handle, len);
1490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301491 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301492 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301493 }
1494 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1495 WMITLV_SET_HDR(&cmd->tlv_header,
1496 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1497 WMITLV_GET_STRUCT_TLVLEN
1498 (wmi_vdev_set_param_cmd_fixed_param));
1499 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301500 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301501 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301502 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301503 param->if_id, param->param_id, param->param_value);
1504 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1505 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301506 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301507 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301508 wmi_buf_free(buf);
1509 }
1510
1511 return ret;
1512}
1513
1514/**
1515 * send_stats_request_cmd_tlv() - WMI request stats function
1516 * @param wmi_handle : handle to WMI.
1517 * @param macaddr : MAC address
1518 * @param param : pointer to hold stats request parameter
1519 *
1520 * Return: 0 on success and -ve on failure.
1521 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301522static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301523 uint8_t macaddr[IEEE80211_ADDR_LEN],
1524 struct stats_request_params *param)
1525{
Govind Singhd3156eb2016-02-26 17:50:39 +05301526 int32_t ret;
1527 wmi_request_stats_cmd_fixed_param *cmd;
1528 wmi_buf_t buf;
1529 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1530
1531 buf = wmi_buf_alloc(wmi_handle, len);
1532 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301533 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1534 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301535 }
1536
1537 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1538 WMITLV_SET_HDR(&cmd->tlv_header,
1539 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1540 WMITLV_GET_STRUCT_TLVLEN
1541 (wmi_request_stats_cmd_fixed_param));
1542 cmd->stats_id = param->stats_id;
1543 cmd->vdev_id = param->vdev_id;
1544 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1545 WMI_REQUEST_STATS_CMDID);
1546 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301547 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301548 wmi_buf_free(buf);
1549 }
1550
1551 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301552}
1553
Govind Singh87542482016-06-08 19:40:11 +05301554#ifdef CONFIG_WIN
1555/**
1556 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1557 * @param wmi_handle : handle to WMI.
1558 * @param macaddr : MAC address
1559 * @param param : pointer to hold stats request parameter
1560 *
1561 * Return: 0 on success and -ve on failure.
1562 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301563static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301564 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1565{
1566 return 0;
1567}
1568#else
Govind Singh5eb51532016-03-09 11:34:12 +05301569/**
1570 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1571 * @param wmi_handle : handle to WMI.
1572 * @param macaddr : MAC address
1573 * @param param : pointer to hold stats request parameter
1574 *
1575 * Return: 0 on success and -ve on failure.
1576 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301577static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301578 uint8_t macaddr[IEEE80211_ADDR_LEN],
1579 struct packet_enable_params *param)
1580{
1581 return 0;
1582}
Govind Singh87542482016-06-08 19:40:11 +05301583#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301584
Govind Singh87542482016-06-08 19:40:11 +05301585#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301586/**
1587 * send_beacon_send_cmd_tlv() - WMI beacon send function
1588 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301589 * @param param : pointer to hold beacon send cmd parameter
1590 *
1591 * Return: 0 on success and -ve on failure.
1592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301593static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301594 struct beacon_params *param)
1595{
Govind Singhd3156eb2016-02-26 17:50:39 +05301596 int32_t ret;
1597 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1598 wmi_bcn_prb_info *bcn_prb_info;
1599 wmi_buf_t wmi_buf;
1600 uint8_t *buf_ptr;
1601 uint32_t wmi_buf_len;
1602
1603 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1604 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1605 param->tmpl_len_aligned;
1606 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1607 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301608 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301609 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301610 }
1611 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1612 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1613 WMITLV_SET_HDR(&cmd->tlv_header,
1614 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1615 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1616 cmd->vdev_id = param->vdev_id;
1617 cmd->tim_ie_offset = param->tim_ie_offset;
1618 cmd->buf_len = param->tmpl_len;
1619 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1620
1621 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1622 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1623 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1624 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1625 bcn_prb_info->caps = 0;
1626 bcn_prb_info->erp = 0;
1627 buf_ptr += sizeof(wmi_bcn_prb_info);
1628
1629 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1630 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301631 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301632
1633 ret = wmi_unified_cmd_send(wmi_handle,
1634 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1635 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301636 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301637 wmi_buf_free(wmi_buf);
1638 }
Govind Singh5eb51532016-03-09 11:34:12 +05301639 return 0;
1640}
Govind Singh87542482016-06-08 19:40:11 +05301641#else
Sathish Kumarfd347372017-02-13 12:29:09 +05301642static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301643 struct beacon_params *param)
1644{
1645 return 0;
1646}
1647
1648/**
1649 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1650 * @param wmi_handle : handle to WMI.
1651 * @param param : pointer to hold beacon send cmd parameter
1652 *
1653 * Return: 0 on success and -ve on failure.
1654 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301655static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301656 struct beacon_tmpl_params *param)
1657{
1658 int32_t ret;
1659 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1660 wmi_bcn_prb_info *bcn_prb_info;
1661 wmi_buf_t wmi_buf;
1662 uint8_t *buf_ptr;
1663 uint32_t wmi_buf_len;
1664
Sathish Kumar45e991b2017-02-27 10:35:40 +05301665 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301666 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1667 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1668 param->tmpl_len_aligned;
1669 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1670 if (!wmi_buf) {
1671 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1672 return QDF_STATUS_E_NOMEM;
1673 }
1674 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1675 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1676 WMITLV_SET_HDR(&cmd->tlv_header,
1677 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1678 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1679 cmd->vdev_id = param->vdev_id;
1680 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301681 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1682 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301683 cmd->buf_len = param->tmpl_len;
1684 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1685
1686 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1687 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1688 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1689 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1690 bcn_prb_info->caps = 0;
1691 bcn_prb_info->erp = 0;
1692 buf_ptr += sizeof(wmi_bcn_prb_info);
1693
1694 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1695 buf_ptr += WMI_TLV_HDR_SIZE;
1696 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1697
1698 ret = wmi_unified_cmd_send(wmi_handle,
1699 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1700 if (ret) {
1701 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1702 wmi_buf_free(wmi_buf);
1703 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301704
Govind Singh87542482016-06-08 19:40:11 +05301705 return 0;
1706}
1707#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301708
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301709#ifdef CONFIG_MCL
1710static inline void copy_peer_flags_tlv(
1711 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1712 struct peer_assoc_params *param)
1713{
1714 cmd->peer_flags = param->peer_flags;
1715}
1716#else
1717static inline void copy_peer_flags_tlv(
1718 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1719 struct peer_assoc_params *param)
1720{
1721 /*
1722 * The target only needs a subset of the flags maintained in the host.
1723 * Just populate those flags and send it down
1724 */
1725 cmd->peer_flags = 0;
1726
1727 /*
1728 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1729 */
1730 if (param->is_wme_set) {
1731
1732 if (param->qos_flag)
1733 cmd->peer_flags |= WMI_PEER_QOS;
1734 if (param->apsd_flag)
1735 cmd->peer_flags |= WMI_PEER_APSD;
1736 if (param->ht_flag)
1737 cmd->peer_flags |= WMI_PEER_HT;
1738 if (param->bw_40)
1739 cmd->peer_flags |= WMI_PEER_40MHZ;
1740 if (param->bw_80)
1741 cmd->peer_flags |= WMI_PEER_80MHZ;
1742 if (param->bw_160)
1743 cmd->peer_flags |= WMI_PEER_160MHZ;
1744
1745 /* Typically if STBC is enabled for VHT it should be enabled
1746 * for HT as well
1747 **/
1748 if (param->stbc_flag)
1749 cmd->peer_flags |= WMI_PEER_STBC;
1750
1751 /* Typically if LDPC is enabled for VHT it should be enabled
1752 * for HT as well
1753 **/
1754 if (param->ldpc_flag)
1755 cmd->peer_flags |= WMI_PEER_LDPC;
1756
1757 if (param->static_mimops_flag)
1758 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1759 if (param->dynamic_mimops_flag)
1760 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1761 if (param->spatial_mux_flag)
1762 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1763 if (param->vht_flag)
1764 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001765 if (param->he_flag)
1766 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301767 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001768
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301769 /*
1770 * Suppress authorization for all AUTH modes that need 4-way handshake
1771 * (during re-association).
1772 * Authorization will be done for these modes on key installation.
1773 */
1774 if (param->auth_flag)
1775 cmd->peer_flags |= WMI_PEER_AUTH;
1776 if (param->need_ptk_4_way)
1777 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1778 else
1779 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1780 if (param->need_gtk_2_way)
1781 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1782 /* safe mode bypass the 4-way handshake */
1783 if (param->safe_mode_enabled)
1784 cmd->peer_flags &=
1785 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1786 /* Disable AMSDU for station transmit, if user configures it */
1787 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1788 * it
1789 * if (param->amsdu_disable) Add after FW support
1790 **/
1791
1792 /* Target asserts if node is marked HT and all MCS is set to 0.
1793 * Mark the node as non-HT if all the mcs rates are disabled through
1794 * iwpriv
1795 **/
1796 if (param->peer_ht_rates.num_rates == 0)
1797 cmd->peer_flags &= ~WMI_PEER_HT;
1798}
1799#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301800
1801#ifdef CONFIG_MCL
1802static inline void copy_peer_mac_addr_tlv(
1803 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1804 struct peer_assoc_params *param)
1805{
1806 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1807 sizeof(param->peer_macaddr));
1808}
1809#else
1810static inline void copy_peer_mac_addr_tlv(
1811 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1812 struct peer_assoc_params *param)
1813{
1814 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1815}
1816#endif
1817
Govind Singh5eb51532016-03-09 11:34:12 +05301818/**
1819 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1820 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301821 * @param param : pointer to peer assoc parameter
1822 *
1823 * Return: 0 on success and -ve on failure.
1824 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301825static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301826 struct peer_assoc_params *param)
1827{
Govind Singhd3156eb2016-02-26 17:50:39 +05301828 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1829 wmi_vht_rate_set *mcs;
1830 wmi_buf_t buf;
1831 int32_t len;
1832 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301833 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301834 uint32_t peer_legacy_rates_align;
1835 uint32_t peer_ht_rates_align;
1836
1837
1838 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1839 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301840
1841 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301842 (peer_legacy_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301843 WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301844 (peer_ht_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301845 sizeof(wmi_vht_rate_set);
1846
1847 buf = wmi_buf_alloc(wmi_handle, len);
1848 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301849 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301850 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301851 }
1852
1853 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1854 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1855 WMITLV_SET_HDR(&cmd->tlv_header,
1856 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1857 WMITLV_GET_STRUCT_TLVLEN
1858 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301859
Govind Singhd3156eb2016-02-26 17:50:39 +05301860 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301861
Govind Singhd3156eb2016-02-26 17:50:39 +05301862 cmd->peer_new_assoc = param->peer_new_assoc;
1863 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301864
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301865 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301866 copy_peer_mac_addr_tlv(cmd, param);
1867
Govind Singhd3156eb2016-02-26 17:50:39 +05301868 cmd->peer_rate_caps = param->peer_rate_caps;
1869 cmd->peer_caps = param->peer_caps;
1870 cmd->peer_listen_intval = param->peer_listen_intval;
1871 cmd->peer_ht_caps = param->peer_ht_caps;
1872 cmd->peer_max_mpdu = param->peer_max_mpdu;
1873 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301874 cmd->peer_vht_caps = param->peer_vht_caps;
1875 cmd->peer_phymode = param->peer_phymode;
1876
1877 /* Update peer legacy rate information */
1878 buf_ptr += sizeof(*cmd);
1879 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301880 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301881 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301882 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301883 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301884 param->peer_legacy_rates.num_rates);
1885
1886 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001887 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301888 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301889 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301890 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301891 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301892 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301893 param->peer_ht_rates.num_rates);
1894
1895 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001896 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301897 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1898 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1899
1900 cmd->peer_nss = param->peer_nss;
1901 mcs = (wmi_vht_rate_set *) buf_ptr;
1902 if (param->vht_capable) {
1903 mcs->rx_max_rate = param->rx_max_rate;
1904 mcs->rx_mcs_set = param->rx_mcs_set;
1905 mcs->tx_max_rate = param->tx_max_rate;
1906 mcs->tx_mcs_set = param->tx_mcs_set;
1907 }
Kris Muthusamy61fe3692017-02-20 02:35:47 -08001908 /* Update 11ax capabilities */
1909 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1910 cmd->peer_he_ops = param->peer_he_ops;
1911 cmd->peer_he_mcs = param->peer_he_mcs;
1912 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1913 sizeof(param->peer_he_cap_phyinfo));
1914 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1915 sizeof(param->peer_ppet));
Govind Singhd3156eb2016-02-26 17:50:39 +05301916
Govind Singhb53420c2016-03-09 14:32:57 +05301917 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301918 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1919 "nss %d phymode %d peer_mpdu_density %d "
1920 "cmd->peer_vht_caps %x", __func__,
1921 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1922 cmd->peer_rate_caps, cmd->peer_caps,
1923 cmd->peer_listen_intval, cmd->peer_ht_caps,
1924 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1925 cmd->peer_mpdu_density,
1926 cmd->peer_vht_caps);
1927
1928 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1929 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301930 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301931 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301932 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301933 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301934 }
1935
1936 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301937}
1938
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301939/* copy_scan_notify_events() - Helper routine to copy scan notify events
1940 */
1941#ifdef CONFIG_MCL
1942static inline void copy_scan_notify_ev_flags(
1943 wmi_start_scan_cmd_fixed_param * cmd,
1944 struct scan_start_params *params)
1945{
1946 cmd->notify_scan_events = params->notify_scan_events;
1947 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1948}
1949#else
1950static inline void copy_scan_notify_ev_flags(
1951 wmi_start_scan_cmd_fixed_param * cmd,
1952 struct scan_start_params *params)
1953{
1954 cmd->notify_scan_events = WMI_SCAN_EVENT_STARTED |
1955 WMI_SCAN_EVENT_COMPLETED |
1956 WMI_SCAN_EVENT_BSS_CHANNEL |
1957 WMI_SCAN_EVENT_FOREIGN_CHANNEL |
1958 WMI_SCAN_EVENT_DEQUEUED
1959 ;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301960
1961 cmd->scan_ctrl_flags = (params->passive_flag) ?
1962 WMI_SCAN_FLAG_PASSIVE : 0;
1963
1964 if (params->is_strict_pscan_en)
1965 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301966
1967 if (params->is_phy_error)
1968 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301969
1970 if (params->half_rate)
1971 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
1972
1973 if (params->quarter_rate)
1974 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
1975
1976 if (params->is_phy_error)
1977 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
1978
1979 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
1980 /* add cck rates if required */
1981 if (params->add_cck_rates)
1982 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
1983 /** It enables the Channel stat event indication to host */
1984 if (params->chan_stat_enable)
1985 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
1986 if (params->add_bcast_probe_reqd)
1987 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
1988 /* off channel TX control */
1989 if (params->offchan_tx_mgmt)
1990 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
1991 if (params->offchan_tx_data)
1992 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301993}
1994#endif
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05301995
1996
1997/* scan_copy_ie_buffer() - Copy scan ie_data */
1998#ifndef CONFIG_MCL
1999static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
2000 struct scan_start_params *params)
2001{
2002 qdf_mem_copy(buf_ptr, params->ie_data, params->ie_len);
2003}
2004#else
2005static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
2006 struct scan_start_params *params)
2007{
2008 qdf_mem_copy(buf_ptr,
2009 (uint8_t *) params->ie_base +
2010 (params->uie_fieldOffset), params->ie_len);
2011}
2012#endif
2013
Govind Singh5eb51532016-03-09 11:34:12 +05302014/**
2015 * send_scan_start_cmd_tlv() - WMI scan start function
2016 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302017 * @param param : pointer to hold scan start cmd parameter
2018 *
2019 * Return: 0 on success and -ve on failure.
2020 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302021static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302022 struct scan_start_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302023{
Govind Singhd3156eb2016-02-26 17:50:39 +05302024 int32_t ret = 0;
2025 int32_t i;
2026 wmi_buf_t wmi_buf;
2027 wmi_start_scan_cmd_fixed_param *cmd;
2028 uint8_t *buf_ptr;
2029 uint32_t *tmp_ptr;
2030 wmi_ssid *ssid = NULL;
2031 wmi_mac_addr *bssid;
2032 int len = sizeof(*cmd);
2033
2034 /* Length TLV placeholder for array of uint32_t */
2035 len += WMI_TLV_HDR_SIZE;
2036 /* calculate the length of buffer required */
2037 if (params->num_chan)
2038 len += params->num_chan * sizeof(uint32_t);
2039
2040 /* Length TLV placeholder for array of wmi_ssid structures */
2041 len += WMI_TLV_HDR_SIZE;
2042 if (params->num_ssids)
2043 len += params->num_ssids * sizeof(wmi_ssid);
2044
2045 /* Length TLV placeholder for array of wmi_mac_addr structures */
2046 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302047 if (params->num_bssid)
2048 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302049
2050 /* Length TLV placeholder for array of bytes */
2051 len += WMI_TLV_HDR_SIZE;
2052 if (params->ie_len)
2053 len += roundup(params->ie_len, sizeof(uint32_t));
2054
2055 /* Allocate the memory */
2056 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2057 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302058 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302059 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302060 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302061 }
2062 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2063 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2064 WMITLV_SET_HDR(&cmd->tlv_header,
2065 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2066 WMITLV_GET_STRUCT_TLVLEN
2067 (wmi_start_scan_cmd_fixed_param));
2068
2069 cmd->scan_id = params->scan_id;
2070 cmd->scan_req_id = params->scan_req_id;
2071 cmd->vdev_id = params->vdev_id;
2072 cmd->scan_priority = params->scan_priority;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302073 copy_scan_notify_ev_flags(cmd, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05302074 cmd->dwell_time_active = params->dwell_time_active;
2075 cmd->dwell_time_passive = params->dwell_time_passive;
2076 cmd->min_rest_time = params->min_rest_time;
2077 cmd->max_rest_time = params->max_rest_time;
2078 cmd->repeat_probe_time = params->repeat_probe_time;
2079 cmd->probe_spacing_time = params->probe_spacing_time;
2080 cmd->idle_time = params->idle_time;
2081 cmd->max_scan_time = params->max_scan_time;
2082 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302083 cmd->burst_duration = params->burst_duration;
2084 cmd->num_chan = params->num_chan;
2085 cmd->num_bssid = params->num_bssid;
2086 cmd->num_ssids = params->num_ssids;
2087 cmd->ie_len = params->ie_len;
2088 cmd->n_probes = params->n_probes;
2089 buf_ptr += sizeof(*cmd);
2090 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2091 for (i = 0; i < params->num_chan; ++i)
2092 tmp_ptr[i] = params->chan_list[i];
2093
2094 WMITLV_SET_HDR(buf_ptr,
2095 WMITLV_TAG_ARRAY_UINT32,
2096 (params->num_chan * sizeof(uint32_t)));
2097 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302098 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302099 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302100 goto error;
2101 }
2102
2103 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2104 (params->num_ssids * sizeof(wmi_ssid)));
2105
2106 if (params->num_ssids) {
2107 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2108 for (i = 0; i < params->num_ssids; ++i) {
2109 ssid->ssid_len = params->ssid[i].length;
Govind Singhb53420c2016-03-09 14:32:57 +05302110 qdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302111 params->ssid[i].length);
2112 ssid++;
2113 }
2114 }
2115 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2116
2117 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2118 (params->num_bssid * sizeof(wmi_mac_addr)));
2119 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302120#if CONFIG_MCL
Govind Singhd3156eb2016-02-26 17:50:39 +05302121 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302122#else
2123 if (params->num_bssid) {
2124 for (i = 0; i < params->num_bssid; ++i) {
2125 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->bssid_list[i],
2126 bssid);
2127 bssid++;
2128 }
2129 }
2130#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302131 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
2132
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302133 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2134 roundup(params->ie_len, sizeof(uint32_t)));
Govind Singhd3156eb2016-02-26 17:50:39 +05302135 if (params->ie_len) {
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302136 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05302137 }
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302138 buf_ptr += WMI_TLV_HDR_SIZE + roundup(params->ie_len, sizeof(uint32_t));
Govind Singhd3156eb2016-02-26 17:50:39 +05302139
2140 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
2141 len, WMI_START_SCAN_CMDID);
2142 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302143 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302144 wmi_buf_free(wmi_buf);
2145 }
2146 return ret;
2147error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302148 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302149 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302150}
2151
2152/**
2153 * send_scan_stop_cmd_tlv() - WMI scan start function
2154 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302155 * @param param : pointer to hold scan start cmd parameter
2156 *
2157 * Return: 0 on success and -ve on failure.
2158 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302159static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302160 struct scan_stop_params *param)
2161{
Govind Singhd3156eb2016-02-26 17:50:39 +05302162 wmi_stop_scan_cmd_fixed_param *cmd;
2163 int ret;
2164 int len = sizeof(*cmd);
2165 wmi_buf_t wmi_buf;
2166
2167 /* Allocate the memory */
2168 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2169 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302170 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302171 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302172 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302173 goto error;
2174 }
2175
2176 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2177 WMITLV_SET_HDR(&cmd->tlv_header,
2178 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2179 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2180 cmd->vdev_id = param->vdev_id;
2181 cmd->requestor = param->requestor;
2182 cmd->scan_id = param->scan_id;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05302183 cmd->pdev_id = param->pdev_id;
Govind Singhd3156eb2016-02-26 17:50:39 +05302184 /* stop the scan with the corresponding scan_id */
2185 cmd->req_type = param->req_type;
2186 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
2187 len, WMI_STOP_SCAN_CMDID);
2188 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302189 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302190 wmi_buf_free(wmi_buf);
2191 }
2192
2193error:
2194 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302195}
2196
Govind Singh87542482016-06-08 19:40:11 +05302197#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302198/**
2199 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2200 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302201 * @param param : pointer to hold scan channel list parameter
2202 *
2203 * Return: 0 on success and -ve on failure.
2204 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302205static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302206 struct scan_chan_list_params *chan_list)
2207{
2208 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302209 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302210 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302211 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302212 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302213 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302214 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2215
2216 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2217 buf = wmi_buf_alloc(wmi_handle, len);
2218 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302219 WMI_LOGE("Failed to allocate memory");
2220 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302221 goto end;
2222 }
2223
2224 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2225 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2226 WMITLV_SET_HDR(&cmd->tlv_header,
2227 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2228 WMITLV_GET_STRUCT_TLVLEN
2229 (wmi_scan_chan_list_cmd_fixed_param));
2230
Govind Singhb53420c2016-03-09 14:32:57 +05302231 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302232
2233 cmd->num_scan_chans = chan_list->num_scan_chans;
2234 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2235 WMITLV_TAG_ARRAY_STRUC,
2236 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302237 chan_info = (wmi_channel_param *)
2238 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302239 tchan_info = chan_list->chan_info;
2240
2241 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2242 WMITLV_SET_HDR(&chan_info->tlv_header,
2243 WMITLV_TAG_STRUC_wmi_channel,
2244 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2245 chan_info->mhz = tchan_info->mhz;
2246 chan_info->band_center_freq1 =
2247 tchan_info->band_center_freq1;
2248 chan_info->band_center_freq2 =
2249 tchan_info->band_center_freq2;
2250 chan_info->info = tchan_info->info;
2251 chan_info->reg_info_1 = tchan_info->reg_info_1;
2252 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302253 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302254
2255 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2256 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2257 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2258 tchan_info++;
2259 chan_info++;
2260 }
2261
Govind Singh67922e82016-04-01 16:48:57 +05302262 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singhd3156eb2016-02-26 17:50:39 +05302263 WMI_SCAN_CHAN_LIST_CMDID);
2264
Govind Singh67922e82016-04-01 16:48:57 +05302265 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302266 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302267 wmi_buf_free(buf);
2268 }
Govind Singh67922e82016-04-01 16:48:57 +05302269
Govind Singhd3156eb2016-02-26 17:50:39 +05302270end:
Govind Singhb53420c2016-03-09 14:32:57 +05302271 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302272}
Govind Singh87542482016-06-08 19:40:11 +05302273#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302274static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302275 struct scan_chan_list_params *chan_list)
2276{
2277 wmi_buf_t buf;
2278 QDF_STATUS qdf_status;
2279 wmi_scan_chan_list_cmd_fixed_param *cmd;
2280 int i;
2281 uint8_t *buf_ptr;
2282 wmi_channel *chan_info;
2283 struct channel_param *tchan_info;
2284 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302285
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302286 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302287 buf = wmi_buf_alloc(wmi_handle, len);
2288 if (!buf) {
2289 WMI_LOGE("Failed to allocate memory");
2290 qdf_status = QDF_STATUS_E_NOMEM;
2291 goto end;
2292 }
2293
2294 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2295 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2296 WMITLV_SET_HDR(&cmd->tlv_header,
2297 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2298 WMITLV_GET_STRUCT_TLVLEN
2299 (wmi_scan_chan_list_cmd_fixed_param));
2300
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302301 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302302
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05302303 cmd->pdev_id = chan_list->pdev_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302304 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302305 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2306 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302307 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302308 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2309 tchan_info = &(chan_list->ch_param[0]);
2310
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302311 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302312 WMITLV_SET_HDR(&chan_info->tlv_header,
2313 WMITLV_TAG_STRUC_wmi_channel,
2314 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2315 chan_info->mhz = tchan_info->mhz;
2316 chan_info->band_center_freq1 =
2317 tchan_info->cfreq1;
2318 chan_info->band_center_freq2 =
2319 tchan_info->cfreq2;
2320
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302321 if (tchan_info->is_chan_passive)
2322 WMI_SET_CHANNEL_FLAG(chan_info,
2323 WMI_CHAN_FLAG_PASSIVE);
2324
2325 if (tchan_info->allow_vht)
2326 WMI_SET_CHANNEL_FLAG(chan_info,
2327 WMI_CHAN_FLAG_ALLOW_VHT);
2328 else if (tchan_info->allow_ht)
2329 WMI_SET_CHANNEL_FLAG(chan_info,
2330 WMI_CHAN_FLAG_ALLOW_HT);
2331 WMI_SET_CHANNEL_MODE(chan_info,
2332 tchan_info->phy_mode);
2333
2334 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2335 * after FW support
2336 */
2337
2338 /* also fill in power information */
2339 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2340 tchan_info->minpower);
2341 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2342 tchan_info->maxpower);
2343 WMI_SET_CHANNEL_REG_POWER(chan_info,
2344 tchan_info->maxregpower);
2345 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2346 tchan_info->antennamax);
2347 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2348 tchan_info->reg_class_id);
2349
Govind Singh87542482016-06-08 19:40:11 +05302350 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2351
Govind Singh87542482016-06-08 19:40:11 +05302352 tchan_info++;
2353 chan_info++;
2354 }
2355
2356 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
2357 WMI_SCAN_CHAN_LIST_CMDID);
2358
2359 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2360 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2361 wmi_buf_free(buf);
2362 }
2363
2364end:
2365 return qdf_status;
2366}
2367#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302368/**
2369 * send_mgmt_cmd_tlv() - WMI scan start function
2370 * @wmi_handle : handle to WMI.
2371 * @param : pointer to hold mgmt cmd parameter
2372 *
2373 * Return: 0 on success and -ve on failure.
2374 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302375static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302376 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302377{
Govind Singh427ee5a2016-02-26 18:09:36 +05302378 wmi_buf_t buf;
2379 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2380 int32_t cmd_len;
2381 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302382 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302383 uint8_t *bufp;
2384 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2385 mgmt_tx_dl_frm_len;
2386
2387 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2388 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2389
2390 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2391 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302392 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2393 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302394 }
2395
2396 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2397 bufp = (uint8_t *) cmd;
2398 WMITLV_SET_HDR(&cmd->tlv_header,
2399 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2400 WMITLV_GET_STRUCT_TLVLEN
2401 (wmi_mgmt_tx_send_cmd_fixed_param));
2402
2403 cmd->vdev_id = param->vdev_id;
2404
Govind Singh224a7312016-06-21 14:33:26 +05302405 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302406 cmd->chanfreq = param->chanfreq;
2407 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2408 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2409 sizeof(uint32_t)));
2410 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302411 qdf_mem_copy(bufp, param->pdata, bufp_len);
2412 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2413 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302414 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002415#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302416 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2417#endif
2418 cmd->frame_len = param->frm_len;
2419 cmd->buf_len = bufp_len;
2420
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002421 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002422 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002423
Govind Singh427ee5a2016-02-26 18:09:36 +05302424 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2425 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302426 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302427 goto err1;
2428 }
Govind Singhb53420c2016-03-09 14:32:57 +05302429 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302430
2431err1:
2432 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302433 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302434}
2435
2436/**
2437 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2438 * @wmi_handle: wmi handle
2439 * @param_value: parameter value
2440 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302441 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302442 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302443static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302444 uint32_t param_value)
2445{
Govind Singh67922e82016-04-01 16:48:57 +05302446 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302447 wmi_modem_power_state_cmd_param *cmd;
2448 wmi_buf_t buf;
2449 uint16_t len = sizeof(*cmd);
2450
2451 buf = wmi_buf_alloc(wmi_handle, len);
2452 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302453 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302454 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302455 }
2456 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2457 WMITLV_SET_HDR(&cmd->tlv_header,
2458 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2459 WMITLV_GET_STRUCT_TLVLEN
2460 (wmi_modem_power_state_cmd_param));
2461 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302462 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302463 param_value);
2464 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2465 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302466 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302467 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302468 wmi_buf_free(buf);
2469 }
Govind Singh67922e82016-04-01 16:48:57 +05302470
Govind Singh427ee5a2016-02-26 18:09:36 +05302471 return ret;
2472}
2473
2474/**
2475 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2476 * @wmi_handle: wmi handle
2477 * @vdev_id: vdev id
2478 * @val: value
2479 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302480 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302481 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302482static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302483 uint32_t vdev_id, uint8_t val)
2484{
2485 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2486 wmi_buf_t buf;
2487 int32_t len = sizeof(*cmd);
2488
Govind Singhb53420c2016-03-09 14:32:57 +05302489 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302490
2491 buf = wmi_buf_alloc(wmi_handle, len);
2492 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302493 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302494 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302495 }
2496 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2497 WMITLV_SET_HDR(&cmd->tlv_header,
2498 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2499 WMITLV_GET_STRUCT_TLVLEN
2500 (wmi_sta_powersave_mode_cmd_fixed_param));
2501 cmd->vdev_id = vdev_id;
2502 if (val)
2503 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2504 else
2505 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2506
2507 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2508 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302509 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302510 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302511 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302512 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302513 }
Govind Singh5eb51532016-03-09 11:34:12 +05302514 return 0;
2515}
2516
Govind Singh427ee5a2016-02-26 18:09:36 +05302517/**
2518 * send_set_mimops_cmd_tlv() - set MIMO powersave
2519 * @wmi_handle: wmi handle
2520 * @vdev_id: vdev id
2521 * @value: value
2522 *
Govind Singhb53420c2016-03-09 14:32:57 +05302523 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302524 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302525static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302526 uint8_t vdev_id, int value)
2527{
Govind Singh67922e82016-04-01 16:48:57 +05302528 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302529 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2530 wmi_buf_t buf;
2531 uint16_t len = sizeof(*cmd);
2532
2533 buf = wmi_buf_alloc(wmi_handle, len);
2534 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302535 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302536 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302537 }
2538 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2539 WMITLV_SET_HDR(&cmd->tlv_header,
2540 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2541 WMITLV_GET_STRUCT_TLVLEN
2542 (wmi_sta_smps_force_mode_cmd_fixed_param));
2543
2544 cmd->vdev_id = vdev_id;
2545
Houston Hoffmanb5168052016-04-14 02:18:01 -07002546 /* WMI_SMPS_FORCED_MODE values do not directly map
2547 * to SM power save values defined in the specification.
2548 * Make sure to send the right mapping.
2549 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302550 switch (value) {
2551 case 0:
2552 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2553 break;
2554 case 1:
2555 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2556 break;
2557 case 2:
2558 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2559 break;
2560 case 3:
2561 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2562 break;
2563 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302564 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2565 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302566 }
2567
Govind Singhb53420c2016-03-09 14:32:57 +05302568 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302569
2570 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2571 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302572 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302573 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302574 wmi_buf_free(buf);
2575 }
2576
2577 return ret;
2578}
2579
2580/**
2581 * send_set_smps_params_cmd_tlv() - set smps params
2582 * @wmi_handle: wmi handle
2583 * @vdev_id: vdev id
2584 * @value: value
2585 *
Govind Singhb53420c2016-03-09 14:32:57 +05302586 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302587 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302588static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302589 int value)
2590{
Govind Singh67922e82016-04-01 16:48:57 +05302591 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302592 wmi_sta_smps_param_cmd_fixed_param *cmd;
2593 wmi_buf_t buf;
2594 uint16_t len = sizeof(*cmd);
2595
2596 buf = wmi_buf_alloc(wmi_handle, len);
2597 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302598 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302599 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302600 }
2601 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2602 WMITLV_SET_HDR(&cmd->tlv_header,
2603 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2604 WMITLV_GET_STRUCT_TLVLEN
2605 (wmi_sta_smps_param_cmd_fixed_param));
2606
2607 cmd->vdev_id = vdev_id;
2608 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2609 cmd->param =
2610 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2611
Govind Singhb53420c2016-03-09 14:32:57 +05302612 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302613 cmd->param);
2614
2615 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2616 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302617 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302618 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302619 wmi_buf_free(buf);
2620 }
2621
2622 return ret;
2623}
2624
2625/**
2626 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2627 * @wmi_handle: wmi handle
2628 * @noa: p2p power save parameters
2629 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302630 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302631 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302632static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302633 struct p2p_ps_params *noa)
2634{
2635 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2636 wmi_p2p_noa_descriptor *noa_discriptor;
2637 wmi_buf_t buf;
2638 uint8_t *buf_ptr;
2639 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302640 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302641 uint32_t duration;
2642
Govind Singhb53420c2016-03-09 14:32:57 +05302643 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302644 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2645 buf = wmi_buf_alloc(wmi_handle, len);
2646 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302647 WMI_LOGE("Failed to allocate memory");
2648 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302649 goto end;
2650 }
2651
2652 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2653 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2654 WMITLV_SET_HDR(&cmd->tlv_header,
2655 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2656 WMITLV_GET_STRUCT_TLVLEN
2657 (wmi_p2p_set_noa_cmd_fixed_param));
2658 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2659 cmd->vdev_id = noa->session_id;
2660 cmd->enable = (duration) ? true : false;
2661 cmd->num_noa = 1;
2662
2663 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2664 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2665 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2666 sizeof
2667 (wmi_p2p_set_noa_cmd_fixed_param)
2668 + WMI_TLV_HDR_SIZE);
2669 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2670 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2671 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2672 noa_discriptor->type_count = noa->count;
2673 noa_discriptor->duration = duration;
2674 noa_discriptor->interval = noa->interval;
2675 noa_discriptor->start_time = 0;
2676
Govind Singhb53420c2016-03-09 14:32:57 +05302677 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302678 cmd->vdev_id, noa->count, noa_discriptor->duration,
2679 noa->interval);
2680 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2681 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302682 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302683 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302684 wmi_buf_free(buf);
2685 }
2686
2687end:
Govind Singhb53420c2016-03-09 14:32:57 +05302688 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302689 return status;
2690}
2691
2692
2693/**
2694 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2695 * @wmi_handle: wmi handle
2696 * @noa: p2p opp power save parameters
2697 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302698 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302699 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302700static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302701 struct p2p_ps_params *oppps)
2702{
2703 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2704 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302705 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302706
Govind Singhb53420c2016-03-09 14:32:57 +05302707 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302708 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2709 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302710 WMI_LOGE("Failed to allocate memory");
2711 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302712 goto end;
2713 }
2714
2715 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2716 WMITLV_SET_HDR(&cmd->tlv_header,
2717 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2718 WMITLV_GET_STRUCT_TLVLEN
2719 (wmi_p2p_set_oppps_cmd_fixed_param));
2720 cmd->vdev_id = oppps->session_id;
2721 if (oppps->ctwindow)
2722 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2723
2724 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302725 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302726 cmd->vdev_id, oppps->ctwindow);
2727 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2728 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302729 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302730 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302731 wmi_buf_free(buf);
2732 }
2733
2734end:
Govind Singhb53420c2016-03-09 14:32:57 +05302735 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302736 return status;
2737}
2738
2739/**
2740 * send_get_temperature_cmd_tlv() - get pdev temperature req
2741 * @wmi_handle: wmi handle
2742 *
Govind Singhb53420c2016-03-09 14:32:57 +05302743 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302744 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302745static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05302746{
2747 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
2748 wmi_buf_t wmi_buf;
2749 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
2750 uint8_t *buf_ptr;
2751
2752 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05302753 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
2754 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05302755 }
2756
2757 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2758 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302759 WMI_LOGE(FL("wmi_buf_alloc failed"));
2760 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302761 }
2762
2763 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2764
2765 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
2766 WMITLV_SET_HDR(&cmd->tlv_header,
2767 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
2768 WMITLV_GET_STRUCT_TLVLEN
2769 (wmi_pdev_get_temperature_cmd_fixed_param));
2770
2771 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
2772 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302773 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05302774 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302775 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302776 }
Govind Singh2edc80f2016-03-01 15:30:53 +05302777
Govind Singhb53420c2016-03-09 14:32:57 +05302778 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302779}
2780
2781/**
2782 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
2783 * @wmi_handle: wmi handle
2784 * @vdevid: vdev id
2785 * @peer_addr: peer mac address
2786 * @auto_triggerparam: auto trigger parameters
2787 * @num_ac: number of access category
2788 *
2789 * This function sets the trigger
2790 * uapsd params such as service interval, delay interval
2791 * and suspend interval which will be used by the firmware
2792 * to send trigger frames periodically when there is no
2793 * traffic on the transmit side.
2794 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302795 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302796 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302797static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302798 struct sta_uapsd_trig_params *param)
2799{
2800 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302801 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302802 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
2803 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
2804 uint32_t i;
2805 wmi_buf_t buf;
2806 uint8_t *buf_ptr;
2807
2808 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2809 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302810 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302811 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302812 }
2813
2814 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2815 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
2816 WMITLV_SET_HDR(&cmd->tlv_header,
2817 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
2818 WMITLV_GET_STRUCT_TLVLEN
2819 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
2820 cmd->vdev_id = param->vdevid;
2821 cmd->num_ac = param->num_ac;
2822 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
2823
2824 /* TLV indicating array of structures to follow */
2825 buf_ptr += sizeof(*cmd);
2826 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
2827
2828 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302829 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302830
2831 /*
2832 * Update tag and length for uapsd auto trigger params (this will take
2833 * care of updating tag and length if it is not pre-filled by caller).
2834 */
2835 for (i = 0; i < param->num_ac; i++) {
2836 WMITLV_SET_HDR((buf_ptr +
2837 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
2838 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
2839 WMITLV_GET_STRUCT_TLVLEN
2840 (wmi_sta_uapsd_auto_trig_param));
2841 }
2842
2843 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2844 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302845 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302846 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302847 wmi_buf_free(buf);
2848 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05302849
Govind Singh427ee5a2016-02-26 18:09:36 +05302850 return ret;
2851}
2852
Govind Singh2edc80f2016-03-01 15:30:53 +05302853/**
2854 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
2855 * @wmi_handle: pointer to the wmi handle
2856 * @utc: pointer to the UTC time struct
2857 *
2858 * Return: 0 on succes
2859 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302860static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302861 struct ocb_utc_param *utc)
2862{
Govind Singh67922e82016-04-01 16:48:57 +05302863 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302864 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
2865 uint8_t *buf_ptr;
2866 uint32_t len, i;
2867 wmi_buf_t buf;
2868
2869 len = sizeof(*cmd);
2870 buf = wmi_buf_alloc(wmi_handle, len);
2871 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302872 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302873 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302874 }
2875
2876 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2877 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
2878 WMITLV_SET_HDR(&cmd->tlv_header,
2879 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
2880 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
2881 cmd->vdev_id = utc->vdev_id;
2882
2883 for (i = 0; i < SIZE_UTC_TIME; i++)
2884 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
2885
2886 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
2887 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
2888
2889 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2890 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302891 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302892 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302893 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302894 }
2895
Govind Singh67922e82016-04-01 16:48:57 +05302896 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302897}
2898
2899/**
2900 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
2901 * frames on a channel
2902 * @wmi_handle: pointer to the wmi handle
2903 * @timing_advert: pointer to the timing advertisement struct
2904 *
2905 * Return: 0 on succes
2906 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302907static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302908 struct ocb_timing_advert_param *timing_advert)
2909{
Govind Singh67922e82016-04-01 16:48:57 +05302910 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302911 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
2912 uint8_t *buf_ptr;
2913 uint32_t len, len_template;
2914 wmi_buf_t buf;
2915
2916 len = sizeof(*cmd) +
2917 WMI_TLV_HDR_SIZE;
2918
2919 len_template = timing_advert->template_length;
2920 /* Add padding to the template if needed */
2921 if (len_template % 4 != 0)
2922 len_template += 4 - (len_template % 4);
2923 len += len_template;
2924
2925 buf = wmi_buf_alloc(wmi_handle, len);
2926 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302927 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302928 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302929 }
2930
2931 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2932 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
2933 WMITLV_SET_HDR(&cmd->tlv_header,
2934 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
2935 WMITLV_GET_STRUCT_TLVLEN(
2936 wmi_ocb_start_timing_advert_cmd_fixed_param));
2937 cmd->vdev_id = timing_advert->vdev_id;
2938 cmd->repeat_rate = timing_advert->repeat_rate;
2939 cmd->channel_freq = timing_advert->chan_freq;
2940 cmd->timestamp_offset = timing_advert->timestamp_offset;
2941 cmd->time_value_offset = timing_advert->time_value_offset;
2942 cmd->timing_advert_template_length = timing_advert->template_length;
2943 buf_ptr += sizeof(*cmd);
2944
2945 /* Add the timing advert template */
2946 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2947 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05302948 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05302949 (uint8_t *)timing_advert->template_value,
2950 timing_advert->template_length);
2951
2952 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2953 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302954 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302955 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302956 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302957 }
2958
Govind Singh67922e82016-04-01 16:48:57 +05302959 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302960}
2961
2962/**
2963 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
2964 * on a channel
2965 * @wmi_handle: pointer to the wmi handle
2966 * @timing_advert: pointer to the timing advertisement struct
2967 *
2968 * Return: 0 on succes
2969 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302970static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302971 struct ocb_timing_advert_param *timing_advert)
2972{
Govind Singh67922e82016-04-01 16:48:57 +05302973 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302974 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
2975 uint8_t *buf_ptr;
2976 uint32_t len;
2977 wmi_buf_t buf;
2978
2979 len = sizeof(*cmd);
2980 buf = wmi_buf_alloc(wmi_handle, len);
2981 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302982 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302983 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302984 }
2985
2986 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2987 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
2988 WMITLV_SET_HDR(&cmd->tlv_header,
2989 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
2990 WMITLV_GET_STRUCT_TLVLEN(
2991 wmi_ocb_stop_timing_advert_cmd_fixed_param));
2992 cmd->vdev_id = timing_advert->vdev_id;
2993 cmd->channel_freq = timing_advert->chan_freq;
2994
2995 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2996 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302997 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302998 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302999 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303000 }
3001
Govind Singh67922e82016-04-01 16:48:57 +05303002 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303003}
3004
3005/**
3006 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3007 * @wmi_handle: pointer to the wmi handle
3008 * @request: pointer to the request
3009 *
3010 * Return: 0 on succes
3011 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303012static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303013 uint8_t vdev_id)
3014{
Govind Singhb53420c2016-03-09 14:32:57 +05303015 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303016 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3017 uint8_t *buf_ptr;
3018 wmi_buf_t buf;
3019 int32_t len;
3020
3021 len = sizeof(*cmd);
3022 buf = wmi_buf_alloc(wmi_handle, len);
3023 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303024 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303025 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303026 }
3027 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3028
3029 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303030 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303031 WMITLV_SET_HDR(&cmd->tlv_header,
3032 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3033 WMITLV_GET_STRUCT_TLVLEN(
3034 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3035 cmd->vdev_id = vdev_id;
3036
3037 /* Send the WMI command */
3038 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3039 WMI_OCB_GET_TSF_TIMER_CMDID);
3040 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303041 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303042 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303043 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303044 }
3045
Govind Singh67922e82016-04-01 16:48:57 +05303046 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303047}
3048
3049/**
3050 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3051 * @wmi_handle: pointer to the wmi handle
3052 * @get_stats_param: pointer to the dcc stats
3053 *
3054 * Return: 0 on succes
3055 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303056static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303057 struct dcc_get_stats_param *get_stats_param)
3058{
Govind Singh67922e82016-04-01 16:48:57 +05303059 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303060 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3061 wmi_dcc_channel_stats_request *channel_stats_array;
3062 wmi_buf_t buf;
3063 uint8_t *buf_ptr;
3064 uint32_t len;
3065 uint32_t i;
3066
3067 /* Validate the input */
3068 if (get_stats_param->request_array_len !=
3069 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303070 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303071 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303072 }
3073
3074 /* Allocate memory for the WMI command */
3075 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3076 get_stats_param->request_array_len;
3077
3078 buf = wmi_buf_alloc(wmi_handle, len);
3079 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303080 WMI_LOGE(FL("wmi_buf_alloc failed"));
3081 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303082 }
3083
3084 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303085 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303086
3087 /* Populate the WMI command */
3088 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3089 buf_ptr += sizeof(*cmd);
3090
3091 WMITLV_SET_HDR(&cmd->tlv_header,
3092 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3093 WMITLV_GET_STRUCT_TLVLEN(
3094 wmi_dcc_get_stats_cmd_fixed_param));
3095 cmd->vdev_id = get_stats_param->vdev_id;
3096 cmd->num_channels = get_stats_param->channel_count;
3097
3098 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3099 get_stats_param->request_array_len);
3100 buf_ptr += WMI_TLV_HDR_SIZE;
3101
3102 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303103 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303104 get_stats_param->request_array_len);
3105 for (i = 0; i < cmd->num_channels; i++)
3106 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3107 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3108 WMITLV_GET_STRUCT_TLVLEN(
3109 wmi_dcc_channel_stats_request));
3110
3111 /* Send the WMI command */
3112 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3113 WMI_DCC_GET_STATS_CMDID);
3114
Govind Singh67922e82016-04-01 16:48:57 +05303115 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303116 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303117 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303118 }
3119
Govind Singh67922e82016-04-01 16:48:57 +05303120 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303121}
3122
3123/**
3124 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3125 * @wmi_handle: pointer to the wmi handle
3126 * @vdev_id: vdev id
3127 * @dcc_stats_bitmap: dcc status bitmap
3128 *
3129 * Return: 0 on succes
3130 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303131static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303132 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3133{
Govind Singh67922e82016-04-01 16:48:57 +05303134 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303135 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3136 wmi_buf_t buf;
3137 uint8_t *buf_ptr;
3138 uint32_t len;
3139
3140 /* Allocate memory for the WMI command */
3141 len = sizeof(*cmd);
3142
3143 buf = wmi_buf_alloc(wmi_handle, len);
3144 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303145 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303146 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303147 }
3148
3149 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303150 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303151
3152 /* Populate the WMI command */
3153 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3154
3155 WMITLV_SET_HDR(&cmd->tlv_header,
3156 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3157 WMITLV_GET_STRUCT_TLVLEN(
3158 wmi_dcc_clear_stats_cmd_fixed_param));
3159 cmd->vdev_id = vdev_id;
3160 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3161
3162 /* Send the WMI command */
3163 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3164 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303165 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303166 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303167 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303168 }
3169
Govind Singh67922e82016-04-01 16:48:57 +05303170 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303171}
3172
3173/**
3174 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3175 * @wmi_handle: pointer to the wmi handle
3176 * @update_ndl_param: pointer to the request parameters
3177 *
3178 * Return: 0 on success
3179 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303180static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303181 struct dcc_update_ndl_param *update_ndl_param)
3182{
Govind Singhb53420c2016-03-09 14:32:57 +05303183 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303184 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3185 wmi_dcc_ndl_chan *ndl_chan_array;
3186 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3187 uint32_t active_state_count;
3188 wmi_buf_t buf;
3189 uint8_t *buf_ptr;
3190 uint32_t len;
3191 uint32_t i;
3192
3193 /* validate the input */
3194 if (update_ndl_param->dcc_ndl_chan_list_len !=
3195 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303196 WMI_LOGE(FL("Invalid parameter"));
3197 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303198 }
3199 active_state_count = 0;
3200 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3201 for (i = 0; i < update_ndl_param->channel_count; i++)
3202 active_state_count +=
3203 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3204 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3205 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303206 WMI_LOGE(FL("Invalid parameter"));
3207 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303208 }
3209
3210 /* Allocate memory for the WMI command */
3211 len = sizeof(*cmd) +
3212 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3213 WMI_TLV_HDR_SIZE +
3214 update_ndl_param->dcc_ndl_active_state_list_len;
3215
3216 buf = wmi_buf_alloc(wmi_handle, len);
3217 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303218 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303219 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303220 }
3221
3222 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303223 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303224
3225 /* Populate the WMI command */
3226 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3227 buf_ptr += sizeof(*cmd);
3228
3229 WMITLV_SET_HDR(&cmd->tlv_header,
3230 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3231 WMITLV_GET_STRUCT_TLVLEN(
3232 wmi_dcc_update_ndl_cmd_fixed_param));
3233 cmd->vdev_id = update_ndl_param->vdev_id;
3234 cmd->num_channel = update_ndl_param->channel_count;
3235
3236 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3237 update_ndl_param->dcc_ndl_chan_list_len);
3238 buf_ptr += WMI_TLV_HDR_SIZE;
3239
3240 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303241 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303242 update_ndl_param->dcc_ndl_chan_list_len);
3243 for (i = 0; i < cmd->num_channel; i++)
3244 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3245 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3246 WMITLV_GET_STRUCT_TLVLEN(
3247 wmi_dcc_ndl_chan));
3248 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3249
3250 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3251 update_ndl_param->dcc_ndl_active_state_list_len);
3252 buf_ptr += WMI_TLV_HDR_SIZE;
3253
3254 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303255 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303256 update_ndl_param->dcc_ndl_active_state_list,
3257 update_ndl_param->dcc_ndl_active_state_list_len);
3258 for (i = 0; i < active_state_count; i++) {
3259 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3260 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3261 WMITLV_GET_STRUCT_TLVLEN(
3262 wmi_dcc_ndl_active_state_config));
3263 }
3264 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3265
3266 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303267 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303268 WMI_DCC_UPDATE_NDL_CMDID);
3269 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303270 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303271 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303272 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303273 }
3274
Govind Singh67922e82016-04-01 16:48:57 +05303275 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303276}
3277
3278/**
3279 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3280 * @wmi_handle: pointer to the wmi handle
3281 * @config: the OCB configuration
3282 *
3283 * Return: 0 on success
3284 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303285static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303286 struct ocb_config_param *config, uint32_t *ch_mhz)
3287{
Govind Singh67922e82016-04-01 16:48:57 +05303288 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303289 wmi_ocb_set_config_cmd_fixed_param *cmd;
3290 wmi_channel *chan;
3291 wmi_ocb_channel *ocb_chan;
3292 wmi_qos_parameter *qos_param;
3293 wmi_dcc_ndl_chan *ndl_chan;
3294 wmi_dcc_ndl_active_state_config *ndl_active_config;
3295 wmi_ocb_schedule_element *sched_elem;
3296 uint8_t *buf_ptr;
3297 wmi_buf_t buf;
3298 int32_t len;
3299 int32_t i, j, active_state_count;
3300
3301 /*
3302 * Validate the dcc_ndl_chan_list_len and count the number of active
3303 * states. Validate dcc_ndl_active_state_list_len.
3304 */
3305 active_state_count = 0;
3306 if (config->dcc_ndl_chan_list_len) {
3307 if (!config->dcc_ndl_chan_list ||
3308 config->dcc_ndl_chan_list_len !=
3309 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303310 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303311 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303312 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303313 }
3314
3315 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3316 i < config->channel_count; ++i, ++ndl_chan)
3317 active_state_count +=
3318 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3319
3320 if (active_state_count) {
3321 if (!config->dcc_ndl_active_state_list ||
3322 config->dcc_ndl_active_state_list_len !=
3323 active_state_count *
3324 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303325 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303326 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303327 }
3328 }
3329 }
3330
3331 len = sizeof(*cmd) +
3332 WMI_TLV_HDR_SIZE + config->channel_count *
3333 sizeof(wmi_channel) +
3334 WMI_TLV_HDR_SIZE + config->channel_count *
3335 sizeof(wmi_ocb_channel) +
3336 WMI_TLV_HDR_SIZE + config->channel_count *
3337 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3338 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3339 WMI_TLV_HDR_SIZE + active_state_count *
3340 sizeof(wmi_dcc_ndl_active_state_config) +
3341 WMI_TLV_HDR_SIZE + config->schedule_size *
3342 sizeof(wmi_ocb_schedule_element);
3343 buf = wmi_buf_alloc(wmi_handle, len);
3344 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303345 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303346 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303347 }
3348
3349 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3350 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3351 WMITLV_SET_HDR(&cmd->tlv_header,
3352 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3353 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3354 cmd->vdev_id = config->session_id;
3355 cmd->channel_count = config->channel_count;
3356 cmd->schedule_size = config->schedule_size;
3357 cmd->flags = config->flags;
3358 buf_ptr += sizeof(*cmd);
3359
3360 /* Add the wmi_channel info */
3361 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3362 config->channel_count*sizeof(wmi_channel));
3363 buf_ptr += WMI_TLV_HDR_SIZE;
3364 for (i = 0; i < config->channel_count; i++) {
3365 chan = (wmi_channel *)buf_ptr;
3366 WMITLV_SET_HDR(&chan->tlv_header,
3367 WMITLV_TAG_STRUC_wmi_channel,
3368 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3369 chan->mhz = config->channels[i].chan_freq;
3370 chan->band_center_freq1 = config->channels[i].chan_freq;
3371 chan->band_center_freq2 = 0;
3372 chan->info = 0;
3373
3374 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3375 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3376 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3377 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3378 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3379 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3380 config->channels[i].antenna_max);
3381
3382 if (config->channels[i].bandwidth < 10)
3383 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3384 else if (config->channels[i].bandwidth < 20)
3385 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3386 buf_ptr += sizeof(*chan);
3387 }
3388
3389 /* Add the wmi_ocb_channel info */
3390 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3391 config->channel_count*sizeof(wmi_ocb_channel));
3392 buf_ptr += WMI_TLV_HDR_SIZE;
3393 for (i = 0; i < config->channel_count; i++) {
3394 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3395 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3396 WMITLV_TAG_STRUC_wmi_ocb_channel,
3397 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3398 ocb_chan->bandwidth = config->channels[i].bandwidth;
3399 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3400 config->channels[i].mac_address.bytes,
3401 &ocb_chan->mac_address);
3402 buf_ptr += sizeof(*ocb_chan);
3403 }
3404
3405 /* Add the wmi_qos_parameter info */
3406 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3407 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3408 buf_ptr += WMI_TLV_HDR_SIZE;
3409 /* WMI_MAX_NUM_AC parameters for each channel */
3410 for (i = 0; i < config->channel_count; i++) {
3411 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3412 qos_param = (wmi_qos_parameter *)buf_ptr;
3413 WMITLV_SET_HDR(&qos_param->tlv_header,
3414 WMITLV_TAG_STRUC_wmi_qos_parameter,
3415 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3416 qos_param->aifsn =
3417 config->channels[i].qos_params[j].aifsn;
3418 qos_param->cwmin =
3419 config->channels[i].qos_params[j].cwmin;
3420 qos_param->cwmax =
3421 config->channels[i].qos_params[j].cwmax;
3422 buf_ptr += sizeof(*qos_param);
3423 }
3424 }
3425
3426 /* Add the wmi_dcc_ndl_chan (per channel) */
3427 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3428 config->dcc_ndl_chan_list_len);
3429 buf_ptr += WMI_TLV_HDR_SIZE;
3430 if (config->dcc_ndl_chan_list_len) {
3431 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303432 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303433 config->dcc_ndl_chan_list_len);
3434 for (i = 0; i < config->channel_count; i++)
3435 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3436 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3437 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3438 buf_ptr += config->dcc_ndl_chan_list_len;
3439 }
3440
3441 /* Add the wmi_dcc_ndl_active_state_config */
3442 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3443 sizeof(wmi_dcc_ndl_active_state_config));
3444 buf_ptr += WMI_TLV_HDR_SIZE;
3445 if (active_state_count) {
3446 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303447 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303448 config->dcc_ndl_active_state_list,
3449 active_state_count * sizeof(*ndl_active_config));
3450 for (i = 0; i < active_state_count; ++i)
3451 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3452 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3453 WMITLV_GET_STRUCT_TLVLEN(
3454 wmi_dcc_ndl_active_state_config));
3455 buf_ptr += active_state_count *
3456 sizeof(*ndl_active_config);
3457 }
3458
3459 /* Add the wmi_ocb_schedule_element info */
3460 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3461 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3462 buf_ptr += WMI_TLV_HDR_SIZE;
3463 for (i = 0; i < config->schedule_size; i++) {
3464 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3465 WMITLV_SET_HDR(&sched_elem->tlv_header,
3466 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3467 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3468 sched_elem->channel_freq = config->schedule[i].chan_freq;
3469 sched_elem->total_duration = config->schedule[i].total_duration;
3470 sched_elem->guard_interval = config->schedule[i].guard_interval;
3471 buf_ptr += sizeof(*sched_elem);
3472 }
3473
3474
3475 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3476 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303477 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303478 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303479 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303480 }
3481
Govind Singh67922e82016-04-01 16:48:57 +05303482 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303483}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303484
3485/**
3486 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3487 * @wmi_handle: wmi handle
3488 * @mcc_adaptive_scheduler: enable/disable
3489 *
3490 * This function enable/disable mcc adaptive scheduler in fw.
3491 *
Govind Singhb53420c2016-03-09 14:32:57 +05303492 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303494static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003495 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3496 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303497{
Govind Singh67922e82016-04-01 16:48:57 +05303498 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303499 wmi_buf_t buf = 0;
3500 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3501 uint16_t len =
3502 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3503
3504 buf = wmi_buf_alloc(wmi_handle, len);
3505 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303506 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3507 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303508 }
3509 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3510 wmi_buf_data(buf);
3511
3512 WMITLV_SET_HDR(&cmd->tlv_header,
3513 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3514 WMITLV_GET_STRUCT_TLVLEN
3515 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3516 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003517 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303518
3519 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3520 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303521 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303522 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303523 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303524 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303525 }
Govind Singh67922e82016-04-01 16:48:57 +05303526
3527 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303528}
3529
3530/**
3531 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3532 * @wmi: wmi handle
3533 * @mcc_channel: mcc channel
3534 * @mcc_channel_time_latency: MCC channel time latency.
3535 *
3536 * Currently used to set time latency for an MCC vdev/adapter using operating
3537 * channel of it and channel number. The info is provided run time using
3538 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3539 *
3540 * Return: CDF status
3541 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303542static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303543 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3544{
Govind Singh67922e82016-04-01 16:48:57 +05303545 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303546 wmi_buf_t buf = 0;
3547 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3548 uint16_t len = 0;
3549 uint8_t *buf_ptr = NULL;
3550 wmi_resmgr_chan_latency chan_latency;
3551 /* Note: we only support MCC time latency for a single channel */
3552 uint32_t num_channels = 1;
3553 uint32_t chan1_freq = mcc_channel_freq;
3554 uint32_t latency_chan1 = mcc_channel_time_latency;
3555
3556
3557 /* If 0ms latency is provided, then FW will set to a default.
3558 * Otherwise, latency must be at least 30ms.
3559 */
3560 if ((latency_chan1 > 0) &&
3561 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303562 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303563 "Minimum is 30ms (or 0 to use default value by "
3564 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303565 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303566 }
3567
3568 /* Set WMI CMD for channel time latency here */
3569 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3570 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3571 num_channels * sizeof(wmi_resmgr_chan_latency);
3572 buf = wmi_buf_alloc(wmi_handle, len);
3573 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303574 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3575 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303576 }
3577 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3578 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3579 wmi_buf_data(buf);
3580 WMITLV_SET_HDR(&cmdTL->tlv_header,
3581 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3582 WMITLV_GET_STRUCT_TLVLEN
3583 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3584 cmdTL->num_chans = num_channels;
3585 /* Update channel time latency information for home channel(s) */
3586 buf_ptr += sizeof(*cmdTL);
3587 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3588 num_channels * sizeof(wmi_resmgr_chan_latency));
3589 buf_ptr += WMI_TLV_HDR_SIZE;
3590 chan_latency.chan_mhz = chan1_freq;
3591 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303592 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303593 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3594 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303595 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303596 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303597 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303598 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303599 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303600 }
Govind Singh67922e82016-04-01 16:48:57 +05303601
3602 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303603}
3604
3605/**
3606 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3607 * @wmi: wmi handle
3608 * @adapter_1_chan_number: adapter 1 channel number
3609 * @adapter_1_quota: adapter 1 quota
3610 * @adapter_2_chan_number: adapter 2 channel number
3611 *
3612 * Return: CDF status
3613 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303614static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303615 uint32_t adapter_1_chan_freq,
3616 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3617{
Govind Singh67922e82016-04-01 16:48:57 +05303618 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303619 wmi_buf_t buf = 0;
3620 uint16_t len = 0;
3621 uint8_t *buf_ptr = NULL;
3622 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3623 wmi_resmgr_chan_time_quota chan_quota;
3624 uint32_t quota_chan1 = adapter_1_quota;
3625 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3626 uint32_t quota_chan2 = 100 - quota_chan1;
3627 /* Note: setting time quota for MCC requires info for 2 channels */
3628 uint32_t num_channels = 2;
3629 uint32_t chan1_freq = adapter_1_chan_freq;
3630 uint32_t chan2_freq = adapter_2_chan_freq;
3631
Govind Singhb53420c2016-03-09 14:32:57 +05303632 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303633 "freq2:%dMHz, Quota2:%dms", __func__,
3634 chan1_freq, quota_chan1, chan2_freq,
3635 quota_chan2);
3636
3637 /*
3638 * Perform sanity check on time quota values provided.
3639 */
3640 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3641 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303642 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303643 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303644 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303645 }
3646 /* Set WMI CMD for channel time quota here */
3647 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3648 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3649 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3650 buf = wmi_buf_alloc(wmi_handle, len);
3651 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303652 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3653 QDF_ASSERT(0);
3654 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303655 }
3656 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3657 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3658 wmi_buf_data(buf);
3659 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3660 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3661 WMITLV_GET_STRUCT_TLVLEN
3662 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3663 cmdTQ->num_chans = num_channels;
3664
3665 /* Update channel time quota information for home channel(s) */
3666 buf_ptr += sizeof(*cmdTQ);
3667 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3668 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3669 buf_ptr += WMI_TLV_HDR_SIZE;
3670 chan_quota.chan_mhz = chan1_freq;
3671 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303672 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303673 /* Construct channel and quota record for the 2nd MCC mode. */
3674 buf_ptr += sizeof(chan_quota);
3675 chan_quota.chan_mhz = chan2_freq;
3676 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05303677 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303678
3679 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3680 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303681 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303682 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303683 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303684 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303685 }
Govind Singh67922e82016-04-01 16:48:57 +05303686
3687 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303688}
3689
3690/**
3691 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3692 * @wmi_handle: Pointer to wmi handle
3693 * @thermal_info: Thermal command information
3694 *
3695 * This function sends the thermal management command
3696 * to the firmware
3697 *
Govind Singhb53420c2016-03-09 14:32:57 +05303698 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303699 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303700static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303701 struct thermal_cmd_params *thermal_info)
3702{
3703 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3704 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303705 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303706 uint32_t len = 0;
3707
3708 len = sizeof(*cmd);
3709
3710 buf = wmi_buf_alloc(wmi_handle, len);
3711 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303712 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3713 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303714 }
3715
3716 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3717
3718 WMITLV_SET_HDR(&cmd->tlv_header,
3719 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3720 WMITLV_GET_STRUCT_TLVLEN
3721 (wmi_thermal_mgmt_cmd_fixed_param));
3722
3723 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3724 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3725 cmd->enable = thermal_info->thermal_enable;
3726
Govind Singhb53420c2016-03-09 14:32:57 +05303727 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303728 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3729
3730 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3731 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303732 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303733 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303734 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303735 }
3736
Govind Singh67922e82016-04-01 16:48:57 +05303737 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303738}
3739
3740
3741/**
3742 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303743 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303744 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3745 *
3746 * This function sends down the LRO configuration parameters to
3747 * the firmware to enable LRO, sets the TCP flags and sets the
3748 * seed values for the toeplitz hash generation
3749 *
Govind Singhb53420c2016-03-09 14:32:57 +05303750 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303751 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303752static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303753 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3754{
3755 wmi_lro_info_cmd_fixed_param *cmd;
3756 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303757 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303758
3759
3760 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3761 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303762 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3763 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303764 }
3765
3766 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3767
3768 WMITLV_SET_HDR(&cmd->tlv_header,
3769 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3770 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3771
3772 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3773 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3774 wmi_lro_cmd->tcp_flag);
3775 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3776 wmi_lro_cmd->tcp_flag_mask);
3777 cmd->toeplitz_hash_ipv4_0_3 =
3778 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3779 cmd->toeplitz_hash_ipv4_4_7 =
3780 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3781 cmd->toeplitz_hash_ipv4_8_11 =
3782 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3783 cmd->toeplitz_hash_ipv4_12_15 =
3784 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3785 cmd->toeplitz_hash_ipv4_16 =
3786 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3787
3788 cmd->toeplitz_hash_ipv6_0_3 =
3789 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3790 cmd->toeplitz_hash_ipv6_4_7 =
3791 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3792 cmd->toeplitz_hash_ipv6_8_11 =
3793 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3794 cmd->toeplitz_hash_ipv6_12_15 =
3795 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3796 cmd->toeplitz_hash_ipv6_16_19 =
3797 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3798 cmd->toeplitz_hash_ipv6_20_23 =
3799 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3800 cmd->toeplitz_hash_ipv6_24_27 =
3801 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3802 cmd->toeplitz_hash_ipv6_28_31 =
3803 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3804 cmd->toeplitz_hash_ipv6_32_35 =
3805 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3806 cmd->toeplitz_hash_ipv6_36_39 =
3807 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3808 cmd->toeplitz_hash_ipv6_40 =
3809 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3810
Govind Singhb53420c2016-03-09 14:32:57 +05303811 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303812 cmd->lro_enable, cmd->tcp_flag_u32);
3813
3814 status = wmi_unified_cmd_send(wmi_handle, buf,
3815 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303816 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303817 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303818 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303819 }
3820
Govind Singh67922e82016-04-01 16:48:57 +05303821 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303822}
3823
Govind Singh4eacd2b2016-03-07 14:24:22 +05303824/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303825 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3826 * @wmi_handle: Pointer to wmi handle
3827 * @rate_report_params: Pointer to peer rate report parameters
3828 *
3829 *
3830 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3831 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303832static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303833 struct wmi_peer_rate_report_params *rate_report_params)
3834{
3835 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3836 wmi_buf_t buf = NULL;
3837 QDF_STATUS status = 0;
3838 uint32_t len = 0;
3839 uint32_t i, j;
3840
3841 len = sizeof(*cmd);
3842
3843 buf = wmi_buf_alloc(wmi_handle, len);
3844 if (!buf) {
3845 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
3846 return QDF_STATUS_E_FAILURE;
3847 }
3848
3849 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3850 wmi_buf_data(buf);
3851
3852 WMITLV_SET_HDR(
3853 &cmd->tlv_header,
3854 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3855 WMITLV_GET_STRUCT_TLVLEN(
3856 wmi_peer_set_rate_report_condition_fixed_param));
3857
3858 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3859 cmd->report_backoff_time = rate_report_params->backoff_time;
3860 cmd->report_timer_period = rate_report_params->timer_period;
3861 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
3862 cmd->cond_per_phy[i].val_cond_flags =
3863 rate_report_params->report_per_phy[i].cond_flags;
3864 cmd->cond_per_phy[i].rate_delta.min_delta =
3865 rate_report_params->report_per_phy[i].delta.delta_min;
3866 cmd->cond_per_phy[i].rate_delta.percentage =
3867 rate_report_params->report_per_phy[i].delta.percent;
3868 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3869 cmd->cond_per_phy[i].rate_threshold[j] =
3870 rate_report_params->report_per_phy[i].
3871 report_rate_threshold[j];
3872 }
3873 }
3874
3875 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
3876 cmd->enable_rate_report,
3877 cmd->report_backoff_time, cmd->report_timer_period);
3878
3879 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3880 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3881 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303882 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303883 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3884 __func__);
3885 }
3886 return status;
3887}
3888
3889/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303890 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3891 * @wmi_handle: wmi handle
3892 * @param: bcn ll cmd parameter
3893 *
Govind Singhb53420c2016-03-09 14:32:57 +05303894 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303895 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303896static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303897 wmi_bcn_send_from_host_cmd_fixed_param *param)
3898{
3899 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3900 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303901 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303902
3903 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3904 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303905 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3906 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303907 }
3908
3909 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3910 WMITLV_SET_HDR(&cmd->tlv_header,
3911 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3912 WMITLV_GET_STRUCT_TLVLEN
3913 (wmi_bcn_send_from_host_cmd_fixed_param));
3914 cmd->vdev_id = param->vdev_id;
3915 cmd->data_len = param->data_len;
3916 cmd->frame_ctrl = param->frame_ctrl;
3917 cmd->frag_ptr = param->frag_ptr;
3918 cmd->dtim_flag = param->dtim_flag;
3919
3920 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3921 WMI_PDEV_SEND_BCN_CMDID);
3922
Govind Singh67922e82016-04-01 16:48:57 +05303923 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303924 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303925 wmi_buf_free(wmi_buf);
3926 }
3927
3928 return ret;
3929}
3930
3931/**
3932 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
3933 * @wmi_handle: wmi handle
3934 * @vdev_id: vdev id
3935 * @max_retries: max retries
3936 * @retry_interval: retry interval
3937 * This function sets sta query related parameters in fw.
3938 *
Govind Singhb53420c2016-03-09 14:32:57 +05303939 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303940 */
3941
Sathish Kumarfd347372017-02-13 12:29:09 +05303942static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303943 uint8_t vdev_id, uint32_t max_retries,
3944 uint32_t retry_interval)
3945{
3946 wmi_buf_t buf;
3947 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
3948 int len;
3949
3950 len = sizeof(*cmd);
3951 buf = wmi_buf_alloc(wmi_handle, len);
3952 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303953 WMI_LOGE(FL("wmi_buf_alloc failed"));
3954 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303955 }
3956
3957 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
3958 WMITLV_SET_HDR(&cmd->tlv_header,
3959 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
3960 WMITLV_GET_STRUCT_TLVLEN
3961 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
3962
3963
3964 cmd->vdev_id = vdev_id;
3965 cmd->sa_query_max_retry_count = max_retries;
3966 cmd->sa_query_retry_interval = retry_interval;
3967
Govind Singhb53420c2016-03-09 14:32:57 +05303968 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303969 vdev_id, retry_interval, max_retries);
3970
3971 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3972 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303973 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05303974 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303975 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303976 }
3977
Govind Singhb53420c2016-03-09 14:32:57 +05303978 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303979 return 0;
3980}
3981
3982/**
3983 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
3984 * @wmi_handle: wmi handle
3985 * @params: sta keep alive parameter
3986 *
3987 * This function sets keep alive related parameters in fw.
3988 *
3989 * Return: CDF status
3990 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303991static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303992 struct sta_params *params)
3993{
3994 wmi_buf_t buf;
3995 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
3996 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
3997 uint8_t *buf_ptr;
3998 int len;
Govind Singh67922e82016-04-01 16:48:57 +05303999 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304000
Govind Singhb53420c2016-03-09 14:32:57 +05304001 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304002
Govind Singh4eacd2b2016-03-07 14:24:22 +05304003 len = sizeof(*cmd) + sizeof(*arp_rsp);
4004 buf = wmi_buf_alloc(wmi_handle, len);
4005 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304006 WMI_LOGE("wmi_buf_alloc failed");
4007 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304008 }
4009
4010 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4011 buf_ptr = (uint8_t *) cmd;
4012 WMITLV_SET_HDR(&cmd->tlv_header,
4013 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4014 WMITLV_GET_STRUCT_TLVLEN
4015 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4016 cmd->interval = params->timeperiod;
4017 cmd->enable = (params->timeperiod) ? 1 : 0;
4018 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304019 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304020 params->timeperiod, params->method);
4021 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4022 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4023 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4024 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4025
4026 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4027 if ((NULL == params->hostv4addr) ||
4028 (NULL == params->destv4addr) ||
4029 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304030 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304031 "destv4addr:%p destmac:%p ", __func__,
4032 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304033 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304034 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304035 }
4036 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304037 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304038 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304039 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304040 WMI_IPV4_ADDR_LEN);
4041 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4042 } else {
4043 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4044 }
4045
Govind Singh67922e82016-04-01 16:48:57 +05304046 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4047 WMI_STA_KEEPALIVE_CMDID);
4048 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304049 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304050 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304051 }
4052
Govind Singhb53420c2016-03-09 14:32:57 +05304053 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304054 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304055}
4056
4057/**
4058 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4059 * @wmi_handle: wmi handle
4060 * @if_id: vdev id
4061 * @gtx_info: GTX config params
4062 *
4063 * This function set GTX related params in firmware.
4064 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304065 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304066 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304067static QDF_STATUS send_vdev_set_gtx_cfg_cmd_tlv(wmi_unified_t wmi_handle, uint32_t if_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304068 struct wmi_gtx_config *gtx_info)
4069{
4070 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4071 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304072 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304073 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304074
Govind Singh4eacd2b2016-03-07 14:24:22 +05304075 buf = wmi_buf_alloc(wmi_handle, len);
4076 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304077 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304078 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304079 }
4080 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4081 WMITLV_SET_HDR(&cmd->tlv_header,
4082 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4083 WMITLV_GET_STRUCT_TLVLEN
4084 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4085 cmd->vdev_id = if_id;
4086
4087 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4088 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4089 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4090 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4091 cmd->gtxPERMargin = gtx_info->gtx_margin;
4092 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4093 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4094 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4095
Govind Singhb53420c2016-03-09 14:32:57 +05304096 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304097 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4098 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4099 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4100 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4101
Abhishek Singh716c46c2016-05-04 16:24:07 +05304102 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304103 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304104 if (QDF_IS_STATUS_ERROR(ret)) {
4105 WMI_LOGE("Failed to set GTX PARAMS");
4106 wmi_buf_free(buf);
4107 }
4108 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304109}
4110
4111/**
4112 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4113 * @wmi_handle: wmi handle
4114 * @edca_params: edca parameters
4115 *
4116 * This function updates EDCA parameters to the target
4117 *
4118 * Return: CDF Status
4119 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304120static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304121 uint8_t vdev_id,
4122 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4123{
4124 uint8_t *buf_ptr;
4125 wmi_buf_t buf;
4126 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4127 wmi_wmm_vparams *wmm_param, *twmm_param;
4128 int len = sizeof(*cmd);
4129 int ac;
4130
4131 buf = wmi_buf_alloc(wmi_handle, len);
4132
4133 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304134 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4135 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304136 }
4137
4138 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4139 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4140 WMITLV_SET_HDR(&cmd->tlv_header,
4141 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4142 WMITLV_GET_STRUCT_TLVLEN
4143 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4144 cmd->vdev_id = vdev_id;
4145
4146 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4147 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4148 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4149 WMITLV_SET_HDR(&wmm_param->tlv_header,
4150 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4151 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4152 wmm_param->cwmin = twmm_param->cwmin;
4153 wmm_param->cwmax = twmm_param->cwmax;
4154 wmm_param->aifs = twmm_param->aifs;
4155 wmm_param->txoplimit = twmm_param->txoplimit;
4156 wmm_param->acm = twmm_param->acm;
4157 wmm_param->no_ack = twmm_param->no_ack;
4158 }
4159
4160 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4161 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4162 goto fail;
4163
Govind Singhb53420c2016-03-09 14:32:57 +05304164 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304165
4166fail:
4167 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304168 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4169 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304170}
4171
4172/**
4173 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4174 * @wmi_handle: wmi handle
4175 * @vdev_id: vdev id
4176 * @probe_rsp_info: probe response info
4177 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304178 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304179 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304180static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304181 uint8_t vdev_id,
4182 struct wmi_probe_resp_params *probe_rsp_info,
4183 uint8_t *frm)
4184{
4185 wmi_prb_tmpl_cmd_fixed_param *cmd;
4186 wmi_bcn_prb_info *bcn_prb_info;
4187 wmi_buf_t wmi_buf;
4188 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4189 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304190 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304191
Govind Singhb53420c2016-03-09 14:32:57 +05304192 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304193
4194 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4195 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4196
4197 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4198 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4199 tmpl_len_aligned;
4200
4201 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304202 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304203 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304204 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304205 }
4206
4207 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4208 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304209 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304210 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304211 }
4212
4213 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4214
4215 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4216 WMITLV_SET_HDR(&cmd->tlv_header,
4217 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4218 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4219 cmd->vdev_id = vdev_id;
4220 cmd->buf_len = tmpl_len;
4221 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4222
4223 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4224 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4225 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4226 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4227 bcn_prb_info->caps = 0;
4228 bcn_prb_info->erp = 0;
4229 buf_ptr += sizeof(wmi_bcn_prb_info);
4230
4231 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4232 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304233 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304234
4235 ret = wmi_unified_cmd_send(wmi_handle,
4236 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304237 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304238 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304239 wmi_buf_free(wmi_buf);
4240 }
4241
4242 return ret;
4243}
4244
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304245#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304246#define WPI_IV_LEN 16
4247
4248/**
4249 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4250 *
4251 * @dest_tx: destination address of tsc key counter
4252 * @src_tx: source address of tsc key counter
4253 * @dest_rx: destination address of rsc key counter
4254 * @src_rx: source address of rsc key counter
4255 *
4256 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4257 *
4258 * Return: None
4259 *
4260 */
4261static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4262 uint8_t *dest_rx, uint8_t *src_rx)
4263{
4264 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4265 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4266}
4267#else
4268static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4269 uint8_t *dest_rx, uint8_t *src_rx)
4270{
4271 return;
4272}
4273#endif
4274
4275/**
4276 * send_setup_install_key_cmd_tlv() - set key parameters
4277 * @wmi_handle: wmi handle
4278 * @key_params: key parameters
4279 *
4280 * This function fills structure from information
4281 * passed in key_params.
4282 *
4283 * Return: QDF_STATUS_SUCCESS - success
4284 * QDF_STATUS_E_FAILURE - failure
4285 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4286 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304287static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304288 struct set_key_params *key_params)
4289{
4290 wmi_vdev_install_key_cmd_fixed_param *cmd;
4291 wmi_buf_t buf;
4292 uint8_t *buf_ptr;
4293 uint32_t len;
4294 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304295 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304296
4297 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4298 WMI_TLV_HDR_SIZE;
4299
4300 buf = wmi_buf_alloc(wmi_handle, len);
4301 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304302 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304303 return QDF_STATUS_E_NOMEM;
4304 }
4305
4306 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4307 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4308 WMITLV_SET_HDR(&cmd->tlv_header,
4309 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4310 WMITLV_GET_STRUCT_TLVLEN
4311 (wmi_vdev_install_key_cmd_fixed_param));
4312 cmd->vdev_id = key_params->vdev_id;
4313 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304314
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304315
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304316 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4317 cmd->key_flags |= key_params->key_flags;
4318 cmd->key_cipher = key_params->key_cipher;
4319 if ((key_params->key_txmic_len) &&
4320 (key_params->key_rxmic_len)) {
4321 cmd->key_txmic_len = key_params->key_txmic_len;
4322 cmd->key_rxmic_len = key_params->key_rxmic_len;
4323 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304324#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304325 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4326 key_params->tx_iv,
4327 cmd->wpi_key_rsc_counter,
4328 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304329#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304330 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4331 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4332 roundup(key_params->key_len, sizeof(uint32_t)));
4333 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4334 qdf_mem_copy((void *)key_data,
4335 (const void *)key_params->key_data, key_params->key_len);
4336 cmd->key_len = key_params->key_len;
4337
4338 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4339 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304340 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304341 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304342
Govind Singh67922e82016-04-01 16:48:57 +05304343 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304344}
4345
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304346/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004347 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4348 * @wmi_handle: wmi handle
4349 * @params: sar limit params
4350 *
4351 * Return: QDF_STATUS_SUCCESS for success or error code
4352 */
4353static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4354 struct sar_limit_cmd_params *sar_limit_params)
4355{
4356 wmi_buf_t buf;
4357 QDF_STATUS qdf_status;
4358 wmi_sar_limits_cmd_fixed_param *cmd;
4359 int i;
4360 uint8_t *buf_ptr;
4361 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4362 struct sar_limit_cmd_row *sar_rows_list;
4363 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4364
4365 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4366 buf = wmi_buf_alloc(wmi_handle, len);
4367 if (!buf) {
4368 WMI_LOGE("Failed to allocate memory");
4369 qdf_status = QDF_STATUS_E_NOMEM;
4370 goto end;
4371 }
4372
4373 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4374 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4375 WMITLV_SET_HDR(&cmd->tlv_header,
4376 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4377 WMITLV_GET_STRUCT_TLVLEN
4378 (wmi_sar_limits_cmd_fixed_param));
4379 cmd->sar_enable = sar_limit_params->sar_enable;
4380 cmd->commit_limits = sar_limit_params->commit_limits;
4381 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4382
4383 WMI_LOGD("no of sar rows = %d, len = %d",
4384 sar_limit_params->num_limit_rows, len);
4385 buf_ptr += sizeof(*cmd);
4386 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4387 sizeof(wmi_sar_limit_cmd_row) *
4388 sar_limit_params->num_limit_rows);
4389 if (cmd->num_limit_rows == 0)
4390 goto send_sar_limits;
4391
4392 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4393 (buf_ptr + WMI_TLV_HDR_SIZE);
4394 sar_rows_list = sar_limit_params->sar_limit_row_list;
4395
4396 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4397 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4398 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4399 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4400 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4401 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4402 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4403 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4404 wmi_sar_rows_list->validity_bitmap =
4405 sar_rows_list->validity_bitmap;
4406 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4407 i, wmi_sar_rows_list->band_id,
4408 wmi_sar_rows_list->chain_id,
4409 wmi_sar_rows_list->mod_id,
4410 wmi_sar_rows_list->limit_value,
4411 wmi_sar_rows_list->validity_bitmap);
4412 sar_rows_list++;
4413 wmi_sar_rows_list++;
4414 }
4415send_sar_limits:
4416 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4417 WMI_SAR_LIMITS_CMDID);
4418
4419 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4420 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4421 wmi_buf_free(buf);
4422 }
4423
4424end:
4425 return qdf_status;
4426}
4427
4428/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304429 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4430 * @wmi_handle: wmi handle
4431 * @params: encrypt/decrypt params
4432 *
4433 * Return: QDF_STATUS_SUCCESS for success or error code
4434 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004435static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304436QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4437 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4438{
4439 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4440 wmi_buf_t wmi_buf;
4441 uint8_t *buf_ptr;
4442 QDF_STATUS ret;
4443 uint32_t len;
4444
4445 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4446
4447 len = sizeof(*cmd) +
4448 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4449 WMI_TLV_HDR_SIZE;
4450 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4451 if (!wmi_buf) {
4452 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4453 __func__);
4454 return QDF_STATUS_E_NOMEM;
4455 }
4456
4457 buf_ptr = wmi_buf_data(wmi_buf);
4458 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4459
4460 WMITLV_SET_HDR(&cmd->tlv_header,
4461 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4462 WMITLV_GET_STRUCT_TLVLEN(
4463 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4464
4465 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4466 cmd->key_flag = encrypt_decrypt_params->key_flag;
4467 cmd->key_idx = encrypt_decrypt_params->key_idx;
4468 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4469 cmd->key_len = encrypt_decrypt_params->key_len;
4470 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4471 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4472
4473 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4474 encrypt_decrypt_params->key_len);
4475
4476 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4477 MAX_MAC_HEADER_LEN);
4478
4479 cmd->data_len = encrypt_decrypt_params->data_len;
4480
4481 if (cmd->data_len) {
4482 buf_ptr += sizeof(*cmd);
4483 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4484 roundup(encrypt_decrypt_params->data_len,
4485 sizeof(A_UINT32)));
4486 buf_ptr += WMI_TLV_HDR_SIZE;
4487 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4488 encrypt_decrypt_params->data_len);
4489 }
4490
4491 /* This conversion is to facilitate data to FW in little endian */
4492 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4493 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4494 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4495 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4496 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4497 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4498
4499 ret = wmi_unified_cmd_send(wmi_handle,
4500 wmi_buf, len,
4501 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4502 if (QDF_IS_STATUS_ERROR(ret)) {
4503 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4504 wmi_buf_free(wmi_buf);
4505 }
4506
4507 return ret;
4508}
4509
4510
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304511
Govind Singh4eacd2b2016-03-07 14:24:22 +05304512/**
4513 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4514 * @wmi_handle: wmi handle
4515 * @vdev_id: vdev id
4516 * @p2p_ie: p2p IE
4517 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304518 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304519 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304520static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304521 A_UINT32 vdev_id, uint8_t *p2p_ie)
4522{
Govind Singh67922e82016-04-01 16:48:57 +05304523 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304524 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4525 wmi_buf_t wmi_buf;
4526 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4527 uint8_t *buf_ptr;
4528
4529 ie_len = (uint32_t) (p2p_ie[1] + 2);
4530
4531 /* More than one P2P IE may be included in a single frame.
4532 If multiple P2P IEs are present, the complete P2P attribute
4533 data consists of the concatenation of the P2P Attribute
4534 fields of the P2P IEs. The P2P Attributes field of each
4535 P2P IE may be any length up to the maximum (251 octets).
4536 In this case host sends one P2P IE to firmware so the length
4537 should not exceed more than 251 bytes
4538 */
4539 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304540 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304541 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304542 }
4543
4544 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4545
4546 wmi_buf_len =
4547 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4548 WMI_TLV_HDR_SIZE;
4549
4550 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4551 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304552 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304553 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304554 }
4555
4556 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4557
4558 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4559 WMITLV_SET_HDR(&cmd->tlv_header,
4560 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4561 WMITLV_GET_STRUCT_TLVLEN
4562 (wmi_p2p_go_set_beacon_ie_fixed_param));
4563 cmd->vdev_id = vdev_id;
4564 cmd->ie_buf_len = ie_len;
4565
4566 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4567 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4568 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304569 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304570
Govind Singhb53420c2016-03-09 14:32:57 +05304571 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304572
4573 ret = wmi_unified_cmd_send(wmi_handle,
4574 wmi_buf, wmi_buf_len,
4575 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304576 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304577 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304578 wmi_buf_free(wmi_buf);
4579 }
4580
Govind Singhb53420c2016-03-09 14:32:57 +05304581 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304582 return ret;
4583}
4584
4585/**
4586 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4587 * @wmi_handle: wmi handle
4588 * @req: gateway parameter update request structure
4589 *
4590 * This function reads the incoming @req and fill in the destination
4591 * WMI structure and sends down the gateway configs down to the firmware
4592 *
Govind Singhb53420c2016-03-09 14:32:57 +05304593 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304594 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304595static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304596 struct gateway_update_req_param *req)
4597{
4598 wmi_roam_subnet_change_config_fixed_param *cmd;
4599 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304600 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304601 int len = sizeof(*cmd);
4602
4603 buf = wmi_buf_alloc(wmi_handle, len);
4604 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304605 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4606 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304607 }
4608
4609 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4610 WMITLV_SET_HDR(&cmd->tlv_header,
4611 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4612 WMITLV_GET_STRUCT_TLVLEN(
4613 wmi_roam_subnet_change_config_fixed_param));
4614
4615 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304616 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4617 QDF_IPV4_ADDR_SIZE);
4618 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4619 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304620 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4621 &cmd->inet_gw_mac_addr);
4622 cmd->max_retries = req->max_retries;
4623 cmd->timeout = req->timeout;
4624 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4625 cmd->flag = 0;
4626 if (req->ipv4_addr_type)
4627 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4628
4629 if (req->ipv6_addr_type)
4630 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4631
4632 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4633 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304634 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304635 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304636 ret);
4637 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304638 }
4639
Govind Singh67922e82016-04-01 16:48:57 +05304640 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304641}
4642
4643/**
4644 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4645 * @wmi_handle: wmi handle
4646 * @req: rssi monitoring request structure
4647 *
4648 * This function reads the incoming @req and fill in the destination
4649 * WMI structure and send down the rssi monitoring configs down to the firmware
4650 *
4651 * Return: 0 on success; error number otherwise
4652 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304653static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304654 struct rssi_monitor_param *req)
4655{
4656 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4657 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304658 QDF_STATUS ret;
4659 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304660
4661 buf = wmi_buf_alloc(wmi_handle, len);
4662 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304663 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4664 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304665 }
4666
4667 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4668 WMITLV_SET_HDR(&cmd->tlv_header,
4669 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4670 WMITLV_GET_STRUCT_TLVLEN(
4671 wmi_rssi_breach_monitor_config_fixed_param));
4672
4673 cmd->vdev_id = req->session_id;
4674 cmd->request_id = req->request_id;
4675 cmd->lo_rssi_reenable_hysteresis = 0;
4676 cmd->hi_rssi_reenable_histeresis = 0;
4677 cmd->min_report_interval = 0;
4678 cmd->max_num_report = 1;
4679 if (req->control) {
4680 /* enable one threshold for each min/max */
4681 cmd->enabled_bitmap = 0x09;
4682 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4683 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4684 } else {
4685 cmd->enabled_bitmap = 0;
4686 cmd->low_rssi_breach_threshold[0] = 0;
4687 cmd->hi_rssi_breach_threshold[0] = 0;
4688 }
4689
4690 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4691 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304692 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304693 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304694 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304695 }
4696
Govind Singhb53420c2016-03-09 14:32:57 +05304697 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304698 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304699}
4700
4701/**
4702 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4703 * @wmi_handle: wmi handle
4704 * @psetoui: OUI parameters
4705 *
4706 * set scan probe OUI parameters in firmware
4707 *
4708 * Return: CDF status
4709 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304710static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304711 struct scan_mac_oui *psetoui)
4712{
4713 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4714 wmi_buf_t wmi_buf;
4715 uint32_t len;
4716 uint8_t *buf_ptr;
4717 uint32_t *oui_buf;
4718
4719 len = sizeof(*cmd);
4720 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4721 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304722 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4723 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304724 }
4725 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4726 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4727 WMITLV_SET_HDR(&cmd->tlv_header,
4728 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4729 WMITLV_GET_STRUCT_TLVLEN
4730 (wmi_scan_prob_req_oui_cmd_fixed_param));
4731
4732 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304733 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304734 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4735 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304736 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304737 cmd->prob_req_oui);
4738
4739 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4740 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304741 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304742 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304743 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304744 }
Govind Singhb53420c2016-03-09 14:32:57 +05304745 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304746}
4747
4748/**
4749 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
4750 * @wmi_handle: wmi handle
4751 * @req: passpoint network request structure
4752 *
4753 * This function sends down WMI command with network id set to wildcard id.
4754 * firmware shall clear all the config entries
4755 *
Govind Singhb53420c2016-03-09 14:32:57 +05304756 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304757 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304758static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304759 struct wifi_passpoint_req_param *req)
4760{
4761 wmi_passpoint_config_cmd_fixed_param *cmd;
4762 wmi_buf_t buf;
4763 uint32_t len;
4764 int ret;
4765
4766 len = sizeof(*cmd);
4767 buf = wmi_buf_alloc(wmi_handle, len);
4768 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304769 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4770 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304771 }
4772
4773 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
4774
4775 WMITLV_SET_HDR(&cmd->tlv_header,
4776 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4777 WMITLV_GET_STRUCT_TLVLEN(
4778 wmi_passpoint_config_cmd_fixed_param));
4779 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
4780
4781 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4782 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4783 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304784 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304785 __func__);
4786 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304787 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304788 }
4789
Govind Singhb53420c2016-03-09 14:32:57 +05304790 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304791}
4792
4793/**
4794 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
4795 * @wmi_handle: wmi handle
4796 * @req: passpoint network request structure
4797 *
4798 * This function reads the incoming @req and fill in the destination
4799 * WMI structure and send down the passpoint configs down to the firmware
4800 *
Govind Singhb53420c2016-03-09 14:32:57 +05304801 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304802 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304803static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304804 struct wifi_passpoint_req_param *req)
4805{
4806 wmi_passpoint_config_cmd_fixed_param *cmd;
4807 u_int8_t i, j, *bytes;
4808 wmi_buf_t buf;
4809 uint32_t len;
4810 int ret;
4811
4812 len = sizeof(*cmd);
4813 for (i = 0; i < req->num_networks; i++) {
4814 buf = wmi_buf_alloc(wmi_handle, len);
4815 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304816 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4817 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304818 }
4819
4820 cmd = (wmi_passpoint_config_cmd_fixed_param *)
4821 wmi_buf_data(buf);
4822
4823 WMITLV_SET_HDR(&cmd->tlv_header,
4824 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4825 WMITLV_GET_STRUCT_TLVLEN(
4826 wmi_passpoint_config_cmd_fixed_param));
4827 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05304828 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
4829 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304830 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05304831 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304832 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
4833 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05304834 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304835 j, bytes[0], bytes[1], bytes[2], bytes[3],
4836 bytes[4], bytes[5], bytes[6], bytes[7]);
4837
Govind Singhb53420c2016-03-09 14:32:57 +05304838 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05304839 &req->networks[i].roaming_consortium_ids[j],
4840 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
4841 }
Govind Singhb53420c2016-03-09 14:32:57 +05304842 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304843 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304844 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304845 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
4846
4847 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4848 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4849 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304850 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304851 __func__);
4852 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304853 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304854 }
4855 }
4856
Govind Singhb53420c2016-03-09 14:32:57 +05304857 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304858}
4859
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304860/**
4861 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
4862 * @wmi_handle: wmi handle
4863 * @scan_cmd_fp: start scan command ptr
4864 * @roam_req: roam request param
4865 *
4866 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
4867 * of WMI_ROAM_SCAN_MODE.
4868 *
4869 * Return: QDF status
4870 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304871static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304872 wmi_start_scan_cmd_fixed_param *
4873 scan_cmd_fp,
4874 struct roam_offload_scan_params *roam_req)
4875{
4876 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304877 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304878 int len;
4879 uint8_t *buf_ptr;
4880 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05304881
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304882#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4883 int auth_mode = roam_req->auth_mode;
4884 wmi_roam_offload_tlv_param *roam_offload_params;
4885 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
4886 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
4887 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304888 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304889#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4890 /* Need to create a buf with roam_scan command at
4891 * front and piggyback with scan command */
4892 len = sizeof(wmi_roam_scan_mode_fixed_param) +
4893#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4894 (2 * WMI_TLV_HDR_SIZE) +
4895#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4896 sizeof(wmi_start_scan_cmd_fixed_param);
4897#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4898 if (roam_req->is_roam_req_valid &&
4899 roam_req->roam_offload_enabled) {
4900 len += sizeof(wmi_roam_offload_tlv_param);
4901 len += WMI_TLV_HDR_SIZE;
4902 if ((auth_mode != WMI_AUTH_NONE) &&
4903 ((auth_mode != WMI_AUTH_OPEN) ||
4904 (auth_mode == WMI_AUTH_OPEN &&
4905 roam_req->mdid.mdie_present) ||
4906 roam_req->is_ese_assoc)) {
4907 len += WMI_TLV_HDR_SIZE;
4908 if (roam_req->is_ese_assoc)
4909 len +=
4910 sizeof(wmi_roam_ese_offload_tlv_param);
4911 else if (auth_mode == WMI_AUTH_FT_RSNA ||
4912 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
4913 (auth_mode == WMI_AUTH_OPEN &&
4914 roam_req->mdid.mdie_present))
4915 len +=
4916 sizeof(wmi_roam_11r_offload_tlv_param);
4917 else
4918 len +=
4919 sizeof(wmi_roam_11i_offload_tlv_param);
4920 } else {
4921 len += WMI_TLV_HDR_SIZE;
4922 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304923
4924 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
4925 + roundup(roam_req->assoc_ie_length,
4926 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304927 } else {
4928 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05304929 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304930 __func__, roam_req->roam_offload_enabled);
4931 else
Govind Singhe7f2f342016-05-23 12:12:52 +05304932 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304933 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304934 }
4935 if (roam_req->is_roam_req_valid &&
4936 roam_req->roam_offload_enabled) {
4937 roam_req->mode = roam_req->mode |
4938 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
4939 }
4940#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4941
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304942 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4943 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4944 len = sizeof(wmi_roam_scan_mode_fixed_param);
4945
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304946 buf = wmi_buf_alloc(wmi_handle, len);
4947 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304948 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304949 return QDF_STATUS_E_NOMEM;
4950 }
4951
4952 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304953
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304954 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
4955 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
4956 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
4957 WMITLV_GET_STRUCT_TLVLEN
4958 (wmi_roam_scan_mode_fixed_param));
4959
4960 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
4961 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304962 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4963 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4964 goto send_roam_scan_mode_cmd;
4965
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304966 /* Fill in scan parameters suitable for roaming scan */
4967 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304968
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304969 qdf_mem_copy(buf_ptr, scan_cmd_fp,
4970 sizeof(wmi_start_scan_cmd_fixed_param));
4971 /* Ensure there is no additional IEs */
4972 scan_cmd_fp->ie_len = 0;
4973 WMITLV_SET_HDR(buf_ptr,
4974 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
4975 WMITLV_GET_STRUCT_TLVLEN
4976 (wmi_start_scan_cmd_fixed_param));
4977#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4978 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
4979 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
4980 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4981 sizeof(wmi_roam_offload_tlv_param));
4982 buf_ptr += WMI_TLV_HDR_SIZE;
4983 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
4984 WMITLV_SET_HDR(buf_ptr,
4985 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
4986 WMITLV_GET_STRUCT_TLVLEN
4987 (wmi_roam_offload_tlv_param));
4988 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
4989 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
4990 roam_offload_params->select_5g_margin =
4991 roam_req->select_5ghz_margin;
4992 roam_offload_params->reassoc_failure_timeout =
4993 roam_req->reassoc_failure_timeout;
4994
4995 /* Fill the capabilities */
4996 roam_offload_params->capability =
4997 roam_req->roam_offload_params.capability;
4998 roam_offload_params->ht_caps_info =
4999 roam_req->roam_offload_params.ht_caps_info;
5000 roam_offload_params->ampdu_param =
5001 roam_req->roam_offload_params.ampdu_param;
5002 roam_offload_params->ht_ext_cap =
5003 roam_req->roam_offload_params.ht_ext_cap;
5004 roam_offload_params->ht_txbf =
5005 roam_req->roam_offload_params.ht_txbf;
5006 roam_offload_params->asel_cap =
5007 roam_req->roam_offload_params.asel_cap;
5008 roam_offload_params->qos_caps =
5009 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005010 roam_offload_params->qos_enabled =
5011 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305012 roam_offload_params->wmm_caps =
5013 roam_req->roam_offload_params.wmm_caps;
5014 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5015 (uint8_t *)roam_req->roam_offload_params.mcsset,
5016 ROAM_OFFLOAD_NUM_MCS_SET);
5017
5018 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5019 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5020 * they are filled in the same order.Depending on the
5021 * authentication type, the other mode TLV's are nullified
5022 * and only headers are filled.*/
5023 if ((auth_mode != WMI_AUTH_NONE) &&
5024 ((auth_mode != WMI_AUTH_OPEN) ||
5025 (auth_mode == WMI_AUTH_OPEN
5026 && roam_req->mdid.mdie_present) ||
5027 roam_req->is_ese_assoc)) {
5028 if (roam_req->is_ese_assoc) {
5029 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5030 WMITLV_GET_STRUCT_TLVLEN(0));
5031 buf_ptr += WMI_TLV_HDR_SIZE;
5032 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5033 WMITLV_GET_STRUCT_TLVLEN(0));
5034 buf_ptr += WMI_TLV_HDR_SIZE;
5035 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5036 sizeof(wmi_roam_ese_offload_tlv_param));
5037 buf_ptr += WMI_TLV_HDR_SIZE;
5038 roam_offload_ese =
5039 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5040 qdf_mem_copy(roam_offload_ese->krk,
5041 roam_req->krk,
5042 sizeof(roam_req->krk));
5043 qdf_mem_copy(roam_offload_ese->btk,
5044 roam_req->btk,
5045 sizeof(roam_req->btk));
5046 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5047 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5048 WMITLV_GET_STRUCT_TLVLEN
5049 (wmi_roam_ese_offload_tlv_param));
5050 buf_ptr +=
5051 sizeof(wmi_roam_ese_offload_tlv_param);
5052 } else if (auth_mode == WMI_AUTH_FT_RSNA
5053 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5054 || (auth_mode == WMI_AUTH_OPEN
5055 && roam_req->mdid.mdie_present)) {
5056 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5057 0);
5058 buf_ptr += WMI_TLV_HDR_SIZE;
5059 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5060 sizeof(wmi_roam_11r_offload_tlv_param));
5061 buf_ptr += WMI_TLV_HDR_SIZE;
5062 roam_offload_11r =
5063 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5064 roam_offload_11r->r0kh_id_len =
5065 roam_req->rokh_id_length;
5066 qdf_mem_copy(roam_offload_11r->r0kh_id,
5067 roam_req->rokh_id,
5068 roam_offload_11r->r0kh_id_len);
5069 qdf_mem_copy(roam_offload_11r->psk_msk,
5070 roam_req->psk_pmk,
5071 sizeof(roam_req->psk_pmk));
5072 roam_offload_11r->psk_msk_len =
5073 roam_req->pmk_len;
5074 roam_offload_11r->mdie_present =
5075 roam_req->mdid.mdie_present;
5076 roam_offload_11r->mdid =
5077 roam_req->mdid.mobility_domain;
5078 if (auth_mode == WMI_AUTH_OPEN) {
5079 /* If FT-Open ensure pmk length
5080 and r0khid len are zero */
5081 roam_offload_11r->r0kh_id_len = 0;
5082 roam_offload_11r->psk_msk_len = 0;
5083 }
5084 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5085 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5086 WMITLV_GET_STRUCT_TLVLEN
5087 (wmi_roam_11r_offload_tlv_param));
5088 buf_ptr +=
5089 sizeof(wmi_roam_11r_offload_tlv_param);
5090 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5091 WMITLV_GET_STRUCT_TLVLEN(0));
5092 buf_ptr += WMI_TLV_HDR_SIZE;
5093 } else {
5094 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5095 sizeof(wmi_roam_11i_offload_tlv_param));
5096 buf_ptr += WMI_TLV_HDR_SIZE;
5097 roam_offload_11i =
5098 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005099 if (roam_req->roam_key_mgmt_offload_enabled &&
5100 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305101 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5102 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305103 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305104 } else {
5105 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5106 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305107 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305108 }
5109
5110 qdf_mem_copy(roam_offload_11i->pmk,
5111 roam_req->psk_pmk,
5112 sizeof(roam_req->psk_pmk));
5113 roam_offload_11i->pmk_len = roam_req->pmk_len;
5114 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5115 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5116 WMITLV_GET_STRUCT_TLVLEN
5117 (wmi_roam_11i_offload_tlv_param));
5118 buf_ptr +=
5119 sizeof(wmi_roam_11i_offload_tlv_param);
5120 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5121 0);
5122 buf_ptr += WMI_TLV_HDR_SIZE;
5123 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5124 0);
5125 buf_ptr += WMI_TLV_HDR_SIZE;
5126 }
5127 } else {
5128 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5129 WMITLV_GET_STRUCT_TLVLEN(0));
5130 buf_ptr += WMI_TLV_HDR_SIZE;
5131 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5132 WMITLV_GET_STRUCT_TLVLEN(0));
5133 buf_ptr += WMI_TLV_HDR_SIZE;
5134 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5135 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305136 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305137 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305138
5139 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5140 sizeof(*assoc_ies));
5141 buf_ptr += WMI_TLV_HDR_SIZE;
5142
5143 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5144 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5145 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5146 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5147 assoc_ies->buf_len = roam_req->assoc_ie_length;
5148
5149 buf_ptr += sizeof(*assoc_ies);
5150
5151 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5152 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5153 buf_ptr += WMI_TLV_HDR_SIZE;
5154
5155 if (assoc_ies->buf_len != 0) {
5156 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5157 assoc_ies->buf_len);
5158 }
5159
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305160 } else {
5161 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5162 WMITLV_GET_STRUCT_TLVLEN(0));
5163 buf_ptr += WMI_TLV_HDR_SIZE;
5164 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5165 WMITLV_GET_STRUCT_TLVLEN(0));
5166 buf_ptr += WMI_TLV_HDR_SIZE;
5167 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5168 WMITLV_GET_STRUCT_TLVLEN(0));
5169 buf_ptr += WMI_TLV_HDR_SIZE;
5170 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5171 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305172 buf_ptr += WMI_TLV_HDR_SIZE;
5173 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5174 WMITLV_GET_STRUCT_TLVLEN(0));
5175 buf_ptr += WMI_TLV_HDR_SIZE;
5176 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5177 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305178 }
5179#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305180
5181send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305182 status = wmi_unified_cmd_send(wmi_handle, buf,
5183 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305184 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305185 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305186 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5187 status);
5188 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305189 }
5190
Govind Singh67922e82016-04-01 16:48:57 +05305191 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305192}
5193
5194
5195/**
5196 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5197 * rssi threashold
5198 * @wmi_handle: wmi handle
5199 * @roam_req: Roaming request buffer
5200 *
5201 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5202 *
5203 * Return: QDF status
5204 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305205static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305206 struct roam_offload_scan_rssi_params *roam_req)
5207{
5208 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305209 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305210 int len;
5211 uint8_t *buf_ptr;
5212 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5213 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5214 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305215 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305216
5217 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5218 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5219 len += sizeof(wmi_roam_scan_extended_threshold_param);
5220 len += WMI_TLV_HDR_SIZE;
5221 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305222 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5223 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305224 buf = wmi_buf_alloc(wmi_handle, len);
5225 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305226 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305227 return QDF_STATUS_E_NOMEM;
5228 }
5229
5230 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5231 rssi_threshold_fp =
5232 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5233 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5234 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5235 WMITLV_GET_STRUCT_TLVLEN
5236 (wmi_roam_scan_rssi_threshold_fixed_param));
5237 /* fill in threshold values */
5238 rssi_threshold_fp->vdev_id = roam_req->session_id;
5239 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5240 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5241 rssi_threshold_fp->hirssi_scan_max_count =
5242 roam_req->hi_rssi_scan_max_count;
5243 rssi_threshold_fp->hirssi_scan_delta =
5244 roam_req->hi_rssi_scan_rssi_delta;
5245 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5246
5247 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5248 WMITLV_SET_HDR(buf_ptr,
5249 WMITLV_TAG_ARRAY_STRUC,
5250 sizeof(wmi_roam_scan_extended_threshold_param));
5251 buf_ptr += WMI_TLV_HDR_SIZE;
5252 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5253
5254 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5255 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5256 ext_thresholds->boost_threshold_5g =
5257 roam_req->boost_threshold_5g;
5258
5259 ext_thresholds->boost_algorithm_5g =
5260 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5261 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5262 ext_thresholds->penalty_algorithm_5g =
5263 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5264 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5265 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5266 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5267 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5268
5269 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5270 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5271 WMITLV_GET_STRUCT_TLVLEN
5272 (wmi_roam_scan_extended_threshold_param));
5273 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5274 WMITLV_SET_HDR(buf_ptr,
5275 WMITLV_TAG_ARRAY_STRUC,
5276 sizeof(wmi_roam_earlystop_rssi_thres_param));
5277 buf_ptr += WMI_TLV_HDR_SIZE;
5278 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5279 early_stop_thresholds->roam_earlystop_thres_min =
5280 roam_req->roam_earlystop_thres_min;
5281 early_stop_thresholds->roam_earlystop_thres_max =
5282 roam_req->roam_earlystop_thres_max;
5283 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5284 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5285 WMITLV_GET_STRUCT_TLVLEN
5286 (wmi_roam_earlystop_rssi_thres_param));
5287
Gupta, Kapil7e652922016-04-12 15:02:00 +05305288 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5289 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5290 sizeof(wmi_roam_dense_thres_param));
5291 buf_ptr += WMI_TLV_HDR_SIZE;
5292 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5293 dense_thresholds->roam_dense_rssi_thres_offset =
5294 roam_req->dense_rssi_thresh_offset;
5295 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5296 dense_thresholds->roam_dense_traffic_thres =
5297 roam_req->traffic_threshold;
5298 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5299 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5300 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5301 WMITLV_GET_STRUCT_TLVLEN
5302 (wmi_roam_dense_thres_param));
5303
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305304 status = wmi_unified_cmd_send(wmi_handle, buf,
5305 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305306 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305307 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305308 status);
5309 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305310 }
5311
Govind Singh67922e82016-04-01 16:48:57 +05305312 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305313}
5314
5315/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305316 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5317 * configuration params
5318 * @wma_handle: wma handler
5319 * @dwelltime_params: pointer to dwelltime_params
5320 *
5321 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5322 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005323static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305324QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5325 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5326{
5327 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5328 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5329 wmi_buf_t buf;
5330 uint8_t *buf_ptr;
5331 int32_t err;
5332 int len;
5333
5334 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5335 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5336 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5337 buf = wmi_buf_alloc(wmi_handle, len);
5338 if (!buf) {
5339 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5340 __func__);
5341 return QDF_STATUS_E_NOMEM;
5342 }
5343 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5344 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5345 WMITLV_SET_HDR(&dwell_param->tlv_header,
5346 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5347 WMITLV_GET_STRUCT_TLVLEN
5348 (wmi_scan_adaptive_dwell_config_fixed_param));
5349
5350 dwell_param->enable = dwelltime_params->is_enabled;
5351 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5352 WMITLV_SET_HDR(buf_ptr,
5353 WMITLV_TAG_ARRAY_STRUC,
5354 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5355 buf_ptr += WMI_TLV_HDR_SIZE;
5356
5357 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5358 WMITLV_SET_HDR(&cmd->tlv_header,
5359 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5360 WMITLV_GET_STRUCT_TLVLEN(
5361 wmi_scan_adaptive_dwell_parameters_tlv));
5362
5363 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5364 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5365 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5366 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5367 err = wmi_unified_cmd_send(wmi_handle, buf,
5368 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5369 if (err) {
5370 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5371 wmi_buf_free(buf);
5372 return QDF_STATUS_E_FAILURE;
5373 }
5374
5375 return QDF_STATUS_SUCCESS;
5376}
5377
5378
5379/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305380 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5381 * @wmi_handle: wmi handle
5382 * @roam_req: Request which contains the filters
5383 *
5384 * There are filters such as whitelist, blacklist and preferred
5385 * list that need to be applied to the scan results to form the
5386 * probable candidates for roaming.
5387 *
5388 * Return: Return success upon succesfully passing the
5389 * parameters to the firmware, otherwise failure.
5390 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305391static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305392 struct roam_scan_filter_params *roam_req)
5393{
5394 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305395 QDF_STATUS status;
5396 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305397 uint32_t len;
5398 uint8_t *buf_ptr;
5399 wmi_roam_filter_fixed_param *roam_filter;
5400 uint8_t *bssid_src_ptr = NULL;
5401 wmi_mac_addr *bssid_dst_ptr = NULL;
5402 wmi_ssid *ssid_ptr = NULL;
5403 uint32_t *bssid_preferred_factor_ptr = NULL;
5404
5405 len = sizeof(wmi_roam_filter_fixed_param);
5406 len += WMI_TLV_HDR_SIZE;
5407 len += roam_req->len;
5408
5409 buf = wmi_buf_alloc(wmi_handle, len);
5410 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305411 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305412 return QDF_STATUS_E_NOMEM;
5413 }
5414
5415 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5416 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5417 WMITLV_SET_HDR(&roam_filter->tlv_header,
5418 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5419 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5420 /* fill in fixed values */
5421 roam_filter->vdev_id = roam_req->session_id;
5422 roam_filter->flags = 0;
5423 roam_filter->op_bitmap = roam_req->op_bitmap;
5424 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5425 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5426 roam_filter->num_bssid_preferred_list =
5427 roam_req->num_bssid_preferred_list;
5428 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5429
5430 WMITLV_SET_HDR((buf_ptr),
5431 WMITLV_TAG_ARRAY_FIXED_STRUC,
5432 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5433 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5434 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5435 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5436 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5437 bssid_src_ptr += ATH_MAC_LEN;
5438 bssid_dst_ptr++;
5439 }
5440 buf_ptr += WMI_TLV_HDR_SIZE +
5441 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5442 WMITLV_SET_HDR((buf_ptr),
5443 WMITLV_TAG_ARRAY_FIXED_STRUC,
5444 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5445 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5446 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5447 qdf_mem_copy(&ssid_ptr->ssid,
5448 &roam_req->ssid_allowed_list[i].mac_ssid,
5449 roam_req->ssid_allowed_list[i].length);
5450 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5451 ssid_ptr++;
5452 }
5453 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5454 sizeof(wmi_ssid));
5455 WMITLV_SET_HDR((buf_ptr),
5456 WMITLV_TAG_ARRAY_FIXED_STRUC,
5457 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5458 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5459 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5460 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5461 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5462 (wmi_mac_addr *)bssid_dst_ptr);
5463 bssid_src_ptr += ATH_MAC_LEN;
5464 bssid_dst_ptr++;
5465 }
5466 buf_ptr += WMI_TLV_HDR_SIZE +
5467 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5469 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5470 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5471 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5472 *bssid_preferred_factor_ptr =
5473 roam_req->bssid_favored_factor[i];
5474 bssid_preferred_factor_ptr++;
5475 }
5476 buf_ptr += WMI_TLV_HDR_SIZE +
5477 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5478
5479 status = wmi_unified_cmd_send(wmi_handle, buf,
5480 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305481 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305482 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305483 status);
5484 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305485 }
Govind Singh67922e82016-04-01 16:48:57 +05305486
5487 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305488}
5489
Govind Singh4eacd2b2016-03-07 14:24:22 +05305490/** send_set_epno_network_list_cmd_tlv() - set epno network list
5491 * @wmi_handle: wmi handle
5492 * @req: epno config params request structure
5493 *
5494 * This function reads the incoming epno config request structure
5495 * and constructs the WMI message to the firmware.
5496 *
5497 * Returns: 0 on success, error number otherwise
5498 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305499static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305500 struct wifi_enhanched_pno_params *req)
5501{
5502 wmi_nlo_config_cmd_fixed_param *cmd;
5503 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305504 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305505 u_int8_t i, *buf_ptr;
5506 wmi_buf_t buf;
5507 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305508 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305509
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305510 /* Fixed Params */
5511 len = sizeof(*cmd);
5512 if (req->num_networks) {
5513 /* TLV place holder for array of structures
5514 * then each nlo_configured_parameters(nlo_list) TLV.
5515 */
5516 len += WMI_TLV_HDR_SIZE;
5517 len += (sizeof(nlo_configured_parameters)
5518 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5519 /* TLV for array of uint32 channel_list */
5520 len += WMI_TLV_HDR_SIZE;
5521 /* TLV for nlo_channel_prediction_cfg */
5522 len += WMI_TLV_HDR_SIZE;
5523 /* TLV for candidate score params */
5524 len += sizeof(enlo_candidate_score_params);
5525 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305526
5527 buf = wmi_buf_alloc(wmi_handle, len);
5528 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305529 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5530 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305531 }
5532
5533 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5534
5535 buf_ptr = (u_int8_t *) cmd;
5536 WMITLV_SET_HDR(&cmd->tlv_header,
5537 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5538 WMITLV_GET_STRUCT_TLVLEN(
5539 wmi_nlo_config_cmd_fixed_param));
5540 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305541
5542 /* set flag to reset if num of networks are 0 */
5543 cmd->flags = (req->num_networks == 0 ?
5544 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305545
5546 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5547
Govind Singhb53420c2016-03-09 14:32:57 +05305548 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305549 WMI_LOGD("SSID count: %d flags: %d",
5550 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305551
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305552 /* Fill nlo_config only when num_networks are non zero */
5553 if (cmd->no_of_ssids) {
5554 /* Fill networks */
5555 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5556 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5557 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305558
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305559 nlo_list = (nlo_configured_parameters *) buf_ptr;
5560 for (i = 0; i < cmd->no_of_ssids; i++) {
5561 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5562 WMITLV_TAG_ARRAY_BYTE,
5563 WMITLV_GET_STRUCT_TLVLEN(
5564 nlo_configured_parameters));
5565 /* Copy ssid and it's length */
5566 nlo_list[i].ssid.valid = true;
5567 nlo_list[i].ssid.ssid.ssid_len =
5568 req->networks[i].ssid.length;
5569 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5570 req->networks[i].ssid.mac_ssid,
5571 nlo_list[i].ssid.ssid.ssid_len);
5572 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5573 nlo_list[i].ssid.ssid.ssid_len,
5574 (char *) nlo_list[i].ssid.ssid.ssid,
5575 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305576
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305577 /* Copy pno flags */
5578 nlo_list[i].bcast_nw_type.valid = true;
5579 nlo_list[i].bcast_nw_type.bcast_nw_type =
5580 req->networks[i].flags;
5581 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305582 nlo_list[i].bcast_nw_type.bcast_nw_type);
5583
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305584 /* Copy auth bit field */
5585 nlo_list[i].auth_type.valid = true;
5586 nlo_list[i].auth_type.auth_type =
5587 req->networks[i].auth_bit_field;
5588 WMI_LOGD("Auth bit field (%u)",
5589 nlo_list[i].auth_type.auth_type);
5590 }
5591
5592 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5593 /* Fill the channel list */
5594 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5595 buf_ptr += WMI_TLV_HDR_SIZE;
5596
5597 /* Fill prediction_param */
5598 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5599 buf_ptr += WMI_TLV_HDR_SIZE;
5600
5601 /* Fill epno candidate score params */
5602 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5603 WMITLV_SET_HDR(buf_ptr,
5604 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5605 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5606 cand_score_params->min5GHz_rssi =
5607 req->min_5ghz_rssi;
5608 cand_score_params->min24GHz_rssi =
5609 req->min_24ghz_rssi;
5610 cand_score_params->initial_score_max =
5611 req->initial_score_max;
5612 cand_score_params->current_connection_bonus =
5613 req->current_connection_bonus;
5614 cand_score_params->same_network_bonus =
5615 req->same_network_bonus;
5616 cand_score_params->secure_bonus =
5617 req->secure_bonus;
5618 cand_score_params->band5GHz_bonus =
5619 req->band_5ghz_bonus;
5620 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305621 }
5622
Govind Singh4eacd2b2016-03-07 14:24:22 +05305623 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305624 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305625 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305626 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305627 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305628 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305629 }
5630
Govind Singhb53420c2016-03-09 14:32:57 +05305631 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305632 req->session_id);
5633
Govind Singh67922e82016-04-01 16:48:57 +05305634 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305635}
5636
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305637
Govind Singh4eacd2b2016-03-07 14:24:22 +05305638/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5639 * @wmi_handle: wmi handle
5640 * @ipa_offload: ipa offload control parameter
5641 *
5642 * Returns: 0 on success, error number otherwise
5643 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305644static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305645 struct ipa_offload_control_params *ipa_offload)
5646{
5647 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5648 wmi_buf_t wmi_buf;
5649 uint32_t len;
5650 u_int8_t *buf_ptr;
5651
5652 len = sizeof(*cmd);
5653 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5654 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305655 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5656 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305657 }
5658
Govind Singhb53420c2016-03-09 14:32:57 +05305659 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305660 ipa_offload->offload_type, ipa_offload->enable);
5661
5662 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5663
5664 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5665 WMITLV_SET_HDR(&cmd->tlv_header,
5666 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5667 WMITLV_GET_STRUCT_TLVLEN(
5668 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5669
5670 cmd->offload_type = ipa_offload->offload_type;
5671 cmd->vdev_id = ipa_offload->vdev_id;
5672 cmd->enable = ipa_offload->enable;
5673
5674 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5675 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305676 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305677 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305678 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305679 }
5680
Govind Singhb53420c2016-03-09 14:32:57 +05305681 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305682}
5683
5684/**
5685 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5686 * @wmi_handle: wmi handle
5687 * @pgetcapab: get capabilities params
5688 *
5689 * This function send request to fw to get extscan capabilities.
5690 *
5691 * Return: CDF status
5692 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305693static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305694 struct extscan_capabilities_params *pgetcapab)
5695{
5696 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5697 wmi_buf_t wmi_buf;
5698 uint32_t len;
5699 uint8_t *buf_ptr;
5700
5701 len = sizeof(*cmd);
5702 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5703 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305704 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5705 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305706 }
5707 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5708
5709 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5710 WMITLV_SET_HDR(&cmd->tlv_header,
5711 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5712 WMITLV_GET_STRUCT_TLVLEN
5713 (wmi_extscan_get_capabilities_cmd_fixed_param));
5714
5715 cmd->request_id = pgetcapab->request_id;
5716
5717 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5718 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305719 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305720 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305721 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305722 }
Govind Singhb53420c2016-03-09 14:32:57 +05305723 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305724}
5725
5726/**
5727 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5728 * @wmi_handle: wmi handle
5729 * @pcached_results: cached results parameters
5730 *
5731 * This function send request to fw to get cached results.
5732 *
5733 * Return: CDF status
5734 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305735static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305736 struct extscan_cached_result_params *pcached_results)
5737{
5738 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5739 wmi_buf_t wmi_buf;
5740 uint32_t len;
5741 uint8_t *buf_ptr;
5742
5743 len = sizeof(*cmd);
5744 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5745 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305746 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5747 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305748 }
5749 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5750
5751 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
5752 WMITLV_SET_HDR(&cmd->tlv_header,
5753 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
5754 WMITLV_GET_STRUCT_TLVLEN
5755 (wmi_extscan_get_cached_results_cmd_fixed_param));
5756
5757 cmd->request_id = pcached_results->request_id;
5758 cmd->vdev_id = pcached_results->session_id;
5759 cmd->control_flags = pcached_results->flush;
5760
5761 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5762 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305763 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305764 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305765 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305766 }
Govind Singhb53420c2016-03-09 14:32:57 +05305767 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305768}
5769
5770/**
5771 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
5772 * @wmi_handle: wmi handle
5773 * @reset_req: Reset change request params
5774 *
5775 * This function sends stop change monitor request to fw.
5776 *
5777 * Return: CDF status
5778 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305779static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305780 struct extscan_capabilities_reset_params *reset_req)
5781{
5782 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5783 wmi_buf_t wmi_buf;
5784 uint32_t len;
5785 uint8_t *buf_ptr;
5786 int change_list = 0;
5787
5788 len = sizeof(*cmd);
5789
5790 /* reset significant change tlv is set to 0 */
5791 len += WMI_TLV_HDR_SIZE;
5792 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
5793 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5794 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305795 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5796 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305797 }
5798 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5799
5800 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5801 buf_ptr;
5802 WMITLV_SET_HDR(&cmd->tlv_header,
5803 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5804 WMITLV_GET_STRUCT_TLVLEN
5805 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5806
5807 cmd->request_id = reset_req->request_id;
5808 cmd->vdev_id = reset_req->session_id;
5809 cmd->mode = 0;
5810
5811 buf_ptr += sizeof(*cmd);
5812 WMITLV_SET_HDR(buf_ptr,
5813 WMITLV_TAG_ARRAY_STRUC,
5814 change_list *
5815 sizeof(wmi_extscan_wlan_change_bssid_param));
5816 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
5817 sizeof
5818 (wmi_extscan_wlan_change_bssid_param));
5819
5820 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5821 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305822 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305823 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305824 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305825 }
Govind Singhb53420c2016-03-09 14:32:57 +05305826 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305827}
5828
5829/**
5830 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
5831 * @wmi_handle: wmi handle
5832 * @psigchange: change monitor request params
5833 * @buf: wmi buffer
5834 * @buf_len: buffer length
5835 *
5836 * This function fills elements of change monitor request buffer.
5837 *
5838 * Return: CDF status
5839 */
Govind Singhb53420c2016-03-09 14:32:57 +05305840static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305841 struct extscan_set_sig_changereq_params
5842 *psigchange, wmi_buf_t *buf, int *buf_len)
5843{
5844 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5845 wmi_extscan_wlan_change_bssid_param *dest_chglist;
5846 uint8_t *buf_ptr;
5847 int j;
5848 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08005849 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305850 struct ap_threshold_params *src_ap = psigchange->ap;
5851
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08005852 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305853 WMI_LOGE("%s: Invalid number of bssid's", __func__);
5854 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305855 }
5856 len += WMI_TLV_HDR_SIZE;
5857 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
5858
5859 *buf = wmi_buf_alloc(wmi_handle, len);
5860 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305861 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305862 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305863 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305864 }
5865 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5866 cmd =
5867 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5868 buf_ptr;
5869 WMITLV_SET_HDR(&cmd->tlv_header,
5870 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5871 WMITLV_GET_STRUCT_TLVLEN
5872 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5873
5874 cmd->request_id = psigchange->request_id;
5875 cmd->vdev_id = psigchange->session_id;
5876 cmd->total_entries = numap;
5877 cmd->mode = 1;
5878 cmd->num_entries_in_page = numap;
5879 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
5880 cmd->max_rssi_samples = psigchange->rssi_sample_size;
5881 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
5882 cmd->max_out_of_range_count = psigchange->min_breaching;
5883
5884 buf_ptr += sizeof(*cmd);
5885 WMITLV_SET_HDR(buf_ptr,
5886 WMITLV_TAG_ARRAY_STRUC,
5887 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5888 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
5889 (buf_ptr + WMI_TLV_HDR_SIZE);
5890
5891 for (j = 0; j < numap; j++) {
5892 WMITLV_SET_HDR(dest_chglist,
5893 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5894 WMITLV_GET_STRUCT_TLVLEN
5895 (wmi_extscan_wlan_change_bssid_param));
5896
5897 dest_chglist->lower_rssi_limit = src_ap->low;
5898 dest_chglist->upper_rssi_limit = src_ap->high;
5899 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
5900 &dest_chglist->bssid);
5901
Govind Singhb53420c2016-03-09 14:32:57 +05305902 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305903 dest_chglist->lower_rssi_limit);
5904 dest_chglist++;
5905 src_ap++;
5906 }
5907 buf_ptr += WMI_TLV_HDR_SIZE +
5908 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5909 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305910 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305911}
5912
5913/**
5914 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
5915 * @wmi_handle: wmi handle
5916 * @psigchange: change monitor request params
5917 *
5918 * This function sends start change monitor request to fw.
5919 *
5920 * Return: CDF status
5921 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305922static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305923 struct extscan_set_sig_changereq_params *
5924 psigchange)
5925{
Govind Singhb53420c2016-03-09 14:32:57 +05305926 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305927 wmi_buf_t buf;
5928 int len;
5929
5930
Govind Singhb53420c2016-03-09 14:32:57 +05305931 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305932 psigchange, &buf,
5933 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305934 if (qdf_status != QDF_STATUS_SUCCESS) {
5935 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305936 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305937 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305938 }
5939 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305940 WMI_LOGE("%s: Failed to get buffer", __func__);
5941 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305942 }
5943 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5944 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305945 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305946 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305947 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305948 }
Govind Singhb53420c2016-03-09 14:32:57 +05305949 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305950}
5951
5952/**
5953 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
5954 * @wmi_handle: wmi handle
5955 * @photlist_reset: hotlist reset params
5956 *
5957 * This function configures hotlist monitor to stop in fw.
5958 *
5959 * Return: CDF status
5960 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305961static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305962 struct extscan_bssid_hotlist_reset_params *photlist_reset)
5963{
5964 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
5965 wmi_buf_t wmi_buf;
5966 uint32_t len;
5967 uint8_t *buf_ptr;
5968 int hotlist_entries = 0;
5969
5970 len = sizeof(*cmd);
5971
5972 /* reset bssid hotlist with tlv set to 0 */
5973 len += WMI_TLV_HDR_SIZE;
5974 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
5975
5976 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5977 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305978 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5979 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305980 }
5981
5982 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5983 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
5984 buf_ptr;
5985 WMITLV_SET_HDR(&cmd->tlv_header,
5986 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
5987 WMITLV_GET_STRUCT_TLVLEN
5988 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
5989
5990 cmd->request_id = photlist_reset->request_id;
5991 cmd->vdev_id = photlist_reset->session_id;
5992 cmd->mode = 0;
5993
5994 buf_ptr += sizeof(*cmd);
5995 WMITLV_SET_HDR(buf_ptr,
5996 WMITLV_TAG_ARRAY_STRUC,
5997 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5998 buf_ptr += WMI_TLV_HDR_SIZE +
5999 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6000
6001 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6002 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306003 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306004 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306005 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306006 }
Govind Singhb53420c2016-03-09 14:32:57 +05306007 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306008}
6009
6010/**
6011 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6012 * @wmi_handle: wmi handle
6013 * @pstopcmd: stop scan command request params
6014 *
6015 * This function sends stop extscan request to fw.
6016 *
6017 * Return: CDF Status.
6018 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306019static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306020 struct extscan_stop_req_params *pstopcmd)
6021{
6022 wmi_extscan_stop_cmd_fixed_param *cmd;
6023 wmi_buf_t wmi_buf;
6024 uint32_t len;
6025 uint8_t *buf_ptr;
6026
6027 len = sizeof(*cmd);
6028 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6029 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306030 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6031 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306032 }
6033 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6034 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6035 WMITLV_SET_HDR(&cmd->tlv_header,
6036 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6037 WMITLV_GET_STRUCT_TLVLEN
6038 (wmi_extscan_stop_cmd_fixed_param));
6039
6040 cmd->request_id = pstopcmd->request_id;
6041 cmd->vdev_id = pstopcmd->session_id;
6042
6043 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6044 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306045 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306046 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306047 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306048 }
6049
Govind Singhb53420c2016-03-09 14:32:57 +05306050 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306051}
6052
6053/**
6054 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6055 * @wmi_handle: wmi handle
6056 * @pstart: scan command request params
6057 * @buf: event buffer
6058 * @buf_len: length of buffer
6059 *
6060 * This function fills individual elements of extscan request and
6061 * TLV for buckets, channel list.
6062 *
6063 * Return: CDF Status.
6064 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006065static
Govind Singhb53420c2016-03-09 14:32:57 +05306066QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306067 struct wifi_scan_cmd_req_params *pstart,
6068 wmi_buf_t *buf, int *buf_len)
6069{
6070 wmi_extscan_start_cmd_fixed_param *cmd;
6071 wmi_extscan_bucket *dest_blist;
6072 wmi_extscan_bucket_channel *dest_clist;
6073 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6074 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6075 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6076
6077 uint8_t *buf_ptr;
6078 int i, k, count = 0;
6079 int len = sizeof(*cmd);
6080 int nbuckets = pstart->numBuckets;
6081 int nchannels = 0;
6082
6083 /* These TLV's are are NULL by default */
6084 uint32_t ie_len_with_pad = 0;
6085 int num_ssid = 0;
6086 int num_bssid = 0;
6087 int ie_len = 0;
6088
6089 uint32_t base_period = pstart->basePeriod;
6090
6091 /* TLV placeholder for ssid_list (NULL) */
6092 len += WMI_TLV_HDR_SIZE;
6093 len += num_ssid * sizeof(wmi_ssid);
6094
6095 /* TLV placeholder for bssid_list (NULL) */
6096 len += WMI_TLV_HDR_SIZE;
6097 len += num_bssid * sizeof(wmi_mac_addr);
6098
6099 /* TLV placeholder for ie_data (NULL) */
6100 len += WMI_TLV_HDR_SIZE;
6101 len += ie_len * sizeof(uint32_t);
6102
6103 /* TLV placeholder for bucket */
6104 len += WMI_TLV_HDR_SIZE;
6105 len += nbuckets * sizeof(wmi_extscan_bucket);
6106
6107 /* TLV channel placeholder */
6108 len += WMI_TLV_HDR_SIZE;
6109 for (i = 0; i < nbuckets; i++) {
6110 nchannels += src_bucket->numChannels;
6111 src_bucket++;
6112 }
6113
Govind Singhb53420c2016-03-09 14:32:57 +05306114 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306115 __func__, nbuckets, nchannels);
6116 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6117 /* Allocate the memory */
6118 *buf = wmi_buf_alloc(wmi_handle, len);
6119 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306120 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306121 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306122 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306123 }
6124 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6125 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6126 WMITLV_SET_HDR(&cmd->tlv_header,
6127 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6128 WMITLV_GET_STRUCT_TLVLEN
6129 (wmi_extscan_start_cmd_fixed_param));
6130
6131 cmd->request_id = pstart->requestId;
6132 cmd->vdev_id = pstart->sessionId;
6133 cmd->base_period = pstart->basePeriod;
6134 cmd->num_buckets = nbuckets;
6135 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306136 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306137 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306138 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306139 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306140#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306141 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6142 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306143 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6144 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6145#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306146 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6147
6148 /* The max dwell time is retrieved from the first channel
6149 * of the first bucket and kept common for all channels.
6150 */
6151 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6152 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6153 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6154 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6155 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6156 cmd->max_table_usage = pstart->report_threshold_percent;
6157 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6158
6159 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306160 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306161 cmd->probe_delay = 0;
6162 cmd->probe_spacing_time = 0;
6163 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306164 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6165 WMI_SCAN_ADD_CCK_RATES |
6166 WMI_SCAN_ADD_OFDM_RATES |
6167 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6168 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306169 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6170 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306171 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306172 cmd->num_ssids = 0;
6173 cmd->num_bssid = 0;
6174 cmd->ie_len = 0;
6175 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6176 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6177
6178 buf_ptr += sizeof(*cmd);
6179 WMITLV_SET_HDR(buf_ptr,
6180 WMITLV_TAG_ARRAY_FIXED_STRUC,
6181 num_ssid * sizeof(wmi_ssid));
6182 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6183
6184 WMITLV_SET_HDR(buf_ptr,
6185 WMITLV_TAG_ARRAY_FIXED_STRUC,
6186 num_bssid * sizeof(wmi_mac_addr));
6187 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6188
6189 ie_len_with_pad = 0;
6190 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6191 ie_len_with_pad);
6192 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6193
6194 WMITLV_SET_HDR(buf_ptr,
6195 WMITLV_TAG_ARRAY_STRUC,
6196 nbuckets * sizeof(wmi_extscan_bucket));
6197 dest_blist = (wmi_extscan_bucket *)
6198 (buf_ptr + WMI_TLV_HDR_SIZE);
6199 src_bucket = pstart->buckets;
6200
6201 /* Retrieve scanning information from each bucket and
6202 * channels and send it to the target
6203 */
6204 for (i = 0; i < nbuckets; i++) {
6205 WMITLV_SET_HDR(dest_blist,
6206 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6207 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6208
6209 dest_blist->bucket_id = src_bucket->bucket;
6210 dest_blist->base_period_multiplier =
6211 src_bucket->period / base_period;
6212 dest_blist->min_period = src_bucket->period;
6213 dest_blist->max_period = src_bucket->max_period;
6214 dest_blist->exp_backoff = src_bucket->exponent;
6215 dest_blist->exp_max_step_count = src_bucket->step_count;
6216 dest_blist->channel_band = src_bucket->band;
6217 dest_blist->num_channels = src_bucket->numChannels;
6218 dest_blist->notify_extscan_events = 0;
6219
6220 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6221 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006222 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6223 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306224
6225 if (src_bucket->reportEvents &
6226 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6227 dest_blist->forwarding_flags =
6228 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6229 dest_blist->notify_extscan_events |=
6230 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6231 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6232 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6233 } else {
6234 dest_blist->forwarding_flags =
6235 WMI_EXTSCAN_NO_FORWARDING;
6236 }
6237
6238 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6239 dest_blist->configuration_flags = 0;
6240 else
6241 dest_blist->configuration_flags =
6242 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6243
Govind Singhb53420c2016-03-09 14:32:57 +05306244 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306245 __func__, dest_blist->notify_extscan_events,
6246 dest_blist->configuration_flags,
6247 dest_blist->forwarding_flags);
6248
6249 dest_blist->min_dwell_time_active =
6250 src_bucket->min_dwell_time_active;
6251 dest_blist->max_dwell_time_active =
6252 src_bucket->max_dwell_time_active;
6253 dest_blist->min_dwell_time_passive =
6254 src_bucket->min_dwell_time_passive;
6255 dest_blist->max_dwell_time_passive =
6256 src_bucket->max_dwell_time_passive;
6257 src_channel = src_bucket->channels;
6258
6259 /* save the channel info to later populate
6260 * the channel TLV
6261 */
6262 for (k = 0; k < src_bucket->numChannels; k++) {
6263 save_channel[count++].channel = src_channel->channel;
6264 src_channel++;
6265 }
6266 dest_blist++;
6267 src_bucket++;
6268 }
6269 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6270 WMITLV_SET_HDR(buf_ptr,
6271 WMITLV_TAG_ARRAY_STRUC,
6272 nchannels * sizeof(wmi_extscan_bucket_channel));
6273 dest_clist = (wmi_extscan_bucket_channel *)
6274 (buf_ptr + WMI_TLV_HDR_SIZE);
6275
6276 /* Active or passive scan is based on the bucket dwell time
6277 * and channel specific active,passive scans are not
6278 * supported yet
6279 */
6280 for (i = 0; i < nchannels; i++) {
6281 WMITLV_SET_HDR(dest_clist,
6282 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6283 WMITLV_GET_STRUCT_TLVLEN
6284 (wmi_extscan_bucket_channel));
6285 dest_clist->channel = save_channel[i].channel;
6286 dest_clist++;
6287 }
6288 buf_ptr += WMI_TLV_HDR_SIZE +
6289 (nchannels * sizeof(wmi_extscan_bucket_channel));
6290 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306291 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306292}
6293
6294/**
6295 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6296 * @wmi_handle: wmi handle
6297 * @pstart: scan command request params
6298 *
6299 * This function sends start extscan request to fw.
6300 *
6301 * Return: CDF Status.
6302 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306303static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306304 struct wifi_scan_cmd_req_params *pstart)
6305{
Govind Singhb53420c2016-03-09 14:32:57 +05306306 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306307 wmi_buf_t buf;
6308 int len;
6309
6310 /* Fill individual elements of extscan request and
6311 * TLV for buckets, channel list.
6312 */
Govind Singhb53420c2016-03-09 14:32:57 +05306313 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306314 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306315 if (qdf_status != QDF_STATUS_SUCCESS) {
6316 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6317 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306318 }
6319 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306320 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306321 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306322 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306323 }
6324 if (wmi_unified_cmd_send(wmi_handle, buf,
6325 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306326 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306327 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306328 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306329 }
6330
Govind Singhb53420c2016-03-09 14:32:57 +05306331 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306332}
6333
6334/**
6335 * send_plm_stop_cmd_tlv() - plm stop request
6336 * @wmi_handle: wmi handle
6337 * @plm: plm request parameters
6338 *
6339 * This function request FW to stop PLM.
6340 *
6341 * Return: CDF status
6342 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306343static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306344 const struct plm_req_params *plm)
6345{
6346 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6347 int32_t len;
6348 wmi_buf_t buf;
6349 uint8_t *buf_ptr;
6350 int ret;
6351
6352 len = sizeof(*cmd);
6353 buf = wmi_buf_alloc(wmi_handle, len);
6354 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306355 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6356 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306357 }
6358
6359 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6360
6361 buf_ptr = (uint8_t *) cmd;
6362
6363 WMITLV_SET_HDR(&cmd->tlv_header,
6364 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6365 WMITLV_GET_STRUCT_TLVLEN
6366 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6367
6368 cmd->vdev_id = plm->session_id;
6369
6370 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306371 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306372
6373 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6374 WMI_VDEV_PLMREQ_STOP_CMDID);
6375 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306376 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306377 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306378 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306379 }
6380
Govind Singhb53420c2016-03-09 14:32:57 +05306381 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306382}
6383
6384/**
6385 * send_plm_start_cmd_tlv() - plm start request
6386 * @wmi_handle: wmi handle
6387 * @plm: plm request parameters
6388 *
6389 * This function request FW to start PLM.
6390 *
6391 * Return: CDF status
6392 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306393static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306394 const struct plm_req_params *plm,
6395 uint32_t *gchannel_list)
6396{
6397 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6398 uint32_t *channel_list;
6399 int32_t len;
6400 wmi_buf_t buf;
6401 uint8_t *buf_ptr;
6402 uint8_t count;
6403 int ret;
6404
6405 /* TLV place holder for channel_list */
6406 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6407 len += sizeof(uint32_t) * plm->plm_num_ch;
6408
6409 buf = wmi_buf_alloc(wmi_handle, len);
6410 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306411 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6412 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306413 }
6414 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6415
6416 buf_ptr = (uint8_t *) cmd;
6417
6418 WMITLV_SET_HDR(&cmd->tlv_header,
6419 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6420 WMITLV_GET_STRUCT_TLVLEN
6421 (wmi_vdev_plmreq_start_cmd_fixed_param));
6422
6423 cmd->vdev_id = plm->session_id;
6424
6425 cmd->meas_token = plm->meas_token;
6426 cmd->dialog_token = plm->diag_token;
6427 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306428 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306429 cmd->off_duration = plm->meas_duration;
6430 cmd->burst_cycle = plm->burst_len;
6431 cmd->tx_power = plm->desired_tx_pwr;
6432 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6433 cmd->num_chans = plm->plm_num_ch;
6434
6435 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6436
Govind Singhb53420c2016-03-09 14:32:57 +05306437 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6438 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6439 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6440 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6441 WMI_LOGD("off_duration: %d", cmd->off_duration);
6442 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6443 WMI_LOGD("tx_power: %d", cmd->tx_power);
6444 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306445
6446 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6447 (cmd->num_chans * sizeof(uint32_t)));
6448
6449 buf_ptr += WMI_TLV_HDR_SIZE;
6450 if (cmd->num_chans) {
6451 channel_list = (uint32_t *) buf_ptr;
6452 for (count = 0; count < cmd->num_chans; count++) {
6453 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306454 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306455 channel_list[count] =
6456 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306457 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306458 }
6459 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6460 }
6461
6462 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6463 WMI_VDEV_PLMREQ_START_CMDID);
6464 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306465 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306466 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306467 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306468 }
6469
Govind Singhb53420c2016-03-09 14:32:57 +05306470 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306471}
6472
6473/**
6474 * send_pno_stop_cmd_tlv() - PNO stop request
6475 * @wmi_handle: wmi handle
6476 * @vdev_id: vdev id
6477 *
6478 * This function request FW to stop ongoing PNO operation.
6479 *
6480 * Return: CDF status
6481 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306482static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306483{
6484 wmi_nlo_config_cmd_fixed_param *cmd;
6485 int32_t len = sizeof(*cmd);
6486 wmi_buf_t buf;
6487 uint8_t *buf_ptr;
6488 int ret;
6489
6490 /*
6491 * TLV place holder for array of structures nlo_configured_parameters
6492 * TLV place holder for array of uint32_t channel_list
6493 * TLV place holder for chnl prediction cfg
6494 */
6495 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6496 buf = wmi_buf_alloc(wmi_handle, len);
6497 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306498 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6499 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306500 }
6501
6502 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6503 buf_ptr = (uint8_t *) cmd;
6504
6505 WMITLV_SET_HDR(&cmd->tlv_header,
6506 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6507 WMITLV_GET_STRUCT_TLVLEN
6508 (wmi_nlo_config_cmd_fixed_param));
6509
6510 cmd->vdev_id = vdev_id;
6511 cmd->flags = WMI_NLO_CONFIG_STOP;
6512 buf_ptr += sizeof(*cmd);
6513
6514 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6515 buf_ptr += WMI_TLV_HDR_SIZE;
6516
6517 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6518 buf_ptr += WMI_TLV_HDR_SIZE;
6519
6520 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6521 buf_ptr += WMI_TLV_HDR_SIZE;
6522
6523
6524 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6525 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6526 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306527 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306528 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306529 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306530 }
6531
Govind Singhb53420c2016-03-09 14:32:57 +05306532 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306533}
6534
6535/**
Govind Singhccb0c272016-04-01 16:30:08 +05306536 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6537 * @buf_ptr: Buffer passed by upper layers
6538 * @pno: Buffer to be sent to the firmware
6539 *
6540 * Copy the PNO Channel prediction configuration parameters
6541 * passed by the upper layers to a WMI format TLV and send it
6542 * down to the firmware.
6543 *
6544 * Return: None
6545 */
6546static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6547 struct pno_scan_req_params *pno)
6548{
6549 nlo_channel_prediction_cfg *channel_prediction_cfg =
6550 (nlo_channel_prediction_cfg *) buf_ptr;
6551 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6552 WMITLV_TAG_ARRAY_BYTE,
6553 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306554#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306555 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6556 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6557 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6558 channel_prediction_cfg->full_scan_period_ms =
6559 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306560#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306561 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6562 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6563 channel_prediction_cfg->enable,
6564 channel_prediction_cfg->top_k_num,
6565 channel_prediction_cfg->stationary_threshold,
6566 channel_prediction_cfg->full_scan_period_ms);
6567}
6568
6569/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306570 * send_pno_start_cmd_tlv() - PNO start request
6571 * @wmi_handle: wmi handle
6572 * @pno: PNO request
6573 *
6574 * This function request FW to start PNO request.
6575 * Request: CDF status
6576 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306577static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306578 struct pno_scan_req_params *pno,
6579 uint32_t *gchannel_freq_list)
6580{
6581 wmi_nlo_config_cmd_fixed_param *cmd;
6582 nlo_configured_parameters *nlo_list;
6583 uint32_t *channel_list;
6584 int32_t len;
6585 wmi_buf_t buf;
6586 uint8_t *buf_ptr;
6587 uint8_t i;
6588 int ret;
6589
6590 /*
6591 * TLV place holder for array nlo_configured_parameters(nlo_list)
6592 * TLV place holder for array of uint32_t channel_list
6593 * TLV place holder for chnnl prediction cfg
6594 */
6595 len = sizeof(*cmd) +
6596 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6597
Govind Singhb53420c2016-03-09 14:32:57 +05306598 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306599 WMI_NLO_MAX_CHAN);
6600 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306601 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306602 len += sizeof(nlo_channel_prediction_cfg);
6603
6604 buf = wmi_buf_alloc(wmi_handle, len);
6605 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306606 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6607 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306608 }
6609
6610 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6611
6612 buf_ptr = (uint8_t *) cmd;
6613 WMITLV_SET_HDR(&cmd->tlv_header,
6614 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6615 WMITLV_GET_STRUCT_TLVLEN
6616 (wmi_nlo_config_cmd_fixed_param));
6617 cmd->vdev_id = pno->sessionId;
6618 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6619
Govind Singh87542482016-06-08 19:40:11 +05306620#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306621 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6622 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306623#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306624 /* Current FW does not support min-max range for dwell time */
6625 cmd->active_dwell_time = pno->active_max_time;
6626 cmd->passive_dwell_time = pno->passive_max_time;
6627
6628 /* Copy scan interval */
6629 cmd->fast_scan_period = pno->fast_scan_period;
6630 cmd->slow_scan_period = pno->slow_scan_period;
6631 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306632 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306633 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306634 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306635
6636 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6637
Govind Singhb53420c2016-03-09 14:32:57 +05306638 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6639 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306640 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6641 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6642 buf_ptr += WMI_TLV_HDR_SIZE;
6643
6644 nlo_list = (nlo_configured_parameters *) buf_ptr;
6645 for (i = 0; i < cmd->no_of_ssids; i++) {
6646 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6647 WMITLV_TAG_ARRAY_BYTE,
6648 WMITLV_GET_STRUCT_TLVLEN
6649 (nlo_configured_parameters));
6650 /* Copy ssid and it's length */
6651 nlo_list[i].ssid.valid = true;
6652 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306653 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306654 pno->aNetworks[i].ssid.mac_ssid,
6655 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306656 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306657 nlo_list[i].ssid.ssid.ssid_len,
6658 (char *)nlo_list[i].ssid.ssid.ssid,
6659 nlo_list[i].ssid.ssid.ssid_len);
6660
6661 /* Copy rssi threshold */
6662 if (pno->aNetworks[i].rssiThreshold &&
6663 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6664 nlo_list[i].rssi_cond.valid = true;
6665 nlo_list[i].rssi_cond.rssi =
6666 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306667 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306668 nlo_list[i].rssi_cond.rssi);
6669 }
6670 nlo_list[i].bcast_nw_type.valid = true;
6671 nlo_list[i].bcast_nw_type.bcast_nw_type =
6672 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306673 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306674 nlo_list[i].bcast_nw_type.bcast_nw_type);
6675 }
6676 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6677
6678 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306679 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306680 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306681 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306682 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6683 (cmd->num_of_channels * sizeof(uint32_t)));
6684 buf_ptr += WMI_TLV_HDR_SIZE;
6685
6686 channel_list = (uint32_t *) buf_ptr;
6687 for (i = 0; i < cmd->num_of_channels; i++) {
6688 channel_list[i] = pno->aNetworks[0].aChannels[i];
6689
6690 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6691 channel_list[i] = gchannel_freq_list[i];
6692
Govind Singhb53420c2016-03-09 14:32:57 +05306693 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306694 }
6695 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6696 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6697 sizeof(nlo_channel_prediction_cfg));
6698 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306699 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306700 buf_ptr += WMI_TLV_HDR_SIZE;
6701 /** TODO: Discrete firmware doesn't have command/option to configure
6702 * App IE which comes from wpa_supplicant as of part PNO start request.
6703 */
6704 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6705 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6706 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306707 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306708 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306709 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306710 }
6711
Govind Singhb53420c2016-03-09 14:32:57 +05306712 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306713}
6714
6715/* send_set_ric_req_cmd_tlv() - set ric request element
6716 * @wmi_handle: wmi handle
6717 * @msg: message
6718 * @is_add_ts: is addts required
6719 *
6720 * This function sets ric request element for 11r roaming.
6721 *
6722 * Return: CDF status
6723 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306724static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306725 void *msg, uint8_t is_add_ts)
6726{
6727 wmi_ric_request_fixed_param *cmd;
6728 wmi_ric_tspec *tspec_param;
6729 wmi_buf_t buf;
6730 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306731 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306732 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6733 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6734
6735 buf = wmi_buf_alloc(wmi_handle, len);
6736 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306737 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6738 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306739 }
6740
6741 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6742
6743 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6744 WMITLV_SET_HDR(&cmd->tlv_header,
6745 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6746 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6747 if (is_add_ts)
6748 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
6749 else
6750 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
6751 cmd->num_ric_request = 1;
6752 cmd->is_add_ric = is_add_ts;
6753
6754 buf_ptr += sizeof(wmi_ric_request_fixed_param);
6755 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
6756
6757 buf_ptr += WMI_TLV_HDR_SIZE;
6758 tspec_param = (wmi_ric_tspec *) buf_ptr;
6759 WMITLV_SET_HDR(&tspec_param->tlv_header,
6760 WMITLV_TAG_STRUC_wmi_ric_tspec,
6761 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
6762
6763 if (is_add_ts)
6764 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05306765#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05306766 else
6767 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05306768#endif
6769 if (ptspecIE) {
6770 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05306771#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05306772 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
6773 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306774#else
Govind Singh87542482016-06-08 19:40:11 +05306775 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
6776 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306777#endif /* ANI_LITTLE_BIT_ENDIAN */
6778
Govind Singh87542482016-06-08 19:40:11 +05306779 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
6780 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
6781 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
6782 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
6783 tspec_param->inactivity_interval = ptspecIE->inactInterval;
6784 tspec_param->suspension_interval = ptspecIE->suspendInterval;
6785 tspec_param->svc_start_time = ptspecIE->svcStartTime;
6786 tspec_param->min_data_rate = ptspecIE->minDataRate;
6787 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
6788 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
6789 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
6790 tspec_param->delay_bound = ptspecIE->delayBound;
6791 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
6792 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
6793 tspec_param->medium_time = 0;
6794 }
Govind Singhb53420c2016-03-09 14:32:57 +05306795 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306796
6797 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6798 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306799 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306800 __func__);
6801 if (is_add_ts)
6802 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05306803 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05306804 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306805 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306806 }
6807
Govind Singhb53420c2016-03-09 14:32:57 +05306808 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306809}
6810
6811/**
6812 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
6813 * @wmi_handle: wmi handle
6814 * @clear_req: ll stats clear request command params
6815 *
Govind Singhb53420c2016-03-09 14:32:57 +05306816 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306817 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306818static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306819 const struct ll_stats_clear_params *clear_req,
6820 uint8_t addr[IEEE80211_ADDR_LEN])
6821{
6822 wmi_clear_link_stats_cmd_fixed_param *cmd;
6823 int32_t len;
6824 wmi_buf_t buf;
6825 uint8_t *buf_ptr;
6826 int ret;
6827
6828 len = sizeof(*cmd);
6829 buf = wmi_buf_alloc(wmi_handle, len);
6830
6831 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306832 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6833 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306834 }
6835
6836 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306837 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306838 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
6839
6840 WMITLV_SET_HDR(&cmd->tlv_header,
6841 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
6842 WMITLV_GET_STRUCT_TLVLEN
6843 (wmi_clear_link_stats_cmd_fixed_param));
6844
6845 cmd->stop_stats_collection_req = clear_req->stop_req;
6846 cmd->vdev_id = clear_req->sta_id;
6847 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
6848
6849 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6850 &cmd->peer_macaddr);
6851
Govind Singhb53420c2016-03-09 14:32:57 +05306852 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
6853 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
6854 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
6855 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
6856 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306857 cmd->peer_macaddr); */
6858
6859 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6860 WMI_CLEAR_LINK_STATS_CMDID);
6861 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306862 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306863 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306864 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306865 }
6866
Govind Singhb53420c2016-03-09 14:32:57 +05306867 WMI_LOGD("Clear Link Layer Stats request sent successfully");
6868 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306869}
6870
6871/**
6872 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
6873 * @wmi_handle: wmi handle
6874 * @setReq: ll stats set request command params
6875 *
Govind Singhb53420c2016-03-09 14:32:57 +05306876 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306877 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306878static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306879 const struct ll_stats_set_params *set_req)
6880{
6881 wmi_start_link_stats_cmd_fixed_param *cmd;
6882 int32_t len;
6883 wmi_buf_t buf;
6884 uint8_t *buf_ptr;
6885 int ret;
6886
6887 len = sizeof(*cmd);
6888 buf = wmi_buf_alloc(wmi_handle, len);
6889
6890 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306891 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6892 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306893 }
6894
6895 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306896 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306897 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
6898
6899 WMITLV_SET_HDR(&cmd->tlv_header,
6900 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
6901 WMITLV_GET_STRUCT_TLVLEN
6902 (wmi_start_link_stats_cmd_fixed_param));
6903
6904 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
6905 cmd->aggressive_statistics_gathering =
6906 set_req->aggressive_statistics_gathering;
6907
Govind Singhb53420c2016-03-09 14:32:57 +05306908 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
6909 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
6910 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306911
6912 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6913 WMI_START_LINK_STATS_CMDID);
6914 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306915 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306916 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306917 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306918 }
6919
Govind Singhb53420c2016-03-09 14:32:57 +05306920 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306921}
6922
6923/**
6924 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
6925 * @wmi_handle:wmi handle
6926 * @get_req:ll stats get request command params
6927 * @addr: mac address
6928 *
Govind Singhb53420c2016-03-09 14:32:57 +05306929 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306930 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306931static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306932 const struct ll_stats_get_params *get_req,
6933 uint8_t addr[IEEE80211_ADDR_LEN])
6934{
6935 wmi_request_link_stats_cmd_fixed_param *cmd;
6936 int32_t len;
6937 wmi_buf_t buf;
6938 uint8_t *buf_ptr;
6939 int ret;
6940
6941 len = sizeof(*cmd);
6942 buf = wmi_buf_alloc(wmi_handle, len);
6943
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05306944 if (!buf) {
6945 WMI_LOGE("%s: buf allocation failed", __func__);
6946 return QDF_STATUS_E_NOMEM;
6947 }
6948
Govind Singh4eacd2b2016-03-07 14:24:22 +05306949 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306950 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306951 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
6952
6953 WMITLV_SET_HDR(&cmd->tlv_header,
6954 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
6955 WMITLV_GET_STRUCT_TLVLEN
6956 (wmi_request_link_stats_cmd_fixed_param));
6957
6958 cmd->request_id = get_req->req_id;
6959 cmd->stats_type = get_req->param_id_mask;
6960 cmd->vdev_id = get_req->sta_id;
6961
6962 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6963 &cmd->peer_macaddr);
6964
Govind Singhb53420c2016-03-09 14:32:57 +05306965 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
6966 WMI_LOGD("Request ID : %d", cmd->request_id);
6967 WMI_LOGD("Stats Type : %d", cmd->stats_type);
6968 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
6969 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306970
6971 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6972 WMI_REQUEST_LINK_STATS_CMDID);
6973 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306974 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306975 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306976 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306977 }
6978
Govind Singhb53420c2016-03-09 14:32:57 +05306979 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306980}
6981
6982/**
6983 * send_get_stats_cmd_tlv() - get stats request
6984 * @wmi_handle: wmi handle
6985 * @get_stats_param: stats params
6986 * @addr: mac address
6987 *
6988 * Return: CDF status
6989 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306990static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306991 struct pe_stats_req *get_stats_param,
6992 uint8_t addr[IEEE80211_ADDR_LEN])
6993{
6994 wmi_buf_t buf;
6995 wmi_request_stats_cmd_fixed_param *cmd;
6996 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6997
6998 buf = wmi_buf_alloc(wmi_handle, len);
6999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307000 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7001 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307002 }
7003
7004
7005 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7006 WMITLV_SET_HDR(&cmd->tlv_header,
7007 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7008 WMITLV_GET_STRUCT_TLVLEN
7009 (wmi_request_stats_cmd_fixed_param));
7010 cmd->stats_id =
7011 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05307012 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307013 cmd->vdev_id = get_stats_param->session_id;
7014 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307015 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307016 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7017 WMI_REQUEST_STATS_CMDID)) {
7018
Govind Singhb53420c2016-03-09 14:32:57 +05307019 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307020 __func__);
7021 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307022 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307023 }
7024
Govind Singhb53420c2016-03-09 14:32:57 +05307025 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307026
7027}
7028
Govind Singh20c5dac2016-03-07 15:33:31 +05307029/**
7030 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7031 * @wmi_handle: wmi handle
7032 * @rssi_req: get RSSI request
7033 *
7034 * Return: CDF status
7035 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307036static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307037{
7038 wmi_buf_t buf;
7039 wmi_request_stats_cmd_fixed_param *cmd;
7040 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7041
7042 buf = wmi_buf_alloc(wmi_handle, len);
7043 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307044 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7045 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307046 }
7047
7048 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7049 WMITLV_SET_HDR(&cmd->tlv_header,
7050 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7051 WMITLV_GET_STRUCT_TLVLEN
7052 (wmi_request_stats_cmd_fixed_param));
7053 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7054 if (wmi_unified_cmd_send
7055 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307056 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307057 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307058 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307059 }
7060
Govind Singhb53420c2016-03-09 14:32:57 +05307061 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307062}
7063
7064/**
7065 * send_snr_cmd_tlv() - get RSSI from fw
7066 * @wmi_handle: wmi handle
7067 * @vdev_id: vdev id
7068 *
7069 * Return: CDF status
7070 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307071static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307072{
7073 wmi_buf_t buf;
7074 wmi_request_stats_cmd_fixed_param *cmd;
7075 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7076
7077 buf = wmi_buf_alloc(wmi_handle, len);
7078 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307079 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7080 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307081 }
7082
7083 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7084 cmd->vdev_id = vdev_id;
7085
7086 WMITLV_SET_HDR(&cmd->tlv_header,
7087 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7088 WMITLV_GET_STRUCT_TLVLEN
7089 (wmi_request_stats_cmd_fixed_param));
7090 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7091 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7092 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307093 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307094 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307095 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307096 }
7097
Govind Singhb53420c2016-03-09 14:32:57 +05307098 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307099}
7100
7101/**
7102 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7103 * @wmi_handle: wmi handle
7104 * @link_status: get link params
7105 *
7106 * Return: CDF status
7107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307108static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307109 struct link_status_params *link_status)
7110{
7111 wmi_buf_t buf;
7112 wmi_request_stats_cmd_fixed_param *cmd;
7113 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7114
7115 buf = wmi_buf_alloc(wmi_handle, len);
7116 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307117 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7118 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307119 }
7120
7121 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7122 WMITLV_SET_HDR(&cmd->tlv_header,
7123 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7124 WMITLV_GET_STRUCT_TLVLEN
7125 (wmi_request_stats_cmd_fixed_param));
7126 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7127 cmd->vdev_id = link_status->session_id;
7128 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7129 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307130 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307131 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307132 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307133 }
7134
Govind Singhb53420c2016-03-09 14:32:57 +05307135 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307136}
7137
Govind Singh20c5dac2016-03-07 15:33:31 +05307138/**
7139 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7140 * @wmi_handle: wmi handle
7141 * @ta_dhcp_ind: DHCP indication parameter
7142 *
7143 * Return: CDF Status
7144 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307145static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307146 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7147{
Govind Singh67922e82016-04-01 16:48:57 +05307148 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307149 wmi_buf_t buf = NULL;
7150 uint8_t *buf_ptr;
7151 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7152 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7153
7154
7155 buf = wmi_buf_alloc(wmi_handle, len);
7156 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307157 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7158 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307159 }
7160
7161 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7162 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7163 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7164 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7165 WMITLV_GET_STRUCT_TLVLEN
7166 (wmi_peer_set_param_cmd_fixed_param));
7167
7168 /* fill in values */
7169 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7170 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7171 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307172 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307173 &ta_dhcp_ind->peer_macaddr,
7174 sizeof(ta_dhcp_ind->peer_macaddr));
7175
7176 status = wmi_unified_cmd_send(wmi_handle, buf,
7177 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307178 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307179 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307180 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307181 wmi_buf_free(buf);
7182 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307183
Govind Singh67922e82016-04-01 16:48:57 +05307184 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307185}
7186
7187/**
7188 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7189 * @wmi_handle: wmi handle
7190 * @pLinkSpeed: link speed info
7191 *
7192 * Return: CDF status
7193 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307194static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307195 wmi_mac_addr peer_macaddr)
7196{
7197 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7198 wmi_buf_t wmi_buf;
7199 uint32_t len;
7200 uint8_t *buf_ptr;
7201
7202 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7203 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7204 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307205 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7206 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307207 }
7208 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7209
7210 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7211 WMITLV_SET_HDR(&cmd->tlv_header,
7212 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7213 WMITLV_GET_STRUCT_TLVLEN
7214 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7215
7216 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307217 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307218 &peer_macaddr,
7219 sizeof(peer_macaddr));
7220
7221
7222 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7223 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307224 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307225 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307226 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307227 }
Govind Singhb53420c2016-03-09 14:32:57 +05307228 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307229}
7230
7231/**
7232 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7233 * @wmi_handle: wmi handler
7234 * @egap_params: pointer to egap_params
7235 *
7236 * Return: 0 for success, otherwise appropriate error code
7237 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307238static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307239 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7240{
7241 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7242 wmi_buf_t buf;
7243 int32_t err;
7244
7245 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7246 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307247 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7248 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307249 }
7250 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7251 WMITLV_SET_HDR(&cmd->tlv_header,
7252 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7253 WMITLV_GET_STRUCT_TLVLEN(
7254 wmi_ap_ps_egap_param_cmd_fixed_param));
7255
7256 cmd->enable = egap_params->enable;
7257 cmd->inactivity_time = egap_params->inactivity_time;
7258 cmd->wait_time = egap_params->wait_time;
7259 cmd->flags = egap_params->flags;
7260 err = wmi_unified_cmd_send(wmi_handle, buf,
7261 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7262 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307263 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307264 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307265 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307266 }
7267
Govind Singhb53420c2016-03-09 14:32:57 +05307268 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307269}
7270
7271/**
7272 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7273 * @wmi_handl: wmi handle
7274 * @cmd: Profiling command index
7275 * @value1: parameter1 value
7276 * @value2: parameter2 value
7277 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307278 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307279 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307280static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307281 uint32_t cmd, uint32_t value1, uint32_t value2)
7282{
7283 wmi_buf_t buf;
7284 int32_t len = 0;
7285 int ret;
7286 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7287 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7288 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7289 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7290
7291 switch (cmd) {
7292 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7293 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7294 buf = wmi_buf_alloc(wmi_handle, len);
7295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307296 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307297 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307298 }
7299 prof_trig_cmd =
7300 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7301 wmi_buf_data(buf);
7302 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7303 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7304 WMITLV_GET_STRUCT_TLVLEN
7305 (wmi_wlan_profile_trigger_cmd_fixed_param));
7306 prof_trig_cmd->enable = value1;
7307 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7308 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7309 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307310 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307311 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307312 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307313 return ret;
7314 }
7315 break;
7316
7317 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7318 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7319 buf = wmi_buf_alloc(wmi_handle, len);
7320 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307321 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307322 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307323 }
7324 profile_getdata_cmd =
7325 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7326 wmi_buf_data(buf);
7327 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7328 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7329 WMITLV_GET_STRUCT_TLVLEN
7330 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7331 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7332 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7333 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307334 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307335 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307336 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307337 return ret;
7338 }
7339 break;
7340
7341 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7342 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7343 buf = wmi_buf_alloc(wmi_handle, len);
7344 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307345 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307346 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307347 }
7348 hist_intvl_cmd =
7349 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7350 wmi_buf_data(buf);
7351 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7352 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7353 WMITLV_GET_STRUCT_TLVLEN
7354 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7355 hist_intvl_cmd->profile_id = value1;
7356 hist_intvl_cmd->value = value2;
7357 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7358 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7359 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307360 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307361 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307362 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307363 return ret;
7364 }
7365 break;
7366
7367 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7368 len =
7369 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7370 buf = wmi_buf_alloc(wmi_handle, len);
7371 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307372 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307373 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307374 }
7375 profile_enable_cmd =
7376 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7377 wmi_buf_data(buf);
7378 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7379 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7380 WMITLV_GET_STRUCT_TLVLEN
7381 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7382 profile_enable_cmd->profile_id = value1;
7383 profile_enable_cmd->enable = value2;
7384 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7385 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7386 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307387 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307388 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307389 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307390 return ret;
7391 }
7392 break;
7393
7394 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307395 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307396 break;
7397 }
7398
7399 return 0;
7400}
7401
Govind Singh20c5dac2016-03-07 15:33:31 +05307402/**
7403 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7404 * @wmi_handle: wmi handle
7405 * @vdev_id: vdev id
7406 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307407 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307408 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307409static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307410{
7411 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7412 wmi_buf_t buf;
7413 int32_t len = sizeof(*cmd);
7414
Govind Singhb53420c2016-03-09 14:32:57 +05307415 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307416 buf = wmi_buf_alloc(wmi_handle, len);
7417 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307418 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307419 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307420 }
7421 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7422 wmi_buf_data(buf);
7423 WMITLV_SET_HDR(&cmd->tlv_header,
7424 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7425 WMITLV_GET_STRUCT_TLVLEN
7426 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7427 cmd->vdev_id = vdev_id;
7428 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7429 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7430 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307431 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307432 __func__);
7433 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307434 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307435 }
7436
7437 return 0;
7438}
7439
7440/**
7441 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7442 * @wmi_handle: wmi handle
7443 * @vdev_id: vdev id
7444 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307445 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307446 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307447static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307448 uint8_t vdev_id)
7449{
7450 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7451 wmi_buf_t buf;
7452 int32_t len = sizeof(*cmd);
7453
Govind Singhb53420c2016-03-09 14:32:57 +05307454 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307455 buf = wmi_buf_alloc(wmi_handle, len);
7456 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307457 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307458 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307459 }
7460 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7461 WMITLV_SET_HDR(&cmd->tlv_header,
7462 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7463 WMITLV_GET_STRUCT_TLVLEN
7464 (wmi_csa_offload_enable_cmd_fixed_param));
7465 cmd->vdev_id = vdev_id;
7466 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7467 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7468 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307469 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307470 __func__);
7471 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307472 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307473 }
7474
7475 return 0;
7476}
7477
7478/**
7479 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7480 * @wmi_handle: wmi handle
7481 * @startOemDataReq: start request params
7482 *
7483 * Return: CDF status
7484 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307485static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007486 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307487 uint8_t *data)
7488{
7489 wmi_buf_t buf;
7490 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307491 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307492
7493 buf = wmi_buf_alloc(wmi_handle,
7494 (data_len + WMI_TLV_HDR_SIZE));
7495 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307496 WMI_LOGE(FL("wmi_buf_alloc failed"));
7497 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307498 }
7499
7500 cmd = (uint8_t *) wmi_buf_data(buf);
7501
7502 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7503 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307504 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307505 data_len);
7506
Govind Singhb53420c2016-03-09 14:32:57 +05307507 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307508 data_len);
7509
7510 ret = wmi_unified_cmd_send(wmi_handle, buf,
7511 (data_len +
7512 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7513
Govind Singh67922e82016-04-01 16:48:57 +05307514 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307515 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307516 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307517 }
7518
Govind Singh67922e82016-04-01 16:48:57 +05307519 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307520}
7521
7522/**
7523 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7524 * @wmi_handle: wmi handle
7525 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7526 *
7527 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7528 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7529 * to firmware based on phyerr filtering
7530 * offload status.
7531 *
7532 * Return: 1 success, 0 failure
7533 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307534static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307535send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7536 bool dfs_phyerr_filter_offload)
7537{
7538 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7539 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7540 wmi_buf_t buf;
7541 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307542 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307543
7544
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007545 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307546 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307547 __func__);
7548 len = sizeof(*disable_phyerr_offload_cmd);
7549 buf = wmi_buf_alloc(wmi_handle, len);
7550 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307551 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307552 return 0;
7553 }
7554 disable_phyerr_offload_cmd =
7555 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7556 wmi_buf_data(buf);
7557
7558 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7559 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7560 WMITLV_GET_STRUCT_TLVLEN
7561 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7562
7563 /*
7564 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7565 * to the firmware to disable the phyerror
7566 * filtering offload.
7567 */
7568 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7569 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307570 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307571 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307572 __func__, ret);
7573 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307574 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307575 }
Govind Singhb53420c2016-03-09 14:32:57 +05307576 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307577 __func__);
7578 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307579 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307580 __func__);
7581
7582 len = sizeof(*enable_phyerr_offload_cmd);
7583 buf = wmi_buf_alloc(wmi_handle, len);
7584 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307585 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7586 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307587 }
7588
7589 enable_phyerr_offload_cmd =
7590 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7591 wmi_buf_data(buf);
7592
7593 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7594 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7595 WMITLV_GET_STRUCT_TLVLEN
7596 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7597
7598 /*
7599 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7600 * to the firmware to enable the phyerror
7601 * filtering offload.
7602 */
7603 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7604 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7605
Govind Singh67922e82016-04-01 16:48:57 +05307606 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307607 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307608 __func__, ret);
7609 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307610 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307611 }
Govind Singhb53420c2016-03-09 14:32:57 +05307612 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307613 __func__);
7614 }
7615
Govind Singhb53420c2016-03-09 14:32:57 +05307616 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307617}
7618
7619#if !defined(REMOVE_PKT_LOG)
7620/**
7621 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7622 * @wmi_handle: wmi handle
7623 * @pktlog_event: pktlog event
7624 * @cmd_id: pktlog cmd id
7625 *
7626 * Return: CDF status
7627 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307628static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307629 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307630 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307631{
7632 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7633 WMI_CMD_ID CMD_ID;
7634 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7635 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7636 int len = 0;
7637 wmi_buf_t buf;
7638
7639 PKTLOG_EVENT = pktlog_event;
7640 CMD_ID = cmd_id;
7641
7642 switch (CMD_ID) {
7643 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7644 len = sizeof(*cmd);
7645 buf = wmi_buf_alloc(wmi_handle, len);
7646 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307647 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7648 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307649 }
7650 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7651 wmi_buf_data(buf);
7652 WMITLV_SET_HDR(&cmd->tlv_header,
7653 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7654 WMITLV_GET_STRUCT_TLVLEN
7655 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7656 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307657 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7658 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007659 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307660 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7661 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307662 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307663 goto wmi_send_failed;
7664 }
7665 break;
7666 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7667 len = sizeof(*disable_cmd);
7668 buf = wmi_buf_alloc(wmi_handle, len);
7669 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307670 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7671 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307672 }
7673 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7674 wmi_buf_data(buf);
7675 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7676 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7677 WMITLV_GET_STRUCT_TLVLEN
7678 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007679 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307680 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7681 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307682 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307683 goto wmi_send_failed;
7684 }
7685 break;
7686 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307687 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307688 break;
7689 }
7690
Govind Singhb53420c2016-03-09 14:32:57 +05307691 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307692
7693wmi_send_failed:
7694 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307695 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307696}
7697#endif /* REMOVE_PKT_LOG */
7698
7699/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307700 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
7701 * @wmi_handle: wmi handle
7702 * @ptrn_id: pattern id
7703 * @vdev_id: vdev id
7704 *
7705 * Return: CDF status
7706 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05307707static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
7708 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307709{
7710 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
7711 wmi_buf_t buf;
7712 int32_t len;
7713 int ret;
7714
7715 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
7716
7717
7718 buf = wmi_buf_alloc(wmi_handle, len);
7719 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307720 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7721 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307722 }
7723
7724 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7725
7726 WMITLV_SET_HDR(&cmd->tlv_header,
7727 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
7728 WMITLV_GET_STRUCT_TLVLEN(
7729 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
7730 cmd->vdev_id = vdev_id;
7731 cmd->pattern_id = ptrn_id;
7732 cmd->pattern_type = WOW_BITMAP_PATTERN;
7733
Govind Singhb53420c2016-03-09 14:32:57 +05307734 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05307735 cmd->pattern_id, vdev_id);
7736
7737 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7738 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
7739 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307740 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307741 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307742 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307743 }
7744
Govind Singhb53420c2016-03-09 14:32:57 +05307745 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307746}
7747
7748/**
7749 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
7750 * @wmi_handle: wmi handle
7751 *
7752 * Sends host wakeup indication to FW. On receiving this indication,
7753 * FW will come out of WOW.
7754 *
7755 * Return: CDF status
7756 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307757static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307758{
7759 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
7760 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05307761 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307762 int32_t len;
7763 int ret;
7764
7765 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
7766
7767 buf = wmi_buf_alloc(wmi_handle, len);
7768 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307769 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7770 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307771 }
7772
7773 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
7774 wmi_buf_data(buf);
7775 WMITLV_SET_HDR(&cmd->tlv_header,
7776 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
7777 WMITLV_GET_STRUCT_TLVLEN
7778 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
7779
7780
7781 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7782 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
7783 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307784 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307785 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307786 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307787 }
7788
Govind Singhb53420c2016-03-09 14:32:57 +05307789 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307790}
7791
7792/**
7793 * send_del_ts_cmd_tlv() - send DELTS request to fw
7794 * @wmi_handle: wmi handle
7795 * @msg: delts params
7796 *
7797 * Return: CDF status
7798 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307799static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307800 uint8_t ac)
7801{
7802 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
7803 wmi_buf_t buf;
7804 int32_t len = sizeof(*cmd);
7805
7806 buf = wmi_buf_alloc(wmi_handle, len);
7807 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307808 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7809 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307810 }
7811 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
7812 WMITLV_SET_HDR(&cmd->tlv_header,
7813 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
7814 WMITLV_GET_STRUCT_TLVLEN
7815 (wmi_vdev_wmm_delts_cmd_fixed_param));
7816 cmd->vdev_id = vdev_id;
7817 cmd->ac = ac;
7818
Govind Singhb53420c2016-03-09 14:32:57 +05307819 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307820 cmd->vdev_id, cmd->ac, __func__, __LINE__);
7821 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7822 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307823 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307824 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307825 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307826 }
7827
Govind Singhb53420c2016-03-09 14:32:57 +05307828 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307829}
7830
7831/**
7832 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
7833 * @wmi_handle: handle to wmi
7834 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
7835 *
Govind Singhb53420c2016-03-09 14:32:57 +05307836 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05307837 * ADD_TS requestes to firmware in loop for all the ACs with
7838 * active flow.
7839 *
7840 * Return: CDF status
7841 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307842static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307843 struct aggr_add_ts_param *aggr_qos_rsp_msg)
7844{
7845 int i = 0;
7846 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
7847 wmi_buf_t buf;
7848 int32_t len = sizeof(*cmd);
7849
7850 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
7851 /* if flow in this AC is active */
7852 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
7853 /*
7854 * as per implementation of wma_add_ts_req() we
7855 * are not waiting any response from firmware so
7856 * apart from sending ADDTS to firmware just send
7857 * success to upper layers
7858 */
Govind Singhb53420c2016-03-09 14:32:57 +05307859 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307860
7861 buf = wmi_buf_alloc(wmi_handle, len);
7862 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307863 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7864 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307865 }
7866 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
7867 wmi_buf_data(buf);
7868 WMITLV_SET_HDR(&cmd->tlv_header,
7869 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
7870 WMITLV_GET_STRUCT_TLVLEN
7871 (wmi_vdev_wmm_addts_cmd_fixed_param));
7872 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
7873 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05307874 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05307875 traffic.userPrio);
7876 cmd->medium_time_us =
7877 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
7878 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05307879 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307880 __func__, __LINE__, cmd->vdev_id, cmd->ac,
7881 cmd->medium_time_us, cmd->downgrade_type);
7882 if (wmi_unified_cmd_send
7883 (wmi_handle, buf, len,
7884 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307885 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307886 __func__);
7887 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05307888 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307889 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307890 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307891 }
7892 }
7893 }
7894
Govind Singhb53420c2016-03-09 14:32:57 +05307895 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307896}
7897
7898/**
7899 * send_add_ts_cmd_tlv() - send ADDTS request to fw
7900 * @wmi_handle: wmi handle
7901 * @msg: ADDTS params
7902 *
7903 * Return: CDF status
7904 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307905static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307906 struct add_ts_param *msg)
7907{
7908 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
7909 wmi_buf_t buf;
7910 int32_t len = sizeof(*cmd);
7911
Govind Singhb53420c2016-03-09 14:32:57 +05307912 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307913
7914 buf = wmi_buf_alloc(wmi_handle, len);
7915 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307916 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7917 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307918 }
7919 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
7920 WMITLV_SET_HDR(&cmd->tlv_header,
7921 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
7922 WMITLV_GET_STRUCT_TLVLEN
7923 (wmi_vdev_wmm_addts_cmd_fixed_param));
7924 cmd->vdev_id = msg->sme_session_id;
7925 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
7926 cmd->medium_time_us = msg->tspec.mediumTime * 32;
7927 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05307928 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307929 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
7930 cmd->downgrade_type, __func__, __LINE__);
7931 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7932 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307933 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
7934 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307935 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307936 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307937 }
7938
Govind Singhb53420c2016-03-09 14:32:57 +05307939 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307940}
7941
7942/**
7943 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
7944 * @wmi_handle: wmi handle
7945 * @vdev_id: vdev id
7946 * @enable: Flag to enable/disable packet filter
7947 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307948 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307949 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307950static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307951 uint8_t vdev_id, bool enable)
7952{
7953 int32_t len;
7954 int ret = 0;
7955 wmi_buf_t buf;
7956 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
7957
7958 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
7959
7960 buf = wmi_buf_alloc(wmi_handle, len);
7961 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307962 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307963 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307964 }
7965
7966 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
7967 WMITLV_SET_HDR(&cmd->tlv_header,
7968 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
7969 WMITLV_GET_STRUCT_TLVLEN(
7970 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
7971
7972 cmd->vdev_id = vdev_id;
7973 if (enable)
7974 cmd->enable = PACKET_FILTER_SET_ENABLE;
7975 else
7976 cmd->enable = PACKET_FILTER_SET_DISABLE;
7977
Govind Singhb53420c2016-03-09 14:32:57 +05307978 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307979 __func__, cmd->enable, vdev_id);
7980
7981 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7982 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307983 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307984 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05307985 wmi_buf_free(buf);
7986 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307987
7988 return ret;
7989}
7990
7991/**
7992 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
7993 * @wmi_handle: wmi handle
7994 * @vdev_id: vdev id
7995 * @rcv_filter_param: Packet filter parameters
7996 * @filter_id: Filter id
7997 * @enable: Flag to add/delete packet filter configuration
7998 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307999 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308000 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308001static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308002 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8003 uint8_t filter_id, bool enable)
8004{
8005 int len, i;
8006 int err = 0;
8007 wmi_buf_t buf;
8008 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8009
8010
8011 /* allocate the memory */
8012 len = sizeof(*cmd);
8013 buf = wmi_buf_alloc(wmi_handle, len);
8014 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308015 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308016 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308017 }
8018
8019 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8020 WMITLV_SET_HDR(&cmd->tlv_header,
8021 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8022 WMITLV_GET_STRUCT_TLVLEN
8023 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8024
8025 cmd->vdev_id = vdev_id;
8026 cmd->filter_id = filter_id;
8027 if (enable)
8028 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8029 else
8030 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8031
8032 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308033 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308034 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8035 rcv_filter_param->numFieldParams);
8036 cmd->filter_type = rcv_filter_param->filterType;
8037 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8038
8039 for (i = 0; i < cmd->num_params; i++) {
8040 cmd->paramsData[i].proto_type =
8041 rcv_filter_param->paramsData[i].protocolLayer;
8042 cmd->paramsData[i].cmp_type =
8043 rcv_filter_param->paramsData[i].cmpFlag;
8044 cmd->paramsData[i].data_length =
8045 rcv_filter_param->paramsData[i].dataLength;
8046 cmd->paramsData[i].data_offset =
8047 rcv_filter_param->paramsData[i].dataOffset;
8048 memcpy(&cmd->paramsData[i].compareData,
8049 rcv_filter_param->paramsData[i].compareData,
8050 sizeof(cmd->paramsData[i].compareData));
8051 memcpy(&cmd->paramsData[i].dataMask,
8052 rcv_filter_param->paramsData[i].dataMask,
8053 sizeof(cmd->paramsData[i].dataMask));
8054 }
8055 }
8056
Govind Singhb53420c2016-03-09 14:32:57 +05308057 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308058 cmd->filter_action, cmd->filter_id, cmd->num_params);
8059 /* send the command along with data */
8060 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8061 WMI_PACKET_FILTER_CONFIG_CMDID);
8062 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308063 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308064 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308065 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308066 }
8067
8068
8069 return 0;
8070}
8071
8072/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308073 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8074 * @wmi_handle: wmi handle
8075 * @pAddPeriodicTxPtrnParams: tx ptrn params
8076 *
8077 * Retrun: CDF status
8078 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308079static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308080 struct periodic_tx_pattern *
8081 pAddPeriodicTxPtrnParams,
8082 uint8_t vdev_id)
8083{
8084 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8085 wmi_buf_t wmi_buf;
8086 uint32_t len;
8087 uint8_t *buf_ptr;
8088 uint32_t ptrn_len, ptrn_len_aligned;
8089 int j;
8090
8091 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8092 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8093 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8094 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8095
8096 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8097 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308098 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8099 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308100 }
8101
8102 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8103
8104 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8105 WMITLV_SET_HDR(&cmd->tlv_header,
8106 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8107 WMITLV_GET_STRUCT_TLVLEN
8108 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8109
8110 /* Pass the pattern id to delete for the corresponding vdev id */
8111 cmd->vdev_id = vdev_id;
8112 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8113 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8114 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8115
8116 /* Pattern info */
8117 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8118 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8119 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308120 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308121 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308122 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308123
Govind Singhb53420c2016-03-09 14:32:57 +05308124 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308125 __func__, cmd->pattern_id, cmd->vdev_id);
8126
8127 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8128 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308129 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308130 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308131 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308132 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308133 }
Govind Singhb53420c2016-03-09 14:32:57 +05308134 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308135}
8136
8137/**
8138 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8139 * @wmi_handle: wmi handle
8140 * @vdev_id: vdev id
8141 * @pattern_id: pattern id
8142 *
8143 * Retrun: CDF status
8144 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308145static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308146 uint8_t vdev_id,
8147 uint8_t pattern_id)
8148{
8149 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8150 wmi_buf_t wmi_buf;
8151 uint32_t len =
8152 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8153
8154 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8155 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308156 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8157 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308158 }
8159
8160 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8161 wmi_buf_data(wmi_buf);
8162 WMITLV_SET_HDR(&cmd->tlv_header,
8163 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8164 WMITLV_GET_STRUCT_TLVLEN
8165 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8166
8167 /* Pass the pattern id to delete for the corresponding vdev id */
8168 cmd->vdev_id = vdev_id;
8169 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308170 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308171 __func__, cmd->pattern_id, cmd->vdev_id);
8172
8173 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8174 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308175 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308176 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308177 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308178 }
Govind Singhb53420c2016-03-09 14:32:57 +05308179 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308180}
8181
8182/**
8183 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8184 * @wmi_handle: wmi handle
8185 * @preq: stats ext params
8186 *
8187 * Return: CDF status
8188 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308189static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308190 struct stats_ext_params *preq)
8191{
Govind Singh67922e82016-04-01 16:48:57 +05308192 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308193 wmi_req_stats_ext_cmd_fixed_param *cmd;
8194 wmi_buf_t buf;
8195 uint16_t len;
8196 uint8_t *buf_ptr;
8197
8198 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8199
8200 buf = wmi_buf_alloc(wmi_handle, len);
8201 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308202 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308203 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308204 }
8205
8206 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8207 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8208
8209 WMITLV_SET_HDR(&cmd->tlv_header,
8210 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8211 WMITLV_GET_STRUCT_TLVLEN
8212 (wmi_req_stats_ext_cmd_fixed_param));
8213 cmd->vdev_id = preq->vdev_id;
8214 cmd->data_len = preq->request_data_len;
8215
Govind Singhb53420c2016-03-09 14:32:57 +05308216 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308217 __func__, preq->request_data_len, preq->vdev_id);
8218
8219 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8220 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8221
8222 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308223 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308224
8225 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8226 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308227 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308228 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308229 ret);
8230 wmi_buf_free(buf);
8231 }
8232
8233 return ret;
8234}
8235
8236/**
8237 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8238 * @wmi_handle: wmi handle
8239 * @params: ext wow params
8240 *
8241 * Return:0 for success or error code
8242 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308243static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308244 struct ext_wow_params *params)
8245{
8246 wmi_extwow_enable_cmd_fixed_param *cmd;
8247 wmi_buf_t buf;
8248 int32_t len;
8249 int ret;
8250
8251 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8252 buf = wmi_buf_alloc(wmi_handle, len);
8253 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308254 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8255 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308256 }
8257
8258 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8259
8260 WMITLV_SET_HDR(&cmd->tlv_header,
8261 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8262 WMITLV_GET_STRUCT_TLVLEN
8263 (wmi_extwow_enable_cmd_fixed_param));
8264
8265 cmd->vdev_id = params->vdev_id;
8266 cmd->type = params->type;
8267 cmd->wakeup_pin_num = params->wakeup_pin_num;
8268
Govind Singhb53420c2016-03-09 14:32:57 +05308269 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308270 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8271
8272 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8273 WMI_EXTWOW_ENABLE_CMDID);
8274 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308275 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308276 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308277 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308278 }
8279
Govind Singhb53420c2016-03-09 14:32:57 +05308280 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308281
8282}
8283
8284/**
8285 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8286 * @wmi_handle: wmi handle
8287 * @app_type1_params: app type1 params
8288 *
8289 * Return: CDF status
8290 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308291static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308292 struct app_type1_params *app_type1_params)
8293{
8294 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8295 wmi_buf_t buf;
8296 int32_t len;
8297 int ret;
8298
8299 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8300 buf = wmi_buf_alloc(wmi_handle, len);
8301 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308302 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8303 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308304 }
8305
8306 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8307 wmi_buf_data(buf);
8308
8309 WMITLV_SET_HDR(&cmd->tlv_header,
8310 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8311 WMITLV_GET_STRUCT_TLVLEN
8312 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8313
8314 cmd->vdev_id = app_type1_params->vdev_id;
8315 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8316 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308317 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308318 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308319 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308320 cmd->passwd_len = app_type1_params->pass_length;
8321
Govind Singhb53420c2016-03-09 14:32:57 +05308322 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308323 "identification_id %.8s id_length %u "
8324 "password %.16s pass_length %u",
8325 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8326 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8327
8328 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8329 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8330 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308331 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308332 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308333 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308334 }
8335
Govind Singhb53420c2016-03-09 14:32:57 +05308336 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308337}
8338
8339/**
8340 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8341 * @wmi_handle: wmi handle
8342 * @appType2Params: app type2 params
8343 *
8344 * Return: CDF status
8345 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308346static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308347 struct app_type2_params *appType2Params)
8348{
8349 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8350 wmi_buf_t buf;
8351 int32_t len;
8352 int ret;
8353
8354 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8355 buf = wmi_buf_alloc(wmi_handle, len);
8356 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308357 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8358 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308359 }
8360
8361 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8362 wmi_buf_data(buf);
8363
8364 WMITLV_SET_HDR(&cmd->tlv_header,
8365 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8366 WMITLV_GET_STRUCT_TLVLEN
8367 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8368
8369 cmd->vdev_id = appType2Params->vdev_id;
8370
Govind Singhb53420c2016-03-09 14:32:57 +05308371 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308372 cmd->rc4_key_len = appType2Params->rc4_key_len;
8373
8374 cmd->ip_id = appType2Params->ip_id;
8375 cmd->ip_device_ip = appType2Params->ip_device_ip;
8376 cmd->ip_server_ip = appType2Params->ip_server_ip;
8377
8378 cmd->tcp_src_port = appType2Params->tcp_src_port;
8379 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8380 cmd->tcp_seq = appType2Params->tcp_seq;
8381 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8382
8383 cmd->keepalive_init = appType2Params->keepalive_init;
8384 cmd->keepalive_min = appType2Params->keepalive_min;
8385 cmd->keepalive_max = appType2Params->keepalive_max;
8386 cmd->keepalive_inc = appType2Params->keepalive_inc;
8387
8388 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8389 &cmd->gateway_mac);
8390 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8391 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8392
Govind Singhb53420c2016-03-09 14:32:57 +05308393 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308394 "rc4_key %.16s rc4_key_len %u "
8395 "ip_id %x ip_device_ip %x ip_server_ip %x "
8396 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8397 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8398 "keepalive_max %u keepalive_inc %u "
8399 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8400 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8401 cmd->rc4_key, cmd->rc4_key_len,
8402 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8403 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8404 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8405 cmd->keepalive_max, cmd->keepalive_inc,
8406 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8407
8408 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8409 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8410 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308411 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308412 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308413 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308414 }
8415
Govind Singhb53420c2016-03-09 14:32:57 +05308416 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308417
8418}
8419
8420/**
8421 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8422 * @wmi_handle: wmi handle
8423 * @timer_val: auto shutdown timer value
8424 *
8425 * Return: CDF status
8426 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308427static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308428 uint32_t timer_val)
8429{
Govind Singh67922e82016-04-01 16:48:57 +05308430 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308431 wmi_buf_t buf = NULL;
8432 uint8_t *buf_ptr;
8433 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8434 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8435
Govind Singhb53420c2016-03-09 14:32:57 +05308436 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308437 __func__, timer_val);
8438
8439 buf = wmi_buf_alloc(wmi_handle, len);
8440 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308441 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8442 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308443 }
8444
8445 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8446 wmi_auto_sh_cmd =
8447 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8448 wmi_auto_sh_cmd->timer_value = timer_val;
8449
8450 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8451 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8452 WMITLV_GET_STRUCT_TLVLEN
8453 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8454
8455 status = wmi_unified_cmd_send(wmi_handle, buf,
8456 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308457 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308458 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308459 __func__, status);
8460 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308461 }
8462
Govind Singh67922e82016-04-01 16:48:57 +05308463 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308464}
8465
8466/**
8467 * send_nan_req_cmd_tlv() - to send nan request to target
8468 * @wmi_handle: wmi handle
8469 * @nan_req: request data which will be non-null
8470 *
8471 * Return: CDF status
8472 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308473static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308474 struct nan_req_params *nan_req)
8475{
Govind Singh67922e82016-04-01 16:48:57 +05308476 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308477 wmi_nan_cmd_param *cmd;
8478 wmi_buf_t buf;
8479 uint16_t len = sizeof(*cmd);
8480 uint16_t nan_data_len, nan_data_len_aligned;
8481 uint8_t *buf_ptr;
8482
8483 /*
8484 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8485 * +------------+----------+-----------------------+--------------+
8486 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8487 * +------------+----------+-----------------------+--------------+
8488 */
8489 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308490 WMI_LOGE("%s:nan req is not valid", __func__);
8491 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308492 }
8493 nan_data_len = nan_req->request_data_len;
8494 nan_data_len_aligned = roundup(nan_req->request_data_len,
8495 sizeof(uint32_t));
8496 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8497 buf = wmi_buf_alloc(wmi_handle, len);
8498 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308499 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8500 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308501 }
8502 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8503 cmd = (wmi_nan_cmd_param *) buf_ptr;
8504 WMITLV_SET_HDR(&cmd->tlv_header,
8505 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8506 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8507 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308508 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308509 __func__, nan_req->request_data_len);
8510 buf_ptr += sizeof(wmi_nan_cmd_param);
8511 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8512 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308513 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308514
8515 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8516 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308517 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308518 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308519 __func__, ret);
8520 wmi_buf_free(buf);
8521 }
8522
8523 return ret;
8524}
8525
8526/**
8527 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8528 * @wmi_handle: wmi handle
8529 * @pDhcpSrvOffloadInfo: DHCP server offload info
8530 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308531 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308532 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308533static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308534 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8535{
8536 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8537 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308538 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308539
8540 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8541 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308542 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308543 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308544 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308545 }
8546
8547 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308548 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308549
8550 WMITLV_SET_HDR(&cmd->tlv_header,
8551 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8552 WMITLV_GET_STRUCT_TLVLEN
8553 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8554 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8555 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8556 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8557 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8558 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308559 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308560 sizeof(*cmd),
8561 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308562 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308563 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308564 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308565 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308566 }
Govind Singhb53420c2016-03-09 14:32:57 +05308567 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308568 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308569
8570 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308571}
8572
8573/**
8574 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8575 * @wmi_handle: wmi handle
8576 * @flashing: flashing request
8577 *
8578 * Return: CDF status
8579 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308580static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308581 struct flashing_req_params *flashing)
8582{
8583 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308584 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308585 wmi_buf_t buf;
8586 uint8_t *buf_ptr;
8587 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8588
8589 buf = wmi_buf_alloc(wmi_handle, len);
8590 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308591 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308592 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308593 }
8594 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8595 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8596 WMITLV_SET_HDR(&cmd->tlv_header,
8597 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8598 WMITLV_GET_STRUCT_TLVLEN
8599 (wmi_set_led_flashing_cmd_fixed_param));
8600 cmd->pattern_id = flashing->pattern_id;
8601 cmd->led_x0 = flashing->led_x0;
8602 cmd->led_x1 = flashing->led_x1;
8603
8604 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8605 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308606 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308607 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308608 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308609 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308610 }
Govind Singh67922e82016-04-01 16:48:57 +05308611
8612 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308613}
8614
8615/**
8616 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8617 * @wmi_handle: wmi handle
8618 * @ch_avoid_update_req: channel avoid update params
8619 *
8620 * Return: CDF status
8621 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308622static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308623{
Govind Singh67922e82016-04-01 16:48:57 +05308624 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308625 wmi_buf_t buf = NULL;
8626 uint8_t *buf_ptr;
8627 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
8628 int len = sizeof(wmi_chan_avoid_update_cmd_param);
8629
8630
8631 buf = wmi_buf_alloc(wmi_handle, len);
8632 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308633 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8634 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308635 }
8636
8637 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8638 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
8639 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
8640 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
8641 WMITLV_GET_STRUCT_TLVLEN
8642 (wmi_chan_avoid_update_cmd_param));
8643
8644 status = wmi_unified_cmd_send(wmi_handle, buf,
8645 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308646 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308647 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05308648 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
8649 " returned Error %d", status);
8650 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308651 }
8652
Govind Singh67922e82016-04-01 16:48:57 +05308653 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308654}
8655
8656/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05308657 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
8658 * @wmi_handle: wmi handle
8659 * @param: pointer to pdev regdomain params
8660 *
8661 * Return: 0 for success or error code
8662 */
8663static QDF_STATUS
8664send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
8665 struct pdev_set_regdomain_params *param)
8666{
8667 wmi_buf_t buf;
8668 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8669 int32_t len = sizeof(*cmd);
8670
8671
8672 buf = wmi_buf_alloc(wmi_handle, len);
8673 if (!buf) {
8674 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8675 return QDF_STATUS_E_NOMEM;
8676 }
8677 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8678 WMITLV_SET_HDR(&cmd->tlv_header,
8679 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8680 WMITLV_GET_STRUCT_TLVLEN
8681 (wmi_pdev_set_regdomain_cmd_fixed_param));
8682
8683 cmd->reg_domain = param->currentRDinuse;
8684 cmd->reg_domain_2G = param->currentRD2G;
8685 cmd->reg_domain_5G = param->currentRD5G;
8686 cmd->conformance_test_limit_2G = param->ctl_2G;
8687 cmd->conformance_test_limit_5G = param->ctl_5G;
8688 cmd->dfs_domain = param->dfsDomain;
8689 cmd->pdev_id = param->pdev_id;
8690
8691 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8692 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
8693 WMI_LOGE("%s: Failed to send pdev set regdomain command",
8694 __func__);
8695 wmi_buf_free(buf);
8696 return QDF_STATUS_E_FAILURE;
8697 }
8698
8699 return QDF_STATUS_SUCCESS;
8700}
8701
8702/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308703 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
8704 * @wmi_handle: wmi handle
8705 * @reg_dmn: reg domain
8706 * @regdmn2G: 2G reg domain
8707 * @regdmn5G: 5G reg domain
8708 * @ctl2G: 2G test limit
8709 * @ctl5G: 5G test limit
8710 *
8711 * Return: none
8712 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308713static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308714 uint32_t reg_dmn, uint16_t regdmn2G,
8715 uint16_t regdmn5G, int8_t ctl2G,
8716 int8_t ctl5G)
8717{
8718 wmi_buf_t buf;
8719 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8720 int32_t len = sizeof(*cmd);
8721
8722
8723 buf = wmi_buf_alloc(wmi_handle, len);
8724 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308725 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8726 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308727 }
8728 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8729 WMITLV_SET_HDR(&cmd->tlv_header,
8730 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8731 WMITLV_GET_STRUCT_TLVLEN
8732 (wmi_pdev_set_regdomain_cmd_fixed_param));
8733 cmd->reg_domain = reg_dmn;
8734 cmd->reg_domain_2G = regdmn2G;
8735 cmd->reg_domain_5G = regdmn5G;
8736 cmd->conformance_test_limit_2G = ctl2G;
8737 cmd->conformance_test_limit_5G = ctl5G;
8738
8739 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8740 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308741 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308742 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308743 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308744 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308745 }
8746
Govind Singhb53420c2016-03-09 14:32:57 +05308747 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308748}
8749
8750
8751/**
8752 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
8753 * @wmi_handle: wmi handle
8754 * @chan_switch_params: Pointer to tdls channel switch parameter structure
8755 *
8756 * This function sets tdls off channel mode
8757 *
8758 * Return: 0 on success; Negative errno otherwise
8759 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308760static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308761 struct tdls_channel_switch_params *chan_switch_params)
8762{
8763 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
8764 wmi_buf_t wmi_buf;
8765 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
8766
8767 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8768 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308769 WMI_LOGE(FL("wmi_buf_alloc failed"));
8770 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308771 }
8772 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
8773 wmi_buf_data(wmi_buf);
8774 WMITLV_SET_HDR(&cmd->tlv_header,
8775 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
8776 WMITLV_GET_STRUCT_TLVLEN(
8777 wmi_tdls_set_offchan_mode_cmd_fixed_param));
8778
8779 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
8780 &cmd->peer_macaddr);
8781 cmd->vdev_id = chan_switch_params->vdev_id;
8782 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
8783 cmd->is_peer_responder = chan_switch_params->is_responder;
8784 cmd->offchan_num = chan_switch_params->tdls_off_ch;
8785 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
8786 cmd->offchan_oper_class = chan_switch_params->oper_class;
8787
Govind Singhb53420c2016-03-09 14:32:57 +05308788 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308789 cmd->peer_macaddr.mac_addr31to0,
8790 cmd->peer_macaddr.mac_addr47to32);
8791
Govind Singhb53420c2016-03-09 14:32:57 +05308792 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05308793 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
8794 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
8795 ),
8796 cmd->vdev_id,
8797 cmd->offchan_mode,
8798 cmd->offchan_num,
8799 cmd->offchan_bw_bitmap,
8800 cmd->is_peer_responder,
8801 cmd->offchan_oper_class);
8802
8803 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8804 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308805 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308806 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308807 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308808 }
8809
8810
Govind Singhb53420c2016-03-09 14:32:57 +05308811 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308812}
8813
8814/**
8815 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
8816 * @wmi_handle: wmi handle
8817 * @pwmaTdlsparams: TDLS params
8818 *
8819 * Return: 0 for sucess or error code
8820 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308821static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308822 void *tdls_param, uint8_t tdls_state)
8823{
8824 wmi_tdls_set_state_cmd_fixed_param *cmd;
8825 wmi_buf_t wmi_buf;
8826
8827 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
8828 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
8829
8830 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8831 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308832 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
8833 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308834 }
8835 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
8836 WMITLV_SET_HDR(&cmd->tlv_header,
8837 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
8838 WMITLV_GET_STRUCT_TLVLEN
8839 (wmi_tdls_set_state_cmd_fixed_param));
8840 cmd->vdev_id = wmi_tdls->vdev_id;
8841 cmd->state = tdls_state;
8842 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
8843 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
8844 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
8845 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
8846 cmd->rssi_delta = wmi_tdls->rssi_delta;
8847 cmd->tdls_options = wmi_tdls->tdls_options;
8848 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
8849 cmd->tdls_peer_traffic_response_timeout_ms =
8850 wmi_tdls->peer_traffic_response_timeout;
8851 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
8852 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
8853 cmd->tdls_puapsd_rx_frame_threshold =
8854 wmi_tdls->puapsd_rx_frame_threshold;
8855 cmd->teardown_notification_ms =
8856 wmi_tdls->teardown_notification_ms;
8857 cmd->tdls_peer_kickout_threshold =
8858 wmi_tdls->tdls_peer_kickout_threshold;
8859
Govind Singhb53420c2016-03-09 14:32:57 +05308860 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05308861 "notification_interval_ms: %d, "
8862 "tx_discovery_threshold: %d, "
8863 "tx_teardown_threshold: %d, "
8864 "rssi_teardown_threshold: %d, "
8865 "rssi_delta: %d, "
8866 "tdls_options: 0x%x, "
8867 "tdls_peer_traffic_ind_window: %d, "
8868 "tdls_peer_traffic_response_timeout: %d, "
8869 "tdls_puapsd_mask: 0x%x, "
8870 "tdls_puapsd_inactivity_time: %d, "
8871 "tdls_puapsd_rx_frame_threshold: %d, "
8872 "teardown_notification_ms: %d, "
8873 "tdls_peer_kickout_threshold: %d",
8874 __func__, tdls_state, cmd->state,
8875 cmd->notification_interval_ms,
8876 cmd->tx_discovery_threshold,
8877 cmd->tx_teardown_threshold,
8878 cmd->rssi_teardown_threshold,
8879 cmd->rssi_delta,
8880 cmd->tdls_options,
8881 cmd->tdls_peer_traffic_ind_window,
8882 cmd->tdls_peer_traffic_response_timeout_ms,
8883 cmd->tdls_puapsd_mask,
8884 cmd->tdls_puapsd_inactivity_time_ms,
8885 cmd->tdls_puapsd_rx_frame_threshold,
8886 cmd->teardown_notification_ms,
8887 cmd->tdls_peer_kickout_threshold);
8888
8889 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8890 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308891 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308892 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308893 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308894 }
Govind Singhb53420c2016-03-09 14:32:57 +05308895 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308896
Govind Singhb53420c2016-03-09 14:32:57 +05308897 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308898}
8899
8900/**
8901 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
8902 * @wmi_handle: wmi handle
8903 * @peerStateParams: TDLS peer state params
8904 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308905 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308906 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308907static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308908 struct tdls_peer_state_params *peerStateParams,
8909 uint32_t *ch_mhz)
8910{
8911 wmi_tdls_peer_update_cmd_fixed_param *cmd;
8912 wmi_tdls_peer_capabilities *peer_cap;
8913 wmi_channel *chan_info;
8914 wmi_buf_t wmi_buf;
8915 uint8_t *buf_ptr;
8916 uint32_t i;
8917 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
8918 sizeof(wmi_tdls_peer_capabilities);
8919
8920
8921 len += WMI_TLV_HDR_SIZE +
8922 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
8923
8924 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8925 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308926 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8927 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308928 }
8929
8930 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8931 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
8932 WMITLV_SET_HDR(&cmd->tlv_header,
8933 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
8934 WMITLV_GET_STRUCT_TLVLEN
8935 (wmi_tdls_peer_update_cmd_fixed_param));
8936
8937 cmd->vdev_id = peerStateParams->vdevId;
8938 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
8939 &cmd->peer_macaddr);
8940
8941
8942 cmd->peer_state = peerStateParams->peerState;
8943
Govind Singhb53420c2016-03-09 14:32:57 +05308944 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05308945 "peer_macaddr.mac_addr31to0: 0x%x, "
8946 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
8947 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
8948 cmd->peer_macaddr.mac_addr31to0,
8949 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
8950
8951 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
8952 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
8953 WMITLV_SET_HDR(&peer_cap->tlv_header,
8954 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
8955 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
8956
8957 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
8958 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
8959 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
8960 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
8961 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
8962 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
8963 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
8964 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
8965
8966 /* Ack and More Data Ack are sent as 0, so no need to set
8967 * but fill SP
8968 */
8969 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
8970 peerStateParams->peerCap.peerMaxSp);
8971
8972 peer_cap->buff_sta_support =
8973 peerStateParams->peerCap.peerBuffStaSupport;
8974 peer_cap->off_chan_support =
8975 peerStateParams->peerCap.peerOffChanSupport;
8976 peer_cap->peer_curr_operclass =
8977 peerStateParams->peerCap.peerCurrOperClass;
8978 /* self curr operclass is not being used and so pass op class for
8979 * preferred off chan in it.
8980 */
8981 peer_cap->self_curr_operclass =
8982 peerStateParams->peerCap.opClassForPrefOffChan;
8983 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
8984 peer_cap->peer_operclass_len =
8985 peerStateParams->peerCap.peerOperClassLen;
8986
Govind Singhb53420c2016-03-09 14:32:57 +05308987 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308988 __func__, peer_cap->peer_operclass_len);
8989 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
8990 peer_cap->peer_operclass[i] =
8991 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05308992 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308993 __func__, i, peer_cap->peer_operclass[i]);
8994 }
8995
8996 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
8997 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
8998 peer_cap->pref_offchan_bw =
8999 peerStateParams->peerCap.prefOffChanBandwidth;
9000
Govind Singhb53420c2016-03-09 14:32:57 +05309001 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309002 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9003 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9004 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9005 " %d, pref_offchan_bw: %d",
9006 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9007 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9008 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9009 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9010 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9011
9012 /* next fill variable size array of peer chan info */
9013 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9014 WMITLV_SET_HDR(buf_ptr,
9015 WMITLV_TAG_ARRAY_STRUC,
9016 sizeof(wmi_channel) *
9017 peerStateParams->peerCap.peerChanLen);
9018 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9019
9020 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9021 WMITLV_SET_HDR(&chan_info->tlv_header,
9022 WMITLV_TAG_STRUC_wmi_channel,
9023 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9024 chan_info->mhz = ch_mhz[i];
9025 chan_info->band_center_freq1 = chan_info->mhz;
9026 chan_info->band_center_freq2 = 0;
9027
Govind Singhb53420c2016-03-09 14:32:57 +05309028 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309029
9030 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9031 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309032 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309033 peerStateParams->peerCap.peerChan[i].chanId,
9034 peerStateParams->peerCap.peerChan[i].dfsSet);
9035 }
9036
9037 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9038 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9039 else
9040 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9041
9042 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9043 peerStateParams->peerCap.
9044 peerChan[i].pwr);
9045
9046 WMI_SET_CHANNEL_REG_POWER(chan_info,
9047 peerStateParams->peerCap.peerChan[i].
9048 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309049 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309050 peerStateParams->peerCap.peerChan[i].pwr);
9051
9052 chan_info++;
9053 }
9054
9055 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9056 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309057 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309058 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309059 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309060 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309061 }
9062
9063
Govind Singhb53420c2016-03-09 14:32:57 +05309064 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309065}
9066
9067/*
9068 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9069 * firmware
9070 * @wmi_handle: Pointer to wmi handle
9071 * @mem_dump_req: Pointer for mem_dump_req
9072 *
9073 * This function sends memory dump request to firmware
9074 *
Govind Singhb53420c2016-03-09 14:32:57 +05309075 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309076 *
9077 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309078static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309079 struct fw_dump_req_param *mem_dump_req)
9080{
9081 wmi_get_fw_mem_dump_fixed_param *cmd;
9082 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309083 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309084 int32_t len;
9085 wmi_buf_t buf;
9086 u_int8_t *buf_ptr;
9087 int ret, loop;
9088
9089 /*
9090 * len = sizeof(fixed param) that includes tlv header +
9091 * tlv header for array of struc +
9092 * sizeof (each struct)
9093 */
9094 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9095 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9096 buf = wmi_buf_alloc(wmi_handle, len);
9097
9098 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309099 WMI_LOGE(FL("Failed allocate wmi buffer"));
9100 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309101 }
9102
9103 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309104 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309105 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9106
9107 WMITLV_SET_HDR(&cmd->tlv_header,
9108 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9109 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9110
9111 cmd->request_id = mem_dump_req->request_id;
9112 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9113
9114 /* TLV indicating array of structures to follow */
9115 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9116 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9117 sizeof(wmi_fw_mem_dump) *
9118 cmd->num_fw_mem_dump_segs);
9119
9120 buf_ptr += WMI_TLV_HDR_SIZE;
9121 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9122
Govind Singhb53420c2016-03-09 14:32:57 +05309123 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309124 mem_dump_req->request_id, mem_dump_req->num_seg);
9125 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309126 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309127 ((uint8_t *)(mem_dump_req->segment) +
9128 loop * sizeof(*seg_req));
9129 WMITLV_SET_HDR(&dump_params->tlv_header,
9130 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9131 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9132 dump_params->seg_id = seg_req->seg_id;
9133 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9134 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9135 dump_params->seg_length = seg_req->seg_length;
9136 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9137 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309138 WMI_LOGI(FL("seg_number:%d"), loop);
9139 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309140 dump_params->seg_id, dump_params->seg_start_addr_lo,
9141 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309142 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309143 dump_params->seg_length, dump_params->dest_addr_lo,
9144 dump_params->dest_addr_hi);
9145 dump_params++;
9146 }
9147
9148 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9149 WMI_GET_FW_MEM_DUMP_CMDID);
9150 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309151 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309152 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309153 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309154 }
9155
Govind Singhb53420c2016-03-09 14:32:57 +05309156 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9157 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309158}
9159
9160/*
9161 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9162 * @wmi_handle: Pointer to WMi handle
9163 * @ie_data: Pointer for ie data
9164 *
9165 * This function sends IE information to firmware
9166 *
Govind Singhb53420c2016-03-09 14:32:57 +05309167 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309168 *
9169 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309170static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309171 struct vdev_ie_info_param *ie_info)
9172{
9173 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9174 wmi_buf_t buf;
9175 uint8_t *buf_ptr;
9176 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309177 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309178
9179
9180 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9181 /* Allocate memory for the WMI command */
9182 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9183
9184 buf = wmi_buf_alloc(wmi_handle, len);
9185 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309186 WMI_LOGE(FL("wmi_buf_alloc failed"));
9187 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309188 }
9189
9190 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309191 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309192
9193 /* Populate the WMI command */
9194 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9195
9196 WMITLV_SET_HDR(&cmd->tlv_header,
9197 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9198 WMITLV_GET_STRUCT_TLVLEN(
9199 wmi_vdev_set_ie_cmd_fixed_param));
9200 cmd->vdev_id = ie_info->vdev_id;
9201 cmd->ie_id = ie_info->ie_id;
9202 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009203 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309204
Govind Singhb53420c2016-03-09 14:32:57 +05309205 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309206 ie_info->length, ie_info->vdev_id);
9207
9208 buf_ptr += sizeof(*cmd);
9209 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9210 buf_ptr += WMI_TLV_HDR_SIZE;
9211
Govind Singhb53420c2016-03-09 14:32:57 +05309212 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309213
9214 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9215 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309216 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309217 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309218 wmi_buf_free(buf);
9219 }
9220
9221 return ret;
9222}
9223
Sathish Kumar497bef42017-03-01 14:02:36 +05309224/**
9225 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9226 *
9227 * @param wmi_handle : handle to WMI.
9228 * @param param : pointer to antenna param
9229 *
9230 * This function sends smart antenna enable command to FW
9231 *
9232 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9233 */
9234static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9235 struct smart_ant_enable_params *param)
9236{
9237 /* Send WMI COMMAND to Enable */
9238 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9239 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9240 wmi_buf_t buf;
9241 uint8_t *buf_ptr;
9242 int len = 0;
9243 QDF_STATUS ret;
9244 int loop = 0;
9245
9246 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9247 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9248 buf = wmi_buf_alloc(wmi_handle, len);
9249
9250 if (!buf) {
9251 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9252 return QDF_STATUS_E_NOMEM;
9253 }
9254
9255 buf_ptr = wmi_buf_data(buf);
9256 qdf_mem_zero(buf_ptr, len);
9257 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9258
9259 WMITLV_SET_HDR(&cmd->tlv_header,
9260 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9261 WMITLV_GET_STRUCT_TLVLEN(
9262 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9263
9264 cmd->pdev_id = param->pdev_id;
9265 cmd->enable = param->enable;
9266 cmd->mode = param->mode;
9267 cmd->rx_antenna = param->rx_antenna;
9268 cmd->tx_default_antenna = param->rx_antenna;
9269
9270 /* TLV indicating array of structures to follow */
9271 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9272 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9273 WMI_HAL_MAX_SANTENNA *
9274 sizeof(wmi_pdev_smart_ant_gpio_handle));
9275
9276 buf_ptr += WMI_TLV_HDR_SIZE;
9277 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9278
9279 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9280 WMITLV_SET_HDR(&gpio_param->tlv_header,
9281 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9282 WMITLV_GET_STRUCT_TLVLEN(
9283 wmi_pdev_smart_ant_gpio_handle));
9284 if (param->mode == SMART_ANT_MODE_SERIAL) {
9285 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
9286 gpio_param->gpio_pin = param->gpio_pin[loop];
9287 gpio_param->gpio_func = param->gpio_func[loop];
9288 } else {
9289 gpio_param->gpio_pin = 0;
9290 gpio_param->gpio_func = 0;
9291 }
9292 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
9293 gpio_param->gpio_pin = param->gpio_pin[loop];
9294 gpio_param->gpio_func = param->gpio_func[loop];
9295 }
9296 /* Setting it to 0 for now */
9297 gpio_param->pdev_id = param->pdev_id;
9298 gpio_param++;
9299 }
9300
9301 ret = wmi_unified_cmd_send(wmi_handle,
9302 buf,
9303 len,
9304 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
9305
9306 if (ret != 0) {
9307 WMI_LOGE(" %s :WMI Failed\n", __func__);
9308 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
9309 cmd->enable,
9310 cmd->mode,
9311 cmd->rx_antenna,
9312 param->gpio_pin[0], param->gpio_pin[1],
9313 param->gpio_pin[2], param->gpio_pin[3],
9314 param->gpio_func[0], param->gpio_func[1],
9315 param->gpio_func[2], param->gpio_func[3],
9316 ret);
9317 wmi_buf_free(buf);
9318 }
9319
9320 return ret;
9321}
9322
9323/**
9324 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
9325 *
9326 * @param wmi_handle : handle to WMI.
9327 * @param param : pointer to rx antenna param
9328 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9329 */
9330static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9331 struct smart_ant_rx_ant_params *param)
9332{
9333 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
9334 wmi_buf_t buf;
9335 uint8_t *buf_ptr;
9336 uint32_t len;
9337 QDF_STATUS ret;
9338
9339 len = sizeof(*cmd);
9340 buf = wmi_buf_alloc(wmi_handle, len);
9341 WMI_LOGD("%s:\n", __func__);
9342 if (!buf) {
9343 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9344 return QDF_STATUS_E_NOMEM;
9345 }
9346
9347 buf_ptr = wmi_buf_data(buf);
9348 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
9349 WMITLV_SET_HDR(&cmd->tlv_header,
9350 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
9351 WMITLV_GET_STRUCT_TLVLEN(
9352 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
9353 cmd->rx_antenna = param->antenna;
9354 cmd->pdev_id = param->pdev_id;
9355
9356 ret = wmi_unified_cmd_send(wmi_handle,
9357 buf,
9358 len,
9359 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
9360
9361 if (ret != 0) {
9362 WMI_LOGE(" %s :WMI Failed\n", __func__);
9363 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
9364 __func__,
9365 cmd->rx_antenna,
9366 ret);
9367 wmi_buf_free(buf);
9368 }
9369
9370 return ret;
9371}
9372
9373/**
9374 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
9375 * @wmi_handle: wmi handle
9376 * @param: pointer to hold ctl table param
9377 *
9378 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9379 */
9380static QDF_STATUS
9381send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
9382 struct ctl_table_params *param)
9383{
9384 uint16_t len, ctl_tlv_len;
9385 uint8_t *buf_ptr;
9386 wmi_buf_t buf;
9387 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
9388 uint32_t *ctl_array;
9389
9390 if (!param->ctl_array)
9391 return QDF_STATUS_E_FAILURE;
9392
9393 if (param->ctl_cmd_len !=
9394 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
9395 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
9396 qdf_print("CTL array len not correct\n");
9397 return QDF_STATUS_E_FAILURE;
9398 }
9399
9400 ctl_tlv_len = WMI_TLV_HDR_SIZE +
9401 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
9402 len = sizeof(*cmd) + ctl_tlv_len;
9403
9404 buf = wmi_buf_alloc(wmi_handle, len);
9405 if (!buf) {
9406 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9407 return QDF_STATUS_E_FAILURE;
9408 }
9409
9410 buf_ptr = wmi_buf_data(buf);
9411 qdf_mem_zero(buf_ptr, len);
9412
9413 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
9414
9415 WMITLV_SET_HDR(&cmd->tlv_header,
9416 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
9417 WMITLV_GET_STRUCT_TLVLEN(
9418 wmi_pdev_set_ctl_table_cmd_fixed_param));
9419 cmd->ctl_len = param->ctl_cmd_len;
9420 cmd->pdev_id = param->pdev_id;
9421
9422 buf_ptr += sizeof(*cmd);
9423 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9424 (cmd->ctl_len));
9425 buf_ptr += WMI_TLV_HDR_SIZE;
9426 ctl_array = (uint32_t *)buf_ptr;
9427
9428 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
9429 sizeof(param->ctl_band));
9430 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
9431 param->ctl_cmd_len -
9432 sizeof(param->ctl_band));
9433
9434 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9435 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
9436 WMI_LOGE("%s:Failed to send command\n", __func__);
9437 wmi_buf_free(buf);
9438 return QDF_STATUS_E_FAILURE;
9439 }
9440
9441 return QDF_STATUS_SUCCESS;
9442}
9443
9444/**
9445 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
9446 * @wmi_handle: wmi handle
9447 * @param: pointer to hold mimogain table param
9448 *
9449 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9450 */
9451static QDF_STATUS
9452send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
9453 struct mimogain_table_params *param)
9454{
9455 uint16_t len, table_tlv_len;
9456 wmi_buf_t buf;
9457 uint8_t *buf_ptr;
9458 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
9459 uint32_t *gain_table;
9460
9461 if (!param->array_gain)
9462 return QDF_STATUS_E_FAILURE;
9463
9464 /* len must be multiple of a single array gain table */
9465 if (param->tbl_len %
9466 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
9467 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
9468 WMI_LOGE("Array gain table len not correct\n");
9469 return QDF_STATUS_E_FAILURE;
9470 }
9471
9472 table_tlv_len = WMI_TLV_HDR_SIZE +
9473 roundup(param->tbl_len, sizeof(uint32_t));
9474 len = sizeof(*cmd) + table_tlv_len;
9475
9476 buf = wmi_buf_alloc(wmi_handle, len);
9477 if (!buf) {
9478 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9479 return QDF_STATUS_E_FAILURE;
9480 }
9481
9482 buf_ptr = wmi_buf_data(buf);
9483 qdf_mem_zero(buf_ptr, len);
9484
9485 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
9486
9487 WMITLV_SET_HDR(&cmd->tlv_header,
9488 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
9489 WMITLV_GET_STRUCT_TLVLEN(
9490 wmi_pdev_set_mimogain_table_cmd_fixed_param));
9491
9492 cmd->pdev_id = param->pdev_id;
9493 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
9494 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
9495 param->multichain_gain_bypass);
9496
9497 buf_ptr += sizeof(*cmd);
9498 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9499 (param->tbl_len));
9500 buf_ptr += WMI_TLV_HDR_SIZE;
9501 gain_table = (uint32_t *)buf_ptr;
9502
9503 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
9504 param->array_gain,
9505 param->tbl_len);
9506
9507 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9508 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
9509 return QDF_STATUS_E_FAILURE;
9510 }
9511
9512 return QDF_STATUS_SUCCESS;
9513}
9514
9515/**
9516 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
9517 * info to fw
9518 * @wmi_handle: wmi handle
9519 * @param: pointer to hold packet power info param
9520 *
9521 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9522 */
9523static QDF_STATUS
9524send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
9525 struct packet_power_info_params *param)
9526{
9527 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
9528 wmi_buf_t wmibuf;
9529 uint8_t *buf_ptr;
9530 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
9531
9532 wmibuf = wmi_buf_alloc(wmi_handle, len);
9533 if (wmibuf == NULL)
9534 return QDF_STATUS_E_NOMEM;
9535
9536 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
9537
9538 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
9539 WMITLV_SET_HDR(&cmd->tlv_header,
9540 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
9541 WMITLV_GET_STRUCT_TLVLEN(
9542 wmi_pdev_get_tpc_cmd_fixed_param));
9543 cmd->pdev_id = param->pdev_id;
9544 cmd->rate_flags = param->rate_flags;
9545 cmd->nss = param->nss;
9546 cmd->preamble = param->preamble;
9547 cmd->hw_rate = param->hw_rate;
9548 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
9549 __func__,
9550 __LINE__,
9551 WMI_PDEV_GET_TPC_CMDID,
9552 *((u_int32_t *)cmd));
9553 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
9554 WMI_PDEV_GET_TPC_CMDID)) {
9555 WMI_LOGE(FL("Failed to get tpc command\n"));
9556 wmi_buf_free(wmibuf);
9557 return QDF_STATUS_E_FAILURE;
9558 }
9559
9560 return QDF_STATUS_SUCCESS;
9561}
9562
9563/**
9564 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
9565 * @wmi_handle: wmi handle
9566 * @param: pointer to hold config ratemask params
9567 *
9568 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9569 */
9570static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
9571 struct config_ratemask_params *param)
9572{
9573 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
9574 wmi_buf_t buf;
9575 int32_t len = sizeof(*cmd);
9576
9577 buf = wmi_buf_alloc(wmi_handle, len);
9578 if (!buf) {
9579 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9580 return QDF_STATUS_E_FAILURE;
9581 }
9582 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
9583 WMITLV_SET_HDR(&cmd->tlv_header,
9584 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
9585 WMITLV_GET_STRUCT_TLVLEN(
9586 wmi_vdev_config_ratemask_cmd_fixed_param));
9587 cmd->vdev_id = param->vdev_id;
9588 cmd->type = param->type;
9589 cmd->mask_lower32 = param->lower32;
9590 cmd->mask_higher32 = param->higher32;
9591 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
9592 param->vdev_id, param->type, param->lower32, param->higher32);
9593
9594 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9595 WMI_VDEV_RATEMASK_CMDID)) {
9596 WMI_LOGE("Seting vdev ratemask failed\n");
9597 wmi_buf_free(buf);
9598 return QDF_STATUS_E_FAILURE;
9599 }
9600
9601 return QDF_STATUS_SUCCESS;
9602}
9603
9604/**
9605 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
9606 * @wmi_handle: wmi handle
9607 * @param: pointer to hold vap dscp tid map param
9608 *
9609 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9610 */
9611static QDF_STATUS
9612send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
9613 struct vap_dscp_tid_map_params *param)
9614{
9615 wmi_buf_t buf;
9616 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
9617 int32_t len = sizeof(*cmd);
9618
9619 buf = wmi_buf_alloc(wmi_handle, len);
9620 if (!buf) {
9621 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9622 return QDF_STATUS_E_FAILURE;
9623 }
9624
9625 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
9626 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
9627 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
9628
9629 cmd->vdev_id = param->vdev_id;
9630 cmd->enable_override = 0;
9631
9632 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
9633 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9634 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
9635 WMI_LOGE("Failed to set dscp cmd\n");
9636 wmi_buf_free(buf);
9637 return QDF_STATUS_E_FAILURE;
9638 }
9639
9640 return QDF_STATUS_SUCCESS;
9641}
9642
9643/**
9644 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
9645 * @wmi_handle: wmi handle
9646 * @macaddr: vdev mac address
9647 * @param: pointer to hold neigbour rx param
9648 *
9649 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9650 */
9651static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
9652 uint8_t macaddr[IEEE80211_ADDR_LEN],
9653 struct set_neighbour_rx_params *param)
9654{
9655 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
9656 wmi_buf_t buf;
9657 int32_t len = sizeof(*cmd);
9658
9659 buf = wmi_buf_alloc(wmi_handle, len);
9660 if (!buf) {
9661 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9662 return QDF_STATUS_E_FAILURE;
9663 }
9664 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
9665 WMITLV_SET_HDR(&cmd->tlv_header,
9666 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
9667 WMITLV_GET_STRUCT_TLVLEN(
9668 wmi_vdev_filter_nrp_config_cmd_fixed_param));
9669 cmd->vdev_id = param->vdev_id;
9670 cmd->bssid_idx = param->idx;
9671 cmd->action = param->action;
9672 cmd->type = param->type;
9673 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
9674 cmd->flag = 0;
9675
9676 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9677 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
9678 WMI_LOGE("Failed to set neighbour rx param\n");
9679 wmi_buf_free(buf);
9680 return QDF_STATUS_E_FAILURE;
9681 }
9682
9683 return QDF_STATUS_SUCCESS;
9684}
9685
9686/**
9687 * send_smart_ant_set_tx_ant_cmd_non_tlv() - WMI set tx antenna function
9688 * @param wmi_handle : handle to WMI.
9689 * @param macaddr : vdev mac address
9690 * @param param : pointer to tx antenna param
9691 *
9692 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9693 */
9694static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9695 uint8_t macaddr[IEEE80211_ADDR_LEN],
9696 struct smart_ant_tx_ant_params *param)
9697{
9698 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
9699 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
9700 wmi_buf_t buf;
9701 int32_t len = 0;
9702 int i;
9703 uint8_t *buf_ptr;
9704 QDF_STATUS ret;
9705
9706 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9707 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
9708 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
9709 buf = wmi_buf_alloc(wmi_handle, len);
9710
9711 if (!buf) {
9712 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9713 return QDF_STATUS_E_NOMEM;
9714 }
9715
9716 buf_ptr = (uint8_t *)wmi_buf_data(buf);
9717 qdf_mem_zero(buf_ptr, len);
9718 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
9719
9720 WMITLV_SET_HDR(&cmd->tlv_header,
9721 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
9722 WMITLV_GET_STRUCT_TLVLEN(
9723 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
9724
9725 cmd->vdev_id = param->vdev_id;
9726 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
9727
9728 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
9729 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9730 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
9731 buf_ptr += WMI_TLV_HDR_SIZE;
9732 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
9733
9734 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
9735 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
9736 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
9737 WMITLV_GET_STRUCT_TLVLEN(
9738 wmi_peer_smart_ant_set_tx_antenna_series));
9739 ant_tx_series->antenna_series = param->antenna_array[i];
9740 ant_tx_series++;
9741 }
9742
9743 ret = wmi_unified_cmd_send(wmi_handle,
9744 buf,
9745 len,
9746 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
9747
9748 if (ret != 0) {
9749 WMI_LOGE(" %s :WMI Failed\n", __func__);
9750 wmi_buf_free(buf);
9751 }
9752
9753 return ret;
9754}
9755
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
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010127static
Govind Singh9ddd5162016-03-07 16:30:32 +053010128void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053010129 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053010130{
Govind Singhe7f2f342016-05-23 12:12:52 +053010131 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053010132 resource_cfg->num_peers = tgt_res_cfg->num_peers;
10133 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
10134 resource_cfg->num_offload_reorder_buffs =
10135 tgt_res_cfg->num_offload_reorder_buffs;
10136 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
10137 resource_cfg->num_tids = tgt_res_cfg->num_tids;
10138 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
10139 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
10140 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
10141 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
10142 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
10143 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
10144 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
10145 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
10146 resource_cfg->scan_max_pending_req =
10147 tgt_res_cfg->scan_max_pending_req;
10148 resource_cfg->bmiss_offload_max_vdev =
10149 tgt_res_cfg->bmiss_offload_max_vdev;
10150 resource_cfg->roam_offload_max_vdev =
10151 tgt_res_cfg->roam_offload_max_vdev;
10152 resource_cfg->roam_offload_max_ap_profiles =
10153 tgt_res_cfg->roam_offload_max_ap_profiles;
10154 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
10155 resource_cfg->num_mcast_table_elems =
10156 tgt_res_cfg->num_mcast_table_elems;
10157 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
10158 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
10159 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
10160 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
10161 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
10162 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
10163 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
10164 resource_cfg->vow_config = tgt_res_cfg->vow_config;
10165 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
10166 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
10167 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
10168 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
10169 resource_cfg->num_tdls_conn_table_entries =
10170 tgt_res_cfg->num_tdls_conn_table_entries;
10171 resource_cfg->beacon_tx_offload_max_vdev =
10172 tgt_res_cfg->beacon_tx_offload_max_vdev;
10173 resource_cfg->num_multicast_filter_entries =
10174 tgt_res_cfg->num_multicast_filter_entries;
10175 resource_cfg->num_wow_filters =
10176 tgt_res_cfg->num_wow_filters;
10177 resource_cfg->num_keep_alive_pattern =
10178 tgt_res_cfg->num_keep_alive_pattern;
10179 resource_cfg->keep_alive_pattern_size =
10180 tgt_res_cfg->keep_alive_pattern_size;
10181 resource_cfg->max_tdls_concurrent_sleep_sta =
10182 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
10183 resource_cfg->max_tdls_concurrent_buffer_sta =
10184 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
10185 resource_cfg->wmi_send_separate =
10186 tgt_res_cfg->wmi_send_separate;
10187 resource_cfg->num_ocb_vdevs =
10188 tgt_res_cfg->num_ocb_vdevs;
10189 resource_cfg->num_ocb_channels =
10190 tgt_res_cfg->num_ocb_channels;
10191 resource_cfg->num_ocb_schedules =
10192 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053010193 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
10194 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
10195 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Govind Singh9ddd5162016-03-07 16:30:32 +053010196}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053010197#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010198/**
10199 * send_init_cmd_tlv() - wmi init command
10200 * @wmi_handle: pointer to wmi handle
10201 * @res_cfg: resource config
10202 * @num_mem_chunks: no of mem chunck
10203 * @mem_chunk: pointer to mem chunck structure
10204 *
10205 * This function sends IE information to firmware
10206 *
Govind Singhb53420c2016-03-09 14:32:57 +053010207 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010208 *
10209 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010210static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053010211 wmi_resource_config *tgt_res_cfg,
10212 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
10213 bool action)
10214{
10215 wmi_buf_t buf;
10216 wmi_init_cmd_fixed_param *cmd;
10217 wmi_abi_version my_vers;
10218 int num_whitelist;
10219 uint8_t *buf_ptr;
10220 wmi_resource_config *resource_cfg;
10221 wlan_host_memory_chunk *host_mem_chunks;
10222 uint32_t mem_chunk_len = 0;
10223 uint16_t idx;
10224 int len;
10225 int ret;
10226
10227 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
10228 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
10229 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
10230 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010231 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
10232 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010233 }
10234
10235 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10236 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
10237 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
10238
10239 host_mem_chunks = (wlan_host_memory_chunk *)
10240 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
10241 + WMI_TLV_HDR_SIZE);
10242
10243 WMITLV_SET_HDR(&cmd->tlv_header,
10244 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
10245 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
10246
Govind Singhb53420c2016-03-09 14:32:57 +053010247 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053010248 WMITLV_SET_HDR(&resource_cfg->tlv_header,
10249 WMITLV_TAG_STRUC_wmi_resource_config,
10250 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
10251
10252 for (idx = 0; idx < num_mem_chunks; ++idx) {
10253 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
10254 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
10255 WMITLV_GET_STRUCT_TLVLEN
10256 (wlan_host_memory_chunk));
10257 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
10258 host_mem_chunks[idx].size = mem_chunks[idx].len;
10259 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053010260 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053010261 idx, host_mem_chunks[idx].size,
10262 host_mem_chunks[idx].ptr);
10263 }
10264 cmd->num_host_mem_chunks = num_mem_chunks;
10265 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
10266 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
10267 WMITLV_TAG_ARRAY_STRUC,
10268 (sizeof(wlan_host_memory_chunk) *
10269 num_mem_chunks));
10270
10271 num_whitelist = sizeof(version_whitelist) /
10272 sizeof(wmi_whitelist_version_info);
10273 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
10274 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
10275 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
10276 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
10277 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
10278 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053010279#ifdef CONFIG_MCL
10280 /* This needs to be enabled for WIN Lithium after removing dependency
10281 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053010282 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
10283 &my_vers,
10284 &wmi_handle->fw_abi_version,
10285 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053010286#endif
Govind Singhb53420c2016-03-09 14:32:57 +053010287 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053010288 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
10289 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
10290 cmd->host_abi_vers.abi_version_ns_0,
10291 cmd->host_abi_vers.abi_version_ns_1,
10292 cmd->host_abi_vers.abi_version_ns_2,
10293 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053010294#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010295 /* Save version sent from host -
10296 * Will be used to check ready event
10297 */
Govind Singhb53420c2016-03-09 14:32:57 +053010298 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010299 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010300#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010301 if (action) {
10302 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10303 WMI_INIT_CMDID);
10304 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010305 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053010306 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010307 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010308 }
10309 } else {
10310 wmi_handle->saved_wmi_init_cmd.buf = buf;
10311 wmi_handle->saved_wmi_init_cmd.buf_len = len;
10312 }
10313
Govind Singhb53420c2016-03-09 14:32:57 +053010314 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010315
10316}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053010317#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010318/**
10319 * send_saved_init_cmd_tlv() - wmi init command
10320 * @wmi_handle: pointer to wmi handle
10321 *
10322 * This function sends IE information to firmware
10323 *
Govind Singhb53420c2016-03-09 14:32:57 +053010324 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010325 *
10326 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010327static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053010328{
10329 int status;
10330
10331 if (!wmi_handle->saved_wmi_init_cmd.buf ||
10332 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053010333 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
10334 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010335 }
10336 status = wmi_unified_cmd_send(wmi_handle,
10337 wmi_handle->saved_wmi_init_cmd.buf,
10338 wmi_handle->saved_wmi_init_cmd.buf_len,
10339 WMI_INIT_CMDID);
10340 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053010341 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053010342 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010343 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010344 }
10345 wmi_handle->saved_wmi_init_cmd.buf = NULL;
10346 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
10347
Govind Singhb53420c2016-03-09 14:32:57 +053010348 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010349}
10350
Sathish Kumarfd347372017-02-13 12:29:09 +053010351static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053010352{
10353 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
10354 wmi_service_ready_event_fixed_param *ev;
10355
10356
10357 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
10358
10359 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
10360 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053010361 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010362
Govind Singh87542482016-06-08 19:40:11 +053010363#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010364 /*Save fw version from service ready message */
10365 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053010366 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010367 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010368#endif
Govind Singhb53420c2016-03-09 14:32:57 +053010369 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010370}
10371
10372/**
10373 * wmi_unified_save_fw_version_cmd() - save fw version
10374 * @wmi_handle: pointer to wmi handle
10375 * @res_cfg: resource config
10376 * @num_mem_chunks: no of mem chunck
10377 * @mem_chunk: pointer to mem chunck structure
10378 *
10379 * This function sends IE information to firmware
10380 *
Govind Singhb53420c2016-03-09 14:32:57 +053010381 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010382 *
10383 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010384static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053010385 void *evt_buf)
10386{
10387 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
10388 wmi_ready_event_fixed_param *ev = NULL;
10389
10390 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
10391 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053010392#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010393 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
10394 &ev->fw_abi_vers)) {
10395 /*
10396 * Error: Our host version and the given firmware version
10397 * are incompatible.
10398 **/
Govind Singhb53420c2016-03-09 14:32:57 +053010399 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053010400 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
10401 __func__,
10402 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
10403 abi_version_0),
10404 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
10405 abi_version_0),
10406 wmi_handle->final_abi_vers.abi_version_ns_0,
10407 wmi_handle->final_abi_vers.abi_version_ns_1,
10408 wmi_handle->final_abi_vers.abi_version_ns_2,
10409 wmi_handle->final_abi_vers.abi_version_ns_3,
10410 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
10411 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
10412 ev->fw_abi_vers.abi_version_ns_0,
10413 ev->fw_abi_vers.abi_version_ns_1,
10414 ev->fw_abi_vers.abi_version_ns_2,
10415 ev->fw_abi_vers.abi_version_ns_3);
10416
Govind Singhb53420c2016-03-09 14:32:57 +053010417 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010418 }
Govind Singhb53420c2016-03-09 14:32:57 +053010419 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010420 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053010421 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010422 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010423#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010424
Govind Singhb53420c2016-03-09 14:32:57 +053010425 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010426}
Govind Singha4836fd2016-03-07 16:45:38 +053010427
10428/**
10429 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
10430 * @wmi_handle: wmi handle
10431 * @custom_addr: base mac address
10432 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010433 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053010434 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010435static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010436 uint8_t *custom_addr)
10437{
10438 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
10439 wmi_buf_t buf;
10440 int err;
10441
10442 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10443 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010444 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010445 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010446 }
10447
10448 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010449 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053010450
10451 WMITLV_SET_HDR(&cmd->tlv_header,
10452 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
10453 WMITLV_GET_STRUCT_TLVLEN
10454 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
10455 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -070010456 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010457 err = wmi_unified_cmd_send(wmi_handle, buf,
10458 sizeof(*cmd),
10459 WMI_PDEV_SET_BASE_MACADDR_CMDID);
10460 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053010461 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053010462 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010463 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010464 }
10465
10466 return 0;
10467}
10468
10469/**
10470 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
10471 * @handle: wmi handle
10472 * @event: Event received from FW
10473 * @len: Length of the event
10474 *
10475 * Enables the low frequency events and disables the high frequency
10476 * events. Bit 17 indicates if the event if low/high frequency.
10477 * 1 - high frequency, 0 - low frequency
10478 *
10479 * Return: 0 on successfully enabling/disabling the events
10480 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010481static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010482 uint8_t *event,
10483 uint32_t len)
10484{
10485 uint32_t num_of_diag_events_logs;
10486 wmi_diag_event_log_config_fixed_param *cmd;
10487 wmi_buf_t buf;
10488 uint8_t *buf_ptr;
10489 uint32_t *cmd_args, *evt_args;
10490 uint32_t buf_len, i;
10491
10492 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
10493 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
10494
Govind Singhb53420c2016-03-09 14:32:57 +053010495 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053010496
10497 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
10498 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010499 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053010500 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010501 }
10502 wmi_event = param_buf->fixed_param;
10503 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
10504 evt_args = param_buf->diag_events_logs_list;
10505 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053010506 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010507 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053010508 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010509 }
10510
Govind Singhb53420c2016-03-09 14:32:57 +053010511 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010512 __func__, num_of_diag_events_logs);
10513
10514 /* Free any previous allocation */
10515 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053010516 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010517
10518 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053010519 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053010520 sizeof(uint32_t));
10521 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010522 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010523 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010524 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010525 }
10526 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
10527
10528 /* Prepare the send buffer */
10529 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10530 (num_of_diag_events_logs * sizeof(uint32_t));
10531
10532 buf = wmi_buf_alloc(wmi_handle, buf_len);
10533 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010534 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10535 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010536 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010537 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010538 }
10539
10540 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10541 buf_ptr = (uint8_t *) cmd;
10542
10543 WMITLV_SET_HDR(&cmd->tlv_header,
10544 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10545 WMITLV_GET_STRUCT_TLVLEN(
10546 wmi_diag_event_log_config_fixed_param));
10547
10548 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
10549
10550 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10551
10552 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10553 (num_of_diag_events_logs * sizeof(uint32_t)));
10554
10555 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10556
10557 /* Populate the events */
10558 for (i = 0; i < num_of_diag_events_logs; i++) {
10559 /* Low freq (0) - Enable (1) the event
10560 * High freq (1) - Disable (0) the event
10561 */
10562 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
10563 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
10564 /* Set the event ID */
10565 WMI_DIAG_ID_SET(cmd_args[i],
10566 WMI_DIAG_ID_GET(evt_args[i]));
10567 /* Set the type */
10568 WMI_DIAG_TYPE_SET(cmd_args[i],
10569 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053010570 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053010571 wmi_handle->events_logs_list[i] = evt_args[i];
10572 }
10573
10574 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
10575 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010576 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010577 __func__);
10578 wmi_buf_free(buf);
10579 /* Not clearing events_logs_list, though wmi cmd failed.
10580 * Host can still have this list
10581 */
Govind Singh67922e82016-04-01 16:48:57 +053010582 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010583 }
10584
10585 return 0;
10586}
10587
10588/**
10589 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
10590 * @wmi_handle: wmi handle
10591 * @start_log: Start logging related parameters
10592 *
10593 * Send the command to the FW based on which specific logging of diag
10594 * event/log id can be started/stopped
10595 *
10596 * Return: None
10597 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010598static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010599 struct wmi_wifi_start_log *start_log)
10600{
10601 wmi_diag_event_log_config_fixed_param *cmd;
10602 wmi_buf_t buf;
10603 uint8_t *buf_ptr;
10604 uint32_t len, count, log_level, i;
10605 uint32_t *cmd_args;
10606 uint32_t total_len;
10607 count = 0;
10608
10609 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010610 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053010611 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010612 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010613 }
10614 /* total_len stores the number of events where BITS 17 and 18 are set.
10615 * i.e., events of high frequency (17) and for extended debugging (18)
10616 */
10617 total_len = 0;
10618 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10619 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
10620 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
10621 total_len++;
10622 }
10623
10624 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10625 (total_len * sizeof(uint32_t));
10626
10627 buf = wmi_buf_alloc(wmi_handle, len);
10628 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010629 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010630 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010631 }
10632 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10633 buf_ptr = (uint8_t *) cmd;
10634
10635 WMITLV_SET_HDR(&cmd->tlv_header,
10636 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10637 WMITLV_GET_STRUCT_TLVLEN(
10638 wmi_diag_event_log_config_fixed_param));
10639
10640 cmd->num_of_diag_events_logs = total_len;
10641
10642 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10643
10644 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10645 (total_len * sizeof(uint32_t)));
10646
10647 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10648
Govind Singh224a7312016-06-21 14:33:26 +053010649 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053010650 log_level = 1;
10651 else
10652 log_level = 0;
10653
Govind Singhb53420c2016-03-09 14:32:57 +053010654 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053010655 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10656 uint32_t val = wmi_handle->events_logs_list[i];
10657 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
10658 (WMI_DIAG_EXT_FEATURE_GET(val))) {
10659
10660 WMI_DIAG_ID_SET(cmd_args[count],
10661 WMI_DIAG_ID_GET(val));
10662 WMI_DIAG_TYPE_SET(cmd_args[count],
10663 WMI_DIAG_TYPE_GET(val));
10664 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
10665 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053010666 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053010667 count++;
10668 }
10669 }
10670
10671 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10672 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010673 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010674 __func__);
10675 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010676 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010677 }
10678
Govind Singhb53420c2016-03-09 14:32:57 +053010679 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010680}
10681
10682/**
10683 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
10684 * @wmi_handle: WMI handle
10685 *
10686 * This function is used to send the flush command to the FW,
10687 * that will flush the fw logs that are residue in the FW
10688 *
10689 * Return: None
10690 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010691static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053010692{
10693 wmi_debug_mesg_flush_fixed_param *cmd;
10694 wmi_buf_t buf;
10695 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053010696 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010697
10698 buf = wmi_buf_alloc(wmi_handle, len);
10699 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010700 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010701 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010702 }
10703
10704 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
10705 WMITLV_SET_HDR(&cmd->tlv_header,
10706 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
10707 WMITLV_GET_STRUCT_TLVLEN(
10708 wmi_debug_mesg_flush_fixed_param));
10709 cmd->reserved0 = 0;
10710
10711 ret = wmi_unified_cmd_send(wmi_handle,
10712 buf,
10713 len,
10714 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010715 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010716 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053010717 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010718 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010719 }
Govind Singhb53420c2016-03-09 14:32:57 +053010720 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053010721
Govind Singh67922e82016-04-01 16:48:57 +053010722 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010723}
10724
10725/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010726 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010727 * @wmi_handle: wmi handle
10728 * @msg: PCL structure containing the PCL and the number of channels
10729 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010730 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053010731 * firmware. The DBS Manager is the consumer of this information in the WLAN
10732 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
10733 * to migrate to a new channel without host driver involvement. An example of
10734 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
10735 * manage the channel selection without firmware involvement.
10736 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010737 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
10738 * channel list. The weights corresponds to the channels sent in
10739 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
10740 * weightage compared to the non PCL channels.
10741 *
Govind Singha4836fd2016-03-07 16:45:38 +053010742 * Return: Success if the cmd is sent successfully to the firmware
10743 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010744static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010745 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053010746{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010747 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010748 wmi_buf_t buf;
10749 uint8_t *buf_ptr;
10750 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010751 uint32_t chan_len;
10752
10753 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053010754
10755 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010756 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053010757
10758 buf = wmi_buf_alloc(wmi_handle, len);
10759 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010760 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10761 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010762 }
10763
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010764 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010765 buf_ptr = (uint8_t *) cmd;
10766 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010767 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
10768 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053010769
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010770 cmd->pdev_id = WMI_PDEV_ID_SOC;
10771 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053010772 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010773
10774 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053010775 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010776 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053010777 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010778 for (i = 0; i < chan_len ; i++) {
10779 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053010780 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010781 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010782 }
10783 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010784 WMI_PDEV_SET_PCL_CMDID)) {
10785 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010786 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010787 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010788 }
Govind Singhb53420c2016-03-09 14:32:57 +053010789 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010790}
10791
10792/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010793 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010794 * @wmi_handle: wmi handle
10795 * @msg: Structure containing the following parameters
10796 *
10797 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
10798 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
10799 *
10800 * Provides notification to the WLAN firmware that host driver is requesting a
10801 * HardWare (HW) Mode change. This command is needed to support iHelium in the
10802 * configurations that include the Dual Band Simultaneous (DBS) feature.
10803 *
10804 * Return: Success if the cmd is sent successfully to the firmware
10805 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010806static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010807 uint32_t hw_mode_index)
10808{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010809 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010810 wmi_buf_t buf;
10811 uint32_t len;
10812
10813 len = sizeof(*cmd);
10814
10815 buf = wmi_buf_alloc(wmi_handle, len);
10816 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010817 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10818 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010819 }
10820
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010821 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010822 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010823 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
10824 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
10825
10826 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010827 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053010828 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053010829
10830 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010831 WMI_PDEV_SET_HW_MODE_CMDID)) {
10832 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010833 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010834 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010835 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010836 }
10837
Govind Singhb53420c2016-03-09 14:32:57 +053010838 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010839}
10840
10841/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010842 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010843 * @wmi_handle: wmi handle
10844 * @msg: Dual MAC config parameters
10845 *
10846 * Configures WLAN firmware with the dual MAC features
10847 *
Govind Singhb53420c2016-03-09 14:32:57 +053010848 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053010849 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010850static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010851QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010852 struct wmi_dual_mac_config *msg)
10853{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010854 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010855 wmi_buf_t buf;
10856 uint32_t len;
10857
10858 len = sizeof(*cmd);
10859
10860 buf = wmi_buf_alloc(wmi_handle, len);
10861 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010862 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10863 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010864 }
10865
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010866 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010867 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010868 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053010869 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010870 wmi_pdev_set_mac_config_cmd_fixed_param));
10871
10872 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010873 cmd->concurrent_scan_config_bits = msg->scan_config;
10874 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053010875 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053010876 __func__, msg->scan_config, msg->fw_mode_config);
10877
10878 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010879 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
10880 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010881 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010882 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010883 }
Govind Singhb53420c2016-03-09 14:32:57 +053010884 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010885}
10886
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053010887#ifdef BIG_ENDIAN_HOST
10888/**
10889* fips_conv_data_be() - LE to BE conversion of FIPS ev data
10890* @param data_len - data length
10891* @param data - pointer to data
10892*
10893* Return: QDF_STATUS - success or error status
10894*/
10895static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
10896 struct fips_params *param)
10897{
10898 unsigned char *key_unaligned, *data_unaligned;
10899 int c;
10900 u_int8_t *key_aligned = NULL;
10901 u_int8_t *data_aligned = NULL;
10902
10903 /* Assigning unaligned space to copy the key */
10904 key_unaligned = qdf_mem_malloc(
10905 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
10906 data_unaligned = qdf_mem_malloc(
10907 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
10908
10909 /* Checking if kmalloc is succesful to allocate space */
10910 if (key_unaligned == NULL)
10911 return QDF_STATUS_SUCCESS;
10912 /* Checking if space is aligned */
10913 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
10914 /* align to 4 */
10915 key_aligned =
10916 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
10917 FIPS_ALIGN);
10918 } else {
10919 key_aligned = (u_int8_t *)key_unaligned;
10920 }
10921
10922 /* memset and copy content from key to key aligned */
10923 OS_MEMSET(key_aligned, 0, param->key_len);
10924 OS_MEMCPY(key_aligned, param->key, param->key_len);
10925
10926 /* print a hexdump for host debug */
10927 print_hex_dump(KERN_DEBUG,
10928 "\t Aligned and Copied Key:@@@@ ",
10929 DUMP_PREFIX_NONE,
10930 16, 1, key_aligned, param->key_len, true);
10931
10932 /* Checking if kmalloc is succesful to allocate space */
10933 if (data_unaligned == NULL)
10934 return QDF_STATUS_SUCCESS;
10935 /* Checking of space is aligned */
10936 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
10937 /* align to 4 */
10938 data_aligned =
10939 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
10940 FIPS_ALIGN);
10941 } else {
10942 data_aligned = (u_int8_t *)data_unaligned;
10943 }
10944
10945 /* memset and copy content from data to data aligned */
10946 OS_MEMSET(data_aligned, 0, param->data_len);
10947 OS_MEMCPY(data_aligned, param->data, param->data_len);
10948
10949 /* print a hexdump for host debug */
10950 print_hex_dump(KERN_DEBUG,
10951 "\t Properly Aligned and Copied Data:@@@@ ",
10952 DUMP_PREFIX_NONE,
10953 16, 1, data_aligned, param->data_len, true);
10954
10955 /* converting to little Endian both key_aligned and
10956 * data_aligned*/
10957 for (c = 0; c < param->key_len/4; c++) {
10958 *((u_int32_t *)key_aligned+c) =
10959 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
10960 }
10961 for (c = 0; c < param->data_len/4; c++) {
10962 *((u_int32_t *)data_aligned+c) =
10963 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
10964 }
10965
10966 /* update endian data to key and data vectors */
10967 OS_MEMCPY(param->key, key_aligned, param->key_len);
10968 OS_MEMCPY(param->data, data_aligned, param->data_len);
10969
10970 /* clean up allocated spaces */
10971 qdf_mem_free(key_unaligned);
10972 key_unaligned = NULL;
10973 key_aligned = NULL;
10974
10975 qdf_mem_free(data_unaligned);
10976 data_unaligned = NULL;
10977 data_aligned = NULL;
10978
10979 return QDF_STATUS_SUCCESS;
10980}
10981#else
10982/**
10983* fips_align_data_be() - DUMMY for LE platform
10984*
10985* Return: QDF_STATUS - success
10986*/
10987static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
10988 struct fips_params *param)
10989{
10990 return QDF_STATUS_SUCCESS;
10991}
10992#endif
10993
10994
10995/**
10996 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
10997 * @wmi_handle: wmi handle
10998 * @param: pointer to hold pdev fips param
10999 *
11000 * Return: 0 for success or error code
11001 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011002static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011003send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
11004 struct fips_params *param)
11005{
11006 wmi_pdev_fips_cmd_fixed_param *cmd;
11007 wmi_buf_t buf;
11008 uint8_t *buf_ptr;
11009 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
11010 QDF_STATUS retval = QDF_STATUS_SUCCESS;
11011
11012 /* Length TLV placeholder for array of bytes */
11013 len += WMI_TLV_HDR_SIZE;
11014 if (param->data_len)
11015 len += (param->data_len*sizeof(uint8_t));
11016
11017 /*
11018 * Data length must be multiples of 16 bytes - checked against 0xF -
11019 * and must be less than WMI_SVC_MSG_SIZE - static size of
11020 * wmi_pdev_fips_cmd structure
11021 */
11022
11023 /* do sanity on the input */
11024 if (!(((param->data_len & 0xF) == 0) &&
11025 ((param->data_len > 0) &&
11026 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
11027 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
11028 return QDF_STATUS_E_INVAL;
11029 }
11030
11031 buf = wmi_buf_alloc(wmi_handle, len);
11032 if (!buf) {
11033 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
11034 return QDF_STATUS_E_FAILURE;
11035 }
11036
11037 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11038 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
11039 WMITLV_SET_HDR(&cmd->tlv_header,
11040 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
11041 WMITLV_GET_STRUCT_TLVLEN
11042 (wmi_pdev_fips_cmd_fixed_param));
11043
11044 cmd->pdev_id = param->pdev_id;
11045 if (param->key != NULL && param->data != NULL) {
11046 cmd->key_len = param->key_len;
11047 cmd->data_len = param->data_len;
11048 cmd->fips_cmd = !!(param->op);
11049
11050 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
11051 return QDF_STATUS_E_FAILURE;
11052
11053 qdf_mem_copy(cmd->key, param->key, param->key_len);
11054
11055 if (param->mode == FIPS_ENGINE_AES_CTR ||
11056 param->mode == FIPS_ENGINE_AES_MIC) {
11057 cmd->mode = param->mode;
11058 } else {
11059 cmd->mode = FIPS_ENGINE_AES_CTR;
11060 }
11061 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
11062 cmd->key_len, cmd->data_len);
11063
11064 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
11065 cmd->key, cmd->key_len, true);
11066 buf_ptr += sizeof(*cmd);
11067
11068 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
11069
11070 buf_ptr += WMI_TLV_HDR_SIZE;
11071 if (param->data_len)
11072 qdf_mem_copy(buf_ptr,
11073 (uint8_t *) param->data, param->data_len);
11074
11075 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
11076 16, 1, buf_ptr, cmd->data_len, true);
11077
11078 buf_ptr += param->data_len;
11079
11080 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11081 WMI_PDEV_FIPS_CMDID);
11082 qdf_print("%s return value %d\n", __func__, retval);
11083 } else {
11084 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
11085 wmi_buf_free(buf);
11086 retval = -QDF_STATUS_E_BADMSG;
11087 }
11088
11089 return retval;
11090}
11091
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011092#ifdef WLAN_PMO_ENABLE
11093/**
11094 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
11095 * @wmi_handle: wmi handle
11096 * @vdev_id: vdev id
11097 * @bitmap: Event bitmap
11098 * @enable: enable/disable
11099 *
11100 * Return: CDF status
11101 */
11102static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
11103 uint32_t vdev_id,
11104 uint32_t bitmap,
11105 bool enable)
11106{
11107 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
11108 uint16_t len;
11109 wmi_buf_t buf;
11110 int ret;
11111
11112 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
11113 buf = wmi_buf_alloc(wmi_handle, len);
11114 if (!buf) {
11115 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
11116 return QDF_STATUS_E_NOMEM;
11117 }
11118 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
11119 WMITLV_SET_HDR(&cmd->tlv_header,
11120 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
11121 WMITLV_GET_STRUCT_TLVLEN
11122 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
11123 cmd->vdev_id = vdev_id;
11124 cmd->is_add = enable;
11125 cmd->event_bitmap = bitmap;
11126
11127 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11128 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
11129 if (ret) {
11130 WMI_LOGE("Failed to config wow wakeup event");
11131 wmi_buf_free(buf);
11132 return QDF_STATUS_E_FAILURE;
11133 }
11134
11135 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
11136 enable ? "enabled" : "disabled");
11137
11138 return QDF_STATUS_SUCCESS;
11139}
11140
11141/**
11142 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
11143 * @wmi_handle: wmi handle
11144 * @vdev_id: vdev id
11145 * @ptrn_id: pattern id
11146 * @ptrn: pattern
11147 * @ptrn_len: pattern length
11148 * @ptrn_offset: pattern offset
11149 * @mask: mask
11150 * @mask_len: mask length
11151 * @user: true for user configured pattern and false for default pattern
11152 * @default_patterns: default patterns
11153 *
11154 * Return: CDF status
11155 */
11156static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
11157 uint8_t vdev_id, uint8_t ptrn_id,
11158 const uint8_t *ptrn, uint8_t ptrn_len,
11159 uint8_t ptrn_offset, const uint8_t *mask,
11160 uint8_t mask_len, bool user,
11161 uint8_t default_patterns)
11162{
11163 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
11164 WOW_BITMAP_PATTERN_T *bitmap_pattern;
11165 wmi_buf_t buf;
11166 uint8_t *buf_ptr;
11167 int32_t len;
11168 int ret;
11169
11170 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
11171 WMI_TLV_HDR_SIZE +
11172 1 * sizeof(WOW_BITMAP_PATTERN_T) +
11173 WMI_TLV_HDR_SIZE +
11174 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
11175 WMI_TLV_HDR_SIZE +
11176 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
11177 WMI_TLV_HDR_SIZE +
11178 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
11179 WMI_TLV_HDR_SIZE +
11180 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
11181
11182 buf = wmi_buf_alloc(wmi_handle, len);
11183 if (!buf) {
11184 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
11185 return QDF_STATUS_E_NOMEM;
11186 }
11187
11188 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
11189 buf_ptr = (uint8_t *) cmd;
11190
11191 WMITLV_SET_HDR(&cmd->tlv_header,
11192 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
11193 WMITLV_GET_STRUCT_TLVLEN
11194 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
11195 cmd->vdev_id = vdev_id;
11196 cmd->pattern_id = ptrn_id;
11197
11198 cmd->pattern_type = WOW_BITMAP_PATTERN;
11199 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
11200
11201 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11202 sizeof(WOW_BITMAP_PATTERN_T));
11203 buf_ptr += WMI_TLV_HDR_SIZE;
11204 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
11205
11206 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
11207 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
11208 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
11209
11210 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
11211 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
11212
11213 bitmap_pattern->pattern_offset = ptrn_offset;
11214 bitmap_pattern->pattern_len = ptrn_len;
11215
11216 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
11217 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
11218
11219 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
11220 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
11221
11222 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
11223 bitmap_pattern->pattern_id = ptrn_id;
11224
11225 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
11226 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
11227 bitmap_pattern->pattern_offset, user);
11228 WMI_LOGI("Pattern : ");
11229 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
11230 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
11231
11232 WMI_LOGI("Mask : ");
11233 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
11234 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
11235
11236 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
11237
11238 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
11239 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11240 buf_ptr += WMI_TLV_HDR_SIZE;
11241
11242 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
11243 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11244 buf_ptr += WMI_TLV_HDR_SIZE;
11245
11246 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
11247 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11248 buf_ptr += WMI_TLV_HDR_SIZE;
11249
11250 /* Fill TLV for pattern_info_timeout but no data. */
11251 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
11252 buf_ptr += WMI_TLV_HDR_SIZE;
11253
11254 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
11255 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
11256 buf_ptr += WMI_TLV_HDR_SIZE;
11257 *(A_UINT32 *) buf_ptr = 0;
11258
11259 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11260 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
11261 if (ret) {
11262 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
11263 wmi_buf_free(buf);
11264 return QDF_STATUS_E_FAILURE;
11265 }
11266
11267 return QDF_STATUS_SUCCESS;
11268}
11269
Govind Singha4836fd2016-03-07 16:45:38 +053011270/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011271 * fill_arp_offload_params_tlv() - Fill ARP offload data
11272 * @wmi_handle: wmi handle
11273 * @offload_req: offload request
11274 * @buf_ptr: buffer pointer
11275 *
11276 * To fill ARP offload data to firmware
11277 * when target goes to wow mode.
11278 *
11279 * Return: None
11280 */
11281static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011282 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011283{
11284
11285 int i;
11286 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011287 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011288
11289 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11290 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
11291 *buf_ptr += WMI_TLV_HDR_SIZE;
11292 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
11293 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
11294 WMITLV_SET_HDR(&arp_tuple->tlv_header,
11295 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
11296 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
11297
11298 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011299 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011300 /* Copy the target ip addr and flags */
11301 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
11302 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011303 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011304 WMI_IPV4_ADDR_LEN);
11305 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011306 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011307 }
11308 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
11309 }
11310}
11311
11312#ifdef WLAN_NS_OFFLOAD
11313/**
11314 * fill_ns_offload_params_tlv() - Fill NS offload data
11315 * @wmi|_handle: wmi handle
11316 * @offload_req: offload request
11317 * @buf_ptr: buffer pointer
11318 *
11319 * To fill NS offload data to firmware
11320 * when target goes to wow mode.
11321 *
11322 * Return: None
11323 */
11324static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011325 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011326{
11327
11328 int i;
11329 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011330
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011331 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11332 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
11333 *buf_ptr += WMI_TLV_HDR_SIZE;
11334 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
11335 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
11336 WMITLV_SET_HDR(&ns_tuple->tlv_header,
11337 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
11338 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
11339
11340 /*
11341 * Fill data only for NS offload in the first ARP tuple for LA
11342 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011343 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011344 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
11345 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011346 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011347 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011348 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011349 sizeof(WMI_IPV6_ADDR));
11350 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011351 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011352 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011353 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011354 ns_tuple->flags |=
11355 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
11356 }
11357 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011358 i, &ns_req->self_ipv6_addr[i],
11359 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011360
11361 /* target MAC is optional, check if it is valid,
11362 * if this is not valid, the target will use the known
11363 * local MAC address rather than the tuple
11364 */
11365 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011366 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011367 &ns_tuple->target_mac);
11368 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
11369 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
11370 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
11371 }
11372 }
11373 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
11374 }
11375}
11376
11377
11378/**
11379 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
11380 * @wmi: wmi handle
11381 * @offload_req: offload request
11382 * @buf_ptr: buffer pointer
11383 *
11384 * To fill extended NS offload extended data to firmware
11385 * when target goes to wow mode.
11386 *
11387 * Return: None
11388 */
11389static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011390 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011391{
11392 int i;
11393 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
11394 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011395
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011396 count = ns_req->num_ns_offload_count;
11397 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011398 WMI_MAX_NS_OFFLOADS;
11399
11400 /* Populate extended NS offload tuples */
11401 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11402 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
11403 *buf_ptr += WMI_TLV_HDR_SIZE;
11404 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
11405 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
11406 WMITLV_SET_HDR(&ns_tuple->tlv_header,
11407 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
11408 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
11409
11410 /*
11411 * Fill data only for NS offload in the first ARP tuple for LA
11412 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011413 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011414 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
11415 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011416 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011417 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011418 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011419 sizeof(WMI_IPV6_ADDR));
11420 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011421 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011422 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011423 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011424 ns_tuple->flags |=
11425 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
11426 }
11427 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011428 i, &ns_req->self_ipv6_addr[i],
11429 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011430
11431 /* target MAC is optional, check if it is valid,
11432 * if this is not valid, the target will use the
11433 * known local MAC address rather than the tuple
11434 */
11435 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011436 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011437 &ns_tuple->target_mac);
11438 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
11439 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
11440 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
11441 }
11442 }
11443 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
11444 }
11445}
11446#else
11447static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011448 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011449{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011450}
11451
11452static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011453 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011454{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011455}
11456#endif
11457
11458/**
Govind Singha4836fd2016-03-07 16:45:38 +053011459 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
11460 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011461 * @arp_offload_req: arp offload request
11462 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053011463 * @arp_only: flag
11464 *
11465 * To configure ARP NS off load data to firmware
11466 * when target goes to wow mode.
11467 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011468 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053011469 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011470static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011471 struct pmo_arp_offload_params *arp_offload_req,
11472 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053011473 uint8_t vdev_id)
11474{
Govind Singha4836fd2016-03-07 16:45:38 +053011475 int32_t res;
11476 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011477 A_UINT8 *buf_ptr;
11478 wmi_buf_t buf;
11479 int32_t len;
11480 uint32_t count = 0, num_ns_ext_tuples = 0;
11481
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011482 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053011483
Govind Singha4836fd2016-03-07 16:45:38 +053011484 /*
11485 * TLV place holder size for array of NS tuples
11486 * TLV place holder size for array of ARP tuples
11487 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011488 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
11489 WMI_TLV_HDR_SIZE +
11490 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
11491 WMI_TLV_HDR_SIZE +
11492 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053011493
11494 /*
11495 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
11496 * extra length for extended NS offload tuples which follows ARP offload
11497 * tuples. Host needs to fill this structure in following format:
11498 * 2 NS ofload tuples
11499 * 2 ARP offload tuples
11500 * N numbers of extended NS offload tuples if HDD has given more than
11501 * 2 NS offload addresses
11502 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011503 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053011504 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011505 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
11506 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053011507 }
11508
11509 buf = wmi_buf_alloc(wmi_handle, len);
11510 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011511 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053011512 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011513 }
11514
11515 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
11516 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
11517 WMITLV_SET_HDR(&cmd->tlv_header,
11518 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
11519 WMITLV_GET_STRUCT_TLVLEN
11520 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
11521 cmd->flags = 0;
11522 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011523 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053011524
Govind Singhb53420c2016-03-09 14:32:57 +053011525 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053011526
Govind Singha4836fd2016-03-07 16:45:38 +053011527 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011528 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
11529 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
11530 if (num_ns_ext_tuples)
11531 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053011532
11533 res = wmi_unified_cmd_send(wmi_handle, buf, len,
11534 WMI_SET_ARP_NS_OFFLOAD_CMDID);
11535 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053011536 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053011537 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011538 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011539 }
11540
Govind Singhb53420c2016-03-09 14:32:57 +053011541 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011542}
11543
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011544/**
11545 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
11546 * @wmi_handle: wmi handle
11547 * @vdev_id: vdev id
11548 * @action: true for enable else false
11549 *
11550 * To enable enhance multicast offload to firmware
11551 * when target goes to wow mode.
11552 *
11553 * Return: QDF Status
11554 */
11555
11556static
11557QDF_STATUS send_enable_enhance_multicast_offload_tlv(
11558 wmi_unified_t wmi_handle,
11559 uint8_t vdev_id, bool action)
11560{
11561 QDF_STATUS status;
11562 wmi_buf_t buf;
11563 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
11564
11565 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11566 if (!buf) {
11567 WMI_LOGE("Failed to allocate buffer to send set key cmd");
11568 return QDF_STATUS_E_NOMEM;
11569 }
11570
11571 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
11572 wmi_buf_data(buf);
11573
11574 WMITLV_SET_HDR(&cmd->tlv_header,
11575 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
11576 WMITLV_GET_STRUCT_TLVLEN(
11577 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
11578
11579 cmd->vdev_id = vdev_id;
11580 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
11581 ENHANCED_MCAST_FILTER_ENABLED);
11582 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
11583 __func__, action, vdev_id);
11584 status = wmi_unified_cmd_send(wmi_handle, buf,
11585 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
11586 if (status != QDF_STATUS_SUCCESS) {
11587 qdf_nbuf_free(buf);
11588 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
11589 __func__);
11590 }
11591
11592 return status;
11593}
11594
11595/**
11596 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
11597 * @wmi_handle: wmi handle
11598 * @param evt_buf: pointer to event buffer
11599 * @param hdr: Pointer to hold header
11600 * @param bufp: Pointer to hold pointer to rx param buffer
11601 *
11602 * Return: QDF_STATUS_SUCCESS for success or error code
11603 */
11604static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
11605 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
11606{
11607 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
11608 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
11609
11610 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
11611 if (!param_buf) {
11612 WMI_LOGE("gtk param_buf is NULL");
11613 return QDF_STATUS_E_INVAL;
11614 }
11615
11616 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
11617 WMI_LOGE("Invalid length for GTK status");
11618 return QDF_STATUS_E_INVAL;
11619 }
11620
11621 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
11622 param_buf->fixed_param;
11623 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
11624 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
11625 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
11626 qdf_mem_copy(&gtk_rsp_param->replay_counter,
11627 &fixed_param->replay_counter,
11628 GTK_REPLAY_COUNTER_BYTES);
11629
11630 return QDF_STATUS_SUCCESS;
11631
11632}
11633
11634#ifdef FEATURE_WLAN_RA_FILTERING
11635/**
11636 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
11637 * @wmi_handle: wmi handle
11638 * @vdev_id: vdev id
11639 *
11640 * Return: CDF status
11641 */
11642static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
11643 uint8_t vdev_id, uint8_t default_pattern,
11644 uint16_t rate_limit_interval)
11645{
11646
11647 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
11648 wmi_buf_t buf;
11649 uint8_t *buf_ptr;
11650 int32_t len;
11651 int ret;
11652
11653 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
11654 WMI_TLV_HDR_SIZE +
11655 0 * sizeof(WOW_BITMAP_PATTERN_T) +
11656 WMI_TLV_HDR_SIZE +
11657 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
11658 WMI_TLV_HDR_SIZE +
11659 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
11660 WMI_TLV_HDR_SIZE +
11661 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
11662 WMI_TLV_HDR_SIZE +
11663 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
11664
11665 buf = wmi_buf_alloc(wmi_handle, len);
11666 if (!buf) {
11667 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
11668 return QDF_STATUS_E_NOMEM;
11669 }
11670
11671 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
11672 buf_ptr = (uint8_t *) cmd;
11673
11674 WMITLV_SET_HDR(&cmd->tlv_header,
11675 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
11676 WMITLV_GET_STRUCT_TLVLEN
11677 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
11678 cmd->vdev_id = vdev_id;
11679 cmd->pattern_id = default_pattern,
11680 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
11681 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
11682
11683 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
11684 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11685 buf_ptr += WMI_TLV_HDR_SIZE;
11686
11687 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
11688 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11689 buf_ptr += WMI_TLV_HDR_SIZE;
11690
11691 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
11692 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11693 buf_ptr += WMI_TLV_HDR_SIZE;
11694
11695 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
11696 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11697 buf_ptr += WMI_TLV_HDR_SIZE;
11698
11699 /* Fill TLV for pattern_info_timeout but no data. */
11700 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
11701 buf_ptr += WMI_TLV_HDR_SIZE;
11702
11703 /* Fill TLV for ra_ratelimit_interval. */
11704 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
11705 buf_ptr += WMI_TLV_HDR_SIZE;
11706
11707 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
11708
11709 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
11710 rate_limit_interval, vdev_id);
11711
11712 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11713 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
11714 if (ret) {
11715 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
11716 wmi_buf_free(buf);
11717 return QDF_STATUS_E_FAILURE;
11718 }
11719
11720 return QDF_STATUS_SUCCESS;
11721
11722}
11723#endif /* FEATURE_WLAN_RA_FILTERING */
11724
11725/**
11726 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
11727 * @wmi_handle: wmi handle
11728 * @vdev_id: vdev id
11729 * @multicastAddr: mcast address
11730 * @clearList: clear list flag
11731 *
11732 * Return: QDF_STATUS_SUCCESS for success or error code
11733 */
11734static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
11735 uint8_t vdev_id,
11736 struct qdf_mac_addr multicast_addr,
11737 bool clearList)
11738{
11739 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
11740 wmi_buf_t buf;
11741 int err;
11742
11743 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11744 if (!buf) {
11745 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
11746 return QDF_STATUS_E_NOMEM;
11747 }
11748
11749 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
11750 qdf_mem_zero(cmd, sizeof(*cmd));
11751
11752 WMITLV_SET_HDR(&cmd->tlv_header,
11753 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
11754 WMITLV_GET_STRUCT_TLVLEN
11755 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
11756 cmd->action =
11757 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
11758 cmd->vdev_id = vdev_id;
11759 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
11760
11761 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
11762 cmd->action, vdev_id, clearList, multicast_addr.bytes);
11763
11764 err = wmi_unified_cmd_send(wmi_handle, buf,
11765 sizeof(*cmd),
11766 WMI_SET_MCASTBCAST_FILTER_CMDID);
11767 if (err) {
11768 WMI_LOGE("Failed to send set_param cmd");
11769 wmi_buf_free(buf);
11770 return QDF_STATUS_E_FAILURE;
11771 }
11772
11773 return QDF_STATUS_SUCCESS;
11774}
11775
11776/**
11777 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
11778 * @wmi_handle: wmi handle
11779 * @vdev_id: vdev id
11780 * @params: GTK offload parameters
11781 *
11782 * Return: CDF status
11783 */
11784static
11785QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
11786 struct pmo_gtk_req *params,
11787 bool enable_offload,
11788 uint32_t gtk_offload_opcode)
11789{
11790 int len;
11791 wmi_buf_t buf;
11792 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
11793 QDF_STATUS status = QDF_STATUS_SUCCESS;
11794
11795 WMI_LOGD("%s Enter", __func__);
11796
11797 len = sizeof(*cmd);
11798
11799 /* alloc wmi buffer */
11800 buf = wmi_buf_alloc(wmi_handle, len);
11801 if (!buf) {
11802 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
11803 status = QDF_STATUS_E_NOMEM;
11804 goto out;
11805 }
11806
11807 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
11808 WMITLV_SET_HDR(&cmd->tlv_header,
11809 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
11810 WMITLV_GET_STRUCT_TLVLEN
11811 (WMI_GTK_OFFLOAD_CMD_fixed_param));
11812
11813 cmd->vdev_id = vdev_id;
11814
11815 /* Request target to enable GTK offload */
11816 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
11817 cmd->flags = gtk_offload_opcode;
11818
11819 /* Copy the keys and replay counter */
11820 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
11821 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
11822 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
11823 GTK_REPLAY_COUNTER_BYTES);
11824 } else {
11825 cmd->flags = gtk_offload_opcode;
11826 }
11827
11828 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
11829
11830 /* send the wmi command */
11831 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11832 WMI_GTK_OFFLOAD_CMDID)) {
11833 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
11834 wmi_buf_free(buf);
11835 status = QDF_STATUS_E_FAILURE;
11836 }
11837
11838out:
11839 WMI_LOGD("%s Exit", __func__);
11840 return status;
11841}
11842
11843/**
11844 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
11845 * @wmi_handle: wmi handle
11846 * @params: GTK offload params
11847 *
11848 * Return: CDF status
11849 */
11850static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
11851 wmi_unified_t wmi_handle,
11852 uint8_t vdev_id,
11853 uint64_t offload_req_opcode)
11854{
11855 int len;
11856 wmi_buf_t buf;
11857 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
11858 QDF_STATUS status = QDF_STATUS_SUCCESS;
11859
11860 len = sizeof(*cmd);
11861
11862 /* alloc wmi buffer */
11863 buf = wmi_buf_alloc(wmi_handle, len);
11864 if (!buf) {
11865 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
11866 status = QDF_STATUS_E_NOMEM;
11867 goto out;
11868 }
11869
11870 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
11871 WMITLV_SET_HDR(&cmd->tlv_header,
11872 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
11873 WMITLV_GET_STRUCT_TLVLEN
11874 (WMI_GTK_OFFLOAD_CMD_fixed_param));
11875
11876 /* Request for GTK offload status */
11877 cmd->flags = offload_req_opcode;
11878 cmd->vdev_id = vdev_id;
11879
11880 /* send the wmi command */
11881 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11882 WMI_GTK_OFFLOAD_CMDID)) {
11883 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
11884 wmi_buf_free(buf);
11885 status = QDF_STATUS_E_FAILURE;
11886 }
11887
11888out:
11889 return status;
11890}
11891
11892/**
11893 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
11894 * @wmi_handle: wmi handler
11895 * @action_params: pointer to action_params
11896 *
11897 * Return: 0 for success, otherwise appropriate error code
11898 */
11899static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
11900 struct pmo_action_wakeup_set_params *action_params)
11901{
11902 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
11903 wmi_buf_t buf;
11904 int i;
11905 int32_t err;
11906
11907 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11908 if (!buf) {
11909 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
11910 return QDF_STATUS_E_NOMEM;
11911 }
11912 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
11913 WMITLV_SET_HDR(&cmd->tlv_header,
11914 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
11915 WMITLV_GET_STRUCT_TLVLEN(
11916 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
11917
11918 cmd->vdev_id = action_params->vdev_id;
11919 cmd->operation = action_params->operation;
11920
11921 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
11922 cmd->action_category_map[i] =
11923 action_params->action_category_map[i];
11924
11925 err = wmi_unified_cmd_send(wmi_handle, buf,
11926 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
11927 if (err) {
11928 WMI_LOGE("Failed to send ap_ps_egap cmd");
11929 wmi_buf_free(buf);
11930 return QDF_STATUS_E_FAILURE;
11931 }
11932
11933 return QDF_STATUS_SUCCESS;
11934}
11935
11936#ifdef FEATURE_WLAN_LPHB
11937
11938/**
11939 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
11940 * @wmi_handle: wmi handle
11941 * @lphb_conf_req: configuration info
11942 *
11943 * Return: CDF status
11944 */
11945static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
11946 wmi_hb_set_enable_cmd_fixed_param *params)
11947{
11948 QDF_STATUS status;
11949 wmi_buf_t buf = NULL;
11950 uint8_t *buf_ptr;
11951 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
11952 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
11953
11954
11955 buf = wmi_buf_alloc(wmi_handle, len);
11956 if (!buf) {
11957 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11958 return QDF_STATUS_E_NOMEM;
11959 }
11960
11961 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11962 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
11963 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
11964 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
11965 WMITLV_GET_STRUCT_TLVLEN
11966 (wmi_hb_set_enable_cmd_fixed_param));
11967
11968 /* fill in values */
11969 hb_enable_fp->vdev_id = params->session;
11970 hb_enable_fp->enable = params->enable;
11971 hb_enable_fp->item = params->item;
11972 hb_enable_fp->session = params->session;
11973
11974 status = wmi_unified_cmd_send(wmi_handle, buf,
11975 len, WMI_HB_SET_ENABLE_CMDID);
11976 if (QDF_IS_STATUS_ERROR(status)) {
11977 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
11978 status);
11979 wmi_buf_free(buf);
11980 }
11981
11982 return status;
11983}
11984
11985/**
11986 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
11987 * @wmi_handle: wmi handle
11988 * @lphb_conf_req: lphb config request
11989 *
11990 * Return: CDF status
11991 */
11992static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
11993 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
11994{
11995 QDF_STATUS status;
11996 wmi_buf_t buf = NULL;
11997 uint8_t *buf_ptr;
11998 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
11999 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
12000
12001 buf = wmi_buf_alloc(wmi_handle, len);
12002 if (!buf) {
12003 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12004 return QDF_STATUS_E_NOMEM;
12005 }
12006
12007 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12008 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
12009 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
12010 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
12011 WMITLV_GET_STRUCT_TLVLEN
12012 (wmi_hb_set_tcp_params_cmd_fixed_param));
12013
12014 /* fill in values */
12015 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
12016 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
12017 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
12018 hb_tcp_params_fp->seq = lphb_conf_req->seq;
12019 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
12020 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
12021 hb_tcp_params_fp->interval = lphb_conf_req->interval;
12022 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
12023 hb_tcp_params_fp->session = lphb_conf_req->session;
12024 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
12025 &lphb_conf_req->gateway_mac,
12026 sizeof(hb_tcp_params_fp->gateway_mac));
12027
12028 status = wmi_unified_cmd_send(wmi_handle, buf,
12029 len, WMI_HB_SET_TCP_PARAMS_CMDID);
12030 if (QDF_IS_STATUS_ERROR(status)) {
12031 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
12032 status);
12033 wmi_buf_free(buf);
12034 }
12035
12036 return status;
12037}
12038
12039/**
12040 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
12041 * @wmi_handle: wmi handle
12042 * @lphb_conf_req: lphb config request
12043 *
12044 * Return: CDF status
12045 */
12046static
12047QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
12048 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
12049{
12050 QDF_STATUS status;
12051 wmi_buf_t buf = NULL;
12052 uint8_t *buf_ptr;
12053 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
12054 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
12055
12056 buf = wmi_buf_alloc(wmi_handle, len);
12057 if (!buf) {
12058 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12059 return QDF_STATUS_E_NOMEM;
12060 }
12061
12062 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12063 hb_tcp_filter_fp =
12064 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
12065 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
12066 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
12067 WMITLV_GET_STRUCT_TLVLEN
12068 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
12069
12070 /* fill in values */
12071 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
12072 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
12073 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
12074 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
12075 memcpy((void *)&hb_tcp_filter_fp->filter,
12076 (void *)&g_hb_tcp_filter_fp->filter,
12077 WMI_WLAN_HB_MAX_FILTER_SIZE);
12078
12079 status = wmi_unified_cmd_send(wmi_handle, buf,
12080 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
12081 if (QDF_IS_STATUS_ERROR(status)) {
12082 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
12083 status);
12084 wmi_buf_free(buf);
12085 }
12086
12087 return status;
12088}
12089
12090/**
12091 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
12092 * @wmi_handle: wmi handle
12093 * @lphb_conf_req: lphb config request
12094 *
12095 * Return: CDF status
12096 */
12097static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
12098 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
12099{
12100 QDF_STATUS status;
12101 wmi_buf_t buf = NULL;
12102 uint8_t *buf_ptr;
12103 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
12104 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
12105
12106 buf = wmi_buf_alloc(wmi_handle, len);
12107 if (!buf) {
12108 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12109 return QDF_STATUS_E_NOMEM;
12110 }
12111
12112 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12113 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
12114 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
12115 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
12116 WMITLV_GET_STRUCT_TLVLEN
12117 (wmi_hb_set_udp_params_cmd_fixed_param));
12118
12119 /* fill in values */
12120 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
12121 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
12122 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
12123 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
12124 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
12125 hb_udp_params_fp->interval = lphb_conf_req->interval;
12126 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
12127 hb_udp_params_fp->session = lphb_conf_req->session;
12128 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
12129 &lphb_conf_req->gateway_mac,
12130 sizeof(lphb_conf_req->gateway_mac));
12131
12132 status = wmi_unified_cmd_send(wmi_handle, buf,
12133 len, WMI_HB_SET_UDP_PARAMS_CMDID);
12134 if (QDF_IS_STATUS_ERROR(status)) {
12135 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
12136 status);
12137 wmi_buf_free(buf);
12138 }
12139
12140 return status;
12141}
12142
12143/**
12144 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
12145 * @wmi_handle: wmi handle
12146 * @lphb_conf_req: lphb config request
12147 *
12148 * Return: CDF status
12149 */
12150static
12151QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
12152 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
12153{
12154 QDF_STATUS status;
12155 wmi_buf_t buf = NULL;
12156 uint8_t *buf_ptr;
12157 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
12158 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
12159
12160 buf = wmi_buf_alloc(wmi_handle, len);
12161 if (!buf) {
12162 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12163 return QDF_STATUS_E_NOMEM;
12164 }
12165
12166 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12167 hb_udp_filter_fp =
12168 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
12169 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
12170 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
12171 WMITLV_GET_STRUCT_TLVLEN
12172 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
12173
12174 /* fill in values */
12175 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
12176 hb_udp_filter_fp->length = lphb_conf_req->length;
12177 hb_udp_filter_fp->offset = lphb_conf_req->offset;
12178 hb_udp_filter_fp->session = lphb_conf_req->session;
12179 memcpy((void *)&hb_udp_filter_fp->filter,
12180 (void *)&lphb_conf_req->filter,
12181 WMI_WLAN_HB_MAX_FILTER_SIZE);
12182
12183 status = wmi_unified_cmd_send(wmi_handle, buf,
12184 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
12185 if (QDF_IS_STATUS_ERROR(status)) {
12186 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
12187 status);
12188 wmi_buf_free(buf);
12189 }
12190
12191 return status;
12192}
12193#endif /* FEATURE_WLAN_LPHB */
12194#endif /* End of WLAN_PMO_ENABLE */
12195
Sathish Kumarfd347372017-02-13 12:29:09 +053012196static QDF_STATUS send_enable_broadcast_filter_cmd_tlv(wmi_unified_t wmi_handle,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053012197 uint8_t vdev_id, bool enable)
12198{
12199 int32_t res;
12200 wmi_hw_data_filter_cmd_fixed_param *cmd;
12201 A_UINT8 *buf_ptr;
12202 wmi_buf_t buf;
12203 int32_t len;
12204
12205 /*
12206 * TLV place holder size for array of ARP tuples
12207 */
12208 len = sizeof(wmi_hw_data_filter_cmd_fixed_param);
12209
12210 buf = wmi_buf_alloc(wmi_handle, len);
12211 if (!buf) {
12212 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12213 return QDF_STATUS_E_NOMEM;
12214 }
12215
12216 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
12217 cmd = (wmi_hw_data_filter_cmd_fixed_param *) buf_ptr;
12218 WMITLV_SET_HDR(&cmd->tlv_header,
12219 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
12220 WMITLV_GET_STRUCT_TLVLEN
12221 (wmi_hw_data_filter_cmd_fixed_param));
12222 cmd->vdev_id = vdev_id;
12223 cmd->enable = enable;
12224 cmd->hw_filter_bitmap = WMI_HW_DATA_FILTER_DROP_NON_ARP_BC;
12225
12226 WMI_LOGD("HW Broadcast Filter vdev_id: %d", cmd->vdev_id);
12227
12228 res = wmi_unified_cmd_send(wmi_handle, buf, len,
12229 WMI_HW_DATA_FILTER_CMDID);
12230 if (res) {
12231 WMI_LOGE("Failed to enable ARP NDP/NSffload");
12232 wmi_buf_free(buf);
12233 return QDF_STATUS_E_FAILURE;
12234 }
12235
12236 return QDF_STATUS_SUCCESS;
12237}
12238
Govind Singha4836fd2016-03-07 16:45:38 +053012239/**
12240 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
12241 * @wmi_handle: wmi handle
12242 * @request: SSID hotlist set request
12243 *
Govind Singhb53420c2016-03-09 14:32:57 +053012244 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053012245 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012246static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053012247send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
12248 struct ssid_hotlist_request_params *request)
12249{
12250 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
12251 wmi_buf_t wmi_buf;
12252 uint32_t len;
12253 uint32_t array_size;
12254 uint8_t *buf_ptr;
12255
12256 /* length of fixed portion */
12257 len = sizeof(*cmd);
12258
12259 /* length of variable portion */
12260 array_size =
12261 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
12262 len += WMI_TLV_HDR_SIZE + array_size;
12263
12264 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12265 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012266 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12267 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012268 }
12269
12270 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
12271 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
12272 buf_ptr;
12273 WMITLV_SET_HDR
12274 (&cmd->tlv_header,
12275 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
12276 WMITLV_GET_STRUCT_TLVLEN
12277 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
12278
12279 cmd->request_id = request->request_id;
12280 cmd->requestor_id = 0;
12281 cmd->vdev_id = request->session_id;
12282 cmd->table_id = 0;
12283 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
12284 cmd->total_entries = request->ssid_count;
12285 cmd->num_entries_in_page = request->ssid_count;
12286 cmd->first_entry_index = 0;
12287
12288 buf_ptr += sizeof(*cmd);
12289 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
12290
12291 if (request->ssid_count) {
12292 wmi_extscan_hotlist_ssid_entry *entry;
12293 int i;
12294
12295 buf_ptr += WMI_TLV_HDR_SIZE;
12296 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
12297 for (i = 0; i < request->ssid_count; i++) {
12298 WMITLV_SET_HDR
12299 (entry,
12300 WMITLV_TAG_ARRAY_STRUC,
12301 WMITLV_GET_STRUCT_TLVLEN
12302 (wmi_extscan_hotlist_ssid_entry));
12303 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053012304 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053012305 request->ssids[i].ssid.mac_ssid,
12306 request->ssids[i].ssid.length);
12307 entry->band = request->ssids[i].band;
12308 entry->min_rssi = request->ssids[i].rssi_low;
12309 entry->max_rssi = request->ssids[i].rssi_high;
12310 entry++;
12311 }
12312 cmd->mode = WMI_EXTSCAN_MODE_START;
12313 } else {
12314 cmd->mode = WMI_EXTSCAN_MODE_STOP;
12315 }
12316
12317 if (wmi_unified_cmd_send
12318 (wmi_handle, wmi_buf, len,
12319 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012320 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053012321 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012322 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012323 }
12324
Govind Singhb53420c2016-03-09 14:32:57 +053012325 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012326}
12327
12328/**
12329 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
12330 * @wmi_handle: wmi handle
12331 * @vdev_id: vdev id
12332 *
12333 * This function sends roam synch complete event to fw.
12334 *
12335 * Return: CDF STATUS
12336 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012337static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012338 uint8_t vdev_id)
12339{
12340 wmi_roam_synch_complete_fixed_param *cmd;
12341 wmi_buf_t wmi_buf;
12342 uint8_t *buf_ptr;
12343 uint16_t len;
12344 len = sizeof(wmi_roam_synch_complete_fixed_param);
12345
12346 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12347 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012348 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12349 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012350 }
12351 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
12352 buf_ptr = (uint8_t *) cmd;
12353 WMITLV_SET_HDR(&cmd->tlv_header,
12354 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
12355 WMITLV_GET_STRUCT_TLVLEN
12356 (wmi_roam_synch_complete_fixed_param));
12357 cmd->vdev_id = vdev_id;
12358 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12359 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012360 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053012361 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012362 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012363 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012364 }
12365
Govind Singhb53420c2016-03-09 14:32:57 +053012366 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012367}
12368
12369/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053012370 * send_fw_test_cmd_tlv() - send fw test command to fw.
12371 * @wmi_handle: wmi handle
12372 * @wmi_fwtest: fw test command
12373 *
12374 * This function sends fw test command to fw.
12375 *
12376 * Return: CDF STATUS
12377 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012378static
Anurag Chouhan459e0152016-07-22 20:19:54 +053012379QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
12380 struct set_fwtest_params *wmi_fwtest)
12381{
12382 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12383 wmi_buf_t wmi_buf;
12384 uint16_t len;
12385
12386 len = sizeof(*cmd);
12387
12388 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12389 if (!wmi_buf) {
12390 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12391 return QDF_STATUS_E_NOMEM;
12392 }
12393
12394 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
12395 WMITLV_SET_HDR(&cmd->tlv_header,
12396 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12397 WMITLV_GET_STRUCT_TLVLEN(
12398 wmi_fwtest_set_param_cmd_fixed_param));
12399 cmd->param_id = wmi_fwtest->arg;
12400 cmd->param_value = wmi_fwtest->value;
12401
12402 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12403 WMI_FWTEST_CMDID)) {
12404 WMI_LOGP("%s: failed to send fw test command", __func__);
12405 qdf_nbuf_free(wmi_buf);
12406 return QDF_STATUS_E_FAILURE;
12407 }
12408
12409 return QDF_STATUS_SUCCESS;
12410}
12411
12412/**
Govind Singha4836fd2016-03-07 16:45:38 +053012413 * send_unit_test_cmd_tlv() - send unit test command to fw.
12414 * @wmi_handle: wmi handle
12415 * @wmi_utest: unit test command
12416 *
12417 * This function send unit test command to fw.
12418 *
12419 * Return: CDF STATUS
12420 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012421static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012422 struct wmi_unit_test_cmd *wmi_utest)
12423{
12424 wmi_unit_test_cmd_fixed_param *cmd;
12425 wmi_buf_t wmi_buf;
12426 uint8_t *buf_ptr;
12427 int i;
12428 uint16_t len, args_tlv_len;
12429 A_UINT32 *unit_test_cmd_args;
12430
12431 args_tlv_len =
12432 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
12433 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
12434
12435 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12436 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012437 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12438 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012439 }
12440
12441 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
12442 buf_ptr = (uint8_t *) cmd;
12443 WMITLV_SET_HDR(&cmd->tlv_header,
12444 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
12445 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
12446 cmd->vdev_id = wmi_utest->vdev_id;
12447 cmd->module_id = wmi_utest->module_id;
12448 cmd->num_args = wmi_utest->num_args;
12449 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
12450 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12451 (wmi_utest->num_args * sizeof(uint32_t)));
12452 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053012453 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053012454 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
12455 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053012456 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012457 }
12458 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12459 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012460 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012461 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012462 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012463 }
12464
Govind Singhb53420c2016-03-09 14:32:57 +053012465 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012466}
12467
12468/**
12469 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
12470 * @wmi_handle: wma handle
12471 * @roaminvoke: roam invoke command
12472 *
12473 * Send roam invoke command to fw for fastreassoc.
12474 *
12475 * Return: CDF STATUS
12476 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012477static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012478 struct wmi_roam_invoke_cmd *roaminvoke,
12479 uint32_t ch_hz)
12480{
12481 wmi_roam_invoke_cmd_fixed_param *cmd;
12482 wmi_buf_t wmi_buf;
12483 u_int8_t *buf_ptr;
12484 u_int16_t len, args_tlv_len;
12485 A_UINT32 *channel_list;
12486 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080012487 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053012488
12489 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080012490 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
12491 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
12492 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012493 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
12494 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12495 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012496 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12497 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012498 }
12499
12500 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
12501 buf_ptr = (u_int8_t *) cmd;
12502 WMITLV_SET_HDR(&cmd->tlv_header,
12503 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
12504 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
12505 cmd->vdev_id = roaminvoke->vdev_id;
12506 cmd->flags = 0;
Naveen Rawat77797922017-01-20 17:00:07 -080012507
12508 if (roaminvoke->frame_len)
12509 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
12510 else
12511 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
12512
Govind Singha4836fd2016-03-07 16:45:38 +053012513 cmd->roam_ap_sel_mode = 0;
12514 cmd->roam_delay = 0;
12515 cmd->num_chan = 1;
12516 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080012517 /* packing 1 beacon/probe_rsp frame with WMI cmd */
12518 cmd->num_buf = 1;
12519
Govind Singha4836fd2016-03-07 16:45:38 +053012520 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
12521 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12522 (sizeof(u_int32_t)));
12523 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
12524 *channel_list = ch_hz;
12525 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
12526 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
12527 (sizeof(wmi_mac_addr)));
12528 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
12529 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080012530
12531 /* move to next tlv i.e. bcn_prb_buf_list */
12532 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
12533
12534 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
12535 sizeof(wmi_tlv_buf_len_param));
12536
12537 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
12538 buf_len_tlv->buf_len = roaminvoke->frame_len;
12539
12540 /* move to next tlv i.e. bcn_prb_frm */
12541 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
12542 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
12543 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
12544
12545 /* copy frame after the header */
12546 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
12547 roaminvoke->frame_buf,
12548 roaminvoke->frame_len);
12549
12550 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
12551 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
12552 buf_ptr + WMI_TLV_HDR_SIZE,
12553 roaminvoke->frame_len);
12554
Govind Singha4836fd2016-03-07 16:45:38 +053012555 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12556 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012557 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053012558 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012559 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012560 }
12561
Govind Singhb53420c2016-03-09 14:32:57 +053012562 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012563}
12564
12565/**
12566 * send_roam_scan_offload_cmd_tlv() - set roam offload command
12567 * @wmi_handle: wmi handle
12568 * @command: command
12569 * @vdev_id: vdev id
12570 *
12571 * This function set roam offload command to fw.
12572 *
12573 * Return: CDF status
12574 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012575static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012576 uint32_t command, uint32_t vdev_id)
12577{
Govind Singh67922e82016-04-01 16:48:57 +053012578 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012579 wmi_roam_scan_cmd_fixed_param *cmd_fp;
12580 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053012581 int len;
12582 uint8_t *buf_ptr;
12583
12584 len = sizeof(wmi_roam_scan_cmd_fixed_param);
12585 buf = wmi_buf_alloc(wmi_handle, len);
12586 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012587 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12588 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012589 }
12590
12591 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12592
12593 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
12594 WMITLV_SET_HDR(&cmd_fp->tlv_header,
12595 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
12596 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
12597 cmd_fp->vdev_id = vdev_id;
12598 cmd_fp->command_arg = command;
12599
12600 status = wmi_unified_cmd_send(wmi_handle, buf,
12601 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053012602 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012603 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012604 status);
Govind Singha4836fd2016-03-07 16:45:38 +053012605 goto error;
12606 }
12607
Govind Singhb53420c2016-03-09 14:32:57 +053012608 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
12609 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012610
12611error:
12612 wmi_buf_free(buf);
12613
Govind Singh67922e82016-04-01 16:48:57 +053012614 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012615}
12616
12617/**
12618 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
12619 * @wmi_handle: wmi handle
12620 * @ap_profile_p: ap profile
12621 * @vdev_id: vdev id
12622 *
12623 * Send WMI_ROAM_AP_PROFILE to firmware
12624 *
12625 * Return: CDF status
12626 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012627static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012628 wmi_ap_profile *ap_profile_p,
12629 uint32_t vdev_id)
12630{
Govind Singha4836fd2016-03-07 16:45:38 +053012631 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012632 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012633 int len;
12634 uint8_t *buf_ptr;
12635 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
12636
12637 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
12638
12639 buf = wmi_buf_alloc(wmi_handle, len);
12640 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012641 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12642 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012643 }
12644
12645 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12646 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
12647 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
12648 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
12649 WMITLV_GET_STRUCT_TLVLEN
12650 (wmi_roam_ap_profile_fixed_param));
12651 /* fill in threshold values */
12652 roam_ap_profile_fp->vdev_id = vdev_id;
12653 roam_ap_profile_fp->id = 0;
12654 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
12655
Govind Singhb53420c2016-03-09 14:32:57 +053012656 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053012657 WMITLV_SET_HDR(buf_ptr,
12658 WMITLV_TAG_STRUC_wmi_ap_profile,
12659 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
12660 status = wmi_unified_cmd_send(wmi_handle, buf,
12661 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053012662 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012663 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012664 status);
Govind Singh67922e82016-04-01 16:48:57 +053012665 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012666 }
12667
Govind Singhb53420c2016-03-09 14:32:57 +053012668 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053012669
Govind Singh67922e82016-04-01 16:48:57 +053012670 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012671}
12672
12673/**
12674 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
12675 * @wmi_handle: wmi handle
12676 * @scan_period: scan period
12677 * @scan_age: scan age
12678 * @vdev_id: vdev id
12679 *
12680 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
12681 *
12682 * Return: CDF status
12683 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012684static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012685 uint32_t scan_period,
12686 uint32_t scan_age,
12687 uint32_t vdev_id)
12688{
Govind Singh67922e82016-04-01 16:48:57 +053012689 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012690 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053012691 int len;
12692 uint8_t *buf_ptr;
12693 wmi_roam_scan_period_fixed_param *scan_period_fp;
12694
12695 /* Send scan period values */
12696 len = sizeof(wmi_roam_scan_period_fixed_param);
12697 buf = wmi_buf_alloc(wmi_handle, len);
12698 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012699 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12700 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012701 }
12702
12703 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12704 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
12705 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
12706 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
12707 WMITLV_GET_STRUCT_TLVLEN
12708 (wmi_roam_scan_period_fixed_param));
12709 /* fill in scan period values */
12710 scan_period_fp->vdev_id = vdev_id;
12711 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
12712 scan_period_fp->roam_scan_age = scan_age;
12713
12714 status = wmi_unified_cmd_send(wmi_handle, buf,
12715 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053012716 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012717 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012718 status);
Govind Singha4836fd2016-03-07 16:45:38 +053012719 goto error;
12720 }
12721
Govind Singhb53420c2016-03-09 14:32:57 +053012722 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012723 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053012724 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012725error:
12726 wmi_buf_free(buf);
12727
Govind Singh67922e82016-04-01 16:48:57 +053012728 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012729}
12730
12731/**
12732 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
12733 * @wmi_handle: wmi handle
12734 * @chan_count: channel count
12735 * @chan_list: channel list
12736 * @list_type: list type
12737 * @vdev_id: vdev id
12738 *
12739 * Set roam offload channel list.
12740 *
12741 * Return: CDF status
12742 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012743static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012744 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070012745 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053012746 uint8_t list_type, uint32_t vdev_id)
12747{
Govind Singha4836fd2016-03-07 16:45:38 +053012748 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012749 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012750 int len, list_tlv_len;
12751 int i;
12752 uint8_t *buf_ptr;
12753 wmi_roam_chan_list_fixed_param *chan_list_fp;
12754 A_UINT32 *roam_chan_list_array;
12755
12756 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053012757 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053012758 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053012759 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053012760 }
12761 /* Channel list is a table of 2 TLV's */
12762 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
12763 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
12764 buf = wmi_buf_alloc(wmi_handle, len);
12765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012766 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12767 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012768 }
12769
12770 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12771 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
12772 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
12773 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
12774 WMITLV_GET_STRUCT_TLVLEN
12775 (wmi_roam_chan_list_fixed_param));
12776 chan_list_fp->vdev_id = vdev_id;
12777 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053012778 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053012779 /* external app is controlling channel list */
12780 chan_list_fp->chan_list_type =
12781 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
12782 } else {
12783 /* umac supplied occupied channel list in LFR */
12784 chan_list_fp->chan_list_type =
12785 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
12786 }
12787
12788 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
12789 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12790 (chan_list_fp->num_chan * sizeof(uint32_t)));
12791 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053012792 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053012793 for (i = 0; ((i < chan_list_fp->num_chan) &&
12794 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
12795 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053012796 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012797 }
12798
12799 status = wmi_unified_cmd_send(wmi_handle, buf,
12800 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053012801 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012802 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012803 status);
Govind Singha4836fd2016-03-07 16:45:38 +053012804 goto error;
12805 }
12806
Govind Singhb53420c2016-03-09 14:32:57 +053012807 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
12808 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012809error:
12810 wmi_buf_free(buf);
12811
Govind Singh67922e82016-04-01 16:48:57 +053012812 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012813}
12814
12815/**
12816 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
12817 * @wmi_handle: wmi handle
12818 * @rssi_change_thresh: RSSI Change threshold
12819 * @bcn_rssi_weight: beacon RSSI weight
12820 * @vdev_id: vdev id
12821 *
12822 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
12823 *
12824 * Return: CDF status
12825 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012826static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012827 uint32_t vdev_id,
12828 int32_t rssi_change_thresh,
12829 uint32_t bcn_rssi_weight,
12830 uint32_t hirssi_delay_btw_scans)
12831{
Govind Singha4836fd2016-03-07 16:45:38 +053012832 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012833 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053012834 int len;
12835 uint8_t *buf_ptr;
12836 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
12837
12838 /* Send rssi change parameters */
12839 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
12840 buf = wmi_buf_alloc(wmi_handle, len);
12841 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012842 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12843 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012844 }
12845
12846 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12847 rssi_change_fp =
12848 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
12849 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
12850 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
12851 WMITLV_GET_STRUCT_TLVLEN
12852 (wmi_roam_scan_rssi_change_threshold_fixed_param));
12853 /* fill in rssi change threshold (hysteresis) values */
12854 rssi_change_fp->vdev_id = vdev_id;
12855 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
12856 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
12857 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
12858
12859 status = wmi_unified_cmd_send(wmi_handle, buf,
12860 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053012861 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012862 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012863 status);
Govind Singha4836fd2016-03-07 16:45:38 +053012864 goto error;
12865 }
12866
Govind Singhb53420c2016-03-09 14:32:57 +053012867 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053012868 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053012869 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
12870 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012871error:
12872 wmi_buf_free(buf);
12873
Govind Singh67922e82016-04-01 16:48:57 +053012874 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053012875}
12876
12877/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
12878 * @wmi_handle: wmi handle.
12879 * @cmd: size of command structure.
12880 * @per_entry_size: per entry size.
12881 *
12882 * This utility function calculates how many hotlist entries can
12883 * fit in one page.
12884 *
12885 * Return: number of entries
12886 */
12887static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
12888 size_t cmd_size,
12889 size_t per_entry_size)
12890{
12891 uint32_t avail_space = 0;
12892 int num_entries = 0;
12893 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
12894
12895 /* Calculate number of hotlist entries that can
12896 * be passed in wma message request.
12897 */
12898 avail_space = max_msg_len - cmd_size;
12899 num_entries = avail_space / per_entry_size;
12900 return num_entries;
12901}
12902
12903/**
12904 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
12905 * @wmi_handle: wmi handle
12906 * @photlist: hotlist command params
12907 * @buf_len: buffer length
12908 *
12909 * This function fills individual elements for hotlist request and
12910 * TLV for bssid entries
12911 *
12912 * Return: CDF Status.
12913 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012914static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012915 struct ext_scan_setbssi_hotlist_params *
12916 photlist, int *buf_len)
12917{
12918 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
12919 wmi_extscan_hotlist_entry *dest_hotlist;
12920 struct ap_threshold_params *src_ap = photlist->ap;
12921 wmi_buf_t buf;
12922 uint8_t *buf_ptr;
12923
12924 int j, index = 0;
12925 int cmd_len = 0;
12926 int num_entries;
12927 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080012928 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053012929 int len = sizeof(*cmd);
12930
12931 len += WMI_TLV_HDR_SIZE;
12932 cmd_len = len;
12933
12934 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
12935 cmd_len,
12936 sizeof(*dest_hotlist));
12937 /* setbssid hotlist expects the bssid list
12938 * to be non zero value
12939 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080012940 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080012941 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053012942 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012943 }
12944
12945 /* Split the hot list entry pages and send multiple command
12946 * requests if the buffer reaches the maximum request size
12947 */
12948 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053012949 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053012950 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
12951 buf = wmi_buf_alloc(wmi_handle, len);
12952 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012953 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
12954 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012955 }
12956 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12957 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
12958 buf_ptr;
12959 WMITLV_SET_HDR(&cmd->tlv_header,
12960 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
12961 WMITLV_GET_STRUCT_TLVLEN
12962 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
12963
12964 /* Multiple requests are sent until the num_entries_in_page
12965 * matches the total_entries
12966 */
12967 cmd->request_id = photlist->requestId;
12968 cmd->vdev_id = photlist->sessionId;
12969 cmd->total_entries = numap;
12970 cmd->mode = 1;
12971 cmd->num_entries_in_page = min_entries;
12972 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
12973 cmd->first_entry_index = index;
12974
Govind Singhb53420c2016-03-09 14:32:57 +053012975 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053012976 __func__, cmd->vdev_id, cmd->total_entries,
12977 cmd->num_entries_in_page,
12978 cmd->lost_ap_scan_count);
12979
12980 buf_ptr += sizeof(*cmd);
12981 WMITLV_SET_HDR(buf_ptr,
12982 WMITLV_TAG_ARRAY_STRUC,
12983 min_entries * sizeof(wmi_extscan_hotlist_entry));
12984 dest_hotlist = (wmi_extscan_hotlist_entry *)
12985 (buf_ptr + WMI_TLV_HDR_SIZE);
12986
12987 /* Populate bssid, channel info and rssi
12988 * for the bssid's that are sent as hotlists.
12989 */
12990 for (j = 0; j < min_entries; j++) {
12991 WMITLV_SET_HDR(dest_hotlist,
12992 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
12993 WMITLV_GET_STRUCT_TLVLEN
12994 (wmi_extscan_hotlist_entry));
12995
12996 dest_hotlist->min_rssi = src_ap->low;
12997 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
12998 &dest_hotlist->bssid);
12999
Govind Singhb53420c2016-03-09 14:32:57 +053013000 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013001 __func__, dest_hotlist->channel,
13002 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053013003 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053013004 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
13005 __func__, dest_hotlist->bssid.mac_addr31to0,
13006 dest_hotlist->bssid.mac_addr47to32);
13007 dest_hotlist++;
13008 src_ap++;
13009 }
13010 buf_ptr += WMI_TLV_HDR_SIZE +
13011 (min_entries * sizeof(wmi_extscan_hotlist_entry));
13012
13013 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13014 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013015 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013016 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013017 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013018 }
13019 index = index + min_entries;
13020 num_entries = numap - min_entries;
13021 len = cmd_len;
13022 }
Govind Singhb53420c2016-03-09 14:32:57 +053013023 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013024}
13025
Govind Singhbca3b1b2016-05-02 17:59:24 +053013026/**
13027 * send_power_dbg_cmd_tlv() - send power debug commands
13028 * @wmi_handle: wmi handle
13029 * @param: wmi power debug parameter
13030 *
13031 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
13032 *
13033 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
13034 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013035static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
13036 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053013037{
13038 wmi_buf_t buf = NULL;
13039 QDF_STATUS status;
13040 int len, args_tlv_len;
13041 uint8_t *buf_ptr;
13042 uint8_t i;
13043 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
13044 uint32_t *cmd_args;
13045
13046 /* Prepare and send power debug cmd parameters */
13047 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
13048 len = sizeof(*cmd) + args_tlv_len;
13049 buf = wmi_buf_alloc(wmi_handle, len);
13050 if (!buf) {
13051 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13052 return QDF_STATUS_E_NOMEM;
13053 }
13054
13055 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13056 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
13057 WMITLV_SET_HDR(&cmd->tlv_header,
13058 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
13059 WMITLV_GET_STRUCT_TLVLEN
13060 (wmi_pdev_wal_power_debug_cmd_fixed_param));
13061
13062 cmd->pdev_id = param->pdev_id;
13063 cmd->module_id = param->module_id;
13064 cmd->num_args = param->num_args;
13065 buf_ptr += sizeof(*cmd);
13066 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13067 (param->num_args * sizeof(uint32_t)));
13068 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13069 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
13070 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
13071 cmd_args[i] = param->args[i];
13072 WMI_LOGI("%d,", param->args[i]);
13073 }
13074
13075 status = wmi_unified_cmd_send(wmi_handle, buf,
13076 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
13077 if (QDF_IS_STATUS_ERROR(status)) {
13078 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
13079 status);
13080 goto error;
13081 }
13082
13083 return QDF_STATUS_SUCCESS;
13084error:
13085 wmi_buf_free(buf);
13086
13087 return status;
13088}
13089
Kiran Venkatappa26117052016-12-23 19:58:54 +053013090/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13091 * @buf_ptr: pointer to current position in init command buffer
13092 * @len: pointer to length. This will be updated with current lenght of cmd
13093 * @param: point host parameters for init command
13094 *
13095 * Return: Updated pointer of buf_ptr.
13096 */
13097static inline uint8_t *copy_hw_mode_in_init_cmd(uint8_t *buf_ptr,
13098 int *len, struct wmi_init_cmd_param *param)
13099{
13100 uint16_t idx;
13101
13102 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13103 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13104 wmi_pdev_band_to_mac *band_to_mac;
13105
13106 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13107 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13108 sizeof(wmi_resource_config) +
13109 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13110 sizeof(wlan_host_memory_chunk)));
13111
13112 WMITLV_SET_HDR(&hw_mode->tlv_header,
13113 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13114 (WMITLV_GET_STRUCT_TLVLEN
13115 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13116
13117 hw_mode->hw_mode_index = param->hw_mode_id;
13118 hw_mode->num_band_to_mac = param->num_band_to_mac;
13119
13120 buf_ptr = (uint8_t *) (hw_mode + 1);
13121 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13122 WMI_TLV_HDR_SIZE);
13123 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13124 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13125 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13126 WMITLV_GET_STRUCT_TLVLEN
13127 (wmi_pdev_band_to_mac));
13128 band_to_mac[idx].pdev_id =
13129 param->band_to_mac[idx].pdev_id;
13130 band_to_mac[idx].start_freq =
13131 param->band_to_mac[idx].start_freq;
13132 band_to_mac[idx].end_freq =
13133 param->band_to_mac[idx].end_freq;
13134 }
13135 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13136 (param->num_band_to_mac *
13137 sizeof(wmi_pdev_band_to_mac)) +
13138 WMI_TLV_HDR_SIZE;
13139
13140 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13141 (param->num_band_to_mac *
13142 sizeof(wmi_pdev_band_to_mac)));
13143 }
13144
13145 return buf_ptr;
13146}
13147
Govind Singhe7f2f342016-05-23 12:12:52 +053013148/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053013149 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
13150 * @wmi_handle: wmi handle
13151 * @param: wmi multiple vdev restart req param
13152 *
13153 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
13154 *
13155 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
13156 */
13157static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
13158 wmi_unified_t wmi_handle,
13159 struct multiple_vdev_restart_params *param)
13160{
13161 wmi_buf_t buf;
13162 QDF_STATUS qdf_status;
13163 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
13164 int i;
13165 uint8_t *buf_ptr;
13166 uint32_t *vdev_ids;
13167 wmi_channel *chan_info;
13168 struct channel_param *tchan_info;
13169 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
13170
13171 len += sizeof(wmi_channel);
13172 if (param->num_vdevs)
13173 len += sizeof(uint32_t) * param->num_vdevs;
13174
13175 buf = wmi_buf_alloc(wmi_handle, len);
13176 if (!buf) {
13177 WMI_LOGE("Failed to allocate memory\n");
13178 qdf_status = QDF_STATUS_E_NOMEM;
13179 goto end;
13180 }
13181
13182 buf_ptr = (uint8_t *)wmi_buf_data(buf);
13183 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
13184 buf_ptr;
13185
13186 WMITLV_SET_HDR(&cmd->tlv_header,
13187 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
13188 WMITLV_GET_STRUCT_TLVLEN
13189 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
13190 cmd->pdev_id = param->pdev_id;
13191 cmd->requestor_id = param->requestor_id;
13192 cmd->disable_hw_ack = param->disable_hw_ack;
13193 cmd->cac_duration_ms = param->cac_duration_ms;
13194 cmd->num_vdevs = param->num_vdevs;
13195
13196 buf_ptr += sizeof(*cmd);
13197
13198 WMITLV_SET_HDR(buf_ptr,
13199 WMITLV_TAG_ARRAY_UINT32,
13200 sizeof(A_UINT32) * param->num_vdevs);
13201 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
13202 for (i = 0; i < param->num_vdevs; i++) {
13203 vdev_ids[i] = param->vdev_ids[i];
13204 }
13205
13206 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
13207
13208 WMITLV_SET_HDR(buf_ptr,
13209 WMITLV_TAG_STRUC_wmi_channel,
13210 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
13211 chan_info = (wmi_channel *)(buf_ptr + WMI_TLV_HDR_SIZE);
13212 tchan_info = &(param->ch_param);
13213 chan_info->mhz = tchan_info->mhz;
13214 chan_info->band_center_freq1 = tchan_info->cfreq1;
13215 chan_info->band_center_freq2 = tchan_info->cfreq2;
13216 if (tchan_info->is_chan_passive)
13217 WMI_SET_CHANNEL_FLAG(chan_info,
13218 WMI_CHAN_FLAG_PASSIVE);
13219 if (tchan_info->allow_vht)
13220 WMI_SET_CHANNEL_FLAG(chan_info,
13221 WMI_CHAN_FLAG_ALLOW_VHT);
13222 else if (tchan_info->allow_ht)
13223 WMI_SET_CHANNEL_FLAG(chan_info,
13224 WMI_CHAN_FLAG_ALLOW_HT);
13225 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
13226 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
13227 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
13228 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
13229 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
13230 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
13231
13232 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
13233 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
13234
13235 if (QDF_IS_STATUS_ERROR(qdf_status)) {
13236 WMI_LOGE("%s: Failed to send\n", __func__);
13237 wmi_buf_free(buf);
13238 }
13239
13240end:
13241 return qdf_status;
13242}
13243
13244/**
Govind Singhe7f2f342016-05-23 12:12:52 +053013245 * init_cmd_send_tlv() - send initialization cmd to fw
13246 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053013247 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053013248 *
13249 * Return: QDF_STATUS_SUCCESS for success or error code
13250 */
13251static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053013252 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053013253{
13254 wmi_buf_t buf;
13255 wmi_init_cmd_fixed_param *cmd;
13256 wmi_abi_version my_vers;
13257 int num_whitelist;
13258 uint8_t *buf_ptr;
13259 wmi_resource_config *resource_cfg;
13260 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053013261 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053013262 uint16_t idx;
13263 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053013264 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053013265
Kiran Venkatappa26117052016-12-23 19:58:54 +053013266 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
13267 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053013268 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053013269
13270 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
13271 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13272 WMI_TLV_HDR_SIZE +
13273 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
13274
13275 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053013276 if (!buf) {
13277 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13278 return QDF_STATUS_E_FAILURE;
13279 }
13280
13281 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13282 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
13283 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
13284
13285 host_mem_chunks = (wlan_host_memory_chunk *)
13286 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
13287 + WMI_TLV_HDR_SIZE);
13288
13289 WMITLV_SET_HDR(&cmd->tlv_header,
13290 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
13291 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
13292
Kiran Venkatappa26117052016-12-23 19:58:54 +053013293 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053013294 WMITLV_SET_HDR(&resource_cfg->tlv_header,
13295 WMITLV_TAG_STRUC_wmi_resource_config,
13296 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
13297
Kiran Venkatappa26117052016-12-23 19:58:54 +053013298 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053013299 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
13300 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
13301 WMITLV_GET_STRUCT_TLVLEN
13302 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053013303 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
13304 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
13305 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053013306 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
13307 idx, host_mem_chunks[idx].size,
13308 host_mem_chunks[idx].ptr);
13309 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053013310 cmd->num_host_mem_chunks = param->num_mem_chunks;
13311 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
13312
Govind Singhe7f2f342016-05-23 12:12:52 +053013313 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
13314 WMITLV_TAG_ARRAY_STRUC,
13315 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053013316 param->num_mem_chunks));
13317
13318 /* Fill hw mode id config */
13319 buf_ptr = copy_hw_mode_in_init_cmd(buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053013320
13321 num_whitelist = sizeof(version_whitelist) /
13322 sizeof(wmi_whitelist_version_info);
13323 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13324 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13325 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13326 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13327 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13328 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13329
Govind Singh87542482016-06-08 19:40:11 +053013330#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013331 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13332 &my_vers,
13333 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13334 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053013335#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053013336 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13337 __func__,
13338 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13339 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13340 cmd->host_abi_vers.abi_version_ns_0,
13341 cmd->host_abi_vers.abi_version_ns_1,
13342 cmd->host_abi_vers.abi_version_ns_2,
13343 cmd->host_abi_vers.abi_version_ns_3);
13344
13345 /* Save version sent from host -
13346 * Will be used to check ready event
13347 */
Govind Singh87542482016-06-08 19:40:11 +053013348#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013349 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13350 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053013351#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053013352 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
13353 if (QDF_IS_STATUS_ERROR(ret)) {
13354 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
13355 ret);
13356 wmi_buf_free(buf);
13357 }
13358 return ret;
13359
Govind Singhe7f2f342016-05-23 12:12:52 +053013360}
13361
13362/**
13363 * save_service_bitmap_tlv() - save service bitmap
13364 * @wmi_handle: wmi handle
13365 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080013366 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053013367 *
13368 * Return: None
13369 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013370#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013371static
Rajeev Kumar77901472017-02-12 02:12:17 -080013372void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
13373 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053013374{
13375 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13376 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13377
13378 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
13379 param_buf->wmi_service_bitmap,
13380 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080013381
13382 if (bitmap_buf)
13383 qdf_mem_copy(bitmap_buf,
13384 param_buf->wmi_service_bitmap,
13385 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053013386}
13387#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013388static
Rajeev Kumar77901472017-02-12 02:12:17 -080013389void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
13390 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053013391{
Rajeev Kumar77901472017-02-12 02:12:17 -080013392 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13393 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053013394
Rajeev Kumar77901472017-02-12 02:12:17 -080013395 if (bitmap_buf)
13396 qdf_mem_copy(bitmap_buf,
13397 param_buf->wmi_service_bitmap,
13398 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
13399}
Govind Singhe7f2f342016-05-23 12:12:52 +053013400#endif
13401
13402/**
13403 * is_service_enabled_tlv() - Check if service enabled
13404 * @param wmi_handle: wmi handle
13405 * @param service_id: service identifier
13406 *
13407 * Return: 1 enabled, 0 disabled
13408 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013409#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013410static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
13411 uint32_t service_id)
13412{
13413 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
13414 service_id);
13415}
13416#else
13417static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
13418 uint32_t service_id)
13419{
13420 return false;
13421}
13422#endif
13423
13424/**
13425 * extract_service_ready_tlv() - extract service ready event
13426 * @wmi_handle: wmi handle
13427 * @param evt_buf: pointer to received event buffer
13428 * @param cap: pointer to hold target capability information extracted from even
13429 *
13430 * Return: QDF_STATUS_SUCCESS for success or error code
13431 */
13432static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080013433 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053013434{
13435 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13436 wmi_service_ready_event_fixed_param *ev;
13437
13438
13439 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13440
13441 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13442 if (!ev) {
13443 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13444 return QDF_STATUS_E_FAILURE;
13445 }
13446
13447 cap->phy_capability = ev->phy_capability;
13448 cap->max_frag_entry = ev->max_frag_entry;
13449 cap->num_rf_chains = ev->num_rf_chains;
13450 cap->ht_cap_info = ev->ht_cap_info;
13451 cap->vht_cap_info = ev->vht_cap_info;
13452 cap->vht_supp_mcs = ev->vht_supp_mcs;
13453 cap->hw_min_tx_power = ev->hw_min_tx_power;
13454 cap->hw_max_tx_power = ev->hw_max_tx_power;
13455 cap->sys_cap_info = ev->sys_cap_info;
13456 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
13457 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
13458 cap->max_num_scan_channels = ev->max_num_scan_channels;
13459 cap->max_supported_macs = ev->max_supported_macs;
13460 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
13461 cap->txrx_chainmask = ev->txrx_chainmask;
13462 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
13463 cap->num_msdu_desc = ev->num_msdu_desc;
13464
13465 return QDF_STATUS_SUCCESS;
13466}
13467
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053013468/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
13469 * to host internal WMI_HOST_REGDMN_MODE values.
13470 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
13471 * host currently. Add this in the future if required.
13472 * 11AX (Phase II) : 11ax related values are not currently
13473 * advertised separately by FW. As part of phase II regulatory bring-up,
13474 * finalize the advertisement mechanism.
13475 * @target_wireless_mode: target wireless mode received in message
13476 *
13477 * Return: returns the host internal wireless mode.
13478 */
13479static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
13480{
13481
13482 uint32_t wireless_modes = 0;
13483
13484 if (target_wireless_mode & REGDMN_MODE_11A)
13485 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
13486
13487 if (target_wireless_mode & REGDMN_MODE_TURBO)
13488 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
13489
13490 if (target_wireless_mode & REGDMN_MODE_11B)
13491 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
13492
13493 if (target_wireless_mode & REGDMN_MODE_PUREG)
13494 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
13495
13496 if (target_wireless_mode & REGDMN_MODE_11G)
13497 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
13498
13499 if (target_wireless_mode & REGDMN_MODE_108G)
13500 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
13501
13502 if (target_wireless_mode & REGDMN_MODE_108A)
13503 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
13504
13505 if (target_wireless_mode & REGDMN_MODE_XR)
13506 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
13507
13508 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
13509 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
13510
13511 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
13512 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
13513
13514 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
13515 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
13516
13517 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
13518 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
13519
13520 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
13521 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
13522
13523 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
13524 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
13525
13526 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
13527 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
13528
13529 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
13530 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
13531
13532 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
13533 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
13534
13535 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
13536 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
13537
13538 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
13539 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
13540
13541 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
13542 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
13543
13544 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
13545 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
13546
13547 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
13548 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
13549
13550 return wireless_modes;
13551}
13552
Govind Singhe7f2f342016-05-23 12:12:52 +053013553/**
13554 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
13555 * @wmi_handle: wmi handle
13556 * @param evt_buf: Pointer to event buffer
13557 * @param cap: pointer to hold HAL reg capabilities
13558 *
13559 * Return: QDF_STATUS_SUCCESS for success or error code
13560 */
13561static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080013562 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053013563{
13564 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13565
13566 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13567
13568 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
13569 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080013570 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053013571
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053013572 cap->wireless_modes = convert_wireless_modes_tlv(
13573 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053013574
Govind Singhe7f2f342016-05-23 12:12:52 +053013575 return QDF_STATUS_SUCCESS;
13576}
13577
13578/**
13579 * extract_host_mem_req_tlv() - Extract host memory request event
13580 * @wmi_handle: wmi handle
13581 * @param evt_buf: pointer to event buffer
13582 * @param num_entries: pointer to hold number of entries requested
13583 *
13584 * Return: Number of entries requested
13585 */
13586static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
13587 void *evt_buf, uint8_t *num_entries)
13588{
13589 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13590 wmi_service_ready_event_fixed_param *ev;
13591
13592 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13593
13594 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13595 if (!ev) {
13596 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13597 return NULL;
13598 }
13599
13600 *num_entries = ev->num_mem_reqs;
13601
13602 return (host_mem_req *)param_buf->mem_reqs;
13603}
13604
13605/**
13606 * save_fw_version_in_service_ready_tlv() - Save fw version in service
13607 * ready function
13608 * @wmi_handle: wmi handle
13609 * @param evt_buf: pointer to event buffer
13610 *
13611 * Return: QDF_STATUS_SUCCESS for success or error code
13612 */
13613static QDF_STATUS
13614save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
13615{
13616 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13617 wmi_service_ready_event_fixed_param *ev;
13618
13619
13620 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13621
13622 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13623 if (!ev) {
13624 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13625 return QDF_STATUS_E_FAILURE;
13626 }
13627
Govind Singh87542482016-06-08 19:40:11 +053013628#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013629 /*Save fw version from service ready message */
13630 /*This will be used while sending INIT message */
13631 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
13632 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053013633#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053013634 return QDF_STATUS_SUCCESS;
13635}
13636
13637/**
13638 * ready_extract_init_status_tlv() - Extract init status from ready event
13639 * @wmi_handle: wmi handle
13640 * @param evt_buf: Pointer to event buffer
13641 *
13642 * Return: ready status
13643 */
13644static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
13645 void *evt_buf)
13646{
13647 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13648 wmi_ready_event_fixed_param *ev = NULL;
13649
13650
13651 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13652 ev = param_buf->fixed_param;
13653
13654 qdf_print("%s:%d\n", __func__, ev->status);
13655
13656 return ev->status;
13657}
13658
13659/**
13660 * ready_extract_mac_addr_tlv() - extract mac address from ready event
13661 * @wmi_handle: wmi handle
13662 * @param evt_buf: pointer to event buffer
13663 * @param macaddr: Pointer to hold MAC address
13664 *
13665 * Return: QDF_STATUS_SUCCESS for success or error code
13666 */
13667static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
13668 void *evt_buf, uint8_t *macaddr)
13669{
13670 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13671 wmi_ready_event_fixed_param *ev = NULL;
13672
13673
13674 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13675 ev = param_buf->fixed_param;
13676
13677 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
13678
13679 return QDF_STATUS_SUCCESS;
13680}
13681
13682/**
13683 * extract_dbglog_data_len_tlv() - extract debuglog data length
13684 * @wmi_handle: wmi handle
13685 * @param evt_buf: pointer to event buffer
13686 *
13687 * Return: length
13688 */
13689static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080013690 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053013691{
13692 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
13693
13694 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
13695
13696 *len = param_buf->num_bufp;
13697
13698 return param_buf->bufp;
13699}
13700
13701/**
13702 * extract_vdev_start_resp_tlv() - extract vdev start response
13703 * @wmi_handle: wmi handle
13704 * @param evt_buf: pointer to event buffer
13705 * @param vdev_rsp: Pointer to hold vdev response
13706 *
13707 * Return: QDF_STATUS_SUCCESS for success or error code
13708 */
13709static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
13710 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
13711{
13712 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
13713 wmi_vdev_start_response_event_fixed_param *ev;
13714
13715 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
13716 if (!param_buf) {
13717 qdf_print("Invalid start response event buffer\n");
13718 return QDF_STATUS_E_INVAL;
13719 }
13720
13721 ev = param_buf->fixed_param;
13722 if (!ev) {
13723 qdf_print("Invalid start response event buffer\n");
13724 return QDF_STATUS_E_INVAL;
13725 }
13726
13727 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
13728
13729 vdev_rsp->vdev_id = ev->vdev_id;
13730 vdev_rsp->requestor_id = ev->requestor_id;
13731 vdev_rsp->resp_type = ev->resp_type;
13732 vdev_rsp->status = ev->status;
13733 vdev_rsp->chain_mask = ev->chain_mask;
13734 vdev_rsp->smps_mode = ev->smps_mode;
13735 vdev_rsp->mac_id = ev->mac_id;
13736 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
13737 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
13738
13739 return QDF_STATUS_SUCCESS;
13740}
13741
13742/**
13743 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
13744 * @wmi_handle: wmi handle
13745 * @param evt_buf: pointer to event buffer
13746 * @param vdev_map: Pointer to hold vdev map
13747 * @param tbttoffset_list: Pointer to tbtt offset list
13748 *
13749 * Return: QDF_STATUS_SUCCESS for success or error code
13750 */
13751static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
13752 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
13753{
13754 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
13755 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
13756
13757 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
13758 if (!param_buf) {
13759 qdf_print("Invalid tbtt update event buffer\n");
13760 return QDF_STATUS_E_INVAL;
13761 }
13762 tbtt_offset_event = param_buf->fixed_param;
13763
13764 *vdev_map = tbtt_offset_event->vdev_map;
13765 *tbttoffset_list = param_buf->tbttoffset_list;
13766
13767 return QDF_STATUS_SUCCESS;
13768}
13769
13770/**
13771 * extract_mgmt_rx_params_tlv() - extract management rx params from event
13772 * @wmi_handle: wmi handle
13773 * @param evt_buf: pointer to event buffer
13774 * @param hdr: Pointer to hold header
13775 * @param bufp: Pointer to hold pointer to rx param buffer
13776 *
13777 * Return: QDF_STATUS_SUCCESS for success or error code
13778 */
13779static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053013780 void *evt_buf, struct mgmt_rx_event_params *hdr,
13781 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053013782{
13783 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
13784 wmi_mgmt_rx_hdr *ev_hdr = NULL;
13785
13786 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
13787 if (!param_tlvs) {
13788 WMI_LOGE("Get NULL point message from FW");
13789 return QDF_STATUS_E_INVAL;
13790 }
13791
13792 ev_hdr = param_tlvs->hdr;
13793 if (!hdr) {
13794 WMI_LOGE("Rx event is NULL");
13795 return QDF_STATUS_E_INVAL;
13796 }
13797
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013798 hdr->pdev_id = ev_hdr->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053013799
13800 hdr->channel = ev_hdr->channel;
13801 hdr->snr = ev_hdr->snr;
13802 hdr->rate = ev_hdr->rate;
13803 hdr->phy_mode = ev_hdr->phy_mode;
13804 hdr->buf_len = ev_hdr->buf_len;
13805 hdr->status = ev_hdr->status;
13806 hdr->flags = ev_hdr->flags;
13807 hdr->rssi = ev_hdr->rssi;
13808 hdr->tsf_delta = ev_hdr->tsf_delta;
13809 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
13810
13811 *bufp = param_tlvs->bufp;
13812
13813 return QDF_STATUS_SUCCESS;
13814}
13815
13816/**
13817 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
13818 * @wmi_handle: wmi handle
13819 * @param evt_buf: pointer to event buffer
13820 * @param vdev_id: Pointer to hold vdev identifier
13821 *
13822 * Return: QDF_STATUS_SUCCESS for success or error code
13823 */
13824static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
13825 void *evt_buf, uint32_t *vdev_id)
13826{
13827 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
13828 wmi_vdev_stopped_event_fixed_param *resp_event;
13829
13830 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
13831 if (!param_buf) {
13832 WMI_LOGE("Invalid event buffer");
13833 return QDF_STATUS_E_INVAL;
13834 }
13835 resp_event = param_buf->fixed_param;
13836 *vdev_id = resp_event->vdev_id;
13837
13838 return QDF_STATUS_SUCCESS;
13839}
13840
13841/**
13842 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
13843 * @wmi_handle: wmi handle
13844 * @param evt_buf: pointer to event buffer
13845 * @param param: Pointer to hold roam param
13846 *
13847 * Return: QDF_STATUS_SUCCESS for success or error code
13848 */
13849static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
13850 void *evt_buf, wmi_host_roam_event *param)
13851{
13852 WMI_ROAM_EVENTID_param_tlvs *param_buf;
13853 wmi_roam_event_fixed_param *evt;
13854
13855 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
13856 if (!param_buf) {
13857 WMI_LOGE("Invalid roam event buffer");
13858 return QDF_STATUS_E_INVAL;
13859 }
13860
13861 evt = param_buf->fixed_param;
13862 qdf_mem_zero(param, sizeof(*param));
13863
13864 param->vdev_id = evt->vdev_id;
13865 param->reason = evt->reason;
13866 param->rssi = evt->rssi;
13867
13868 return QDF_STATUS_SUCCESS;
13869}
13870
13871/**
13872 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
13873 * @wmi_handle: wmi handle
13874 * @param evt_buf: pointer to event buffer
13875 * @param param: Pointer to hold vdev scan param
13876 *
13877 * Return: QDF_STATUS_SUCCESS for success or error code
13878 */
13879static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
13880 void *evt_buf, wmi_host_scan_event *param)
13881{
13882 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
13883 wmi_scan_event_fixed_param *evt = NULL;
13884
13885 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
13886 evt = param_buf->fixed_param;
13887
13888 qdf_mem_zero(param, sizeof(*param));
13889 switch (evt->event) {
13890 case WMI_SCAN_EVENT_STARTED:
13891 param->event = WMI_HOST_SCAN_EVENT_STARTED;
13892 break;
13893 case WMI_SCAN_EVENT_COMPLETED:
13894 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
13895 break;
13896 case WMI_SCAN_EVENT_BSS_CHANNEL:
13897 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
13898 break;
13899 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
13900 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
13901 break;
13902 case WMI_SCAN_EVENT_DEQUEUED:
13903 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
13904 break;
13905 case WMI_SCAN_EVENT_PREEMPTED:
13906 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
13907 break;
13908 case WMI_SCAN_EVENT_START_FAILED:
13909 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
13910 break;
13911 case WMI_SCAN_EVENT_RESTARTED:
13912 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
13913 break;
13914 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
13915 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
13916 break;
13917 case WMI_SCAN_EVENT_MAX:
13918 default:
13919 param->event = WMI_HOST_SCAN_EVENT_MAX;
13920 break;
13921 };
13922
13923 switch (evt->reason) {
13924 case WMI_SCAN_REASON_NONE:
13925 param->reason = WMI_HOST_SCAN_REASON_NONE;
13926 break;
13927 case WMI_SCAN_REASON_COMPLETED:
13928 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
13929 break;
13930 case WMI_SCAN_REASON_CANCELLED:
13931 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
13932 break;
13933 case WMI_SCAN_REASON_PREEMPTED:
13934 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
13935 break;
13936 case WMI_SCAN_REASON_TIMEDOUT:
13937 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
13938 break;
13939 case WMI_SCAN_REASON_INTERNAL_FAILURE:
13940 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
13941 break;
13942 case WMI_SCAN_REASON_MAX:
13943 default:
13944 param->reason = WMI_HOST_SCAN_REASON_MAX;
13945 break;
13946 };
13947
13948 param->channel_freq = evt->channel_freq;
13949 param->requestor = evt->requestor;
13950 param->scan_id = evt->scan_id;
13951 param->vdev_id = evt->vdev_id;
13952
13953 return QDF_STATUS_SUCCESS;
13954}
13955
13956/**
13957 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
13958 * @wmi_handle: wmi handle
13959 * @param evt_buf: pointer to event buffer
13960 * @param param: Pointer to hold MGMT TX completion params
13961 *
13962 * Return: QDF_STATUS_SUCCESS for success or error code
13963 */
13964static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
13965 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
13966{
13967 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
13968 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
13969
13970 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
13971 evt_buf;
13972 if (!param_buf) {
13973 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
13974 return QDF_STATUS_E_INVAL;
13975 }
13976 cmpl_params = param_buf->fixed_param;
13977
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013978 param->pdev_id = cmpl_params->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053013979 param->desc_id = cmpl_params->desc_id;
13980 param->status = cmpl_params->status;
13981
13982 return QDF_STATUS_SUCCESS;
13983}
13984
13985/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053013986 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
13987 * status tlv
13988 * @wmi_handle: wmi handle
13989 * @param evt_buf: pointer to event buffer
13990 * @param param: Pointer to hold csa switch count status event param
13991 *
13992 * Return: QDF_STATUS_SUCCESS for success or error code
13993 */
13994static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
13995 wmi_unified_t wmi_handle,
13996 void *evt_buf,
13997 struct pdev_csa_switch_count_status *param)
13998{
13999 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
14000 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
14001
14002 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
14003 evt_buf;
14004 if (!param_buf) {
14005 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
14006 return QDF_STATUS_E_INVAL;
14007 }
14008
14009 csa_status = param_buf->fixed_param;
14010
14011 param->pdev_id = csa_status->pdev_id;
14012 param->current_switch_count = csa_status->current_switch_count;
14013 param->num_vdevs = csa_status->num_vdevs;
14014 param->vdev_ids = param_buf->vdev_ids;
14015
14016 return QDF_STATUS_SUCCESS;
14017}
14018
14019/**
Govind Singhe7f2f342016-05-23 12:12:52 +053014020 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
14021 * @wmi_handle: wmi handle
14022 * @param evt_buf: pointer to event buffer
14023 * @param vdev_map: Pointer to hold vdev map
14024 *
14025 * Return: QDF_STATUS_SUCCESS for success or error code
14026 */
14027static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
14028 void *evt_buf, uint32_t *vdev_map)
14029{
14030 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
14031 wmi_host_swba_event_fixed_param *swba_event;
14032
14033 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
14034 if (!param_buf) {
14035 WMI_LOGE("Invalid swba event buffer");
14036 return QDF_STATUS_E_INVAL;
14037 }
14038 swba_event = param_buf->fixed_param;
14039 *vdev_map = swba_event->vdev_map;
14040
14041 return QDF_STATUS_SUCCESS;
14042}
14043
14044/**
14045 * extract_swba_tim_info_tlv() - extract swba tim info from event
14046 * @wmi_handle: wmi handle
14047 * @param evt_buf: pointer to event buffer
14048 * @param idx: Index to bcn info
14049 * @param tim_info: Pointer to hold tim info
14050 *
14051 * Return: QDF_STATUS_SUCCESS for success or error code
14052 */
14053static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
14054 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
14055{
14056 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
14057 wmi_tim_info *tim_info_ev;
14058
14059 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
14060 if (!param_buf) {
14061 WMI_LOGE("Invalid swba event buffer");
14062 return QDF_STATUS_E_INVAL;
14063 }
14064
14065 tim_info_ev = &param_buf->tim_info[idx];
14066
14067 tim_info->tim_len = tim_info_ev->tim_len;
14068 tim_info->tim_mcast = tim_info_ev->tim_mcast;
14069 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
14070 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
14071 tim_info->tim_changed = tim_info_ev->tim_changed;
14072 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
14073
14074 return QDF_STATUS_SUCCESS;
14075}
14076
14077/**
14078 * extract_swba_noa_info_tlv() - extract swba NoA information from event
14079 * @wmi_handle: wmi handle
14080 * @param evt_buf: pointer to event buffer
14081 * @param idx: Index to bcn info
14082 * @param p2p_desc: Pointer to hold p2p NoA info
14083 *
14084 * Return: QDF_STATUS_SUCCESS for success or error code
14085 */
14086static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
14087 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
14088{
14089 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
14090 wmi_p2p_noa_info *p2p_noa_info;
14091 uint8_t i = 0;
14092
14093 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
14094 if (!param_buf) {
14095 WMI_LOGE("Invalid swba event buffer");
14096 return QDF_STATUS_E_INVAL;
14097 }
14098
14099 p2p_noa_info = &param_buf->p2p_noa_info[idx];
14100
14101 p2p_desc->modified = false;
14102 p2p_desc->num_descriptors = 0;
14103 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
14104 p2p_desc->modified = true;
14105 p2p_desc->index =
14106 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
14107 p2p_desc->oppPS =
14108 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
14109 p2p_desc->ctwindow =
14110 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
14111 p2p_desc->num_descriptors =
14112 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
14113 (p2p_noa_info);
14114 for (i = 0; i < p2p_desc->num_descriptors; i++) {
14115 p2p_desc->noa_descriptors[i].type_count =
14116 (uint8_t) p2p_noa_info->noa_descriptors[i].
14117 type_count;
14118 p2p_desc->noa_descriptors[i].duration =
14119 p2p_noa_info->noa_descriptors[i].duration;
14120 p2p_desc->noa_descriptors[i].interval =
14121 p2p_noa_info->noa_descriptors[i].interval;
14122 p2p_desc->noa_descriptors[i].start_time =
14123 p2p_noa_info->noa_descriptors[i].start_time;
14124 }
14125 }
14126
14127 return QDF_STATUS_SUCCESS;
14128}
14129
14130/**
14131 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
14132 * @wmi_handle: wmi handle
14133 * @param evt_buf: pointer to event buffer
14134 * @param ev: Pointer to hold peer param
14135 *
14136 * Return: QDF_STATUS_SUCCESS for success or error code
14137 */
14138static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
14139 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
14140{
14141 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
14142 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
14143
14144 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
14145 kickout_event = param_buf->fixed_param;
14146
14147 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
14148 ev->peer_macaddr);
14149
14150 ev->reason = kickout_event->reason;
14151 ev->rssi = kickout_event->rssi;
14152
14153 return QDF_STATUS_SUCCESS;
14154}
14155
14156/**
14157 * extract_all_stats_counts_tlv() - extract all stats count from event
14158 * @wmi_handle: wmi handle
14159 * @param evt_buf: pointer to event buffer
14160 * @param stats_param: Pointer to hold stats count
14161 *
14162 * Return: QDF_STATUS_SUCCESS for success or error code
14163 */
14164static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
14165 void *evt_buf, wmi_host_stats_event *stats_param)
14166{
14167 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14168 wmi_stats_event_fixed_param *ev;
14169
14170 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14171
14172 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14173 if (!ev) {
14174 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
14175 return QDF_STATUS_E_FAILURE;
14176 }
14177
14178 switch (ev->stats_id) {
14179 case WMI_REQUEST_PEER_STAT:
14180 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
14181 break;
14182
14183 case WMI_REQUEST_AP_STAT:
14184 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
14185 break;
14186
14187 case WMI_REQUEST_PDEV_STAT:
14188 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
14189 break;
14190
14191 case WMI_REQUEST_VDEV_STAT:
14192 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
14193 break;
14194
14195 case WMI_REQUEST_BCNFLT_STAT:
14196 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
14197 break;
14198
14199 case WMI_REQUEST_VDEV_RATE_STAT:
14200 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
14201 break;
14202
14203 default:
14204 stats_param->stats_id = 0;
14205 break;
14206
14207 }
14208
14209 stats_param->num_pdev_stats = ev->num_pdev_stats;
14210 stats_param->num_pdev_ext_stats = 0;
14211 stats_param->num_vdev_stats = ev->num_vdev_stats;
14212 stats_param->num_peer_stats = ev->num_peer_stats;
14213 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
14214 stats_param->num_chan_stats = ev->num_chan_stats;
14215
14216 return QDF_STATUS_SUCCESS;
14217}
14218
14219/**
14220 * extract_pdev_stats_tlv() - extract pdev stats from event
14221 * @wmi_handle: wmi handle
14222 * @param evt_buf: pointer to event buffer
14223 * @param index: Index into pdev stats
14224 * @param pdev_stats: Pointer to hold pdev stats
14225 *
14226 * Return: QDF_STATUS_SUCCESS for success or error code
14227 */
14228static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
14229 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
14230{
14231 return QDF_STATUS_SUCCESS;
14232}
14233
14234/**
14235 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
14236 * @wmi_handle: wmi handle
14237 * @param evt_buf: pointer to event buffer
14238 * @param index: Index into extended pdev stats
14239 * @param pdev_ext_stats: Pointer to hold extended pdev stats
14240 *
14241 * Return: QDF_STATUS_SUCCESS for success or error code
14242 */
14243static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
14244 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
14245{
14246 return QDF_STATUS_SUCCESS;
14247}
14248
14249/**
14250 * extract_vdev_stats_tlv() - extract vdev stats from event
14251 * @wmi_handle: wmi handle
14252 * @param evt_buf: pointer to event buffer
14253 * @param index: Index into vdev stats
14254 * @param vdev_stats: Pointer to hold vdev stats
14255 *
14256 * Return: QDF_STATUS_SUCCESS for success or error code
14257 */
14258static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
14259 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
14260{
14261 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14262 wmi_stats_event_fixed_param *ev_param;
14263 uint8_t *data;
14264
14265 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14266 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14267 data = (uint8_t *) param_buf->data;
14268
14269 if (index < ev_param->num_vdev_stats) {
14270 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
14271 ((ev_param->num_pdev_stats) *
14272 sizeof(wmi_pdev_stats)) +
14273 (index * sizeof(wmi_vdev_stats)));
14274
14275 vdev_stats->vdev_id = ev->vdev_id;
14276 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
14277 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
14278
14279 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
14280 sizeof(ev->tx_frm_cnt));
14281 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
14282 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
14283 ev->multiple_retry_cnt,
14284 sizeof(ev->multiple_retry_cnt));
14285 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
14286 sizeof(ev->fail_cnt));
14287 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
14288 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
14289 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
14290 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
14291 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
14292 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
14293 sizeof(ev->tx_rate_history));
14294 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
14295 sizeof(ev->bcn_rssi_history));
14296
14297 }
14298
14299 return QDF_STATUS_SUCCESS;
14300}
14301
14302/**
14303 * extract_peer_stats_tlv() - extract peer stats from event
14304 * @wmi_handle: wmi handle
14305 * @param evt_buf: pointer to event buffer
14306 * @param index: Index into peer stats
14307 * @param peer_stats: Pointer to hold peer stats
14308 *
14309 * Return: QDF_STATUS_SUCCESS for success or error code
14310 */
14311static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
14312 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
14313{
14314 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14315 wmi_stats_event_fixed_param *ev_param;
14316 uint8_t *data;
14317
14318 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14319 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14320 data = (uint8_t *) param_buf->data;
14321
14322 if (index < ev_param->num_peer_stats) {
14323 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
14324 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
14325 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
14326 (index * sizeof(wmi_peer_stats)));
14327
14328 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
14329
14330 OS_MEMCPY(&(peer_stats->peer_macaddr),
14331 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
14332
14333 peer_stats->peer_rssi = ev->peer_rssi;
14334 peer_stats->peer_tx_rate = ev->peer_tx_rate;
14335 peer_stats->peer_rx_rate = ev->peer_rx_rate;
14336 }
14337
14338 return QDF_STATUS_SUCCESS;
14339}
14340
14341/**
14342 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
14343 * @wmi_handle: wmi handle
14344 * @param evt_buf: pointer to event buffer
14345 * @param index: Index into bcn fault stats
14346 * @param bcnflt_stats: Pointer to hold bcn fault stats
14347 *
14348 * Return: QDF_STATUS_SUCCESS for success or error code
14349 */
14350static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
14351 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
14352{
14353 return QDF_STATUS_SUCCESS;
14354}
14355
14356/**
14357 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
14358 * @wmi_handle: wmi handle
14359 * @param evt_buf: pointer to event buffer
14360 * @param index: Index into extended peer stats
14361 * @param peer_extd_stats: Pointer to hold extended peer stats
14362 *
14363 * Return: QDF_STATUS_SUCCESS for success or error code
14364 */
14365static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
14366 void *evt_buf, uint32_t index,
14367 wmi_host_peer_extd_stats *peer_extd_stats)
14368{
14369 return QDF_STATUS_SUCCESS;
14370}
14371
14372/**
14373 * extract_chan_stats_tlv() - extract chan stats from event
14374 * @wmi_handle: wmi handle
14375 * @param evt_buf: pointer to event buffer
14376 * @param index: Index into chan stats
14377 * @param vdev_extd_stats: Pointer to hold chan stats
14378 *
14379 * Return: QDF_STATUS_SUCCESS for success or error code
14380 */
14381static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
14382 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
14383{
14384 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14385 wmi_stats_event_fixed_param *ev_param;
14386 uint8_t *data;
14387
14388 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14389 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14390 data = (uint8_t *) param_buf->data;
14391
14392 if (index < ev_param->num_chan_stats) {
14393 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
14394 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
14395 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
14396 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
14397 (index * sizeof(wmi_chan_stats)));
14398
14399
14400 /* Non-TLV doesnt have num_chan_stats */
14401 chan_stats->chan_mhz = ev->chan_mhz;
14402 chan_stats->sampling_period_us = ev->sampling_period_us;
14403 chan_stats->rx_clear_count = ev->rx_clear_count;
14404 chan_stats->tx_duration_us = ev->tx_duration_us;
14405 chan_stats->rx_duration_us = ev->rx_duration_us;
14406 }
14407
14408 return QDF_STATUS_SUCCESS;
14409}
14410
14411/**
14412 * extract_profile_ctx_tlv() - extract profile context from event
14413 * @wmi_handle: wmi handle
14414 * @param evt_buf: pointer to event buffer
14415 * @idx: profile stats index to extract
14416 * @param profile_ctx: Pointer to hold profile context
14417 *
14418 * Return: QDF_STATUS_SUCCESS for success or error code
14419 */
14420static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
14421 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
14422{
14423 return QDF_STATUS_SUCCESS;
14424}
14425
14426/**
14427 * extract_profile_data_tlv() - extract profile data from event
14428 * @wmi_handle: wmi handle
14429 * @param evt_buf: pointer to event buffer
14430 * @param profile_data: Pointer to hold profile data
14431 *
14432 * Return: QDF_STATUS_SUCCESS for success or error code
14433 */
14434static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
14435 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
14436{
14437
14438 return QDF_STATUS_SUCCESS;
14439}
14440
14441/**
14442 * extract_chan_info_event_tlv() - extract chan information from event
14443 * @wmi_handle: wmi handle
14444 * @param evt_buf: pointer to event buffer
14445 * @param chan_info: Pointer to hold chan information
14446 *
14447 * Return: QDF_STATUS_SUCCESS for success or error code
14448 */
14449static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
14450 void *evt_buf, wmi_host_chan_info_event *chan_info)
14451{
14452 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
14453 wmi_chan_info_event_fixed_param *ev;
14454
14455 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
14456
14457 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
14458 if (!ev) {
14459 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
14460 return QDF_STATUS_E_FAILURE;
14461 }
14462
14463 chan_info->err_code = ev->err_code;
14464 chan_info->freq = ev->freq;
14465 chan_info->cmd_flags = ev->cmd_flags;
14466 chan_info->noise_floor = ev->noise_floor;
14467 chan_info->rx_clear_count = ev->rx_clear_count;
14468 chan_info->cycle_count = ev->cycle_count;
14469
14470 return QDF_STATUS_SUCCESS;
14471}
14472
14473/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053014474 * extract_pdev_utf_event_tlv() - extract UTF data info from event
14475 * @wmi_handle: WMI handle
14476 * @param evt_buf: Pointer to event buffer
14477 * @param param: Pointer to hold data
14478 *
14479 * Return : QDF_STATUS_SUCCESS for success or error code
14480 */
14481static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
14482 uint8_t *evt_buf,
14483 struct wmi_host_pdev_utf_event *event)
14484{
14485 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
14486
14487 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
14488 event->data = param_buf->data;
14489 event->datalen = param_buf->num_data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053014490 /* Set pdev_id=1 until FW adds support to include pdev_id */
14491 event->pdev_id = 1;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053014492
14493 return QDF_STATUS_SUCCESS;
14494}
14495/**
Govind Singhe7f2f342016-05-23 12:12:52 +053014496 * extract_channel_hopping_event_tlv() - extract channel hopping param
14497 * from event
14498 * @wmi_handle: wmi handle
14499 * @param evt_buf: pointer to event buffer
14500 * @param ch_hopping: Pointer to hold channel hopping param
14501 *
14502 * Return: QDF_STATUS_SUCCESS for success or error code
14503 */
14504static QDF_STATUS extract_channel_hopping_event_tlv(wmi_unified_t wmi_handle,
14505 void *evt_buf, wmi_host_pdev_channel_hopping_event *chan_info)
14506{
14507 return QDF_STATUS_SUCCESS;
14508}
14509
Kiran Venkatappa06520822016-08-10 23:55:40 +053014510/**
14511 * extract_service_ready_ext_tlv() - extract basic extended service ready params
14512 * from event
14513 * @wmi_handle: wmi handle
14514 * @param evt_buf: pointer to event buffer
14515 * @param param: Pointer to hold evt buf
14516 *
14517 * Return: QDF_STATUS_SUCCESS for success or error code
14518 */
14519static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014520 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014521{
14522 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
14523 wmi_service_ready_ext_event_fixed_param *ev;
14524 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
14525 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
14526
14527 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14528 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014529 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014530
14531 ev = param_buf->fixed_param;
14532 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014533 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014534
14535 /* Move this to host based bitmap */
14536 param->default_conc_scan_config_bits =
14537 ev->default_conc_scan_config_bits;
14538 param->default_fw_config_bits = ev->default_fw_config_bits;
14539 param->he_cap_info = ev->he_cap_info;
14540 param->mpdu_density = ev->mpdu_density;
14541 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
14542 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
14543
14544 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014545 if (hw_caps)
14546 param->num_hw_modes = hw_caps->num_hw_modes;
14547 else
14548 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014549
14550 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014551 if (reg_caps)
14552 param->num_phy = reg_caps->num_phy;
14553 else
14554 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014555
14556 return QDF_STATUS_SUCCESS;
14557}
14558
14559/**
14560 * extract_hw_mode_cap_service_ready_ext_tlv() -
14561 * extract HW mode cap from service ready event
14562 * @wmi_handle: wmi handle
14563 * @param evt_buf: pointer to event buffer
14564 * @param param: Pointer to hold evt buf
14565 * @param hw_mode_idx: hw mode idx should be less than num_mode
14566 *
14567 * Return: QDF_STATUS_SUCCESS for success or error code
14568 */
14569static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
14570 wmi_unified_t wmi_handle,
14571 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014572 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014573{
14574 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
14575 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
14576
14577 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14578 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014579 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014580
14581 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014582 if (!hw_caps)
14583 return QDF_STATUS_E_INVAL;
14584
Kiran Venkatappa06520822016-08-10 23:55:40 +053014585 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014586 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014587
14588 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
14589 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
14590
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014591 param->hw_mode_config_type =
14592 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
14593
Kiran Venkatappa06520822016-08-10 23:55:40 +053014594 return QDF_STATUS_SUCCESS;
14595}
14596
14597/**
14598 * extract_mac_phy_cap_service_ready_ext_tlv() -
14599 * extract MAC phy cap from service ready event
14600 * @wmi_handle: wmi handle
14601 * @param evt_buf: pointer to event buffer
14602 * @param param: Pointer to hold evt buf
14603 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014604 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053014605 *
14606 * Return: QDF_STATUS_SUCCESS for success or error code
14607 */
14608static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
14609 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014610 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014611 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014612{
14613 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014614 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014615 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
14616 uint32_t phy_map;
14617 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014618
14619 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14620 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014621 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014622
14623 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014624 if (!hw_caps)
14625 return QDF_STATUS_E_INVAL;
14626
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014627 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
14628 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
14629 break;
14630
14631 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
14632 while (phy_map) {
14633 phy_map >>= 1;
14634 phy_idx++;
14635 }
14636 }
14637
14638 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014639 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014640
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014641 phy_idx += phy_id;
14642 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014643 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014644
14645 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053014646
14647 param->hw_mode_id = mac_phy_caps->hw_mode_id;
14648 param->pdev_id = mac_phy_caps->pdev_id;
14649 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053014650 param->supports_11b =
14651 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
14652 param->supports_11g =
14653 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
14654 param->supports_11a =
14655 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
14656 param->supports_11n =
14657 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
14658 param->supports_11ac =
14659 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
14660 param->supports_11ax =
14661 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053014662
14663 param->supported_bands = mac_phy_caps->supported_bands;
14664 param->ampdu_density = mac_phy_caps->ampdu_density;
14665 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
14666 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
14667 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
14668 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
14669 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
14670 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
14671 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
14672 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
14673 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
14674 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
14675 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
14676 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
14677 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
14678 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
14679 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
14680 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080014681 qdf_mem_copy(&param->he_cap_phy_info_2G,
14682 &mac_phy_caps->he_cap_phy_info_2G,
14683 sizeof(param->he_cap_phy_info_2G));
14684 qdf_mem_copy(&param->he_cap_phy_info_5G,
14685 &mac_phy_caps->he_cap_phy_info_5G,
14686 sizeof(param->he_cap_phy_info_5G));
14687 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
14688 sizeof(param->he_ppet2G));
14689 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
14690 sizeof(param->he_ppet5G));
Kiran Venkatappa06520822016-08-10 23:55:40 +053014691
14692 return QDF_STATUS_SUCCESS;
14693}
14694
14695/**
14696 * extract_reg_cap_service_ready_ext_tlv() -
14697 * extract REG cap from service ready event
14698 * @wmi_handle: wmi handle
14699 * @param evt_buf: pointer to event buffer
14700 * @param param: Pointer to hold evt buf
14701 * @param phy_idx: phy idx should be less than num_mode
14702 *
14703 * Return: QDF_STATUS_SUCCESS for success or error code
14704 */
14705static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
14706 wmi_unified_t wmi_handle,
14707 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014708 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053014709{
14710 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
14711 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
14712 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
14713
14714 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
14715 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014716 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014717
14718 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014719 if (!reg_caps)
14720 return QDF_STATUS_E_INVAL;
14721
Kiran Venkatappa06520822016-08-10 23:55:40 +053014722 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014723 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053014724
14725 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
14726
14727 param->phy_id = ext_reg_cap->phy_id;
14728 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
14729 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
14730 param->regcap1 = ext_reg_cap->regcap1;
14731 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053014732 param->wireless_modes = convert_wireless_modes_tlv(
14733 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053014734 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
14735 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
14736 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
14737 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
14738
14739 return QDF_STATUS_SUCCESS;
14740}
14741
Kiran Venkatappafea8a802016-12-29 18:09:32 +053014742/**
14743 * extract_dcs_interference_type_tlv() - extract dcs interference type
14744 * from event
14745 * @wmi_handle: wmi handle
14746 * @param evt_buf: pointer to event buffer
14747 * @param param: Pointer to hold dcs interference param
14748 *
14749 * Return: 0 for success or error code
14750 */
14751static QDF_STATUS extract_dcs_interference_type_tlv(
14752 wmi_unified_t wmi_handle,
14753 void *evt_buf, struct wmi_host_dcs_interference_param *param)
14754{
14755 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
14756
14757 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
14758 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014759 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053014760
14761 param->interference_type = param_buf->fixed_param->interference_type;
14762 param->pdev_id = param_buf->fixed_param->pdev_id;
14763
14764 return QDF_STATUS_SUCCESS;
14765}
14766
14767/*
14768 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
14769 * @wmi_handle: wmi handle
14770 * @param evt_buf: pointer to event buffer
14771 * @param cw_int: Pointer to hold cw interference
14772 *
14773 * Return: 0 for success or error code
14774 */
14775static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
14776 void *evt_buf,
14777 wmi_host_ath_dcs_cw_int *cw_int)
14778{
14779 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
14780 wlan_dcs_cw_int *ev;
14781
14782 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
14783 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014784 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053014785
14786 ev = param_buf->cw_int;
14787
14788 cw_int->channel = ev->channel;
14789
14790 return QDF_STATUS_SUCCESS;
14791}
14792
14793/**
14794 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
14795 * @wmi_handle: wmi handle
14796 * @param evt_buf: pointer to event buffer
14797 * @param wlan_stat: Pointer to hold wlan stats
14798 *
14799 * Return: 0 for success or error code
14800 */
14801static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
14802 void *evt_buf,
14803 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
14804{
14805 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
14806 wlan_dcs_im_tgt_stats_t *ev;
14807
14808 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
14809 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053014810 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053014811
14812 ev = param_buf->wlan_stat;
14813 wlan_stat->reg_tsf32 = ev->reg_tsf32;
14814 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
14815 wlan_stat->tx_waste_time = ev->tx_waste_time;
14816 wlan_stat->rx_time = ev->rx_time;
14817 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
14818 wlan_stat->mib_stats.listen_time = ev->listen_time;
14819 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
14820 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
14821 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
14822 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
14823 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
14824 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
14825 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
14826 wlan_stat->chan_nf = ev->chan_nf;
14827 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
14828
14829 return QDF_STATUS_SUCCESS;
14830}
14831
Kiran Venkatappac813ec92016-12-29 22:07:14 +053014832#ifdef BIG_ENDIAN_HOST
14833/**
14834 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
14835 * @param data_len - data length
14836 * @param data - pointer to data
14837 *
14838 * Return: QDF_STATUS - success or error status
14839 */
14840static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
14841{
14842 uint8_t *data_aligned = NULL;
14843 int c;
14844 unsigned char *data_unaligned;
14845
14846 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
14847 FIPS_ALIGN));
14848 /* Assigning unaligned space to copy the data */
14849 /* Checking if kmalloc does succesful allocation */
14850 if (data_unaligned == NULL)
14851 return QDF_STATUS_E_FAILURE;
14852
14853 /* Checking if space is alligned */
14854 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
14855 /* align the data space */
14856 data_aligned =
14857 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
14858 } else {
14859 data_aligned = (u_int8_t *)data_unaligned;
14860 }
14861
14862 /* memset and copy content from data to data aligned */
14863 OS_MEMSET(data_aligned, 0, data_len);
14864 OS_MEMCPY(data_aligned, data, data_len);
14865 /* Endianness to LE */
14866 for (c = 0; c < data_len/4; c++) {
14867 *((u_int32_t *)data_aligned + c) =
14868 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
14869 }
14870
14871 /* Copy content to event->data */
14872 OS_MEMCPY(data, data_aligned, data_len);
14873
14874 /* clean up allocated space */
14875 qdf_mem_free(data_unaligned);
14876 data_aligned = NULL;
14877 data_unaligned = NULL;
14878
14879 /*************************************************************/
14880
14881 return QDF_STATUS_SUCCESS;
14882}
14883#else
14884/**
14885 * fips_conv_data_be() - DUMMY for LE platform
14886 *
14887 * Return: QDF_STATUS - success
14888 */
14889static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
14890{
14891 return QDF_STATUS_SUCCESS;
14892}
14893#endif
14894
14895/**
14896 * extract_fips_event_data_tlv() - extract fips event data
14897 * @wmi_handle: wmi handle
14898 * @param evt_buf: pointer to event buffer
14899 * @param param: pointer FIPS event params
14900 *
14901 * Return: 0 for success or error code
14902 */
14903static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
14904 void *evt_buf, struct wmi_host_fips_event_param *param)
14905{
14906 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
14907 wmi_pdev_fips_event_fixed_param *event;
14908
14909 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
14910 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
14911
14912 if (fips_conv_data_be(event->data_len, param_buf->data) !=
14913 QDF_STATUS_SUCCESS)
14914 return QDF_STATUS_E_FAILURE;
14915
14916 param->data = (uint32_t *)param_buf->data;
14917 param->data_len = event->data_len;
14918 param->error_status = event->error_status;
14919
14920 return QDF_STATUS_SUCCESS;
14921}
14922
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053014923/*
14924 * extract_peer_delete_response_event_tlv() - extract peer delete response event
14925 * @wmi_handle: wmi handle
14926 * @param evt_buf: pointer to event buffer
14927 * @param vdev_id: Pointer to hold vdev_id
14928 * @param mac_addr: Pointer to hold peer mac address
14929 *
14930 * Return: QDF_STATUS_SUCCESS for success or error code
14931 */
14932static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
14933 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
14934{
14935 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
14936 wmi_peer_delete_resp_event_fixed_param *ev;
14937
14938 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
14939
14940 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
14941 if (!ev) {
14942 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
14943 return QDF_STATUS_E_FAILURE;
14944 }
14945
14946 param->vdev_id = ev->vdev_id;
14947 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
14948 &param->mac_address.bytes[0]);
14949
14950 return QDF_STATUS_SUCCESS;
14951}
14952
Govind Singhecf03cd2016-05-12 12:45:51 +053014953static bool is_management_record_tlv(uint32_t cmd_id)
14954{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053014955 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053014956 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053014957
Govind Singhecf03cd2016-05-12 12:45:51 +053014958 return false;
14959}
14960
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053014961static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
14962{
14963 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
14964
14965 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
14966
14967 switch (set_cmd->param_id) {
14968 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
14969 case WMI_VDEV_PARAM_DTIM_POLICY:
14970 return HTC_TX_PACKET_TAG_AUTO_PM;
14971 default:
14972 break;
14973 }
14974
14975 return 0;
14976}
14977
14978static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
14979{
14980 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
14981
14982 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
14983
14984 switch (ps_cmd->param) {
14985 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
14986 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
14987 case WMI_STA_PS_ENABLE_QPOWER:
14988 return HTC_TX_PACKET_TAG_AUTO_PM;
14989 default:
14990 break;
14991 }
14992
14993 return 0;
14994}
14995
14996static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
14997 uint32_t cmd_id)
14998{
14999 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
15000 return 0;
15001
15002 switch (cmd_id) {
15003 case WMI_VDEV_SET_PARAM_CMDID:
15004 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
15005 case WMI_STA_POWERSAVE_PARAM_CMDID:
15006 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
15007 default:
15008 break;
15009 }
15010
15011 return 0;
15012}
15013
15014static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
15015{
15016 uint16_t tag = 0;
15017
15018 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
15019 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
15020 __func__);
15021 return tag;
15022 }
15023
15024 if (wmi_handle->tag_crash_inject)
15025 tag = HTC_TX_PACKET_TAG_AUTO_PM;
15026
15027 wmi_handle->tag_crash_inject = false;
15028 return tag;
15029}
15030
15031/**
15032 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
15033 * @wmi_handle: WMI handle
15034 * @buf: WMI buffer
15035 * @cmd_id: WMI command Id
15036 *
15037 * Return htc_tx_tag
15038 */
15039static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
15040 wmi_buf_t buf,
15041 uint32_t cmd_id)
15042{
15043 uint16_t htc_tx_tag = 0;
15044
15045 switch (cmd_id) {
15046 case WMI_WOW_ENABLE_CMDID:
15047 case WMI_PDEV_SUSPEND_CMDID:
15048 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
15049 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
15050 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
15051 case WMI_PDEV_RESUME_CMDID:
15052 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
15053 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
15054#ifdef FEATURE_WLAN_D0WOW
15055 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
15056#endif
15057 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
15058 break;
15059 case WMI_FORCE_FW_HANG_CMDID:
15060 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
15061 break;
15062 case WMI_VDEV_SET_PARAM_CMDID:
15063 case WMI_STA_POWERSAVE_PARAM_CMDID:
15064 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
15065 default:
15066 break;
15067 }
15068
15069 return htc_tx_tag;
15070}
15071
Govind Singh5eb51532016-03-09 11:34:12 +053015072struct wmi_ops tlv_ops = {
15073 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
15074 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
15075 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053015076 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
15077 .send_hidden_ssid_vdev_restart_cmd =
15078 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053015079 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
15080 .send_peer_param_cmd = send_peer_param_cmd_tlv,
15081 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053015082 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053015083 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053015084 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070015085 .send_peer_rx_reorder_queue_setup_cmd =
15086 send_peer_rx_reorder_queue_setup_cmd_tlv,
15087 .send_peer_rx_reorder_queue_remove_cmd =
15088 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053015089 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
15090 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
15091 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053015092 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
15093 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
15094 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
15095 .send_suspend_cmd = send_suspend_cmd_tlv,
15096 .send_resume_cmd = send_resume_cmd_tlv,
15097 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
15098 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
15099 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
15100 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
15101 .send_dbglog_cmd = send_dbglog_cmd_tlv,
15102 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
15103 .send_stats_request_cmd = send_stats_request_cmd_tlv,
15104 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
15105 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053015106#ifndef CONFIG_MCL
15107 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
15108#endif
Govind Singh5eb51532016-03-09 11:34:12 +053015109 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
15110 .send_scan_start_cmd = send_scan_start_cmd_tlv,
15111 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
15112 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053015113 .send_mgmt_cmd = send_mgmt_cmd_tlv,
15114 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
15115 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015116 .send_set_sta_uapsd_auto_trig_cmd =
15117 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053015118 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
15119 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
15120 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
15121 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
15122 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053015123 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
15124 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
15125 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
15126 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
15127 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
15128 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
15129 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015130 .send_ocb_start_timing_advert_cmd =
15131 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053015132 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
15133 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
15134 .send_set_mcc_channel_time_latency_cmd =
15135 send_set_mcc_channel_time_latency_cmd_tlv,
15136 .send_set_mcc_channel_time_quota_cmd =
15137 send_set_mcc_channel_time_quota_cmd_tlv,
15138 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
15139 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053015140 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015141 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
15142 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
15143 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015144 .send_probe_rsp_tmpl_send_cmd =
15145 send_probe_rsp_tmpl_send_cmd_tlv,
15146 .send_p2p_go_set_beacon_ie_cmd =
15147 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053015148 .send_setup_install_key_cmd =
15149 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015150 .send_set_gateway_params_cmd =
15151 send_set_gateway_params_cmd_tlv,
15152 .send_set_rssi_monitoring_cmd =
15153 send_set_rssi_monitoring_cmd_tlv,
15154 .send_scan_probe_setoui_cmd =
15155 send_scan_probe_setoui_cmd_tlv,
15156 .send_reset_passpoint_network_list_cmd =
15157 send_reset_passpoint_network_list_cmd_tlv,
15158 .send_set_passpoint_network_list_cmd =
15159 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053015160 .send_roam_scan_offload_rssi_thresh_cmd =
15161 send_roam_scan_offload_rssi_thresh_cmd_tlv,
15162 .send_roam_scan_filter_cmd =
15163 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053015164 .send_set_epno_network_list_cmd =
15165 send_set_epno_network_list_cmd_tlv,
15166 .send_ipa_offload_control_cmd =
15167 send_ipa_offload_control_cmd_tlv,
15168 .send_extscan_get_capabilities_cmd =
15169 send_extscan_get_capabilities_cmd_tlv,
15170 .send_extscan_get_cached_results_cmd =
15171 send_extscan_get_cached_results_cmd_tlv,
15172 .send_extscan_stop_change_monitor_cmd =
15173 send_extscan_stop_change_monitor_cmd_tlv,
15174 .send_extscan_start_change_monitor_cmd =
15175 send_extscan_start_change_monitor_cmd_tlv,
15176 .send_extscan_stop_hotlist_monitor_cmd =
15177 send_extscan_stop_hotlist_monitor_cmd_tlv,
15178 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
15179 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
15180 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
15181 .send_plm_start_cmd = send_plm_start_cmd_tlv,
15182 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053015183#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053015184 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053015185#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053015186 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
15187 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
15188 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
15189 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
15190 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015191 .send_snr_request_cmd = send_snr_request_cmd_tlv,
15192 .send_snr_cmd = send_snr_cmd_tlv,
15193 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015194#ifdef WLAN_PMO_ENABLE
15195 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
15196 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
15197 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
15198 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
15199 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
15200 .send_process_gtk_offload_getinfo_cmd =
15201 send_process_gtk_offload_getinfo_cmd_tlv,
15202 .send_enable_enhance_multicast_offload_cmd =
15203 send_enable_enhance_multicast_offload_tlv,
15204 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
15205#ifdef FEATURE_WLAN_RA_FILTERING
15206 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
15207#endif
15208 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015209 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
15210 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015211 .send_lphb_config_tcp_pkt_filter_cmd =
15212 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015213 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
15214 .send_lphb_config_udp_pkt_filter_cmd =
15215 send_lphb_config_udp_pkt_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015216#endif /* End of WLAN_PMO_ENABLE */
15217#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053015218 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
15219 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
15220 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053015221 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
15222 .send_process_update_edca_param_cmd =
15223 send_process_update_edca_param_cmd_tlv,
15224 .send_roam_scan_offload_mode_cmd =
15225 send_roam_scan_offload_mode_cmd_tlv,
15226 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
15227 .send_roam_scan_offload_ap_profile_cmd =
15228 send_roam_scan_offload_ap_profile_cmd_tlv,
15229#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053015230 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
15231 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015232 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
15233 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
15234 .send_dfs_phyerr_filter_offload_en_cmd =
15235 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015236 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
15237 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
15238 .send_del_ts_cmd = send_del_ts_cmd_tlv,
15239 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
15240 .send_add_ts_cmd = send_add_ts_cmd_tlv,
15241 .send_enable_disable_packet_filter_cmd =
15242 send_enable_disable_packet_filter_cmd_tlv,
15243 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015244 .send_process_add_periodic_tx_ptrn_cmd =
15245 send_process_add_periodic_tx_ptrn_cmd_tlv,
15246 .send_process_del_periodic_tx_ptrn_cmd =
15247 send_process_del_periodic_tx_ptrn_cmd_tlv,
15248 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
15249 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
15250 .send_set_app_type2_params_in_fw_cmd =
15251 send_set_app_type2_params_in_fw_cmd_tlv,
15252 .send_set_auto_shutdown_timer_cmd =
15253 send_set_auto_shutdown_timer_cmd_tlv,
15254 .send_nan_req_cmd = send_nan_req_cmd_tlv,
15255 .send_process_dhcpserver_offload_cmd =
15256 send_process_dhcpserver_offload_cmd_tlv,
15257 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
15258 .send_process_ch_avoid_update_cmd =
15259 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053015260 .send_pdev_set_regdomain_cmd =
15261 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053015262 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
15263 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
15264 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
15265 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
15266 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
15267 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053015268#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053015269 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053015270#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053015271 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053015272 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053015273 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053015274 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053015275 .send_set_base_macaddr_indicate_cmd =
15276 send_set_base_macaddr_indicate_cmd_tlv,
15277 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
15278 .send_enable_specific_fw_logs_cmd =
15279 send_enable_specific_fw_logs_cmd_tlv,
15280 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053015281 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053015282 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053015283 .send_pdev_set_dual_mac_config_cmd =
15284 send_pdev_set_dual_mac_config_cmd_tlv,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015285 .send_enable_broadcast_filter_cmd =
15286 send_enable_broadcast_filter_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053015287 .send_app_type1_params_in_fw_cmd =
15288 send_app_type1_params_in_fw_cmd_tlv,
15289 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
15290 .send_process_roam_synch_complete_cmd =
15291 send_process_roam_synch_complete_cmd_tlv,
15292 .send_unit_test_cmd = send_unit_test_cmd_tlv,
15293 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
15294 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053015295 .send_roam_scan_offload_scan_period_cmd =
15296 send_roam_scan_offload_scan_period_cmd_tlv,
15297 .send_roam_scan_offload_chan_list_cmd =
15298 send_roam_scan_offload_chan_list_cmd_tlv,
15299 .send_roam_scan_offload_rssi_change_cmd =
15300 send_roam_scan_offload_rssi_change_cmd_tlv,
15301 .send_get_buf_extscan_hotlist_cmd =
15302 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053015303 .send_adapt_dwelltime_params_cmd =
15304 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053015305 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053015306 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
15307 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
15308 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
15309 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
15310 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
15311 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
15312 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
15313 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
15314 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053015315 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
15316 .send_smart_ant_set_training_info_cmd =
15317 send_smart_ant_set_training_info_cmd_tlv,
15318 .send_smart_ant_set_node_config_cmd =
15319 send_smart_ant_set_node_config_cmd_tlv,
15320 .send_set_atf_cmd = send_set_atf_cmd_tlv,
15321 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
15322 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053015323 .get_target_cap_from_service_ready = extract_service_ready_tlv,
15324 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
15325 .extract_host_mem_req = extract_host_mem_req_tlv,
15326 .save_service_bitmap = save_service_bitmap_tlv,
15327 .is_service_enabled = is_service_enabled_tlv,
15328 .save_fw_version = save_fw_version_in_service_ready_tlv,
15329 .ready_extract_init_status = ready_extract_init_status_tlv,
15330 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
15331 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
15332 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
15333 .extract_tbttoffset_update_params =
15334 extract_tbttoffset_update_params_tlv,
15335 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
15336 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
15337 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
15338 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
15339 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
15340 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
15341 .extract_swba_tim_info = extract_swba_tim_info_tlv,
15342 .extract_swba_noa_info = extract_swba_noa_info_tlv,
15343 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
15344 .extract_all_stats_count = extract_all_stats_counts_tlv,
15345 .extract_pdev_stats = extract_pdev_stats_tlv,
15346 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
15347 .extract_vdev_stats = extract_vdev_stats_tlv,
15348 .extract_peer_stats = extract_peer_stats_tlv,
15349 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
15350 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
15351 .extract_chan_stats = extract_chan_stats_tlv,
15352 .extract_profile_ctx = extract_profile_ctx_tlv,
15353 .extract_profile_data = extract_profile_data_tlv,
15354 .extract_chan_info_event = extract_chan_info_event_tlv,
15355 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053015356 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053015357 .send_encrypt_decrypt_send_cmd =
15358 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080015359 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053015360 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053015361 .send_multiple_vdev_restart_req_cmd =
15362 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053015363 .extract_service_ready_ext = extract_service_ready_ext_tlv,
15364 .extract_hw_mode_cap_service_ready_ext =
15365 extract_hw_mode_cap_service_ready_ext_tlv,
15366 .extract_mac_phy_cap_service_ready_ext =
15367 extract_mac_phy_cap_service_ready_ext_tlv,
15368 .extract_reg_cap_service_ready_ext =
15369 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053015370 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053015371 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015372 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
15373 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
15374 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053015375 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053015376 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053015377 .extract_peer_delete_response_event =
15378 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053015379 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053015380 .extract_pdev_csa_switch_count_status =
15381 extract_pdev_csa_switch_count_status_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053015382};
15383
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015384#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015385/**
15386 * populate_tlv_service() - populates wmi services
15387 *
15388 * @param wmi_service: Pointer to hold wmi_service
15389 * Return: None
15390 */
15391static void populate_tlv_service(uint32_t *wmi_service)
15392{
15393 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
15394 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
15395 wmi_service[wmi_service_roam_scan_offload] =
15396 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
15397 wmi_service[wmi_service_bcn_miss_offload] =
15398 WMI_SERVICE_BCN_MISS_OFFLOAD;
15399 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
15400 wmi_service[wmi_service_sta_advanced_pwrsave] =
15401 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
15402 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
15403 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
15404 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
15405 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
15406 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
15407 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
15408 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
15409 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
15410 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
15411 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
15412 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
15413 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
15414 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
15415 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
15416 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
15417 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
15418 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
15419 wmi_service[wmi_service_packet_power_save] =
15420 WMI_SERVICE_PACKET_POWER_SAVE;
15421 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
15422 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
15423 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
15424 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
15425 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
15426 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
15427 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
15428 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
15429 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
15430 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
15431 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
15432 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
15433 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
15434 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
15435 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
15436 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
15437 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
15438 wmi_service[wmi_service_mcc_bcn_interval_change] =
15439 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
15440 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
15441 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
15442 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
15443 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
15444 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
15445 wmi_service[wmi_service_lte_ant_share_support] =
15446 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
15447 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
15448 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
15449 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
15450 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
15451 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
15452 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
15453 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
15454 wmi_service[wmi_service_bcn_txrate_override] =
15455 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
15456 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
15457 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
15458 wmi_service[wmi_service_estimate_linkspeed] =
15459 WMI_SERVICE_ESTIMATE_LINKSPEED;
15460 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
15461 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
15462 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
15463 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
15464 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
15465 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
15466 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
15467 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
15468 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
15469 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
15470 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
15471 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
15472 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
15473 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
15474 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
15475 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
15476 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
15477 wmi_service[wmi_service_sap_auth_offload] =
15478 WMI_SERVICE_SAP_AUTH_OFFLOAD;
15479 wmi_service[wmi_service_dual_band_simultaneous_support] =
15480 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
15481 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
15482 wmi_service[wmi_service_ap_arpns_offload] =
15483 WMI_SERVICE_AP_ARPNS_OFFLOAD;
15484 wmi_service[wmi_service_per_band_chainmask_support] =
15485 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
15486 wmi_service[wmi_service_packet_filter_offload] =
15487 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
15488 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
15489 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
15490 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
15491 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015492 wmi_service[wmi_service_multiple_vdev_restart] =
15493 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
Govind Singhe7f2f342016-05-23 12:12:52 +053015494
15495 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
15496 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
15497 wmi_service[wmi_service_smart_antenna_sw_support] =
15498 WMI_SERVICE_UNAVAILABLE;
15499 wmi_service[wmi_service_smart_antenna_hw_support] =
15500 WMI_SERVICE_UNAVAILABLE;
15501 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
15502 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
15503 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
15504 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
15505 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
15506 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
15507 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
15508 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
15509 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
15510 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
15511 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
15512
15513 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
15514 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
15515 wmi_service[wmi_service_periodic_chan_stat_support] =
15516 WMI_SERVICE_UNAVAILABLE;
15517 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
15518 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
15519 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
Sathish Kumar699f6b52016-11-10 15:30:22 +053015520 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
Sathish Kumar58a9fb92017-01-19 14:57:37 +053015521 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053015522 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Govind Singhe7f2f342016-05-23 12:12:52 +053015523}
15524
15525/**
15526 * populate_tlv_event_id() - populates wmi event ids
15527 *
15528 * @param event_ids: Pointer to hold event ids
15529 * Return: None
15530 */
15531static void populate_tlv_events_id(uint32_t *event_ids)
15532{
15533 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
15534 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
15535 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
15536 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
15537 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
15538 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
15539 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
15540 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
15541 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
15542 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
15543 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
15544 event_ids[wmi_service_ready_ext_event_id] =
15545 WMI_SERVICE_READY_EXT_EVENTID;
15546 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
15547 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
15548 event_ids[wmi_vdev_install_key_complete_event_id] =
15549 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
15550 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
15551 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
15552
15553 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
15554 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
15555 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
15556 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
15557 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
15558 event_ids[wmi_peer_estimated_linkspeed_event_id] =
15559 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
15560 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053015561 event_ids[wmi_peer_delete_response_event_id] =
15562 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053015563 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
15564 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
15565 event_ids[wmi_tbttoffset_update_event_id] =
15566 WMI_TBTTOFFSET_UPDATE_EVENTID;
15567 event_ids[wmi_offload_bcn_tx_status_event_id] =
15568 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
15569 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
15570 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
15571 event_ids[wmi_mgmt_tx_completion_event_id] =
15572 WMI_MGMT_TX_COMPLETION_EVENTID;
15573
15574 event_ids[wmi_tx_delba_complete_event_id] =
15575 WMI_TX_DELBA_COMPLETE_EVENTID;
15576 event_ids[wmi_tx_addba_complete_event_id] =
15577 WMI_TX_ADDBA_COMPLETE_EVENTID;
15578 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
15579
15580 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
15581
15582 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
15583 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
15584
15585 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
15586
15587 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
15588
15589 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
15590
15591 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
15592 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
15593 event_ids[wmi_do_wow_disable_ack_event_id] =
15594 WMI_D0_WOW_DISABLE_ACK_EVENTID;
15595 event_ids[wmi_wow_initial_wakeup_event_id] =
15596 WMI_WOW_INITIAL_WAKEUP_EVENTID;
15597
15598 event_ids[wmi_rtt_meas_report_event_id] =
15599 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
15600 event_ids[wmi_tsf_meas_report_event_id] =
15601 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
15602 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
15603 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
15604 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
15605 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
15606 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
15607 event_ids[wmi_update_fw_mem_dump_event_id] =
15608 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
15609 event_ids[wmi_diag_event_id_log_supported_event_id] =
15610 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
15611 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
15612 event_ids[wmi_nlo_scan_complete_event_id] =
15613 WMI_NLO_SCAN_COMPLETE_EVENTID;
15614 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
15615 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
15616
15617 event_ids[wmi_gtk_offload_status_event_id] =
15618 WMI_GTK_OFFLOAD_STATUS_EVENTID;
15619 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
15620 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
15621 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
15622
15623 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
15624
15625 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
15626
15627 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
15628 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
15629 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
15630 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
15631 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
15632 event_ids[wmi_wlan_profile_data_event_id] =
15633 WMI_WLAN_PROFILE_DATA_EVENTID;
15634 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
15635 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
15636 event_ids[wmi_vdev_get_keepalive_event_id] =
15637 WMI_VDEV_GET_KEEPALIVE_EVENTID;
15638 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
15639
15640 event_ids[wmi_diag_container_event_id] =
15641 WMI_DIAG_DATA_CONTAINER_EVENTID;
15642
15643 event_ids[wmi_host_auto_shutdown_event_id] =
15644 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
15645
15646 event_ids[wmi_update_whal_mib_stats_event_id] =
15647 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
15648
15649 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
15650 event_ids[wmi_update_vdev_rate_stats_event_id] =
15651 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
15652
15653 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
15654
15655 /** Set OCB Sched Response, deprecated */
15656 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
15657
15658 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
15659 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
15660 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
15661
15662 /* GPIO Event */
15663 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
15664 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
15665
15666 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
15667 event_ids[wmi_rfkill_state_change_event_id] =
15668 WMI_RFKILL_STATE_CHANGE_EVENTID;
15669
15670 /* TDLS Event */
15671 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
15672
15673 event_ids[wmi_batch_scan_enabled_event_id] =
15674 WMI_BATCH_SCAN_ENABLED_EVENTID;
15675 event_ids[wmi_batch_scan_result_event_id] =
15676 WMI_BATCH_SCAN_RESULT_EVENTID;
15677 /* OEM Event */
15678 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
15679 event_ids[wmi_oem_meas_report_event_id] =
15680 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
15681 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
15682
15683 /* NAN Event */
15684 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
15685
15686 /* LPI Event */
15687 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
15688 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
15689 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
15690
15691 /* ExtScan events */
15692 event_ids[wmi_extscan_start_stop_event_id] =
15693 WMI_EXTSCAN_START_STOP_EVENTID;
15694 event_ids[wmi_extscan_operation_event_id] =
15695 WMI_EXTSCAN_OPERATION_EVENTID;
15696 event_ids[wmi_extscan_table_usage_event_id] =
15697 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
15698 event_ids[wmi_extscan_cached_results_event_id] =
15699 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
15700 event_ids[wmi_extscan_wlan_change_results_event_id] =
15701 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
15702 event_ids[wmi_extscan_hotlist_match_event_id] =
15703 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
15704 event_ids[wmi_extscan_capabilities_event_id] =
15705 WMI_EXTSCAN_CAPABILITIES_EVENTID;
15706 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
15707 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
15708
15709 /* mDNS offload events */
15710 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
15711
15712 /* SAP Authentication offload events */
15713 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
15714 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
15715
15716 /** Out-of-context-of-bss (OCB) events */
15717 event_ids[wmi_ocb_set_config_resp_event_id] =
15718 WMI_OCB_SET_CONFIG_RESP_EVENTID;
15719 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
15720 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
15721 event_ids[wmi_dcc_get_stats_resp_event_id] =
15722 WMI_DCC_GET_STATS_RESP_EVENTID;
15723 event_ids[wmi_dcc_update_ndl_resp_event_id] =
15724 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
15725 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
15726 /* System-On-Chip events */
15727 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
15728 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
15729 event_ids[wmi_soc_hw_mode_transition_event_id] =
15730 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
15731 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
15732 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053015733 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015734 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
15735 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053015736}
15737
15738/**
15739 * populate_pdev_param_tlv() - populates pdev params
15740 *
15741 * @param pdev_param: Pointer to hold pdev params
15742 * Return: None
15743 */
15744static void populate_pdev_param_tlv(uint32_t *pdev_param)
15745{
15746 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
15747 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
15748 pdev_param[wmi_pdev_param_txpower_limit2g] =
15749 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
15750 pdev_param[wmi_pdev_param_txpower_limit5g] =
15751 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
15752 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
15753 pdev_param[wmi_pdev_param_beacon_gen_mode] =
15754 WMI_PDEV_PARAM_BEACON_GEN_MODE;
15755 pdev_param[wmi_pdev_param_beacon_tx_mode] =
15756 WMI_PDEV_PARAM_BEACON_TX_MODE;
15757 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
15758 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
15759 pdev_param[wmi_pdev_param_protection_mode] =
15760 WMI_PDEV_PARAM_PROTECTION_MODE;
15761 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
15762 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
15763 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
15764 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
15765 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
15766 pdev_param[wmi_pdev_param_sta_kickout_th] =
15767 WMI_PDEV_PARAM_STA_KICKOUT_TH;
15768 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
15769 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
15770 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
15771 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
15772 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
15773 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
15774 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
15775 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
15776 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
15777 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
15778 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
15779 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
15780 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
15781 pdev_param[wmi_pdev_param_ltr_sleep_override] =
15782 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
15783 pdev_param[wmi_pdev_param_ltr_rx_override] =
15784 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
15785 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
15786 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
15787 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
15788 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
15789 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
15790 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
15791 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
15792 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
15793 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
15794 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
15795 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
15796 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
15797 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
15798 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
15799 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
15800 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
15801 pdev_param[wmi_pdev_param_peer_stats_update_period] =
15802 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
15803 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
15804 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
15805 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
15806 pdev_param[wmi_pdev_param_arp_ac_override] =
15807 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
15808 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
15809 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
15810 pdev_param[wmi_pdev_param_ani_poll_period] =
15811 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
15812 pdev_param[wmi_pdev_param_ani_listen_period] =
15813 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
15814 pdev_param[wmi_pdev_param_ani_ofdm_level] =
15815 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
15816 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
15817 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
15818 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
15819 pdev_param[wmi_pdev_param_idle_ps_config] =
15820 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
15821 pdev_param[wmi_pdev_param_power_gating_sleep] =
15822 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
15823 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
15824 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
15825 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
15826 pdev_param[wmi_pdev_param_hw_rfkill_config] =
15827 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
15828 pdev_param[wmi_pdev_param_low_power_rf_enable] =
15829 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
15830 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
15831 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
15832 pdev_param[wmi_pdev_param_power_collapse_enable] =
15833 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
15834 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
15835 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
15836 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
15837 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
15838 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
15839 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
15840 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
15841 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
15842 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
15843 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
15844 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
15845 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
15846 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
15847 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
15848 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
15849 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
15850 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
15851 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
15852 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
15853 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
15854 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
15855 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
15856 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
15857 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
15858 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
15859 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
15860 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
15861 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
15862 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
15863 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
15864 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
15865 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
15866 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
15867 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
15868 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
15869 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
15870 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
15871 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
15872 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
15873 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
15874 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
15875 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
15876 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
15877 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
15878 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
15879 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
15880 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
15881 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
15882 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
15883 WMI_UNAVAILABLE_PARAM;
15884 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
15885 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
15886 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
15887 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
15888 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
15889 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
15890 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
15891 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
15892 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
15893 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
15894 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
15895 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
15896 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
15897 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
15898 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
15899 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
15900 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
15901 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
15902 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
15903 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
15904 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
15905 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
15906 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
15907 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
15908 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
15909 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
15910 WMI_UNAVAILABLE_PARAM;
15911 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
15912 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
15913 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
15914 WMI_UNAVAILABLE_PARAM;
15915 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
15916 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
15917 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
15918 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
15919 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
15920 WMI_UNAVAILABLE_PARAM;
15921 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
15922 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
15923 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053015924 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
15925 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053015926 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053015927 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
15928 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015929}
15930
15931/**
15932 * populate_vdev_param_tlv() - populates vdev params
15933 *
15934 * @param vdev_param: Pointer to hold vdev params
15935 * Return: None
15936 */
15937static void populate_vdev_param_tlv(uint32_t *vdev_param)
15938{
15939 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
15940 vdev_param[wmi_vdev_param_fragmentation_threshold] =
15941 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
15942 vdev_param[wmi_vdev_param_beacon_interval] =
15943 WMI_VDEV_PARAM_BEACON_INTERVAL;
15944 vdev_param[wmi_vdev_param_listen_interval] =
15945 WMI_VDEV_PARAM_LISTEN_INTERVAL;
15946 vdev_param[wmi_vdev_param_multicast_rate] =
15947 WMI_VDEV_PARAM_MULTICAST_RATE;
15948 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
15949 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
15950 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
15951 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
15952 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
15953 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
15954 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
15955 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
15956 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
15957 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
15958 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
15959 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
15960 vdev_param[wmi_vdev_param_bmiss_count_max] =
15961 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
15962 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
15963 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
15964 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
15965 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
15966 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
15967 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
15968 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
15969 vdev_param[wmi_vdev_param_disable_htprotection] =
15970 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
15971 vdev_param[wmi_vdev_param_sta_quickkickout] =
15972 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
15973 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
15974 vdev_param[wmi_vdev_param_protection_mode] =
15975 WMI_VDEV_PARAM_PROTECTION_MODE;
15976 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
15977 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
15978 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
15979 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
15980 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
15981 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
15982 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
15983 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
15984 vdev_param[wmi_vdev_param_bcast_data_rate] =
15985 WMI_VDEV_PARAM_BCAST_DATA_RATE;
15986 vdev_param[wmi_vdev_param_mcast_data_rate] =
15987 WMI_VDEV_PARAM_MCAST_DATA_RATE;
15988 vdev_param[wmi_vdev_param_mcast_indicate] =
15989 WMI_VDEV_PARAM_MCAST_INDICATE;
15990 vdev_param[wmi_vdev_param_dhcp_indicate] =
15991 WMI_VDEV_PARAM_DHCP_INDICATE;
15992 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
15993 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
15994 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
15995 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
15996 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
15997 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
15998 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
15999 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
16000 vdev_param[wmi_vdev_param_ap_enable_nawds] =
16001 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
16002 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
16003 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
16004 vdev_param[wmi_vdev_param_packet_powersave] =
16005 WMI_VDEV_PARAM_PACKET_POWERSAVE;
16006 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
16007 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
16008 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
16009 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
16010 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
16011 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
16012 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
16013 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
16014 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
16015 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
16016 vdev_param[wmi_vdev_param_early_rx_slop_step] =
16017 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
16018 vdev_param[wmi_vdev_param_early_rx_init_slop] =
16019 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
16020 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
16021 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
16022 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
16023 vdev_param[wmi_vdev_param_snr_num_for_cal] =
16024 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
16025 vdev_param[wmi_vdev_param_roam_fw_offload] =
16026 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
16027 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
16028 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
16029 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
16030 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
16031 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
16032 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
16033 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
16034 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
16035 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
16036 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
16037 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
16038 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
16039 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
16040 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
16041 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
16042 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
16043 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
16044 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
16045 vdev_param[wmi_vdev_param_inactivity_cnt] =
16046 WMI_VDEV_PARAM_INACTIVITY_CNT;
16047 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
16048 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
16049 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
16050 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
16051 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
16052 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
16053 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
16054 vdev_param[wmi_vdev_param_rx_leak_window] =
16055 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
16056 vdev_param[wmi_vdev_param_stats_avg_factor] =
16057 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
16058 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
16059 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
16060 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
16061 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
16062 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
16063 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053016064 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
16065 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053016066 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080016067 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
16068 vdev_param[wmi_vdev_param_he_range_ext_enable] =
16069 WMI_VDEV_PARAM_HE_RANGE_EXT;
16070 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
16071 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
16072 vdev_param[wmi_vdev_param_tx_ofdma_cplen] =
16073 WMI_VDEV_PARAM_TX_OFDMA_CPLEN;
Govind Singhe7f2f342016-05-23 12:12:52 +053016074}
16075#endif
16076
Govind Singh5eb51532016-03-09 11:34:12 +053016077/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053016078 * populate_target_defines_tlv() - Populate target defines and params
16079 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053016080 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053016081 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053016082 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053016083#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053016084static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053016085{
Govind Singhe7f2f342016-05-23 12:12:52 +053016086 populate_tlv_service(wmi_handle->services);
16087 populate_tlv_events_id(wmi_handle->wmi_events);
16088 populate_pdev_param_tlv(wmi_handle->pdev_param);
16089 populate_vdev_param_tlv(wmi_handle->vdev_param);
16090}
16091#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053016092static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
16093{ }
16094#endif
16095
16096/**
16097 * wmi_tlv_attach() - Attach TLV APIs
16098 *
16099 * Return: None
16100 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053016101void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053016102{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053016103 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053016104#ifdef WMI_INTERFACE_EVENT_LOGGING
16105 wmi_handle->log_info.buf_offset_command = 2;
16106 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053016107#endif
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053016108 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053016109}