blob: d7d91daaea06d0b8bf771a72097476424e7847f7 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
2 * Copyright (c) 2016 The Linux Foundation. All rights reserved.
3 *
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
28#include "wmi_unified_tlv.h"
29#include "wmi_unified_api.h"
30#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053031#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053032#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053033#include "wmi_version_whitelist.h"
Govind Singh5eb51532016-03-09 11:34:12 +053034
35/**
36 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
37 * @wmi_handle: wmi handle
38 * @param: pointer to hold vdev create parameter
39 * @macaddr: vdev mac address
40 *
Govind Singhe7f2f342016-05-23 12:12:52 +053041 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053042 */
Govind Singhb53420c2016-03-09 14:32:57 +053043QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053044 uint8_t macaddr[IEEE80211_ADDR_LEN],
45 struct vdev_create_params *param)
46{
47 wmi_vdev_create_cmd_fixed_param *cmd;
48 wmi_buf_t buf;
49 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053050 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070051 int num_bands = 2;
52 uint8_t *buf_ptr;
53 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053054
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070055 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053056 buf = wmi_buf_alloc(wmi_handle, len);
57 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053058 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053059 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053060 }
61 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
62 WMITLV_SET_HDR(&cmd->tlv_header,
63 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
64 WMITLV_GET_STRUCT_TLVLEN
65 (wmi_vdev_create_cmd_fixed_param));
66 cmd->vdev_id = param->if_id;
67 cmd->vdev_type = param->type;
68 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070069 cmd->num_cfg_txrx_streams = num_bands;
Govind Singh4df47142016-04-16 19:24:23 -070070 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +053071 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +053072 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +053073 __func__, param->if_id,
74 macaddr[0], macaddr[1], macaddr[2],
75 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070076 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
77 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
78 (num_bands * sizeof(wmi_vdev_txrx_streams)));
79 buf_ptr += WMI_TLV_HDR_SIZE;
80
Govind Singh224a7312016-06-21 14:33:26 +053081 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070082 param->type, param->subtype,
83 param->nss_2g, param->nss_5g);
84 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
85 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
86 txrx_streams->supported_tx_streams = param->nss_2g;
87 txrx_streams->supported_rx_streams = param->nss_2g;
88 WMITLV_SET_HDR(&txrx_streams->tlv_header,
89 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
90 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
91
92 txrx_streams++;
93 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
94 txrx_streams->supported_tx_streams = param->nss_5g;
95 txrx_streams->supported_rx_streams = param->nss_5g;
96 WMITLV_SET_HDR(&txrx_streams->tlv_header,
97 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
98 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +053099 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530100 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530101 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530102 wmi_buf_free(buf);
103 }
104
105 return ret;
106}
107
108/**
109 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
110 * @wmi_handle: wmi handle
111 * @if_id: vdev id
112 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530113 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530114 */
Govind Singhb53420c2016-03-09 14:32:57 +0530115QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530116 uint8_t if_id)
117{
118 wmi_vdev_delete_cmd_fixed_param *cmd;
119 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530120 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530121
122 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
123 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530124 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530125 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530126 }
127
128 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
129 WMITLV_SET_HDR(&cmd->tlv_header,
130 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
131 WMITLV_GET_STRUCT_TLVLEN
132 (wmi_vdev_delete_cmd_fixed_param));
133 cmd->vdev_id = if_id;
134 ret = wmi_unified_cmd_send(wmi_handle, buf,
135 sizeof(wmi_vdev_delete_cmd_fixed_param),
136 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530137 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530138 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530139 wmi_buf_free(buf);
140 }
Govind Singhb53420c2016-03-09 14:32:57 +0530141 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530142
143 return ret;
144}
145
146/**
147 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
148 * @wmi: wmi handle
149 * @vdev_id: vdev id
150 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530151 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530152 */
Govind Singhb53420c2016-03-09 14:32:57 +0530153QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530154 uint8_t vdev_id)
155{
156 wmi_vdev_stop_cmd_fixed_param *cmd;
157 wmi_buf_t buf;
158 int32_t len = sizeof(*cmd);
159
160 buf = wmi_buf_alloc(wmi, len);
161 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530162 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530163 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530164 }
165 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
166 WMITLV_SET_HDR(&cmd->tlv_header,
167 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
168 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
169 cmd->vdev_id = vdev_id;
170 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530171 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530172 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530173 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530174 }
175
176 return 0;
177}
178
179/**
180 * send_vdev_down_cmd_tlv() - send vdev down command to fw
181 * @wmi: wmi handle
182 * @vdev_id: vdev id
183 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530184 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530185 */
Govind Singhb53420c2016-03-09 14:32:57 +0530186QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530187{
188 wmi_vdev_down_cmd_fixed_param *cmd;
189 wmi_buf_t buf;
190 int32_t len = sizeof(*cmd);
191
192 buf = wmi_buf_alloc(wmi, len);
193 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530194 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530195 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530196 }
197 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
198 WMITLV_SET_HDR(&cmd->tlv_header,
199 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
200 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
201 cmd->vdev_id = vdev_id;
202 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530203 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530204 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530205 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530206 }
Govind Singhb53420c2016-03-09 14:32:57 +0530207 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530208
209 return 0;
210}
211
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530212#ifdef CONFIG_MCL
213static inline void copy_channel_info(
214 wmi_vdev_start_request_cmd_fixed_param * cmd,
215 wmi_channel *chan,
216 struct vdev_start_params *req)
217{
218 chan->mhz = req->chan_freq;
219
220 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
221
222 chan->band_center_freq1 = req->band_center_freq1;
223 chan->band_center_freq2 = req->band_center_freq2;
224
225 if (req->is_half_rate)
226 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
227 else if (req->is_quarter_rate)
228 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
229
230 if (req->is_dfs) {
231 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
232 cmd->disable_hw_ack = req->dis_hw_ack;
233 }
234
235 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
236 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
237
238}
239#else
240static inline void copy_channel_info(
241 wmi_vdev_start_request_cmd_fixed_param * cmd,
242 wmi_channel *chan,
243 struct vdev_start_params *req)
244{
245 chan->mhz = req->channel.mhz;
246
247 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
248
249 chan->band_center_freq1 = req->channel.cfreq1;
250 chan->band_center_freq2 = req->channel.cfreq2;
251
252 if (req->channel.half_rate)
253 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
254 else if (req->channel.quarter_rate)
255 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
256
257 if (req->channel.dfs_set) {
258 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
259 cmd->disable_hw_ack = req->disable_hw_ack;
260 }
261
262 /* FIXME: Find out min, max and regulatory power levels */
263 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
264 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
265
266}
267#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530268/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530269 * send_vdev_start_cmd_tlv() - send vdev start request to fw
270 * @wmi_handle: wmi handle
271 * @req: vdev start params
272 *
273 * Return: QDF status
274 */
275QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
276 struct vdev_start_params *req)
277{
278 wmi_vdev_start_request_cmd_fixed_param *cmd;
279 wmi_buf_t buf;
280 wmi_channel *chan;
281 int32_t len, ret;
282 uint8_t *buf_ptr;
283
284 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
285 buf = wmi_buf_alloc(wmi_handle, len);
286 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530287 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530288 return QDF_STATUS_E_NOMEM;
289 }
290 buf_ptr = (uint8_t *) wmi_buf_data(buf);
291 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
292 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
293 WMITLV_SET_HDR(&cmd->tlv_header,
294 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
295 WMITLV_GET_STRUCT_TLVLEN
296 (wmi_vdev_start_request_cmd_fixed_param));
297 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
298 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
299 cmd->vdev_id = req->vdev_id;
300
301 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530302 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530303
304 cmd->beacon_interval = req->beacon_intval;
305 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530306
307 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530308 cmd->beacon_interval = req->beacon_intval;
309 cmd->dtim_period = req->dtim_period;
310
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530311 /* Copy the SSID */
312 if (req->ssid.length) {
313 if (req->ssid.length < sizeof(cmd->ssid.ssid))
314 cmd->ssid.ssid_len = req->ssid.length;
315 else
316 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
317 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
318 cmd->ssid.ssid_len);
319 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530320
321 if (req->hidden_ssid)
322 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
323
324 if (req->pmf_enabled)
325 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530326 }
327
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530328 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530329 cmd->preferred_rx_streams = req->preferred_rx_streams;
330 cmd->preferred_tx_streams = req->preferred_tx_streams;
331
332 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
333 sizeof(wmi_channel));
334 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
335 cmd->num_noa_descriptors *
336 sizeof(wmi_p2p_noa_descriptor));
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530337 WMI_LOGA("\n%s: vdev_id %d freq %d chanmode %d is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530338 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
339 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
340 "Tx SS %d, Rx SS %d",
341 __func__, req->vdev_id, chan->mhz, req->chan_mode,
342 req->is_dfs, req->beacon_intval, cmd->dtim_period,
343 chan->band_center_freq1, chan->band_center_freq2,
344 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
345 req->preferred_tx_streams, req->preferred_rx_streams);
346
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530347 if (req->is_restart)
348 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
349 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530350 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530351 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
352 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530353 if (ret) {
354 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530355 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530356 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530357 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530358
359 return QDF_STATUS_SUCCESS;
360}
361
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530362/**
363 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
364 * @wmi_handle: wmi handle
365 * @restart_params: vdev restart params
366 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530367 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530368 */
369QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
370 struct hidden_ssid_vdev_restart_params *restart_params)
371{
372 wmi_vdev_start_request_cmd_fixed_param *cmd;
373 wmi_buf_t buf;
374 wmi_channel *chan;
375 int32_t len;
376 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530377 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530378
379 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
380 buf = wmi_buf_alloc(wmi_handle, len);
381 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530382 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530383 return QDF_STATUS_E_NOMEM;
384 }
385 buf_ptr = (uint8_t *) wmi_buf_data(buf);
386 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
387 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
388
389 WMITLV_SET_HDR(&cmd->tlv_header,
390 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
391 WMITLV_GET_STRUCT_TLVLEN
392 (wmi_vdev_start_request_cmd_fixed_param));
393
394 WMITLV_SET_HDR(&chan->tlv_header,
395 WMITLV_TAG_STRUC_wmi_channel,
396 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
397
398 cmd->vdev_id = restart_params->session_id;
399 cmd->ssid.ssid_len = restart_params->ssid_len;
400 qdf_mem_copy(cmd->ssid.ssid,
401 restart_params->ssid,
402 cmd->ssid.ssid_len);
403 cmd->flags = restart_params->flags;
404 cmd->requestor_id = restart_params->requestor_id;
405 cmd->disable_hw_ack = restart_params->disable_hw_ack;
406
407 chan->mhz = restart_params->mhz;
408 chan->band_center_freq1 =
409 restart_params->band_center_freq1;
410 chan->band_center_freq2 =
411 restart_params->band_center_freq2;
412 chan->info = restart_params->info;
413 chan->reg_info_1 = restart_params->reg_info_1;
414 chan->reg_info_2 = restart_params->reg_info_2;
415
416 cmd->num_noa_descriptors = 0;
417 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
418 sizeof(wmi_channel));
419 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
420 cmd->num_noa_descriptors *
421 sizeof(wmi_p2p_noa_descriptor));
422
423 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
424 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530425 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530426 wmi_buf_free(buf);
427 return QDF_STATUS_E_FAILURE;
428 }
429 return QDF_STATUS_SUCCESS;
430}
431
432
433/**
Govind Singh5eb51532016-03-09 11:34:12 +0530434 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
435 * @wmi: wmi handle
436 * @peer_addr: peer mac address
437 * @param: pointer to hold peer flush tid parameter
438 *
439 * Return: 0 for sucess or error code
440 */
Govind Singhb53420c2016-03-09 14:32:57 +0530441QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530442 uint8_t peer_addr[IEEE80211_ADDR_LEN],
443 struct peer_flush_params *param)
444{
445 wmi_peer_flush_tids_cmd_fixed_param *cmd;
446 wmi_buf_t buf;
447 int32_t len = sizeof(*cmd);
448
449 buf = wmi_buf_alloc(wmi, len);
450 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530451 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530452 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530453 }
454 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
455 WMITLV_SET_HDR(&cmd->tlv_header,
456 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
457 WMITLV_GET_STRUCT_TLVLEN
458 (wmi_peer_flush_tids_cmd_fixed_param));
459 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
460 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
461 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530462 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530463 peer_addr, param->vdev_id,
464 param->peer_tid_bitmap);
465 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530466 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530467 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530468 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530469 }
470
471 return 0;
472}
473
474/**
475 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
476 * @wmi: wmi handle
477 * @peer_addr: peer mac addr
478 * @vdev_id: vdev id
479 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530480 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530481 */
Govind Singhb53420c2016-03-09 14:32:57 +0530482QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530483 uint8_t peer_addr[IEEE80211_ADDR_LEN],
484 uint8_t vdev_id)
485{
486 wmi_peer_delete_cmd_fixed_param *cmd;
487 wmi_buf_t buf;
488 int32_t len = sizeof(*cmd);
489 buf = wmi_buf_alloc(wmi, len);
490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530491 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530492 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530493 }
494 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
495 WMITLV_SET_HDR(&cmd->tlv_header,
496 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
497 WMITLV_GET_STRUCT_TLVLEN
498 (wmi_peer_delete_cmd_fixed_param));
499 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
500 cmd->vdev_id = vdev_id;
501
502 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530503 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530504 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530505 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530506 }
Govind Singhb53420c2016-03-09 14:32:57 +0530507 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530508
509 return 0;
510}
511
512/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530513 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
514 * to target id.
515 * @targ_paramid: Target parameter id to hold the result.
516 * @peer_param_id: host param id.
517 *
518 * Return: QDF_STATUS_SUCCESS for success
519 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
520 */
521#ifdef CONFIG_MCL
522static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
523 uint32_t *targ_paramid,
524 uint32_t peer_param_id)
525{
526 *targ_paramid = peer_param_id;
527 return QDF_STATUS_SUCCESS;
528}
529#else
530static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
531 uint32_t *targ_paramid,
532 uint32_t peer_param_id)
533{
534 switch (peer_param_id) {
535 case WMI_HOST_PEER_MIMO_PS_STATE:
536 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
537 break;
538 case WMI_HOST_PEER_AMPDU:
539 *targ_paramid = WMI_PEER_AMPDU;
540 break;
541 case WMI_HOST_PEER_AUTHORIZE:
542 *targ_paramid = WMI_PEER_AUTHORIZE;
543 break;
544 case WMI_HOST_PEER_CHWIDTH:
545 *targ_paramid = WMI_PEER_CHWIDTH;
546 break;
547 case WMI_HOST_PEER_NSS:
548 *targ_paramid = WMI_PEER_NSS;
549 break;
550 case WMI_HOST_PEER_USE_4ADDR:
551 *targ_paramid = WMI_PEER_USE_4ADDR;
552 break;
553 case WMI_HOST_PEER_MEMBERSHIP:
554 *targ_paramid = WMI_PEER_MEMBERSHIP;
555 break;
556 case WMI_HOST_PEER_USERPOS:
557 *targ_paramid = WMI_PEER_USERPOS;
558 break;
559 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
560 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
561 break;
562 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
563 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
564 break;
565 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
566 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
567 break;
568 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
569 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
570 break;
571 case WMI_HOST_PEER_PHYMODE:
572 *targ_paramid = WMI_PEER_PHYMODE;
573 break;
574 case WMI_HOST_PEER_USE_FIXED_PWR:
575 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
576 break;
577 case WMI_HOST_PEER_PARAM_FIXED_RATE:
578 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
579 break;
580 case WMI_HOST_PEER_SET_MU_WHITELIST:
581 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
582 break;
583 case WMI_HOST_PEER_SET_MAC_TX_RATE:
584 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
585 break;
586 case WMI_HOST_PEER_SET_MIN_TX_RATE:
587 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
588 break;
589 default:
590 return QDF_STATUS_E_NOSUPPORT;
591 }
592
593 return QDF_STATUS_SUCCESS;
594}
595#endif
596/**
Govind Singh5eb51532016-03-09 11:34:12 +0530597 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530598 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530599 * @peer_addr: peer mac address
600 * @param : pointer to hold peer set parameter
601 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530602 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530603 */
Govind Singhb53420c2016-03-09 14:32:57 +0530604QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530605 uint8_t peer_addr[IEEE80211_ADDR_LEN],
606 struct peer_set_params *param)
607{
608 wmi_peer_set_param_cmd_fixed_param *cmd;
609 wmi_buf_t buf;
610 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530611 uint32_t param_id;
612
613 if (convert_host_peer_id_to_target_id_tlv(&param_id,
614 param->param_id) != QDF_STATUS_SUCCESS)
615 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530616
617 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
618 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530619 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530620 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530621 }
622 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
623 WMITLV_SET_HDR(&cmd->tlv_header,
624 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
625 WMITLV_GET_STRUCT_TLVLEN
626 (wmi_peer_set_param_cmd_fixed_param));
627 cmd->vdev_id = param->vdev_id;
628 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530629 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530630 cmd->param_value = param->param_value;
631 err = wmi_unified_cmd_send(wmi, buf,
632 sizeof(wmi_peer_set_param_cmd_fixed_param),
633 WMI_PEER_SET_PARAM_CMDID);
634 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530635 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530636 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530637 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530638 }
639
640 return 0;
641}
642
643/**
644 * send_vdev_up_cmd_tlv() - send vdev up command in fw
645 * @wmi: wmi handle
646 * @bssid: bssid
647 * @vdev_up_params: pointer to hold vdev up parameter
648 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530649 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530650 */
Govind Singhb53420c2016-03-09 14:32:57 +0530651QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530652 uint8_t bssid[IEEE80211_ADDR_LEN],
653 struct vdev_up_params *params)
654{
655 wmi_vdev_up_cmd_fixed_param *cmd;
656 wmi_buf_t buf;
657 int32_t len = sizeof(*cmd);
658
Govind Singhb53420c2016-03-09 14:32:57 +0530659 WMI_LOGD("%s: VDEV_UP", __func__);
660 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530661 params->vdev_id, params->assoc_id, bssid);
662 buf = wmi_buf_alloc(wmi, len);
663 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530664 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530665 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530666 }
667 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
668 WMITLV_SET_HDR(&cmd->tlv_header,
669 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
670 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
671 cmd->vdev_id = params->vdev_id;
672 cmd->vdev_assoc_id = params->assoc_id;
673 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
674 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530675 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530676 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530677 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530678 }
679
680 return 0;
681}
682
683/**
684 * send_peer_create_cmd_tlv() - send peer create command to fw
685 * @wmi: wmi handle
686 * @peer_addr: peer mac address
687 * @peer_type: peer type
688 * @vdev_id: vdev id
689 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530690 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530691 */
Govind Singhb53420c2016-03-09 14:32:57 +0530692QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530693 struct peer_create_params *param)
694{
695 wmi_peer_create_cmd_fixed_param *cmd;
696 wmi_buf_t buf;
697 int32_t len = sizeof(*cmd);
698
699 buf = wmi_buf_alloc(wmi, len);
700 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530701 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530702 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530703 }
704 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
705 WMITLV_SET_HDR(&cmd->tlv_header,
706 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
707 WMITLV_GET_STRUCT_TLVLEN
708 (wmi_peer_create_cmd_fixed_param));
709 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
710 cmd->peer_type = param->peer_type;
711 cmd->vdev_id = param->vdev_id;
712
713 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530714 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530715 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530716 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530717 }
Govind Singhb53420c2016-03-09 14:32:57 +0530718 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530719 param->vdev_id);
720
721 return 0;
722}
723
724/**
725 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
726 * @wmi_handle: wmi handle
727 * @value: value
728 * @mac_id: mac id to have radio context
729 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530730 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530731 */
Govind Singhb53420c2016-03-09 14:32:57 +0530732QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530733 uint32_t value, uint8_t mac_id)
734{
735 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
736 wmi_buf_t buf;
737 int32_t len = sizeof(*cmd);
738
Govind Singhb53420c2016-03-09 14:32:57 +0530739 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530740
741 buf = wmi_buf_alloc(wmi_handle, len);
742 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530743 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530744 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530745 }
746
747 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
748 WMITLV_SET_HDR(&cmd->tlv_header,
749 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
750 WMITLV_GET_STRUCT_TLVLEN
751 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530752 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530753 cmd->enable = value;
754
755 if (wmi_unified_cmd_send(wmi_handle, buf, len,
756 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530757 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530758 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530759 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530760 }
761
762 return 0;
763}
764
765/**
766 * send_pdev_utf_cmd_tlv() - send utf command to fw
767 * @wmi_handle: wmi handle
768 * @param: pointer to pdev_utf_params
769 * @mac_id: mac id to have radio context
770 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530771 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530772 */
Govind Singhb53420c2016-03-09 14:32:57 +0530773QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530774send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
775 struct pdev_utf_params *param,
776 uint8_t mac_id)
777{
778 wmi_buf_t buf;
779 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +0530780 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530781 static uint8_t msgref = 1;
782 uint8_t segNumber = 0, segInfo, numSegments;
783 uint16_t chunk_len, total_bytes;
784 uint8_t *bufpos;
785 struct seg_hdr_info segHdrInfo;
786
787 bufpos = param->utf_payload;
788 total_bytes = param->len;
789 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
790 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
791 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
792
793 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
794 numSegments++;
795
796 while (param->len) {
797 if (param->len > MAX_WMI_UTF_LEN)
798 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
799 else
800 chunk_len = param->len;
801
802 buf = wmi_buf_alloc(wmi_handle,
803 (chunk_len + sizeof(segHdrInfo) +
804 WMI_TLV_HDR_SIZE));
805 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530806 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530807 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530808 }
809
810 cmd = (uint8_t *) wmi_buf_data(buf);
811
812 segHdrInfo.len = total_bytes;
813 segHdrInfo.msgref = msgref;
814 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
815 segHdrInfo.segmentInfo = segInfo;
816 segHdrInfo.pad = 0;
817
Govind Singhb53420c2016-03-09 14:32:57 +0530818 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +0530819 " segHdrInfo.segmentInfo = %d",
820 __func__, segHdrInfo.len, segHdrInfo.msgref,
821 segHdrInfo.segmentInfo);
822
Govind Singhb53420c2016-03-09 14:32:57 +0530823 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +0530824 "chunk len %d", __func__, total_bytes, segNumber,
825 numSegments, chunk_len);
826
827 segNumber++;
828
829 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
830 (chunk_len + sizeof(segHdrInfo)));
831 cmd += WMI_TLV_HDR_SIZE;
832 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
833 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
834
835 ret = wmi_unified_cmd_send(wmi_handle, buf,
836 (chunk_len + sizeof(segHdrInfo) +
837 WMI_TLV_HDR_SIZE),
838 WMI_PDEV_UTF_CMDID);
839
Govind Singh67922e82016-04-01 16:48:57 +0530840 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530841 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530842 wmi_buf_free(buf);
843 break;
844 }
845
846 param->len -= chunk_len;
847 bufpos += chunk_len;
848 }
849
850 msgref++;
851
852 return ret;
853}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530854#ifdef CONFIG_MCL
855static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
856 uint32_t host_param)
857{
858 return host_param;
859}
860#else
861static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
862 uint32_t host_param)
863{
864 if (host_param < wmi_pdev_param_max)
865 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +0530866
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530867 return WMI_UNAVAILABLE_PARAM;
868}
869#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530870/**
871 * send_pdev_param_cmd_tlv() - set pdev parameters
872 * @wmi_handle: wmi handle
873 * @param: pointer to pdev parameter
874 * @mac_id: radio context
875 *
876 * Return: 0 on success, errno on failure
877 */
Govind Singhb53420c2016-03-09 14:32:57 +0530878QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530879send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
880 struct pdev_params *param,
881 uint8_t mac_id)
882{
Govind Singh67922e82016-04-01 16:48:57 +0530883 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530884 wmi_pdev_set_param_cmd_fixed_param *cmd;
885 wmi_buf_t buf;
886 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530887 uint32_t pdev_param;
888
889 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
890 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
891 WMI_LOGW("%s: Unavailable param %d\n",
892 __func__, param->param_id);
893 return QDF_STATUS_E_INVAL;
894 }
Govind Singh5eb51532016-03-09 11:34:12 +0530895
896 buf = wmi_buf_alloc(wmi_handle, len);
897 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530898 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530899 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530900 }
901 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
902 WMITLV_SET_HDR(&cmd->tlv_header,
903 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
904 WMITLV_GET_STRUCT_TLVLEN
905 (wmi_pdev_set_param_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530906 cmd->pdev_id = 0;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530907 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +0530908 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +0530909 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530910 param->param_value);
911 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
912 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530913 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530914 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +0530915 wmi_buf_free(buf);
916 }
917 return ret;
918}
919
920/**
921 * send_suspend_cmd_tlv() - WMI suspend function
922 * @param wmi_handle : handle to WMI.
923 * @param param : pointer to hold suspend parameter
924 * @mac_id: radio context
925 *
926 * Return 0 on success and -ve on failure.
927 */
Govind Singhb53420c2016-03-09 14:32:57 +0530928QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530929 struct suspend_params *param,
930 uint8_t mac_id)
931{
932 wmi_pdev_suspend_cmd_fixed_param *cmd;
933 wmi_buf_t wmibuf;
934 uint32_t len = sizeof(*cmd);
935 int32_t ret;
936
937 /*
938 * send the comand to Target to ignore the
939 * PCIE reset so as to ensure that Host and target
940 * states are in sync
941 */
942 wmibuf = wmi_buf_alloc(wmi_handle, len);
943 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +0530944 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530945
946 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
947 WMITLV_SET_HDR(&cmd->tlv_header,
948 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
949 WMITLV_GET_STRUCT_TLVLEN
950 (wmi_pdev_suspend_cmd_fixed_param));
951 if (param->disable_target_intr)
952 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
953 else
954 cmd->suspend_opt = WMI_PDEV_SUSPEND;
955 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
956 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +0530957 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +0530958 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +0530959 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530960 }
961
962 return ret;
963}
964
965/**
966 * send_resume_cmd_tlv() - WMI resume function
967 * @param wmi_handle : handle to WMI.
968 * @mac_id: radio context
969 *
970 * Return: 0 on success and -ve on failure.
971 */
Govind Singhb53420c2016-03-09 14:32:57 +0530972QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530973 uint8_t mac_id)
974{
975 wmi_buf_t wmibuf;
976 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +0530977 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530978
979 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
980 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +0530981 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530982 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
983 WMITLV_SET_HDR(&cmd->tlv_header,
984 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
985 WMITLV_GET_STRUCT_TLVLEN
986 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -0700987 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +0530988 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
989 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530990 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530991 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530992 wmi_buf_free(wmibuf);
993 }
994
995 return ret;
996}
997
998/**
999 * send_wow_enable_cmd_tlv() - WMI wow enable function
1000 * @param wmi_handle : handle to WMI.
1001 * @param param : pointer to hold wow enable parameter
1002 * @mac_id: radio context
1003 *
1004 * Return: 0 on success and -ve on failure.
1005 */
Govind Singhb53420c2016-03-09 14:32:57 +05301006QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301007 struct wow_cmd_params *param,
1008 uint8_t mac_id)
1009{
1010 wmi_wow_enable_cmd_fixed_param *cmd;
1011 wmi_buf_t buf;
1012 int32_t len;
1013 int32_t ret;
1014
1015 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1016
1017 buf = wmi_buf_alloc(wmi_handle, len);
1018 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301019 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1020 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301021 }
1022 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1023 WMITLV_SET_HDR(&cmd->tlv_header,
1024 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1025 WMITLV_GET_STRUCT_TLVLEN
1026 (wmi_wow_enable_cmd_fixed_param));
1027 cmd->enable = param->enable;
1028 if (param->can_suspend_link)
1029 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1030 else
1031 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
1032
Govind Singhb53420c2016-03-09 14:32:57 +05301033 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301034 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1035 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1036
1037 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1038 WMI_WOW_ENABLE_CMDID);
1039 if (ret)
1040 wmi_buf_free(buf);
1041
1042 return ret;
1043}
1044
1045/**
1046 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301047 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301048 * @peer_addr: peer mac address
1049 * @param: pointer to ap_ps parameter structure
1050 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301051 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301052 */
Govind Singhb53420c2016-03-09 14:32:57 +05301053QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301054 uint8_t *peer_addr,
1055 struct ap_ps_params *param)
1056{
1057 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1058 wmi_buf_t buf;
1059 int32_t err;
1060
1061 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1062 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301063 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301064 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301065 }
1066 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1067 WMITLV_SET_HDR(&cmd->tlv_header,
1068 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1069 WMITLV_GET_STRUCT_TLVLEN
1070 (wmi_ap_ps_peer_cmd_fixed_param));
1071 cmd->vdev_id = param->vdev_id;
1072 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1073 cmd->param = param->param;
1074 cmd->value = param->value;
1075 err = wmi_unified_cmd_send(wmi_handle, buf,
1076 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1077 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301078 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301079 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301080 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301081 }
1082
1083 return 0;
1084}
1085
1086/**
1087 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301088 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301089 * @peer_addr: peer mac address
1090 * @param: pointer to sta_ps parameter structure
1091 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301092 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301093 */
Govind Singhb53420c2016-03-09 14:32:57 +05301094QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301095 struct sta_ps_params *param)
1096{
1097 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1098 wmi_buf_t buf;
1099 int32_t len = sizeof(*cmd);
1100
1101 buf = wmi_buf_alloc(wmi_handle, len);
1102 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301103 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301104 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301105 }
1106
1107 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1108 WMITLV_SET_HDR(&cmd->tlv_header,
1109 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1110 WMITLV_GET_STRUCT_TLVLEN
1111 (wmi_sta_powersave_param_cmd_fixed_param));
1112 cmd->vdev_id = param->vdev_id;
1113 cmd->param = param->param;
1114 cmd->value = param->value;
1115
1116 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1117 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301118 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301119 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301120 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301121 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301122 }
1123
1124 return 0;
1125}
1126
1127/**
1128 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301129 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301130 * @param: ponirt to crash inject paramter structure
1131 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301132 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301133 */
Govind Singhb53420c2016-03-09 14:32:57 +05301134QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301135 struct crash_inject *param)
1136{
1137 int32_t ret = 0;
1138 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1139 uint16_t len = sizeof(*cmd);
1140 wmi_buf_t buf;
1141
1142 buf = wmi_buf_alloc(wmi_handle, len);
1143 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301144 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301145 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301146 }
1147
1148 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1149 WMITLV_SET_HDR(&cmd->tlv_header,
1150 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1151 WMITLV_GET_STRUCT_TLVLEN
1152 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1153 cmd->type = param->type;
1154 cmd->delay_time_ms = param->delay_time_ms;
1155
1156 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1157 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301158 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301159 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301160 __func__, ret);
1161 wmi_buf_free(buf);
1162 }
1163
1164 return ret;
1165}
1166
1167/**
1168 * send_dbglog_cmd_tlv() - set debug log level
1169 * @param wmi_handle : handle to WMI.
1170 * @param param : pointer to hold dbglog level parameter
1171 *
1172 * Return: 0 on success and -ve on failure.
1173 */
Govind Singhb53420c2016-03-09 14:32:57 +05301174QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301175send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1176 struct dbglog_params *dbglog_param)
1177{
1178 wmi_buf_t buf;
1179 wmi_debug_log_config_cmd_fixed_param *configmsg;
1180 A_STATUS status = A_OK;
1181 int32_t i;
1182 int32_t len;
1183 int8_t *buf_ptr;
1184 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1185
1186 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1187
1188 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1189 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1190 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1191 buf = wmi_buf_alloc(wmi_handle, len);
1192 if (buf == NULL)
1193 return A_NO_MEMORY;
1194
1195 configmsg =
1196 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1197 buf_ptr = (int8_t *) configmsg;
1198 WMITLV_SET_HDR(&configmsg->tlv_header,
1199 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1200 WMITLV_GET_STRUCT_TLVLEN
1201 (wmi_debug_log_config_cmd_fixed_param));
1202 configmsg->dbg_log_param = dbglog_param->param;
1203 configmsg->value = dbglog_param->val;
1204 /* Filling in the data part of second tlv -- should
1205 * follow first tlv _ WMI_TLV_HDR_SIZE */
1206 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1207 sizeof
1208 (wmi_debug_log_config_cmd_fixed_param)
1209 + WMI_TLV_HDR_SIZE);
1210 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1211 WMITLV_TAG_ARRAY_UINT32,
1212 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1213 if (dbglog_param->module_id_bitmap) {
1214 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1215 module_id_bitmap_array[i] =
1216 dbglog_param->module_id_bitmap[i];
1217 }
1218 }
1219
1220 status = wmi_unified_cmd_send(wmi_handle, buf,
1221 len, WMI_DBGLOG_CFG_CMDID);
1222
1223 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301224 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301225
1226 return status;
1227}
1228
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301229#ifdef CONFIG_MCL
1230static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1231 uint32_t host_param)
1232{
1233 return host_param;
1234}
1235#else
1236static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1237 uint32_t host_param)
1238{
1239 if (host_param < wmi_vdev_param_max)
1240 return wmi_handle->vdev_param[host_param];
1241
1242 return WMI_UNAVAILABLE_PARAM;
1243}
1244#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301245/**
1246 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1247 * @param wmi_handle : handle to WMI.
1248 * @param macaddr : MAC address
1249 * @param param : pointer to hold vdev set parameter
1250 *
1251 * Return: 0 on success and -ve on failure.
1252 */
Govind Singhb53420c2016-03-09 14:32:57 +05301253QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301254 struct vdev_set_params *param)
1255{
Govind Singh67922e82016-04-01 16:48:57 +05301256 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301257 wmi_vdev_set_param_cmd_fixed_param *cmd;
1258 wmi_buf_t buf;
1259 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301260 uint32_t vdev_param;
1261
1262 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1263 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1264 WMI_LOGW("%s:Vdev param %d not available", __func__,
1265 param->param_id);
1266 return QDF_STATUS_E_INVAL;
1267
1268 }
Govind Singh5eb51532016-03-09 11:34:12 +05301269
1270 buf = wmi_buf_alloc(wmi_handle, len);
1271 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301272 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301273 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301274 }
1275 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1276 WMITLV_SET_HDR(&cmd->tlv_header,
1277 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1278 WMITLV_GET_STRUCT_TLVLEN
1279 (wmi_vdev_set_param_cmd_fixed_param));
1280 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301281 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301282 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301283 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301284 param->if_id, param->param_id, param->param_value);
1285 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1286 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301287 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301288 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301289 wmi_buf_free(buf);
1290 }
1291
1292 return ret;
1293}
1294
1295/**
1296 * send_stats_request_cmd_tlv() - WMI request stats function
1297 * @param wmi_handle : handle to WMI.
1298 * @param macaddr : MAC address
1299 * @param param : pointer to hold stats request parameter
1300 *
1301 * Return: 0 on success and -ve on failure.
1302 */
Govind Singhb53420c2016-03-09 14:32:57 +05301303QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301304 uint8_t macaddr[IEEE80211_ADDR_LEN],
1305 struct stats_request_params *param)
1306{
Govind Singhd3156eb2016-02-26 17:50:39 +05301307 int32_t ret;
1308 wmi_request_stats_cmd_fixed_param *cmd;
1309 wmi_buf_t buf;
1310 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1311
1312 buf = wmi_buf_alloc(wmi_handle, len);
1313 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301314 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1315 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301316 }
1317
1318 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1319 WMITLV_SET_HDR(&cmd->tlv_header,
1320 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1321 WMITLV_GET_STRUCT_TLVLEN
1322 (wmi_request_stats_cmd_fixed_param));
1323 cmd->stats_id = param->stats_id;
1324 cmd->vdev_id = param->vdev_id;
1325 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1326 WMI_REQUEST_STATS_CMDID);
1327 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301328 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301329 wmi_buf_free(buf);
1330 }
1331
1332 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301333}
1334
Govind Singh87542482016-06-08 19:40:11 +05301335#ifdef CONFIG_WIN
1336/**
1337 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1338 * @param wmi_handle : handle to WMI.
1339 * @param macaddr : MAC address
1340 * @param param : pointer to hold stats request parameter
1341 *
1342 * Return: 0 on success and -ve on failure.
1343 */
1344QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
1345 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1346{
1347 return 0;
1348}
1349#else
Govind Singh5eb51532016-03-09 11:34:12 +05301350/**
1351 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1352 * @param wmi_handle : handle to WMI.
1353 * @param macaddr : MAC address
1354 * @param param : pointer to hold stats request parameter
1355 *
1356 * Return: 0 on success and -ve on failure.
1357 */
Govind Singhb53420c2016-03-09 14:32:57 +05301358QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301359 uint8_t macaddr[IEEE80211_ADDR_LEN],
1360 struct packet_enable_params *param)
1361{
1362 return 0;
1363}
Govind Singh87542482016-06-08 19:40:11 +05301364#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301365
Govind Singh87542482016-06-08 19:40:11 +05301366#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301367/**
1368 * send_beacon_send_cmd_tlv() - WMI beacon send function
1369 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301370 * @param param : pointer to hold beacon send cmd parameter
1371 *
1372 * Return: 0 on success and -ve on failure.
1373 */
Govind Singhb53420c2016-03-09 14:32:57 +05301374QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301375 struct beacon_params *param)
1376{
Govind Singhd3156eb2016-02-26 17:50:39 +05301377 int32_t ret;
1378 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1379 wmi_bcn_prb_info *bcn_prb_info;
1380 wmi_buf_t wmi_buf;
1381 uint8_t *buf_ptr;
1382 uint32_t wmi_buf_len;
1383
1384 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1385 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1386 param->tmpl_len_aligned;
1387 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1388 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301389 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301390 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301391 }
1392 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1393 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1394 WMITLV_SET_HDR(&cmd->tlv_header,
1395 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1396 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1397 cmd->vdev_id = param->vdev_id;
1398 cmd->tim_ie_offset = param->tim_ie_offset;
1399 cmd->buf_len = param->tmpl_len;
1400 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1401
1402 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1403 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1404 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1405 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1406 bcn_prb_info->caps = 0;
1407 bcn_prb_info->erp = 0;
1408 buf_ptr += sizeof(wmi_bcn_prb_info);
1409
1410 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1411 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301412 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301413
1414 ret = wmi_unified_cmd_send(wmi_handle,
1415 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1416 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301417 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301418 wmi_buf_free(wmi_buf);
1419 }
Govind Singh5eb51532016-03-09 11:34:12 +05301420 return 0;
1421}
Govind Singh87542482016-06-08 19:40:11 +05301422#else
1423QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
1424 struct beacon_params *param)
1425{
1426 return 0;
1427}
1428
1429/**
1430 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1431 * @param wmi_handle : handle to WMI.
1432 * @param param : pointer to hold beacon send cmd parameter
1433 *
1434 * Return: 0 on success and -ve on failure.
1435 */
1436QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
1437 struct beacon_tmpl_params *param)
1438{
1439 int32_t ret;
1440 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1441 wmi_bcn_prb_info *bcn_prb_info;
1442 wmi_buf_t wmi_buf;
1443 uint8_t *buf_ptr;
1444 uint32_t wmi_buf_len;
1445
1446 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1447 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1448 param->tmpl_len_aligned;
1449 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1450 if (!wmi_buf) {
1451 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1452 return QDF_STATUS_E_NOMEM;
1453 }
1454 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1455 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1456 WMITLV_SET_HDR(&cmd->tlv_header,
1457 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1458 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1459 cmd->vdev_id = param->vdev_id;
1460 cmd->tim_ie_offset = param->tim_ie_offset;
1461 cmd->buf_len = param->tmpl_len;
1462 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1463
1464 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1465 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1466 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1467 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1468 bcn_prb_info->caps = 0;
1469 bcn_prb_info->erp = 0;
1470 buf_ptr += sizeof(wmi_bcn_prb_info);
1471
1472 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1473 buf_ptr += WMI_TLV_HDR_SIZE;
1474 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1475
1476 ret = wmi_unified_cmd_send(wmi_handle,
1477 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1478 if (ret) {
1479 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1480 wmi_buf_free(wmi_buf);
1481 }
1482 return 0;
1483}
1484#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301485
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301486#ifdef CONFIG_MCL
1487static inline void copy_peer_flags_tlv(
1488 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1489 struct peer_assoc_params *param)
1490{
1491 cmd->peer_flags = param->peer_flags;
1492}
1493#else
1494static inline void copy_peer_flags_tlv(
1495 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1496 struct peer_assoc_params *param)
1497{
1498 /*
1499 * The target only needs a subset of the flags maintained in the host.
1500 * Just populate those flags and send it down
1501 */
1502 cmd->peer_flags = 0;
1503
1504 /*
1505 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1506 */
1507 if (param->is_wme_set) {
1508
1509 if (param->qos_flag)
1510 cmd->peer_flags |= WMI_PEER_QOS;
1511 if (param->apsd_flag)
1512 cmd->peer_flags |= WMI_PEER_APSD;
1513 if (param->ht_flag)
1514 cmd->peer_flags |= WMI_PEER_HT;
1515 if (param->bw_40)
1516 cmd->peer_flags |= WMI_PEER_40MHZ;
1517 if (param->bw_80)
1518 cmd->peer_flags |= WMI_PEER_80MHZ;
1519 if (param->bw_160)
1520 cmd->peer_flags |= WMI_PEER_160MHZ;
1521
1522 /* Typically if STBC is enabled for VHT it should be enabled
1523 * for HT as well
1524 **/
1525 if (param->stbc_flag)
1526 cmd->peer_flags |= WMI_PEER_STBC;
1527
1528 /* Typically if LDPC is enabled for VHT it should be enabled
1529 * for HT as well
1530 **/
1531 if (param->ldpc_flag)
1532 cmd->peer_flags |= WMI_PEER_LDPC;
1533
1534 if (param->static_mimops_flag)
1535 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1536 if (param->dynamic_mimops_flag)
1537 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1538 if (param->spatial_mux_flag)
1539 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1540 if (param->vht_flag)
1541 cmd->peer_flags |= WMI_PEER_VHT;
1542 }
1543 /*
1544 * Suppress authorization for all AUTH modes that need 4-way handshake
1545 * (during re-association).
1546 * Authorization will be done for these modes on key installation.
1547 */
1548 if (param->auth_flag)
1549 cmd->peer_flags |= WMI_PEER_AUTH;
1550 if (param->need_ptk_4_way)
1551 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1552 else
1553 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1554 if (param->need_gtk_2_way)
1555 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1556 /* safe mode bypass the 4-way handshake */
1557 if (param->safe_mode_enabled)
1558 cmd->peer_flags &=
1559 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1560 /* Disable AMSDU for station transmit, if user configures it */
1561 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1562 * it
1563 * if (param->amsdu_disable) Add after FW support
1564 **/
1565
1566 /* Target asserts if node is marked HT and all MCS is set to 0.
1567 * Mark the node as non-HT if all the mcs rates are disabled through
1568 * iwpriv
1569 **/
1570 if (param->peer_ht_rates.num_rates == 0)
1571 cmd->peer_flags &= ~WMI_PEER_HT;
1572}
1573#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301574/**
1575 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1576 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301577 * @param param : pointer to peer assoc parameter
1578 *
1579 * Return: 0 on success and -ve on failure.
1580 */
Govind Singhb53420c2016-03-09 14:32:57 +05301581QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301582 struct peer_assoc_params *param)
1583{
Govind Singhd3156eb2016-02-26 17:50:39 +05301584 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1585 wmi_vht_rate_set *mcs;
1586 wmi_buf_t buf;
1587 int32_t len;
1588 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301589 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301590 uint32_t peer_legacy_rates_align;
1591 uint32_t peer_ht_rates_align;
1592
1593
1594 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1595 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301596
1597 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301598 (peer_legacy_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301599 WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301600 (peer_ht_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301601 sizeof(wmi_vht_rate_set);
1602
1603 buf = wmi_buf_alloc(wmi_handle, len);
1604 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301605 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301606 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301607 }
1608
1609 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1610 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1611 WMITLV_SET_HDR(&cmd->tlv_header,
1612 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1613 WMITLV_GET_STRUCT_TLVLEN
1614 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301615
Govind Singhd3156eb2016-02-26 17:50:39 +05301616 cmd->vdev_id = param->vdev_id;
Govind Singh3419aea2016-03-28 22:02:42 +05301617 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1618 sizeof(param->peer_macaddr));
Govind Singhd3156eb2016-02-26 17:50:39 +05301619 cmd->peer_new_assoc = param->peer_new_assoc;
1620 cmd->peer_associd = param->peer_associd;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301621 copy_peer_flags_tlv(cmd, param);
Govind Singhd3156eb2016-02-26 17:50:39 +05301622 cmd->peer_rate_caps = param->peer_rate_caps;
1623 cmd->peer_caps = param->peer_caps;
1624 cmd->peer_listen_intval = param->peer_listen_intval;
1625 cmd->peer_ht_caps = param->peer_ht_caps;
1626 cmd->peer_max_mpdu = param->peer_max_mpdu;
1627 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301628 cmd->peer_vht_caps = param->peer_vht_caps;
1629 cmd->peer_phymode = param->peer_phymode;
1630
1631 /* Update peer legacy rate information */
1632 buf_ptr += sizeof(*cmd);
1633 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301634 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301635 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301636 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301637 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301638 param->peer_legacy_rates.num_rates);
1639
1640 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001641 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301642 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301643 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301644 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301645 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301646 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301647 param->peer_ht_rates.num_rates);
1648
1649 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001650 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301651 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1652 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1653
1654 cmd->peer_nss = param->peer_nss;
1655 mcs = (wmi_vht_rate_set *) buf_ptr;
1656 if (param->vht_capable) {
1657 mcs->rx_max_rate = param->rx_max_rate;
1658 mcs->rx_mcs_set = param->rx_mcs_set;
1659 mcs->tx_max_rate = param->tx_max_rate;
1660 mcs->tx_mcs_set = param->tx_mcs_set;
1661 }
1662
Govind Singhb53420c2016-03-09 14:32:57 +05301663 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301664 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1665 "nss %d phymode %d peer_mpdu_density %d "
1666 "cmd->peer_vht_caps %x", __func__,
1667 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1668 cmd->peer_rate_caps, cmd->peer_caps,
1669 cmd->peer_listen_intval, cmd->peer_ht_caps,
1670 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1671 cmd->peer_mpdu_density,
1672 cmd->peer_vht_caps);
1673
1674 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1675 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301676 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301677 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301678 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301679 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301680 }
1681
1682 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301683}
1684
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301685/* copy_scan_notify_events() - Helper routine to copy scan notify events
1686 */
1687#ifdef CONFIG_MCL
1688static inline void copy_scan_notify_ev_flags(
1689 wmi_start_scan_cmd_fixed_param * cmd,
1690 struct scan_start_params *params)
1691{
1692 cmd->notify_scan_events = params->notify_scan_events;
1693 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1694}
1695#else
1696static inline void copy_scan_notify_ev_flags(
1697 wmi_start_scan_cmd_fixed_param * cmd,
1698 struct scan_start_params *params)
1699{
1700 cmd->notify_scan_events = WMI_SCAN_EVENT_STARTED |
1701 WMI_SCAN_EVENT_COMPLETED |
1702 WMI_SCAN_EVENT_BSS_CHANNEL |
1703 WMI_SCAN_EVENT_FOREIGN_CHANNEL |
1704 WMI_SCAN_EVENT_DEQUEUED
1705 ;
1706 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1707 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
1708
1709 if (params->is_phy_error)
1710 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
1711}
1712#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301713/**
1714 * send_scan_start_cmd_tlv() - WMI scan start function
1715 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301716 * @param param : pointer to hold scan start cmd parameter
1717 *
1718 * Return: 0 on success and -ve on failure.
1719 */
Govind Singhb53420c2016-03-09 14:32:57 +05301720QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301721 struct scan_start_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05301722{
Govind Singhd3156eb2016-02-26 17:50:39 +05301723 int32_t ret = 0;
1724 int32_t i;
1725 wmi_buf_t wmi_buf;
1726 wmi_start_scan_cmd_fixed_param *cmd;
1727 uint8_t *buf_ptr;
1728 uint32_t *tmp_ptr;
1729 wmi_ssid *ssid = NULL;
1730 wmi_mac_addr *bssid;
1731 int len = sizeof(*cmd);
1732
1733 /* Length TLV placeholder for array of uint32_t */
1734 len += WMI_TLV_HDR_SIZE;
1735 /* calculate the length of buffer required */
1736 if (params->num_chan)
1737 len += params->num_chan * sizeof(uint32_t);
1738
1739 /* Length TLV placeholder for array of wmi_ssid structures */
1740 len += WMI_TLV_HDR_SIZE;
1741 if (params->num_ssids)
1742 len += params->num_ssids * sizeof(wmi_ssid);
1743
1744 /* Length TLV placeholder for array of wmi_mac_addr structures */
1745 len += WMI_TLV_HDR_SIZE;
1746 len += sizeof(wmi_mac_addr);
1747
1748 /* Length TLV placeholder for array of bytes */
1749 len += WMI_TLV_HDR_SIZE;
1750 if (params->ie_len)
1751 len += roundup(params->ie_len, sizeof(uint32_t));
1752
1753 /* Allocate the memory */
1754 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1755 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301756 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301757 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05301758 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05301759 }
1760 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1761 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
1762 WMITLV_SET_HDR(&cmd->tlv_header,
1763 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
1764 WMITLV_GET_STRUCT_TLVLEN
1765 (wmi_start_scan_cmd_fixed_param));
1766
1767 cmd->scan_id = params->scan_id;
1768 cmd->scan_req_id = params->scan_req_id;
1769 cmd->vdev_id = params->vdev_id;
1770 cmd->scan_priority = params->scan_priority;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301771 copy_scan_notify_ev_flags(cmd, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05301772 cmd->dwell_time_active = params->dwell_time_active;
1773 cmd->dwell_time_passive = params->dwell_time_passive;
1774 cmd->min_rest_time = params->min_rest_time;
1775 cmd->max_rest_time = params->max_rest_time;
1776 cmd->repeat_probe_time = params->repeat_probe_time;
1777 cmd->probe_spacing_time = params->probe_spacing_time;
1778 cmd->idle_time = params->idle_time;
1779 cmd->max_scan_time = params->max_scan_time;
1780 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05301781 cmd->burst_duration = params->burst_duration;
1782 cmd->num_chan = params->num_chan;
1783 cmd->num_bssid = params->num_bssid;
1784 cmd->num_ssids = params->num_ssids;
1785 cmd->ie_len = params->ie_len;
1786 cmd->n_probes = params->n_probes;
1787 buf_ptr += sizeof(*cmd);
1788 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
1789 for (i = 0; i < params->num_chan; ++i)
1790 tmp_ptr[i] = params->chan_list[i];
1791
1792 WMITLV_SET_HDR(buf_ptr,
1793 WMITLV_TAG_ARRAY_UINT32,
1794 (params->num_chan * sizeof(uint32_t)));
1795 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05301796 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05301797 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05301798 goto error;
1799 }
1800
1801 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1802 (params->num_ssids * sizeof(wmi_ssid)));
1803
1804 if (params->num_ssids) {
1805 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
1806 for (i = 0; i < params->num_ssids; ++i) {
1807 ssid->ssid_len = params->ssid[i].length;
Govind Singhb53420c2016-03-09 14:32:57 +05301808 qdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05301809 params->ssid[i].length);
1810 ssid++;
1811 }
1812 }
1813 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
1814
1815 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1816 (params->num_bssid * sizeof(wmi_mac_addr)));
1817 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
1818 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
1819 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
1820
1821 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, params->ie_len_with_pad);
1822 if (params->ie_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05301823 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singhd3156eb2016-02-26 17:50:39 +05301824 (uint8_t *) params->ie_base +
1825 (params->uie_fieldOffset), params->ie_len);
1826 }
1827 buf_ptr += WMI_TLV_HDR_SIZE + params->ie_len_with_pad;
1828
1829 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1830 len, WMI_START_SCAN_CMDID);
1831 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301832 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301833 wmi_buf_free(wmi_buf);
1834 }
1835 return ret;
1836error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05301837 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05301838 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301839}
1840
1841/**
1842 * send_scan_stop_cmd_tlv() - WMI scan start function
1843 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301844 * @param param : pointer to hold scan start cmd parameter
1845 *
1846 * Return: 0 on success and -ve on failure.
1847 */
Govind Singhb53420c2016-03-09 14:32:57 +05301848QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301849 struct scan_stop_params *param)
1850{
Govind Singhd3156eb2016-02-26 17:50:39 +05301851 wmi_stop_scan_cmd_fixed_param *cmd;
1852 int ret;
1853 int len = sizeof(*cmd);
1854 wmi_buf_t wmi_buf;
1855
1856 /* Allocate the memory */
1857 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1858 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301859 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301860 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301861 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301862 goto error;
1863 }
1864
1865 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1866 WMITLV_SET_HDR(&cmd->tlv_header,
1867 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
1868 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
1869 cmd->vdev_id = param->vdev_id;
1870 cmd->requestor = param->requestor;
1871 cmd->scan_id = param->scan_id;
1872 /* stop the scan with the corresponding scan_id */
1873 cmd->req_type = param->req_type;
1874 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1875 len, WMI_STOP_SCAN_CMDID);
1876 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301877 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301878 wmi_buf_free(wmi_buf);
1879 }
1880
1881error:
1882 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301883}
1884
Govind Singh87542482016-06-08 19:40:11 +05301885#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301886/**
1887 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
1888 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301889 * @param param : pointer to hold scan channel list parameter
1890 *
1891 * Return: 0 on success and -ve on failure.
1892 */
Govind Singhb53420c2016-03-09 14:32:57 +05301893QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301894 struct scan_chan_list_params *chan_list)
1895{
1896 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05301897 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05301898 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301899 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05301900 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05301901 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05301902 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
1903
1904 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
1905 buf = wmi_buf_alloc(wmi_handle, len);
1906 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301907 WMI_LOGE("Failed to allocate memory");
1908 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301909 goto end;
1910 }
1911
1912 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1913 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
1914 WMITLV_SET_HDR(&cmd->tlv_header,
1915 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
1916 WMITLV_GET_STRUCT_TLVLEN
1917 (wmi_scan_chan_list_cmd_fixed_param));
1918
Govind Singhb53420c2016-03-09 14:32:57 +05301919 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301920
1921 cmd->num_scan_chans = chan_list->num_scan_chans;
1922 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
1923 WMITLV_TAG_ARRAY_STRUC,
1924 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05301925 chan_info = (wmi_channel_param *)
1926 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301927 tchan_info = chan_list->chan_info;
1928
1929 for (i = 0; i < chan_list->num_scan_chans; ++i) {
1930 WMITLV_SET_HDR(&chan_info->tlv_header,
1931 WMITLV_TAG_STRUC_wmi_channel,
1932 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
1933 chan_info->mhz = tchan_info->mhz;
1934 chan_info->band_center_freq1 =
1935 tchan_info->band_center_freq1;
1936 chan_info->band_center_freq2 =
1937 tchan_info->band_center_freq2;
1938 chan_info->info = tchan_info->info;
1939 chan_info->reg_info_1 = tchan_info->reg_info_1;
1940 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05301941 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05301942
1943 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
1944 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
1945 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
1946 tchan_info++;
1947 chan_info++;
1948 }
1949
Govind Singh67922e82016-04-01 16:48:57 +05301950 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singhd3156eb2016-02-26 17:50:39 +05301951 WMI_SCAN_CHAN_LIST_CMDID);
1952
Govind Singh67922e82016-04-01 16:48:57 +05301953 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301954 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05301955 wmi_buf_free(buf);
1956 }
Govind Singh67922e82016-04-01 16:48:57 +05301957
Govind Singhd3156eb2016-02-26 17:50:39 +05301958end:
Govind Singhb53420c2016-03-09 14:32:57 +05301959 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05301960}
Govind Singh87542482016-06-08 19:40:11 +05301961#else
1962QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
1963 struct scan_chan_list_params *chan_list)
1964{
1965 wmi_buf_t buf;
1966 QDF_STATUS qdf_status;
1967 wmi_scan_chan_list_cmd_fixed_param *cmd;
1968 int i;
1969 uint8_t *buf_ptr;
1970 wmi_channel *chan_info;
1971 struct channel_param *tchan_info;
1972 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05301973
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301974 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05301975 buf = wmi_buf_alloc(wmi_handle, len);
1976 if (!buf) {
1977 WMI_LOGE("Failed to allocate memory");
1978 qdf_status = QDF_STATUS_E_NOMEM;
1979 goto end;
1980 }
1981
1982 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1983 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
1984 WMITLV_SET_HDR(&cmd->tlv_header,
1985 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
1986 WMITLV_GET_STRUCT_TLVLEN
1987 (wmi_scan_chan_list_cmd_fixed_param));
1988
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301989 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05301990
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301991 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05301992 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
1993 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301994 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05301995 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
1996 tchan_info = &(chan_list->ch_param[0]);
1997
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301998 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05301999 WMITLV_SET_HDR(&chan_info->tlv_header,
2000 WMITLV_TAG_STRUC_wmi_channel,
2001 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2002 chan_info->mhz = tchan_info->mhz;
2003 chan_info->band_center_freq1 =
2004 tchan_info->cfreq1;
2005 chan_info->band_center_freq2 =
2006 tchan_info->cfreq2;
2007
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302008 if (tchan_info->is_chan_passive)
2009 WMI_SET_CHANNEL_FLAG(chan_info,
2010 WMI_CHAN_FLAG_PASSIVE);
2011
2012 if (tchan_info->allow_vht)
2013 WMI_SET_CHANNEL_FLAG(chan_info,
2014 WMI_CHAN_FLAG_ALLOW_VHT);
2015 else if (tchan_info->allow_ht)
2016 WMI_SET_CHANNEL_FLAG(chan_info,
2017 WMI_CHAN_FLAG_ALLOW_HT);
2018 WMI_SET_CHANNEL_MODE(chan_info,
2019 tchan_info->phy_mode);
2020
2021 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2022 * after FW support
2023 */
2024
2025 /* also fill in power information */
2026 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2027 tchan_info->minpower);
2028 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2029 tchan_info->maxpower);
2030 WMI_SET_CHANNEL_REG_POWER(chan_info,
2031 tchan_info->maxregpower);
2032 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2033 tchan_info->antennamax);
2034 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2035 tchan_info->reg_class_id);
2036
Govind Singh87542482016-06-08 19:40:11 +05302037 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2038
Govind Singh87542482016-06-08 19:40:11 +05302039 tchan_info++;
2040 chan_info++;
2041 }
2042
2043 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
2044 WMI_SCAN_CHAN_LIST_CMDID);
2045
2046 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2047 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2048 wmi_buf_free(buf);
2049 }
2050
2051end:
2052 return qdf_status;
2053}
2054#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302055/**
2056 * send_mgmt_cmd_tlv() - WMI scan start function
2057 * @wmi_handle : handle to WMI.
2058 * @param : pointer to hold mgmt cmd parameter
2059 *
2060 * Return: 0 on success and -ve on failure.
2061 */
Govind Singhb53420c2016-03-09 14:32:57 +05302062QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302063 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302064{
Govind Singh427ee5a2016-02-26 18:09:36 +05302065 wmi_buf_t buf;
2066 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2067 int32_t cmd_len;
2068 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302069 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302070 uint8_t *bufp;
2071 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2072 mgmt_tx_dl_frm_len;
2073
2074 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2075 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2076
2077 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2078 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302079 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2080 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302081 }
2082
2083 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2084 bufp = (uint8_t *) cmd;
2085 WMITLV_SET_HDR(&cmd->tlv_header,
2086 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2087 WMITLV_GET_STRUCT_TLVLEN
2088 (wmi_mgmt_tx_send_cmd_fixed_param));
2089
2090 cmd->vdev_id = param->vdev_id;
2091
Govind Singh224a7312016-06-21 14:33:26 +05302092 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302093 cmd->chanfreq = param->chanfreq;
2094 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2095 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2096 sizeof(uint32_t)));
2097 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302098 qdf_mem_copy(bufp, param->pdata, bufp_len);
2099 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2100 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302101 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2102#if defined(HELIUMPLUS_PADDR64)
2103 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2104#endif
2105 cmd->frame_len = param->frm_len;
2106 cmd->buf_len = bufp_len;
2107
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002108 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002109 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002110
Govind Singh427ee5a2016-02-26 18:09:36 +05302111 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2112 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302113 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302114 goto err1;
2115 }
Govind Singhb53420c2016-03-09 14:32:57 +05302116 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302117
2118err1:
2119 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302120 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302121}
2122
2123/**
2124 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2125 * @wmi_handle: wmi handle
2126 * @param_value: parameter value
2127 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302128 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302129 */
Govind Singhb53420c2016-03-09 14:32:57 +05302130QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302131 uint32_t param_value)
2132{
Govind Singh67922e82016-04-01 16:48:57 +05302133 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302134 wmi_modem_power_state_cmd_param *cmd;
2135 wmi_buf_t buf;
2136 uint16_t len = sizeof(*cmd);
2137
2138 buf = wmi_buf_alloc(wmi_handle, len);
2139 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302140 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302141 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302142 }
2143 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2144 WMITLV_SET_HDR(&cmd->tlv_header,
2145 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2146 WMITLV_GET_STRUCT_TLVLEN
2147 (wmi_modem_power_state_cmd_param));
2148 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302149 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302150 param_value);
2151 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2152 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302153 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302154 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302155 wmi_buf_free(buf);
2156 }
Govind Singh67922e82016-04-01 16:48:57 +05302157
Govind Singh427ee5a2016-02-26 18:09:36 +05302158 return ret;
2159}
2160
2161/**
2162 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2163 * @wmi_handle: wmi handle
2164 * @vdev_id: vdev id
2165 * @val: value
2166 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302167 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302168 */
Govind Singhb53420c2016-03-09 14:32:57 +05302169QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302170 uint32_t vdev_id, uint8_t val)
2171{
2172 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2173 wmi_buf_t buf;
2174 int32_t len = sizeof(*cmd);
2175
Govind Singhb53420c2016-03-09 14:32:57 +05302176 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302177
2178 buf = wmi_buf_alloc(wmi_handle, len);
2179 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302180 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302181 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302182 }
2183 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2184 WMITLV_SET_HDR(&cmd->tlv_header,
2185 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2186 WMITLV_GET_STRUCT_TLVLEN
2187 (wmi_sta_powersave_mode_cmd_fixed_param));
2188 cmd->vdev_id = vdev_id;
2189 if (val)
2190 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2191 else
2192 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2193
2194 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2195 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302196 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302197 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302198 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302199 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302200 }
Govind Singh5eb51532016-03-09 11:34:12 +05302201 return 0;
2202}
2203
Govind Singh427ee5a2016-02-26 18:09:36 +05302204/**
2205 * send_set_mimops_cmd_tlv() - set MIMO powersave
2206 * @wmi_handle: wmi handle
2207 * @vdev_id: vdev id
2208 * @value: value
2209 *
Govind Singhb53420c2016-03-09 14:32:57 +05302210 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302211 */
Govind Singhb53420c2016-03-09 14:32:57 +05302212QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302213 uint8_t vdev_id, int value)
2214{
Govind Singh67922e82016-04-01 16:48:57 +05302215 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302216 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2217 wmi_buf_t buf;
2218 uint16_t len = sizeof(*cmd);
2219
2220 buf = wmi_buf_alloc(wmi_handle, len);
2221 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302222 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302223 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302224 }
2225 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2226 WMITLV_SET_HDR(&cmd->tlv_header,
2227 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2228 WMITLV_GET_STRUCT_TLVLEN
2229 (wmi_sta_smps_force_mode_cmd_fixed_param));
2230
2231 cmd->vdev_id = vdev_id;
2232
Houston Hoffmanb5168052016-04-14 02:18:01 -07002233 /* WMI_SMPS_FORCED_MODE values do not directly map
2234 * to SM power save values defined in the specification.
2235 * Make sure to send the right mapping.
2236 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302237 switch (value) {
2238 case 0:
2239 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2240 break;
2241 case 1:
2242 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2243 break;
2244 case 2:
2245 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2246 break;
2247 case 3:
2248 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2249 break;
2250 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302251 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2252 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302253 }
2254
Govind Singhb53420c2016-03-09 14:32:57 +05302255 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302256
2257 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2258 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302259 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302260 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302261 wmi_buf_free(buf);
2262 }
2263
2264 return ret;
2265}
2266
2267/**
2268 * send_set_smps_params_cmd_tlv() - set smps params
2269 * @wmi_handle: wmi handle
2270 * @vdev_id: vdev id
2271 * @value: value
2272 *
Govind Singhb53420c2016-03-09 14:32:57 +05302273 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302274 */
Govind Singhb53420c2016-03-09 14:32:57 +05302275QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302276 int value)
2277{
Govind Singh67922e82016-04-01 16:48:57 +05302278 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302279 wmi_sta_smps_param_cmd_fixed_param *cmd;
2280 wmi_buf_t buf;
2281 uint16_t len = sizeof(*cmd);
2282
2283 buf = wmi_buf_alloc(wmi_handle, len);
2284 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302285 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302286 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302287 }
2288 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2289 WMITLV_SET_HDR(&cmd->tlv_header,
2290 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2291 WMITLV_GET_STRUCT_TLVLEN
2292 (wmi_sta_smps_param_cmd_fixed_param));
2293
2294 cmd->vdev_id = vdev_id;
2295 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2296 cmd->param =
2297 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2298
Govind Singhb53420c2016-03-09 14:32:57 +05302299 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302300 cmd->param);
2301
2302 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2303 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302304 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302305 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302306 wmi_buf_free(buf);
2307 }
2308
2309 return ret;
2310}
2311
2312/**
2313 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2314 * @wmi_handle: wmi handle
2315 * @noa: p2p power save parameters
2316 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302317 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302318 */
Govind Singhb53420c2016-03-09 14:32:57 +05302319QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302320 struct p2p_ps_params *noa)
2321{
2322 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2323 wmi_p2p_noa_descriptor *noa_discriptor;
2324 wmi_buf_t buf;
2325 uint8_t *buf_ptr;
2326 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302327 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302328 uint32_t duration;
2329
Govind Singhb53420c2016-03-09 14:32:57 +05302330 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302331 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2332 buf = wmi_buf_alloc(wmi_handle, len);
2333 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302334 WMI_LOGE("Failed to allocate memory");
2335 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302336 goto end;
2337 }
2338
2339 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2340 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2341 WMITLV_SET_HDR(&cmd->tlv_header,
2342 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2343 WMITLV_GET_STRUCT_TLVLEN
2344 (wmi_p2p_set_noa_cmd_fixed_param));
2345 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2346 cmd->vdev_id = noa->session_id;
2347 cmd->enable = (duration) ? true : false;
2348 cmd->num_noa = 1;
2349
2350 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2351 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2352 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2353 sizeof
2354 (wmi_p2p_set_noa_cmd_fixed_param)
2355 + WMI_TLV_HDR_SIZE);
2356 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2357 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2358 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2359 noa_discriptor->type_count = noa->count;
2360 noa_discriptor->duration = duration;
2361 noa_discriptor->interval = noa->interval;
2362 noa_discriptor->start_time = 0;
2363
Govind Singhb53420c2016-03-09 14:32:57 +05302364 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302365 cmd->vdev_id, noa->count, noa_discriptor->duration,
2366 noa->interval);
2367 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2368 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302369 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302370 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302371 wmi_buf_free(buf);
2372 }
2373
2374end:
Govind Singhb53420c2016-03-09 14:32:57 +05302375 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302376 return status;
2377}
2378
2379
2380/**
2381 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2382 * @wmi_handle: wmi handle
2383 * @noa: p2p opp power save parameters
2384 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302385 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302386 */
Govind Singhb53420c2016-03-09 14:32:57 +05302387QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302388 struct p2p_ps_params *oppps)
2389{
2390 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2391 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302392 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302393
Govind Singhb53420c2016-03-09 14:32:57 +05302394 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302395 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2396 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302397 WMI_LOGE("Failed to allocate memory");
2398 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302399 goto end;
2400 }
2401
2402 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2403 WMITLV_SET_HDR(&cmd->tlv_header,
2404 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2405 WMITLV_GET_STRUCT_TLVLEN
2406 (wmi_p2p_set_oppps_cmd_fixed_param));
2407 cmd->vdev_id = oppps->session_id;
2408 if (oppps->ctwindow)
2409 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2410
2411 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302412 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302413 cmd->vdev_id, oppps->ctwindow);
2414 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2415 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302416 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302417 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302418 wmi_buf_free(buf);
2419 }
2420
2421end:
Govind Singhb53420c2016-03-09 14:32:57 +05302422 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302423 return status;
2424}
2425
2426/**
2427 * send_get_temperature_cmd_tlv() - get pdev temperature req
2428 * @wmi_handle: wmi handle
2429 *
Govind Singhb53420c2016-03-09 14:32:57 +05302430 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302431 */
Govind Singhb53420c2016-03-09 14:32:57 +05302432QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05302433{
2434 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
2435 wmi_buf_t wmi_buf;
2436 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
2437 uint8_t *buf_ptr;
2438
2439 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05302440 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
2441 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05302442 }
2443
2444 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2445 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302446 WMI_LOGE(FL("wmi_buf_alloc failed"));
2447 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302448 }
2449
2450 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2451
2452 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
2453 WMITLV_SET_HDR(&cmd->tlv_header,
2454 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
2455 WMITLV_GET_STRUCT_TLVLEN
2456 (wmi_pdev_get_temperature_cmd_fixed_param));
2457
2458 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
2459 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302460 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05302461 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302462 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302463 }
Govind Singh2edc80f2016-03-01 15:30:53 +05302464
Govind Singhb53420c2016-03-09 14:32:57 +05302465 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302466}
2467
2468/**
2469 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
2470 * @wmi_handle: wmi handle
2471 * @vdevid: vdev id
2472 * @peer_addr: peer mac address
2473 * @auto_triggerparam: auto trigger parameters
2474 * @num_ac: number of access category
2475 *
2476 * This function sets the trigger
2477 * uapsd params such as service interval, delay interval
2478 * and suspend interval which will be used by the firmware
2479 * to send trigger frames periodically when there is no
2480 * traffic on the transmit side.
2481 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302482 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302483 */
Govind Singhb53420c2016-03-09 14:32:57 +05302484QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302485 struct sta_uapsd_trig_params *param)
2486{
2487 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302488 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302489 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
2490 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
2491 uint32_t i;
2492 wmi_buf_t buf;
2493 uint8_t *buf_ptr;
2494
2495 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2496 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302497 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302498 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302499 }
2500
2501 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2502 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
2503 WMITLV_SET_HDR(&cmd->tlv_header,
2504 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
2505 WMITLV_GET_STRUCT_TLVLEN
2506 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
2507 cmd->vdev_id = param->vdevid;
2508 cmd->num_ac = param->num_ac;
2509 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
2510
2511 /* TLV indicating array of structures to follow */
2512 buf_ptr += sizeof(*cmd);
2513 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
2514
2515 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302516 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302517
2518 /*
2519 * Update tag and length for uapsd auto trigger params (this will take
2520 * care of updating tag and length if it is not pre-filled by caller).
2521 */
2522 for (i = 0; i < param->num_ac; i++) {
2523 WMITLV_SET_HDR((buf_ptr +
2524 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
2525 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
2526 WMITLV_GET_STRUCT_TLVLEN
2527 (wmi_sta_uapsd_auto_trig_param));
2528 }
2529
2530 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2531 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302532 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302533 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302534 wmi_buf_free(buf);
2535 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05302536
Govind Singh427ee5a2016-02-26 18:09:36 +05302537 return ret;
2538}
2539
Govind Singh2edc80f2016-03-01 15:30:53 +05302540/**
2541 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
2542 * @wmi_handle: pointer to the wmi handle
2543 * @utc: pointer to the UTC time struct
2544 *
2545 * Return: 0 on succes
2546 */
Govind Singhb53420c2016-03-09 14:32:57 +05302547QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302548 struct ocb_utc_param *utc)
2549{
Govind Singh67922e82016-04-01 16:48:57 +05302550 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302551 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
2552 uint8_t *buf_ptr;
2553 uint32_t len, i;
2554 wmi_buf_t buf;
2555
2556 len = sizeof(*cmd);
2557 buf = wmi_buf_alloc(wmi_handle, len);
2558 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302559 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302560 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302561 }
2562
2563 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2564 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
2565 WMITLV_SET_HDR(&cmd->tlv_header,
2566 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
2567 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
2568 cmd->vdev_id = utc->vdev_id;
2569
2570 for (i = 0; i < SIZE_UTC_TIME; i++)
2571 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
2572
2573 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
2574 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
2575
2576 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2577 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302578 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302579 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302580 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302581 }
2582
Govind Singh67922e82016-04-01 16:48:57 +05302583 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302584}
2585
2586/**
2587 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
2588 * frames on a channel
2589 * @wmi_handle: pointer to the wmi handle
2590 * @timing_advert: pointer to the timing advertisement struct
2591 *
2592 * Return: 0 on succes
2593 */
Govind Singhb53420c2016-03-09 14:32:57 +05302594QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302595 struct ocb_timing_advert_param *timing_advert)
2596{
Govind Singh67922e82016-04-01 16:48:57 +05302597 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302598 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
2599 uint8_t *buf_ptr;
2600 uint32_t len, len_template;
2601 wmi_buf_t buf;
2602
2603 len = sizeof(*cmd) +
2604 WMI_TLV_HDR_SIZE;
2605
2606 len_template = timing_advert->template_length;
2607 /* Add padding to the template if needed */
2608 if (len_template % 4 != 0)
2609 len_template += 4 - (len_template % 4);
2610 len += len_template;
2611
2612 buf = wmi_buf_alloc(wmi_handle, len);
2613 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302614 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302615 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302616 }
2617
2618 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2619 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
2620 WMITLV_SET_HDR(&cmd->tlv_header,
2621 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
2622 WMITLV_GET_STRUCT_TLVLEN(
2623 wmi_ocb_start_timing_advert_cmd_fixed_param));
2624 cmd->vdev_id = timing_advert->vdev_id;
2625 cmd->repeat_rate = timing_advert->repeat_rate;
2626 cmd->channel_freq = timing_advert->chan_freq;
2627 cmd->timestamp_offset = timing_advert->timestamp_offset;
2628 cmd->time_value_offset = timing_advert->time_value_offset;
2629 cmd->timing_advert_template_length = timing_advert->template_length;
2630 buf_ptr += sizeof(*cmd);
2631
2632 /* Add the timing advert template */
2633 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2634 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05302635 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05302636 (uint8_t *)timing_advert->template_value,
2637 timing_advert->template_length);
2638
2639 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2640 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302641 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302642 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302643 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302644 }
2645
Govind Singh67922e82016-04-01 16:48:57 +05302646 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302647}
2648
2649/**
2650 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
2651 * on a channel
2652 * @wmi_handle: pointer to the wmi handle
2653 * @timing_advert: pointer to the timing advertisement struct
2654 *
2655 * Return: 0 on succes
2656 */
Govind Singhb53420c2016-03-09 14:32:57 +05302657QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302658 struct ocb_timing_advert_param *timing_advert)
2659{
Govind Singh67922e82016-04-01 16:48:57 +05302660 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302661 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
2662 uint8_t *buf_ptr;
2663 uint32_t len;
2664 wmi_buf_t buf;
2665
2666 len = sizeof(*cmd);
2667 buf = wmi_buf_alloc(wmi_handle, len);
2668 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302669 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302670 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302671 }
2672
2673 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2674 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
2675 WMITLV_SET_HDR(&cmd->tlv_header,
2676 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
2677 WMITLV_GET_STRUCT_TLVLEN(
2678 wmi_ocb_stop_timing_advert_cmd_fixed_param));
2679 cmd->vdev_id = timing_advert->vdev_id;
2680 cmd->channel_freq = timing_advert->chan_freq;
2681
2682 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2683 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302684 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302685 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302686 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302687 }
2688
Govind Singh67922e82016-04-01 16:48:57 +05302689 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302690}
2691
2692/**
2693 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
2694 * @wmi_handle: pointer to the wmi handle
2695 * @request: pointer to the request
2696 *
2697 * Return: 0 on succes
2698 */
Govind Singhb53420c2016-03-09 14:32:57 +05302699QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302700 uint8_t vdev_id)
2701{
Govind Singhb53420c2016-03-09 14:32:57 +05302702 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302703 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
2704 uint8_t *buf_ptr;
2705 wmi_buf_t buf;
2706 int32_t len;
2707
2708 len = sizeof(*cmd);
2709 buf = wmi_buf_alloc(wmi_handle, len);
2710 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302711 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302712 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302713 }
2714 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2715
2716 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302717 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302718 WMITLV_SET_HDR(&cmd->tlv_header,
2719 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
2720 WMITLV_GET_STRUCT_TLVLEN(
2721 wmi_ocb_get_tsf_timer_cmd_fixed_param));
2722 cmd->vdev_id = vdev_id;
2723
2724 /* Send the WMI command */
2725 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2726 WMI_OCB_GET_TSF_TIMER_CMDID);
2727 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05302728 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302729 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302730 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302731 }
2732
Govind Singh67922e82016-04-01 16:48:57 +05302733 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302734}
2735
2736/**
2737 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
2738 * @wmi_handle: pointer to the wmi handle
2739 * @get_stats_param: pointer to the dcc stats
2740 *
2741 * Return: 0 on succes
2742 */
Govind Singhb53420c2016-03-09 14:32:57 +05302743QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302744 struct dcc_get_stats_param *get_stats_param)
2745{
Govind Singh67922e82016-04-01 16:48:57 +05302746 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302747 wmi_dcc_get_stats_cmd_fixed_param *cmd;
2748 wmi_dcc_channel_stats_request *channel_stats_array;
2749 wmi_buf_t buf;
2750 uint8_t *buf_ptr;
2751 uint32_t len;
2752 uint32_t i;
2753
2754 /* Validate the input */
2755 if (get_stats_param->request_array_len !=
2756 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302757 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05302758 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302759 }
2760
2761 /* Allocate memory for the WMI command */
2762 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
2763 get_stats_param->request_array_len;
2764
2765 buf = wmi_buf_alloc(wmi_handle, len);
2766 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302767 WMI_LOGE(FL("wmi_buf_alloc failed"));
2768 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302769 }
2770
2771 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302772 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302773
2774 /* Populate the WMI command */
2775 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
2776 buf_ptr += sizeof(*cmd);
2777
2778 WMITLV_SET_HDR(&cmd->tlv_header,
2779 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
2780 WMITLV_GET_STRUCT_TLVLEN(
2781 wmi_dcc_get_stats_cmd_fixed_param));
2782 cmd->vdev_id = get_stats_param->vdev_id;
2783 cmd->num_channels = get_stats_param->channel_count;
2784
2785 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2786 get_stats_param->request_array_len);
2787 buf_ptr += WMI_TLV_HDR_SIZE;
2788
2789 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302790 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05302791 get_stats_param->request_array_len);
2792 for (i = 0; i < cmd->num_channels; i++)
2793 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
2794 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
2795 WMITLV_GET_STRUCT_TLVLEN(
2796 wmi_dcc_channel_stats_request));
2797
2798 /* Send the WMI command */
2799 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2800 WMI_DCC_GET_STATS_CMDID);
2801
Govind Singh67922e82016-04-01 16:48:57 +05302802 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302803 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302804 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302805 }
2806
Govind Singh67922e82016-04-01 16:48:57 +05302807 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302808}
2809
2810/**
2811 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
2812 * @wmi_handle: pointer to the wmi handle
2813 * @vdev_id: vdev id
2814 * @dcc_stats_bitmap: dcc status bitmap
2815 *
2816 * Return: 0 on succes
2817 */
Govind Singhb53420c2016-03-09 14:32:57 +05302818QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302819 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
2820{
Govind Singh67922e82016-04-01 16:48:57 +05302821 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302822 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
2823 wmi_buf_t buf;
2824 uint8_t *buf_ptr;
2825 uint32_t len;
2826
2827 /* Allocate memory for the WMI command */
2828 len = sizeof(*cmd);
2829
2830 buf = wmi_buf_alloc(wmi_handle, len);
2831 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302832 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302833 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302834 }
2835
2836 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302837 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302838
2839 /* Populate the WMI command */
2840 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
2841
2842 WMITLV_SET_HDR(&cmd->tlv_header,
2843 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
2844 WMITLV_GET_STRUCT_TLVLEN(
2845 wmi_dcc_clear_stats_cmd_fixed_param));
2846 cmd->vdev_id = vdev_id;
2847 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
2848
2849 /* Send the WMI command */
2850 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2851 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302852 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302853 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302854 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302855 }
2856
Govind Singh67922e82016-04-01 16:48:57 +05302857 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302858}
2859
2860/**
2861 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
2862 * @wmi_handle: pointer to the wmi handle
2863 * @update_ndl_param: pointer to the request parameters
2864 *
2865 * Return: 0 on success
2866 */
Govind Singhb53420c2016-03-09 14:32:57 +05302867QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302868 struct dcc_update_ndl_param *update_ndl_param)
2869{
Govind Singhb53420c2016-03-09 14:32:57 +05302870 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05302871 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
2872 wmi_dcc_ndl_chan *ndl_chan_array;
2873 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
2874 uint32_t active_state_count;
2875 wmi_buf_t buf;
2876 uint8_t *buf_ptr;
2877 uint32_t len;
2878 uint32_t i;
2879
2880 /* validate the input */
2881 if (update_ndl_param->dcc_ndl_chan_list_len !=
2882 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302883 WMI_LOGE(FL("Invalid parameter"));
2884 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302885 }
2886 active_state_count = 0;
2887 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
2888 for (i = 0; i < update_ndl_param->channel_count; i++)
2889 active_state_count +=
2890 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
2891 if (update_ndl_param->dcc_ndl_active_state_list_len !=
2892 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302893 WMI_LOGE(FL("Invalid parameter"));
2894 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302895 }
2896
2897 /* Allocate memory for the WMI command */
2898 len = sizeof(*cmd) +
2899 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
2900 WMI_TLV_HDR_SIZE +
2901 update_ndl_param->dcc_ndl_active_state_list_len;
2902
2903 buf = wmi_buf_alloc(wmi_handle, len);
2904 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302905 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302906 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302907 }
2908
2909 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302910 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302911
2912 /* Populate the WMI command */
2913 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
2914 buf_ptr += sizeof(*cmd);
2915
2916 WMITLV_SET_HDR(&cmd->tlv_header,
2917 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
2918 WMITLV_GET_STRUCT_TLVLEN(
2919 wmi_dcc_update_ndl_cmd_fixed_param));
2920 cmd->vdev_id = update_ndl_param->vdev_id;
2921 cmd->num_channel = update_ndl_param->channel_count;
2922
2923 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2924 update_ndl_param->dcc_ndl_chan_list_len);
2925 buf_ptr += WMI_TLV_HDR_SIZE;
2926
2927 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302928 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05302929 update_ndl_param->dcc_ndl_chan_list_len);
2930 for (i = 0; i < cmd->num_channel; i++)
2931 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
2932 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
2933 WMITLV_GET_STRUCT_TLVLEN(
2934 wmi_dcc_ndl_chan));
2935 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
2936
2937 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2938 update_ndl_param->dcc_ndl_active_state_list_len);
2939 buf_ptr += WMI_TLV_HDR_SIZE;
2940
2941 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302942 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05302943 update_ndl_param->dcc_ndl_active_state_list,
2944 update_ndl_param->dcc_ndl_active_state_list_len);
2945 for (i = 0; i < active_state_count; i++) {
2946 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
2947 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
2948 WMITLV_GET_STRUCT_TLVLEN(
2949 wmi_dcc_ndl_active_state_config));
2950 }
2951 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
2952
2953 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05302954 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05302955 WMI_DCC_UPDATE_NDL_CMDID);
2956 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05302957 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302958 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05302959 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302960 }
2961
Govind Singh67922e82016-04-01 16:48:57 +05302962 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05302963}
2964
2965/**
2966 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
2967 * @wmi_handle: pointer to the wmi handle
2968 * @config: the OCB configuration
2969 *
2970 * Return: 0 on success
2971 */
Govind Singhb53420c2016-03-09 14:32:57 +05302972QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302973 struct ocb_config_param *config, uint32_t *ch_mhz)
2974{
Govind Singh67922e82016-04-01 16:48:57 +05302975 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302976 wmi_ocb_set_config_cmd_fixed_param *cmd;
2977 wmi_channel *chan;
2978 wmi_ocb_channel *ocb_chan;
2979 wmi_qos_parameter *qos_param;
2980 wmi_dcc_ndl_chan *ndl_chan;
2981 wmi_dcc_ndl_active_state_config *ndl_active_config;
2982 wmi_ocb_schedule_element *sched_elem;
2983 uint8_t *buf_ptr;
2984 wmi_buf_t buf;
2985 int32_t len;
2986 int32_t i, j, active_state_count;
2987
2988 /*
2989 * Validate the dcc_ndl_chan_list_len and count the number of active
2990 * states. Validate dcc_ndl_active_state_list_len.
2991 */
2992 active_state_count = 0;
2993 if (config->dcc_ndl_chan_list_len) {
2994 if (!config->dcc_ndl_chan_list ||
2995 config->dcc_ndl_chan_list_len !=
2996 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302997 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05302998 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05302999 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303000 }
3001
3002 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3003 i < config->channel_count; ++i, ++ndl_chan)
3004 active_state_count +=
3005 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3006
3007 if (active_state_count) {
3008 if (!config->dcc_ndl_active_state_list ||
3009 config->dcc_ndl_active_state_list_len !=
3010 active_state_count *
3011 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303012 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303013 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303014 }
3015 }
3016 }
3017
3018 len = sizeof(*cmd) +
3019 WMI_TLV_HDR_SIZE + config->channel_count *
3020 sizeof(wmi_channel) +
3021 WMI_TLV_HDR_SIZE + config->channel_count *
3022 sizeof(wmi_ocb_channel) +
3023 WMI_TLV_HDR_SIZE + config->channel_count *
3024 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3025 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3026 WMI_TLV_HDR_SIZE + active_state_count *
3027 sizeof(wmi_dcc_ndl_active_state_config) +
3028 WMI_TLV_HDR_SIZE + config->schedule_size *
3029 sizeof(wmi_ocb_schedule_element);
3030 buf = wmi_buf_alloc(wmi_handle, len);
3031 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303032 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303033 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303034 }
3035
3036 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3037 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3038 WMITLV_SET_HDR(&cmd->tlv_header,
3039 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3040 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3041 cmd->vdev_id = config->session_id;
3042 cmd->channel_count = config->channel_count;
3043 cmd->schedule_size = config->schedule_size;
3044 cmd->flags = config->flags;
3045 buf_ptr += sizeof(*cmd);
3046
3047 /* Add the wmi_channel info */
3048 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3049 config->channel_count*sizeof(wmi_channel));
3050 buf_ptr += WMI_TLV_HDR_SIZE;
3051 for (i = 0; i < config->channel_count; i++) {
3052 chan = (wmi_channel *)buf_ptr;
3053 WMITLV_SET_HDR(&chan->tlv_header,
3054 WMITLV_TAG_STRUC_wmi_channel,
3055 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3056 chan->mhz = config->channels[i].chan_freq;
3057 chan->band_center_freq1 = config->channels[i].chan_freq;
3058 chan->band_center_freq2 = 0;
3059 chan->info = 0;
3060
3061 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3062 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3063 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3064 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3065 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3066 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3067 config->channels[i].antenna_max);
3068
3069 if (config->channels[i].bandwidth < 10)
3070 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3071 else if (config->channels[i].bandwidth < 20)
3072 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3073 buf_ptr += sizeof(*chan);
3074 }
3075
3076 /* Add the wmi_ocb_channel info */
3077 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3078 config->channel_count*sizeof(wmi_ocb_channel));
3079 buf_ptr += WMI_TLV_HDR_SIZE;
3080 for (i = 0; i < config->channel_count; i++) {
3081 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3082 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3083 WMITLV_TAG_STRUC_wmi_ocb_channel,
3084 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3085 ocb_chan->bandwidth = config->channels[i].bandwidth;
3086 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3087 config->channels[i].mac_address.bytes,
3088 &ocb_chan->mac_address);
3089 buf_ptr += sizeof(*ocb_chan);
3090 }
3091
3092 /* Add the wmi_qos_parameter info */
3093 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3094 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3095 buf_ptr += WMI_TLV_HDR_SIZE;
3096 /* WMI_MAX_NUM_AC parameters for each channel */
3097 for (i = 0; i < config->channel_count; i++) {
3098 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3099 qos_param = (wmi_qos_parameter *)buf_ptr;
3100 WMITLV_SET_HDR(&qos_param->tlv_header,
3101 WMITLV_TAG_STRUC_wmi_qos_parameter,
3102 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3103 qos_param->aifsn =
3104 config->channels[i].qos_params[j].aifsn;
3105 qos_param->cwmin =
3106 config->channels[i].qos_params[j].cwmin;
3107 qos_param->cwmax =
3108 config->channels[i].qos_params[j].cwmax;
3109 buf_ptr += sizeof(*qos_param);
3110 }
3111 }
3112
3113 /* Add the wmi_dcc_ndl_chan (per channel) */
3114 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3115 config->dcc_ndl_chan_list_len);
3116 buf_ptr += WMI_TLV_HDR_SIZE;
3117 if (config->dcc_ndl_chan_list_len) {
3118 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303119 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303120 config->dcc_ndl_chan_list_len);
3121 for (i = 0; i < config->channel_count; i++)
3122 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3123 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3124 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3125 buf_ptr += config->dcc_ndl_chan_list_len;
3126 }
3127
3128 /* Add the wmi_dcc_ndl_active_state_config */
3129 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3130 sizeof(wmi_dcc_ndl_active_state_config));
3131 buf_ptr += WMI_TLV_HDR_SIZE;
3132 if (active_state_count) {
3133 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303134 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303135 config->dcc_ndl_active_state_list,
3136 active_state_count * sizeof(*ndl_active_config));
3137 for (i = 0; i < active_state_count; ++i)
3138 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3139 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3140 WMITLV_GET_STRUCT_TLVLEN(
3141 wmi_dcc_ndl_active_state_config));
3142 buf_ptr += active_state_count *
3143 sizeof(*ndl_active_config);
3144 }
3145
3146 /* Add the wmi_ocb_schedule_element info */
3147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3148 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3149 buf_ptr += WMI_TLV_HDR_SIZE;
3150 for (i = 0; i < config->schedule_size; i++) {
3151 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3152 WMITLV_SET_HDR(&sched_elem->tlv_header,
3153 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3154 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3155 sched_elem->channel_freq = config->schedule[i].chan_freq;
3156 sched_elem->total_duration = config->schedule[i].total_duration;
3157 sched_elem->guard_interval = config->schedule[i].guard_interval;
3158 buf_ptr += sizeof(*sched_elem);
3159 }
3160
3161
3162 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3163 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303164 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303165 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303166 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303167 }
3168
Govind Singh67922e82016-04-01 16:48:57 +05303169 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303170}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303171
3172/**
3173 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3174 * @wmi_handle: wmi handle
3175 * @mcc_adaptive_scheduler: enable/disable
3176 *
3177 * This function enable/disable mcc adaptive scheduler in fw.
3178 *
Govind Singhb53420c2016-03-09 14:32:57 +05303179 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303180 */
Govind Singhb53420c2016-03-09 14:32:57 +05303181QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003182 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3183 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303184{
Govind Singh67922e82016-04-01 16:48:57 +05303185 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303186 wmi_buf_t buf = 0;
3187 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3188 uint16_t len =
3189 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3190
3191 buf = wmi_buf_alloc(wmi_handle, len);
3192 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303193 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3194 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303195 }
3196 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3197 wmi_buf_data(buf);
3198
3199 WMITLV_SET_HDR(&cmd->tlv_header,
3200 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3201 WMITLV_GET_STRUCT_TLVLEN
3202 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3203 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003204 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303205
3206 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3207 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303208 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303209 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303210 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303211 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303212 }
Govind Singh67922e82016-04-01 16:48:57 +05303213
3214 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303215}
3216
3217/**
3218 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3219 * @wmi: wmi handle
3220 * @mcc_channel: mcc channel
3221 * @mcc_channel_time_latency: MCC channel time latency.
3222 *
3223 * Currently used to set time latency for an MCC vdev/adapter using operating
3224 * channel of it and channel number. The info is provided run time using
3225 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3226 *
3227 * Return: CDF status
3228 */
Govind Singhb53420c2016-03-09 14:32:57 +05303229QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303230 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3231{
Govind Singh67922e82016-04-01 16:48:57 +05303232 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303233 wmi_buf_t buf = 0;
3234 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3235 uint16_t len = 0;
3236 uint8_t *buf_ptr = NULL;
3237 wmi_resmgr_chan_latency chan_latency;
3238 /* Note: we only support MCC time latency for a single channel */
3239 uint32_t num_channels = 1;
3240 uint32_t chan1_freq = mcc_channel_freq;
3241 uint32_t latency_chan1 = mcc_channel_time_latency;
3242
3243
3244 /* If 0ms latency is provided, then FW will set to a default.
3245 * Otherwise, latency must be at least 30ms.
3246 */
3247 if ((latency_chan1 > 0) &&
3248 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303249 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303250 "Minimum is 30ms (or 0 to use default value by "
3251 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303252 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303253 }
3254
3255 /* Set WMI CMD for channel time latency here */
3256 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3257 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3258 num_channels * sizeof(wmi_resmgr_chan_latency);
3259 buf = wmi_buf_alloc(wmi_handle, len);
3260 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303261 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3262 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303263 }
3264 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3265 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3266 wmi_buf_data(buf);
3267 WMITLV_SET_HDR(&cmdTL->tlv_header,
3268 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3269 WMITLV_GET_STRUCT_TLVLEN
3270 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3271 cmdTL->num_chans = num_channels;
3272 /* Update channel time latency information for home channel(s) */
3273 buf_ptr += sizeof(*cmdTL);
3274 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3275 num_channels * sizeof(wmi_resmgr_chan_latency));
3276 buf_ptr += WMI_TLV_HDR_SIZE;
3277 chan_latency.chan_mhz = chan1_freq;
3278 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303279 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303280 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3281 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303282 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303283 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303284 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303285 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303286 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303287 }
Govind Singh67922e82016-04-01 16:48:57 +05303288
3289 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303290}
3291
3292/**
3293 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3294 * @wmi: wmi handle
3295 * @adapter_1_chan_number: adapter 1 channel number
3296 * @adapter_1_quota: adapter 1 quota
3297 * @adapter_2_chan_number: adapter 2 channel number
3298 *
3299 * Return: CDF status
3300 */
Govind Singhb53420c2016-03-09 14:32:57 +05303301QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303302 uint32_t adapter_1_chan_freq,
3303 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3304{
Govind Singh67922e82016-04-01 16:48:57 +05303305 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303306 wmi_buf_t buf = 0;
3307 uint16_t len = 0;
3308 uint8_t *buf_ptr = NULL;
3309 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3310 wmi_resmgr_chan_time_quota chan_quota;
3311 uint32_t quota_chan1 = adapter_1_quota;
3312 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3313 uint32_t quota_chan2 = 100 - quota_chan1;
3314 /* Note: setting time quota for MCC requires info for 2 channels */
3315 uint32_t num_channels = 2;
3316 uint32_t chan1_freq = adapter_1_chan_freq;
3317 uint32_t chan2_freq = adapter_2_chan_freq;
3318
Govind Singhb53420c2016-03-09 14:32:57 +05303319 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303320 "freq2:%dMHz, Quota2:%dms", __func__,
3321 chan1_freq, quota_chan1, chan2_freq,
3322 quota_chan2);
3323
3324 /*
3325 * Perform sanity check on time quota values provided.
3326 */
3327 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3328 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303329 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303330 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303331 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303332 }
3333 /* Set WMI CMD for channel time quota here */
3334 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3335 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3336 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3337 buf = wmi_buf_alloc(wmi_handle, len);
3338 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303339 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3340 QDF_ASSERT(0);
3341 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303342 }
3343 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3344 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3345 wmi_buf_data(buf);
3346 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3347 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3348 WMITLV_GET_STRUCT_TLVLEN
3349 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3350 cmdTQ->num_chans = num_channels;
3351
3352 /* Update channel time quota information for home channel(s) */
3353 buf_ptr += sizeof(*cmdTQ);
3354 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3355 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3356 buf_ptr += WMI_TLV_HDR_SIZE;
3357 chan_quota.chan_mhz = chan1_freq;
3358 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303359 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303360 /* Construct channel and quota record for the 2nd MCC mode. */
3361 buf_ptr += sizeof(chan_quota);
3362 chan_quota.chan_mhz = chan2_freq;
3363 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05303364 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303365
3366 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3367 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303368 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303369 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303370 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303371 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303372 }
Govind Singh67922e82016-04-01 16:48:57 +05303373
3374 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303375}
3376
3377/**
3378 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3379 * @wmi_handle: Pointer to wmi handle
3380 * @thermal_info: Thermal command information
3381 *
3382 * This function sends the thermal management command
3383 * to the firmware
3384 *
Govind Singhb53420c2016-03-09 14:32:57 +05303385 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303386 */
Govind Singhb53420c2016-03-09 14:32:57 +05303387QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303388 struct thermal_cmd_params *thermal_info)
3389{
3390 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3391 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303392 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303393 uint32_t len = 0;
3394
3395 len = sizeof(*cmd);
3396
3397 buf = wmi_buf_alloc(wmi_handle, len);
3398 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303399 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3400 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303401 }
3402
3403 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3404
3405 WMITLV_SET_HDR(&cmd->tlv_header,
3406 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3407 WMITLV_GET_STRUCT_TLVLEN
3408 (wmi_thermal_mgmt_cmd_fixed_param));
3409
3410 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3411 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3412 cmd->enable = thermal_info->thermal_enable;
3413
Govind Singhb53420c2016-03-09 14:32:57 +05303414 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303415 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3416
3417 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3418 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303419 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303420 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303421 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303422 }
3423
Govind Singh67922e82016-04-01 16:48:57 +05303424 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303425}
3426
3427
3428/**
3429 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303430 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303431 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3432 *
3433 * This function sends down the LRO configuration parameters to
3434 * the firmware to enable LRO, sets the TCP flags and sets the
3435 * seed values for the toeplitz hash generation
3436 *
Govind Singhb53420c2016-03-09 14:32:57 +05303437 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303438 */
Govind Singhb53420c2016-03-09 14:32:57 +05303439QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303440 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3441{
3442 wmi_lro_info_cmd_fixed_param *cmd;
3443 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303444 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303445
3446
3447 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3448 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303449 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3450 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303451 }
3452
3453 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3454
3455 WMITLV_SET_HDR(&cmd->tlv_header,
3456 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3457 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3458
3459 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3460 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3461 wmi_lro_cmd->tcp_flag);
3462 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3463 wmi_lro_cmd->tcp_flag_mask);
3464 cmd->toeplitz_hash_ipv4_0_3 =
3465 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3466 cmd->toeplitz_hash_ipv4_4_7 =
3467 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3468 cmd->toeplitz_hash_ipv4_8_11 =
3469 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3470 cmd->toeplitz_hash_ipv4_12_15 =
3471 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3472 cmd->toeplitz_hash_ipv4_16 =
3473 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3474
3475 cmd->toeplitz_hash_ipv6_0_3 =
3476 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3477 cmd->toeplitz_hash_ipv6_4_7 =
3478 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3479 cmd->toeplitz_hash_ipv6_8_11 =
3480 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3481 cmd->toeplitz_hash_ipv6_12_15 =
3482 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3483 cmd->toeplitz_hash_ipv6_16_19 =
3484 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3485 cmd->toeplitz_hash_ipv6_20_23 =
3486 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3487 cmd->toeplitz_hash_ipv6_24_27 =
3488 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3489 cmd->toeplitz_hash_ipv6_28_31 =
3490 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3491 cmd->toeplitz_hash_ipv6_32_35 =
3492 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3493 cmd->toeplitz_hash_ipv6_36_39 =
3494 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3495 cmd->toeplitz_hash_ipv6_40 =
3496 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3497
Govind Singhb53420c2016-03-09 14:32:57 +05303498 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303499 cmd->lro_enable, cmd->tcp_flag_u32);
3500
3501 status = wmi_unified_cmd_send(wmi_handle, buf,
3502 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303503 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303504 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303505 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303506 }
3507
Govind Singh67922e82016-04-01 16:48:57 +05303508 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303509}
3510
Govind Singh4eacd2b2016-03-07 14:24:22 +05303511/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303512 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3513 * @wmi_handle: Pointer to wmi handle
3514 * @rate_report_params: Pointer to peer rate report parameters
3515 *
3516 *
3517 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3518 */
3519QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
3520 struct wmi_peer_rate_report_params *rate_report_params)
3521{
3522 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3523 wmi_buf_t buf = NULL;
3524 QDF_STATUS status = 0;
3525 uint32_t len = 0;
3526 uint32_t i, j;
3527
3528 len = sizeof(*cmd);
3529
3530 buf = wmi_buf_alloc(wmi_handle, len);
3531 if (!buf) {
3532 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
3533 return QDF_STATUS_E_FAILURE;
3534 }
3535
3536 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3537 wmi_buf_data(buf);
3538
3539 WMITLV_SET_HDR(
3540 &cmd->tlv_header,
3541 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3542 WMITLV_GET_STRUCT_TLVLEN(
3543 wmi_peer_set_rate_report_condition_fixed_param));
3544
3545 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3546 cmd->report_backoff_time = rate_report_params->backoff_time;
3547 cmd->report_timer_period = rate_report_params->timer_period;
3548 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
3549 cmd->cond_per_phy[i].val_cond_flags =
3550 rate_report_params->report_per_phy[i].cond_flags;
3551 cmd->cond_per_phy[i].rate_delta.min_delta =
3552 rate_report_params->report_per_phy[i].delta.delta_min;
3553 cmd->cond_per_phy[i].rate_delta.percentage =
3554 rate_report_params->report_per_phy[i].delta.percent;
3555 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3556 cmd->cond_per_phy[i].rate_threshold[j] =
3557 rate_report_params->report_per_phy[i].
3558 report_rate_threshold[j];
3559 }
3560 }
3561
3562 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
3563 cmd->enable_rate_report,
3564 cmd->report_backoff_time, cmd->report_timer_period);
3565
3566 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3567 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3568 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303569 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303570 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3571 __func__);
3572 }
3573 return status;
3574}
3575
3576/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303577 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3578 * @wmi_handle: wmi handle
3579 * @param: bcn ll cmd parameter
3580 *
Govind Singhb53420c2016-03-09 14:32:57 +05303581 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303582 */
Govind Singhb53420c2016-03-09 14:32:57 +05303583QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303584 wmi_bcn_send_from_host_cmd_fixed_param *param)
3585{
3586 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3587 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303588 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303589
3590 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3591 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303592 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3593 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303594 }
3595
3596 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3597 WMITLV_SET_HDR(&cmd->tlv_header,
3598 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3599 WMITLV_GET_STRUCT_TLVLEN
3600 (wmi_bcn_send_from_host_cmd_fixed_param));
3601 cmd->vdev_id = param->vdev_id;
3602 cmd->data_len = param->data_len;
3603 cmd->frame_ctrl = param->frame_ctrl;
3604 cmd->frag_ptr = param->frag_ptr;
3605 cmd->dtim_flag = param->dtim_flag;
3606
3607 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3608 WMI_PDEV_SEND_BCN_CMDID);
3609
Govind Singh67922e82016-04-01 16:48:57 +05303610 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303611 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303612 wmi_buf_free(wmi_buf);
3613 }
3614
3615 return ret;
3616}
3617
3618/**
3619 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
3620 * @wmi_handle: wmi handle
3621 * @vdev_id: vdev id
3622 * @max_retries: max retries
3623 * @retry_interval: retry interval
3624 * This function sets sta query related parameters in fw.
3625 *
Govind Singhb53420c2016-03-09 14:32:57 +05303626 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303627 */
3628
Govind Singhb53420c2016-03-09 14:32:57 +05303629QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303630 uint8_t vdev_id, uint32_t max_retries,
3631 uint32_t retry_interval)
3632{
3633 wmi_buf_t buf;
3634 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
3635 int len;
3636
3637 len = sizeof(*cmd);
3638 buf = wmi_buf_alloc(wmi_handle, len);
3639 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303640 WMI_LOGE(FL("wmi_buf_alloc failed"));
3641 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303642 }
3643
3644 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
3645 WMITLV_SET_HDR(&cmd->tlv_header,
3646 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
3647 WMITLV_GET_STRUCT_TLVLEN
3648 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
3649
3650
3651 cmd->vdev_id = vdev_id;
3652 cmd->sa_query_max_retry_count = max_retries;
3653 cmd->sa_query_retry_interval = retry_interval;
3654
Govind Singhb53420c2016-03-09 14:32:57 +05303655 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303656 vdev_id, retry_interval, max_retries);
3657
3658 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3659 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303660 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05303661 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303662 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303663 }
3664
Govind Singhb53420c2016-03-09 14:32:57 +05303665 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303666 return 0;
3667}
3668
3669/**
3670 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
3671 * @wmi_handle: wmi handle
3672 * @params: sta keep alive parameter
3673 *
3674 * This function sets keep alive related parameters in fw.
3675 *
3676 * Return: CDF status
3677 */
Govind Singhb53420c2016-03-09 14:32:57 +05303678QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303679 struct sta_params *params)
3680{
3681 wmi_buf_t buf;
3682 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
3683 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
3684 uint8_t *buf_ptr;
3685 int len;
Govind Singh67922e82016-04-01 16:48:57 +05303686 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303687
Govind Singhb53420c2016-03-09 14:32:57 +05303688 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303689
Govind Singh4eacd2b2016-03-07 14:24:22 +05303690 len = sizeof(*cmd) + sizeof(*arp_rsp);
3691 buf = wmi_buf_alloc(wmi_handle, len);
3692 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303693 WMI_LOGE("wmi_buf_alloc failed");
3694 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303695 }
3696
3697 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
3698 buf_ptr = (uint8_t *) cmd;
3699 WMITLV_SET_HDR(&cmd->tlv_header,
3700 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
3701 WMITLV_GET_STRUCT_TLVLEN
3702 (WMI_STA_KEEPALIVE_CMD_fixed_param));
3703 cmd->interval = params->timeperiod;
3704 cmd->enable = (params->timeperiod) ? 1 : 0;
3705 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05303706 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303707 params->timeperiod, params->method);
3708 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
3709 WMITLV_SET_HDR(&arp_rsp->tlv_header,
3710 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
3711 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
3712
3713 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
3714 if ((NULL == params->hostv4addr) ||
3715 (NULL == params->destv4addr) ||
3716 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303717 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05303718 "destv4addr:%p destmac:%p ", __func__,
3719 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303720 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303721 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303722 }
3723 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05303724 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303725 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05303726 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303727 WMI_IPV4_ADDR_LEN);
3728 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
3729 } else {
3730 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
3731 }
3732
Govind Singh67922e82016-04-01 16:48:57 +05303733 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3734 WMI_STA_KEEPALIVE_CMDID);
3735 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303736 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303737 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303738 }
3739
Govind Singhb53420c2016-03-09 14:32:57 +05303740 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303741 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303742}
3743
3744/**
3745 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
3746 * @wmi_handle: wmi handle
3747 * @if_id: vdev id
3748 * @gtx_info: GTX config params
3749 *
3750 * This function set GTX related params in firmware.
3751 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303752 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303753 */
Govind Singhb53420c2016-03-09 14:32:57 +05303754QDF_STATUS send_vdev_set_gtx_cfg_cmd_tlv(wmi_unified_t wmi_handle, uint32_t if_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303755 struct wmi_gtx_config *gtx_info)
3756{
3757 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
3758 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05303759 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303760 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303761
Govind Singh4eacd2b2016-03-07 14:24:22 +05303762 buf = wmi_buf_alloc(wmi_handle, len);
3763 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303764 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303765 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303766 }
3767 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
3768 WMITLV_SET_HDR(&cmd->tlv_header,
3769 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
3770 WMITLV_GET_STRUCT_TLVLEN
3771 (wmi_vdev_set_gtx_params_cmd_fixed_param));
3772 cmd->vdev_id = if_id;
3773
3774 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
3775 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
3776 cmd->userGtxMask = gtx_info->gtx_usrcfg;
3777 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
3778 cmd->gtxPERMargin = gtx_info->gtx_margin;
3779 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
3780 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
3781 cmd->gtxBWMask = gtx_info->gtx_bwmask;
3782
Govind Singhb53420c2016-03-09 14:32:57 +05303783 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05303784 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
3785 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
3786 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
3787 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
3788
Abhishek Singh716c46c2016-05-04 16:24:07 +05303789 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303790 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303791 if (QDF_IS_STATUS_ERROR(ret)) {
3792 WMI_LOGE("Failed to set GTX PARAMS");
3793 wmi_buf_free(buf);
3794 }
3795 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303796}
3797
3798/**
3799 * send_process_update_edca_param_cmd_tlv() - update EDCA params
3800 * @wmi_handle: wmi handle
3801 * @edca_params: edca parameters
3802 *
3803 * This function updates EDCA parameters to the target
3804 *
3805 * Return: CDF Status
3806 */
Govind Singhb53420c2016-03-09 14:32:57 +05303807QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303808 uint8_t vdev_id,
3809 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
3810{
3811 uint8_t *buf_ptr;
3812 wmi_buf_t buf;
3813 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
3814 wmi_wmm_vparams *wmm_param, *twmm_param;
3815 int len = sizeof(*cmd);
3816 int ac;
3817
3818 buf = wmi_buf_alloc(wmi_handle, len);
3819
3820 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303821 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3822 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303823 }
3824
3825 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3826 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
3827 WMITLV_SET_HDR(&cmd->tlv_header,
3828 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3829 WMITLV_GET_STRUCT_TLVLEN
3830 (wmi_vdev_set_wmm_params_cmd_fixed_param));
3831 cmd->vdev_id = vdev_id;
3832
3833 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
3834 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
3835 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
3836 WMITLV_SET_HDR(&wmm_param->tlv_header,
3837 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3838 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
3839 wmm_param->cwmin = twmm_param->cwmin;
3840 wmm_param->cwmax = twmm_param->cwmax;
3841 wmm_param->aifs = twmm_param->aifs;
3842 wmm_param->txoplimit = twmm_param->txoplimit;
3843 wmm_param->acm = twmm_param->acm;
3844 wmm_param->no_ack = twmm_param->no_ack;
3845 }
3846
3847 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3848 WMI_VDEV_SET_WMM_PARAMS_CMDID))
3849 goto fail;
3850
Govind Singhb53420c2016-03-09 14:32:57 +05303851 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303852
3853fail:
3854 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303855 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
3856 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303857}
3858
3859/**
3860 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
3861 * @wmi_handle: wmi handle
3862 * @vdev_id: vdev id
3863 * @probe_rsp_info: probe response info
3864 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303865 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303866 */
Govind Singhb53420c2016-03-09 14:32:57 +05303867QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303868 uint8_t vdev_id,
3869 struct wmi_probe_resp_params *probe_rsp_info,
3870 uint8_t *frm)
3871{
3872 wmi_prb_tmpl_cmd_fixed_param *cmd;
3873 wmi_bcn_prb_info *bcn_prb_info;
3874 wmi_buf_t wmi_buf;
3875 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
3876 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05303877 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303878
Govind Singhb53420c2016-03-09 14:32:57 +05303879 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303880
3881 tmpl_len = probe_rsp_info->probeRespTemplateLen;
3882 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
3883
3884 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
3885 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
3886 tmpl_len_aligned;
3887
3888 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05303889 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303890 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05303891 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303892 }
3893
3894 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3895 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303896 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303897 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303898 }
3899
3900 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3901
3902 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
3903 WMITLV_SET_HDR(&cmd->tlv_header,
3904 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
3905 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
3906 cmd->vdev_id = vdev_id;
3907 cmd->buf_len = tmpl_len;
3908 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
3909
3910 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
3911 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
3912 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
3913 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
3914 bcn_prb_info->caps = 0;
3915 bcn_prb_info->erp = 0;
3916 buf_ptr += sizeof(wmi_bcn_prb_info);
3917
3918 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
3919 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303920 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303921
3922 ret = wmi_unified_cmd_send(wmi_handle,
3923 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303924 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303925 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303926 wmi_buf_free(wmi_buf);
3927 }
3928
3929 return ret;
3930}
3931
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303932#ifdef FEATURE_WLAN_WAPI
3933#define WPI_IV_LEN 16
3934
3935/**
3936 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
3937 *
3938 * @dest_tx: destination address of tsc key counter
3939 * @src_tx: source address of tsc key counter
3940 * @dest_rx: destination address of rsc key counter
3941 * @src_rx: source address of rsc key counter
3942 *
3943 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
3944 *
3945 * Return: None
3946 *
3947 */
3948static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
3949 uint8_t *dest_rx, uint8_t *src_rx)
3950{
3951 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
3952 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
3953}
3954#else
3955static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
3956 uint8_t *dest_rx, uint8_t *src_rx)
3957{
3958 return;
3959}
3960#endif
3961
3962/**
3963 * send_setup_install_key_cmd_tlv() - set key parameters
3964 * @wmi_handle: wmi handle
3965 * @key_params: key parameters
3966 *
3967 * This function fills structure from information
3968 * passed in key_params.
3969 *
3970 * Return: QDF_STATUS_SUCCESS - success
3971 * QDF_STATUS_E_FAILURE - failure
3972 * QDF_STATUS_E_NOMEM - not able to allocate buffer
3973 */
3974QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
3975 struct set_key_params *key_params)
3976{
3977 wmi_vdev_install_key_cmd_fixed_param *cmd;
3978 wmi_buf_t buf;
3979 uint8_t *buf_ptr;
3980 uint32_t len;
3981 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05303982 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303983
3984 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
3985 WMI_TLV_HDR_SIZE;
3986
3987 buf = wmi_buf_alloc(wmi_handle, len);
3988 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05303989 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303990 return QDF_STATUS_E_NOMEM;
3991 }
3992
3993 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3994 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
3995 WMITLV_SET_HDR(&cmd->tlv_header,
3996 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
3997 WMITLV_GET_STRUCT_TLVLEN
3998 (wmi_vdev_install_key_cmd_fixed_param));
3999 cmd->vdev_id = key_params->vdev_id;
4000 cmd->key_ix = key_params->key_idx;
4001 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4002 cmd->key_flags |= key_params->key_flags;
4003 cmd->key_cipher = key_params->key_cipher;
4004 if ((key_params->key_txmic_len) &&
4005 (key_params->key_rxmic_len)) {
4006 cmd->key_txmic_len = key_params->key_txmic_len;
4007 cmd->key_rxmic_len = key_params->key_rxmic_len;
4008 }
Govind Singh87542482016-06-08 19:40:11 +05304009#ifdef FEATURE_WLAN_WAPI
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304010 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4011 key_params->tx_iv,
4012 cmd->wpi_key_rsc_counter,
4013 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304014#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304015 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4016 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4017 roundup(key_params->key_len, sizeof(uint32_t)));
4018 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4019 qdf_mem_copy((void *)key_data,
4020 (const void *)key_params->key_data, key_params->key_len);
4021 cmd->key_len = key_params->key_len;
4022
4023 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4024 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304025 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304026 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304027
Govind Singh67922e82016-04-01 16:48:57 +05304028 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304029}
4030
4031
Govind Singh4eacd2b2016-03-07 14:24:22 +05304032/**
4033 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4034 * @wmi_handle: wmi handle
4035 * @vdev_id: vdev id
4036 * @p2p_ie: p2p IE
4037 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304038 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304039 */
Govind Singhb53420c2016-03-09 14:32:57 +05304040QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304041 A_UINT32 vdev_id, uint8_t *p2p_ie)
4042{
Govind Singh67922e82016-04-01 16:48:57 +05304043 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304044 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4045 wmi_buf_t wmi_buf;
4046 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4047 uint8_t *buf_ptr;
4048
4049 ie_len = (uint32_t) (p2p_ie[1] + 2);
4050
4051 /* More than one P2P IE may be included in a single frame.
4052 If multiple P2P IEs are present, the complete P2P attribute
4053 data consists of the concatenation of the P2P Attribute
4054 fields of the P2P IEs. The P2P Attributes field of each
4055 P2P IE may be any length up to the maximum (251 octets).
4056 In this case host sends one P2P IE to firmware so the length
4057 should not exceed more than 251 bytes
4058 */
4059 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304060 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304061 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304062 }
4063
4064 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4065
4066 wmi_buf_len =
4067 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4068 WMI_TLV_HDR_SIZE;
4069
4070 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4071 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304072 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304073 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304074 }
4075
4076 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4077
4078 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4079 WMITLV_SET_HDR(&cmd->tlv_header,
4080 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4081 WMITLV_GET_STRUCT_TLVLEN
4082 (wmi_p2p_go_set_beacon_ie_fixed_param));
4083 cmd->vdev_id = vdev_id;
4084 cmd->ie_buf_len = ie_len;
4085
4086 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4087 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4088 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304089 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304090
Govind Singhb53420c2016-03-09 14:32:57 +05304091 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304092
4093 ret = wmi_unified_cmd_send(wmi_handle,
4094 wmi_buf, wmi_buf_len,
4095 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304096 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304097 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304098 wmi_buf_free(wmi_buf);
4099 }
4100
Govind Singhb53420c2016-03-09 14:32:57 +05304101 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304102 return ret;
4103}
4104
4105/**
4106 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4107 * @wmi_handle: wmi handle
4108 * @req: gateway parameter update request structure
4109 *
4110 * This function reads the incoming @req and fill in the destination
4111 * WMI structure and sends down the gateway configs down to the firmware
4112 *
Govind Singhb53420c2016-03-09 14:32:57 +05304113 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304114 */
Govind Singhb53420c2016-03-09 14:32:57 +05304115QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304116 struct gateway_update_req_param *req)
4117{
4118 wmi_roam_subnet_change_config_fixed_param *cmd;
4119 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304120 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304121 int len = sizeof(*cmd);
4122
4123 buf = wmi_buf_alloc(wmi_handle, len);
4124 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304125 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4126 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304127 }
4128
4129 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4130 WMITLV_SET_HDR(&cmd->tlv_header,
4131 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4132 WMITLV_GET_STRUCT_TLVLEN(
4133 wmi_roam_subnet_change_config_fixed_param));
4134
4135 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304136 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4137 QDF_IPV4_ADDR_SIZE);
4138 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4139 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304140 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4141 &cmd->inet_gw_mac_addr);
4142 cmd->max_retries = req->max_retries;
4143 cmd->timeout = req->timeout;
4144 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4145 cmd->flag = 0;
4146 if (req->ipv4_addr_type)
4147 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4148
4149 if (req->ipv6_addr_type)
4150 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4151
4152 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4153 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304154 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304155 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304156 ret);
4157 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304158 }
4159
Govind Singh67922e82016-04-01 16:48:57 +05304160 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304161}
4162
4163/**
4164 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4165 * @wmi_handle: wmi handle
4166 * @req: rssi monitoring request structure
4167 *
4168 * This function reads the incoming @req and fill in the destination
4169 * WMI structure and send down the rssi monitoring configs down to the firmware
4170 *
4171 * Return: 0 on success; error number otherwise
4172 */
Govind Singhb53420c2016-03-09 14:32:57 +05304173QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304174 struct rssi_monitor_param *req)
4175{
4176 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4177 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304178 QDF_STATUS ret;
4179 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304180
4181 buf = wmi_buf_alloc(wmi_handle, len);
4182 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304183 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4184 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304185 }
4186
4187 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4188 WMITLV_SET_HDR(&cmd->tlv_header,
4189 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4190 WMITLV_GET_STRUCT_TLVLEN(
4191 wmi_rssi_breach_monitor_config_fixed_param));
4192
4193 cmd->vdev_id = req->session_id;
4194 cmd->request_id = req->request_id;
4195 cmd->lo_rssi_reenable_hysteresis = 0;
4196 cmd->hi_rssi_reenable_histeresis = 0;
4197 cmd->min_report_interval = 0;
4198 cmd->max_num_report = 1;
4199 if (req->control) {
4200 /* enable one threshold for each min/max */
4201 cmd->enabled_bitmap = 0x09;
4202 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4203 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4204 } else {
4205 cmd->enabled_bitmap = 0;
4206 cmd->low_rssi_breach_threshold[0] = 0;
4207 cmd->hi_rssi_breach_threshold[0] = 0;
4208 }
4209
4210 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4211 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304212 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304213 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304214 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304215 }
4216
Govind Singhb53420c2016-03-09 14:32:57 +05304217 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304218 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304219}
4220
4221/**
4222 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4223 * @wmi_handle: wmi handle
4224 * @psetoui: OUI parameters
4225 *
4226 * set scan probe OUI parameters in firmware
4227 *
4228 * Return: CDF status
4229 */
Govind Singhb53420c2016-03-09 14:32:57 +05304230QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304231 struct scan_mac_oui *psetoui)
4232{
4233 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4234 wmi_buf_t wmi_buf;
4235 uint32_t len;
4236 uint8_t *buf_ptr;
4237 uint32_t *oui_buf;
4238
4239 len = sizeof(*cmd);
4240 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4241 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304242 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4243 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304244 }
4245 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4246 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4247 WMITLV_SET_HDR(&cmd->tlv_header,
4248 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4249 WMITLV_GET_STRUCT_TLVLEN
4250 (wmi_scan_prob_req_oui_cmd_fixed_param));
4251
4252 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304253 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304254 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4255 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304256 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304257 cmd->prob_req_oui);
4258
4259 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4260 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304261 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304262 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304263 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304264 }
Govind Singhb53420c2016-03-09 14:32:57 +05304265 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304266}
4267
4268/**
4269 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
4270 * @wmi_handle: wmi handle
4271 * @req: passpoint network request structure
4272 *
4273 * This function sends down WMI command with network id set to wildcard id.
4274 * firmware shall clear all the config entries
4275 *
Govind Singhb53420c2016-03-09 14:32:57 +05304276 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304277 */
Govind Singhb53420c2016-03-09 14:32:57 +05304278QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304279 struct wifi_passpoint_req_param *req)
4280{
4281 wmi_passpoint_config_cmd_fixed_param *cmd;
4282 wmi_buf_t buf;
4283 uint32_t len;
4284 int ret;
4285
4286 len = sizeof(*cmd);
4287 buf = wmi_buf_alloc(wmi_handle, len);
4288 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304289 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4290 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304291 }
4292
4293 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
4294
4295 WMITLV_SET_HDR(&cmd->tlv_header,
4296 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4297 WMITLV_GET_STRUCT_TLVLEN(
4298 wmi_passpoint_config_cmd_fixed_param));
4299 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
4300
4301 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4302 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4303 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304304 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304305 __func__);
4306 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304307 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304308 }
4309
Govind Singhb53420c2016-03-09 14:32:57 +05304310 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304311}
4312
4313/**
4314 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
4315 * @wmi_handle: wmi handle
4316 * @req: passpoint network request structure
4317 *
4318 * This function reads the incoming @req and fill in the destination
4319 * WMI structure and send down the passpoint configs down to the firmware
4320 *
Govind Singhb53420c2016-03-09 14:32:57 +05304321 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304322 */
Govind Singhb53420c2016-03-09 14:32:57 +05304323QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304324 struct wifi_passpoint_req_param *req)
4325{
4326 wmi_passpoint_config_cmd_fixed_param *cmd;
4327 u_int8_t i, j, *bytes;
4328 wmi_buf_t buf;
4329 uint32_t len;
4330 int ret;
4331
4332 len = sizeof(*cmd);
4333 for (i = 0; i < req->num_networks; i++) {
4334 buf = wmi_buf_alloc(wmi_handle, len);
4335 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304336 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4337 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304338 }
4339
4340 cmd = (wmi_passpoint_config_cmd_fixed_param *)
4341 wmi_buf_data(buf);
4342
4343 WMITLV_SET_HDR(&cmd->tlv_header,
4344 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4345 WMITLV_GET_STRUCT_TLVLEN(
4346 wmi_passpoint_config_cmd_fixed_param));
4347 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05304348 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
4349 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304350 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05304351 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304352 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
4353 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05304354 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304355 j, bytes[0], bytes[1], bytes[2], bytes[3],
4356 bytes[4], bytes[5], bytes[6], bytes[7]);
4357
Govind Singhb53420c2016-03-09 14:32:57 +05304358 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05304359 &req->networks[i].roaming_consortium_ids[j],
4360 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
4361 }
Govind Singhb53420c2016-03-09 14:32:57 +05304362 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304363 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304364 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304365 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
4366
4367 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4368 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4369 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304370 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304371 __func__);
4372 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304373 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304374 }
4375 }
4376
Govind Singhb53420c2016-03-09 14:32:57 +05304377 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304378}
4379
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304380/**
4381 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
4382 * @wmi_handle: wmi handle
4383 * @scan_cmd_fp: start scan command ptr
4384 * @roam_req: roam request param
4385 *
4386 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
4387 * of WMI_ROAM_SCAN_MODE.
4388 *
4389 * Return: QDF status
4390 */
4391QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
4392 wmi_start_scan_cmd_fixed_param *
4393 scan_cmd_fp,
4394 struct roam_offload_scan_params *roam_req)
4395{
4396 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304397 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304398 int len;
4399 uint8_t *buf_ptr;
4400 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05304401
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304402#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4403 int auth_mode = roam_req->auth_mode;
4404 wmi_roam_offload_tlv_param *roam_offload_params;
4405 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
4406 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
4407 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304408 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304409#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4410 /* Need to create a buf with roam_scan command at
4411 * front and piggyback with scan command */
4412 len = sizeof(wmi_roam_scan_mode_fixed_param) +
4413#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4414 (2 * WMI_TLV_HDR_SIZE) +
4415#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4416 sizeof(wmi_start_scan_cmd_fixed_param);
4417#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4418 if (roam_req->is_roam_req_valid &&
4419 roam_req->roam_offload_enabled) {
4420 len += sizeof(wmi_roam_offload_tlv_param);
4421 len += WMI_TLV_HDR_SIZE;
4422 if ((auth_mode != WMI_AUTH_NONE) &&
4423 ((auth_mode != WMI_AUTH_OPEN) ||
4424 (auth_mode == WMI_AUTH_OPEN &&
4425 roam_req->mdid.mdie_present) ||
4426 roam_req->is_ese_assoc)) {
4427 len += WMI_TLV_HDR_SIZE;
4428 if (roam_req->is_ese_assoc)
4429 len +=
4430 sizeof(wmi_roam_ese_offload_tlv_param);
4431 else if (auth_mode == WMI_AUTH_FT_RSNA ||
4432 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
4433 (auth_mode == WMI_AUTH_OPEN &&
4434 roam_req->mdid.mdie_present))
4435 len +=
4436 sizeof(wmi_roam_11r_offload_tlv_param);
4437 else
4438 len +=
4439 sizeof(wmi_roam_11i_offload_tlv_param);
4440 } else {
4441 len += WMI_TLV_HDR_SIZE;
4442 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304443
4444 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
4445 + roundup(roam_req->assoc_ie_length,
4446 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304447 } else {
4448 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05304449 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304450 __func__, roam_req->roam_offload_enabled);
4451 else
Govind Singhe7f2f342016-05-23 12:12:52 +05304452 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304453 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304454 }
4455 if (roam_req->is_roam_req_valid &&
4456 roam_req->roam_offload_enabled) {
4457 roam_req->mode = roam_req->mode |
4458 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
4459 }
4460#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4461
4462 buf = wmi_buf_alloc(wmi_handle, len);
4463 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304464 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304465 return QDF_STATUS_E_NOMEM;
4466 }
4467
4468 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304469
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304470 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
4471 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
4472 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
4473 WMITLV_GET_STRUCT_TLVLEN
4474 (wmi_roam_scan_mode_fixed_param));
4475
4476 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
4477 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
4478 /* Fill in scan parameters suitable for roaming scan */
4479 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
4480 qdf_mem_copy(buf_ptr, scan_cmd_fp,
4481 sizeof(wmi_start_scan_cmd_fixed_param));
4482 /* Ensure there is no additional IEs */
4483 scan_cmd_fp->ie_len = 0;
4484 WMITLV_SET_HDR(buf_ptr,
4485 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
4486 WMITLV_GET_STRUCT_TLVLEN
4487 (wmi_start_scan_cmd_fixed_param));
4488#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4489 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
4490 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
4491 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4492 sizeof(wmi_roam_offload_tlv_param));
4493 buf_ptr += WMI_TLV_HDR_SIZE;
4494 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
4495 WMITLV_SET_HDR(buf_ptr,
4496 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
4497 WMITLV_GET_STRUCT_TLVLEN
4498 (wmi_roam_offload_tlv_param));
4499 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
4500 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
4501 roam_offload_params->select_5g_margin =
4502 roam_req->select_5ghz_margin;
4503 roam_offload_params->reassoc_failure_timeout =
4504 roam_req->reassoc_failure_timeout;
4505
4506 /* Fill the capabilities */
4507 roam_offload_params->capability =
4508 roam_req->roam_offload_params.capability;
4509 roam_offload_params->ht_caps_info =
4510 roam_req->roam_offload_params.ht_caps_info;
4511 roam_offload_params->ampdu_param =
4512 roam_req->roam_offload_params.ampdu_param;
4513 roam_offload_params->ht_ext_cap =
4514 roam_req->roam_offload_params.ht_ext_cap;
4515 roam_offload_params->ht_txbf =
4516 roam_req->roam_offload_params.ht_txbf;
4517 roam_offload_params->asel_cap =
4518 roam_req->roam_offload_params.asel_cap;
4519 roam_offload_params->qos_caps =
4520 roam_req->roam_offload_params.qos_caps;
4521 roam_offload_params->wmm_caps =
4522 roam_req->roam_offload_params.wmm_caps;
4523 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
4524 (uint8_t *)roam_req->roam_offload_params.mcsset,
4525 ROAM_OFFLOAD_NUM_MCS_SET);
4526
4527 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
4528 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
4529 * they are filled in the same order.Depending on the
4530 * authentication type, the other mode TLV's are nullified
4531 * and only headers are filled.*/
4532 if ((auth_mode != WMI_AUTH_NONE) &&
4533 ((auth_mode != WMI_AUTH_OPEN) ||
4534 (auth_mode == WMI_AUTH_OPEN
4535 && roam_req->mdid.mdie_present) ||
4536 roam_req->is_ese_assoc)) {
4537 if (roam_req->is_ese_assoc) {
4538 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4539 WMITLV_GET_STRUCT_TLVLEN(0));
4540 buf_ptr += WMI_TLV_HDR_SIZE;
4541 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4542 WMITLV_GET_STRUCT_TLVLEN(0));
4543 buf_ptr += WMI_TLV_HDR_SIZE;
4544 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4545 sizeof(wmi_roam_ese_offload_tlv_param));
4546 buf_ptr += WMI_TLV_HDR_SIZE;
4547 roam_offload_ese =
4548 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
4549 qdf_mem_copy(roam_offload_ese->krk,
4550 roam_req->krk,
4551 sizeof(roam_req->krk));
4552 qdf_mem_copy(roam_offload_ese->btk,
4553 roam_req->btk,
4554 sizeof(roam_req->btk));
4555 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
4556 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
4557 WMITLV_GET_STRUCT_TLVLEN
4558 (wmi_roam_ese_offload_tlv_param));
4559 buf_ptr +=
4560 sizeof(wmi_roam_ese_offload_tlv_param);
4561 } else if (auth_mode == WMI_AUTH_FT_RSNA
4562 || auth_mode == WMI_AUTH_FT_RSNA_PSK
4563 || (auth_mode == WMI_AUTH_OPEN
4564 && roam_req->mdid.mdie_present)) {
4565 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4566 0);
4567 buf_ptr += WMI_TLV_HDR_SIZE;
4568 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4569 sizeof(wmi_roam_11r_offload_tlv_param));
4570 buf_ptr += WMI_TLV_HDR_SIZE;
4571 roam_offload_11r =
4572 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
4573 roam_offload_11r->r0kh_id_len =
4574 roam_req->rokh_id_length;
4575 qdf_mem_copy(roam_offload_11r->r0kh_id,
4576 roam_req->rokh_id,
4577 roam_offload_11r->r0kh_id_len);
4578 qdf_mem_copy(roam_offload_11r->psk_msk,
4579 roam_req->psk_pmk,
4580 sizeof(roam_req->psk_pmk));
4581 roam_offload_11r->psk_msk_len =
4582 roam_req->pmk_len;
4583 roam_offload_11r->mdie_present =
4584 roam_req->mdid.mdie_present;
4585 roam_offload_11r->mdid =
4586 roam_req->mdid.mobility_domain;
4587 if (auth_mode == WMI_AUTH_OPEN) {
4588 /* If FT-Open ensure pmk length
4589 and r0khid len are zero */
4590 roam_offload_11r->r0kh_id_len = 0;
4591 roam_offload_11r->psk_msk_len = 0;
4592 }
4593 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
4594 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
4595 WMITLV_GET_STRUCT_TLVLEN
4596 (wmi_roam_11r_offload_tlv_param));
4597 buf_ptr +=
4598 sizeof(wmi_roam_11r_offload_tlv_param);
4599 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4600 WMITLV_GET_STRUCT_TLVLEN(0));
4601 buf_ptr += WMI_TLV_HDR_SIZE;
4602 } else {
4603 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4604 sizeof(wmi_roam_11i_offload_tlv_param));
4605 buf_ptr += WMI_TLV_HDR_SIZE;
4606 roam_offload_11i =
4607 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07004608 if (roam_req->roam_key_mgmt_offload_enabled &&
4609 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304610 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
4611 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304612 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304613 } else {
4614 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
4615 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304616 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304617 }
4618
4619 qdf_mem_copy(roam_offload_11i->pmk,
4620 roam_req->psk_pmk,
4621 sizeof(roam_req->psk_pmk));
4622 roam_offload_11i->pmk_len = roam_req->pmk_len;
4623 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
4624 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
4625 WMITLV_GET_STRUCT_TLVLEN
4626 (wmi_roam_11i_offload_tlv_param));
4627 buf_ptr +=
4628 sizeof(wmi_roam_11i_offload_tlv_param);
4629 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4630 0);
4631 buf_ptr += WMI_TLV_HDR_SIZE;
4632 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4633 0);
4634 buf_ptr += WMI_TLV_HDR_SIZE;
4635 }
4636 } else {
4637 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4638 WMITLV_GET_STRUCT_TLVLEN(0));
4639 buf_ptr += WMI_TLV_HDR_SIZE;
4640 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4641 WMITLV_GET_STRUCT_TLVLEN(0));
4642 buf_ptr += WMI_TLV_HDR_SIZE;
4643 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4644 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304645 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304646 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304647
4648 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4649 sizeof(*assoc_ies));
4650 buf_ptr += WMI_TLV_HDR_SIZE;
4651
4652 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
4653 WMITLV_SET_HDR(&assoc_ies->tlv_header,
4654 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
4655 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
4656 assoc_ies->buf_len = roam_req->assoc_ie_length;
4657
4658 buf_ptr += sizeof(*assoc_ies);
4659
4660 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4661 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
4662 buf_ptr += WMI_TLV_HDR_SIZE;
4663
4664 if (assoc_ies->buf_len != 0) {
4665 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
4666 assoc_ies->buf_len);
4667 }
4668
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304669 } else {
4670 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4671 WMITLV_GET_STRUCT_TLVLEN(0));
4672 buf_ptr += WMI_TLV_HDR_SIZE;
4673 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4674 WMITLV_GET_STRUCT_TLVLEN(0));
4675 buf_ptr += WMI_TLV_HDR_SIZE;
4676 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4677 WMITLV_GET_STRUCT_TLVLEN(0));
4678 buf_ptr += WMI_TLV_HDR_SIZE;
4679 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4680 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304681 buf_ptr += WMI_TLV_HDR_SIZE;
4682 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4683 WMITLV_GET_STRUCT_TLVLEN(0));
4684 buf_ptr += WMI_TLV_HDR_SIZE;
4685 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4686 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304687 }
4688#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4689 status = wmi_unified_cmd_send(wmi_handle, buf,
4690 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05304691 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304692 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304693 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
4694 status);
4695 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304696 }
4697
Govind Singh67922e82016-04-01 16:48:57 +05304698 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304699}
4700
4701
4702/**
4703 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
4704 * rssi threashold
4705 * @wmi_handle: wmi handle
4706 * @roam_req: Roaming request buffer
4707 *
4708 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
4709 *
4710 * Return: QDF status
4711 */
4712QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
4713 struct roam_offload_scan_rssi_params *roam_req)
4714{
4715 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304716 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304717 int len;
4718 uint8_t *buf_ptr;
4719 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
4720 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
4721 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05304722 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304723
4724 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4725 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
4726 len += sizeof(wmi_roam_scan_extended_threshold_param);
4727 len += WMI_TLV_HDR_SIZE;
4728 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05304729 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
4730 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304731 buf = wmi_buf_alloc(wmi_handle, len);
4732 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304733 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304734 return QDF_STATUS_E_NOMEM;
4735 }
4736
4737 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4738 rssi_threshold_fp =
4739 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
4740 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
4741 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
4742 WMITLV_GET_STRUCT_TLVLEN
4743 (wmi_roam_scan_rssi_threshold_fixed_param));
4744 /* fill in threshold values */
4745 rssi_threshold_fp->vdev_id = roam_req->session_id;
4746 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
4747 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
4748 rssi_threshold_fp->hirssi_scan_max_count =
4749 roam_req->hi_rssi_scan_max_count;
4750 rssi_threshold_fp->hirssi_scan_delta =
4751 roam_req->hi_rssi_scan_rssi_delta;
4752 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
4753
4754 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4755 WMITLV_SET_HDR(buf_ptr,
4756 WMITLV_TAG_ARRAY_STRUC,
4757 sizeof(wmi_roam_scan_extended_threshold_param));
4758 buf_ptr += WMI_TLV_HDR_SIZE;
4759 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
4760
4761 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
4762 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
4763 ext_thresholds->boost_threshold_5g =
4764 roam_req->boost_threshold_5g;
4765
4766 ext_thresholds->boost_algorithm_5g =
4767 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4768 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
4769 ext_thresholds->penalty_algorithm_5g =
4770 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4771 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
4772 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
4773 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
4774 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
4775
4776 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
4777 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
4778 WMITLV_GET_STRUCT_TLVLEN
4779 (wmi_roam_scan_extended_threshold_param));
4780 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
4781 WMITLV_SET_HDR(buf_ptr,
4782 WMITLV_TAG_ARRAY_STRUC,
4783 sizeof(wmi_roam_earlystop_rssi_thres_param));
4784 buf_ptr += WMI_TLV_HDR_SIZE;
4785 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
4786 early_stop_thresholds->roam_earlystop_thres_min =
4787 roam_req->roam_earlystop_thres_min;
4788 early_stop_thresholds->roam_earlystop_thres_max =
4789 roam_req->roam_earlystop_thres_max;
4790 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
4791 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
4792 WMITLV_GET_STRUCT_TLVLEN
4793 (wmi_roam_earlystop_rssi_thres_param));
4794
Gupta, Kapil7e652922016-04-12 15:02:00 +05304795 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
4796 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4797 sizeof(wmi_roam_dense_thres_param));
4798 buf_ptr += WMI_TLV_HDR_SIZE;
4799 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
4800 dense_thresholds->roam_dense_rssi_thres_offset =
4801 roam_req->dense_rssi_thresh_offset;
4802 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
4803 dense_thresholds->roam_dense_traffic_thres =
4804 roam_req->traffic_threshold;
4805 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
4806 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
4807 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
4808 WMITLV_GET_STRUCT_TLVLEN
4809 (wmi_roam_dense_thres_param));
4810
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304811 status = wmi_unified_cmd_send(wmi_handle, buf,
4812 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05304813 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304814 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304815 status);
4816 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304817 }
4818
Govind Singh67922e82016-04-01 16:48:57 +05304819 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304820}
4821
4822/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05304823 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
4824 * configuration params
4825 * @wma_handle: wma handler
4826 * @dwelltime_params: pointer to dwelltime_params
4827 *
4828 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
4829 */
4830QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
4831 struct wmi_adaptive_dwelltime_params *dwelltime_params)
4832{
4833 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
4834 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
4835 wmi_buf_t buf;
4836 uint8_t *buf_ptr;
4837 int32_t err;
4838 int len;
4839
4840 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
4841 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
4842 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
4843 buf = wmi_buf_alloc(wmi_handle, len);
4844 if (!buf) {
4845 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
4846 __func__);
4847 return QDF_STATUS_E_NOMEM;
4848 }
4849 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4850 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
4851 WMITLV_SET_HDR(&dwell_param->tlv_header,
4852 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
4853 WMITLV_GET_STRUCT_TLVLEN
4854 (wmi_scan_adaptive_dwell_config_fixed_param));
4855
4856 dwell_param->enable = dwelltime_params->is_enabled;
4857 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
4858 WMITLV_SET_HDR(buf_ptr,
4859 WMITLV_TAG_ARRAY_STRUC,
4860 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
4861 buf_ptr += WMI_TLV_HDR_SIZE;
4862
4863 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
4864 WMITLV_SET_HDR(&cmd->tlv_header,
4865 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
4866 WMITLV_GET_STRUCT_TLVLEN(
4867 wmi_scan_adaptive_dwell_parameters_tlv));
4868
4869 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
4870 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
4871 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
4872 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
4873 err = wmi_unified_cmd_send(wmi_handle, buf,
4874 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
4875 if (err) {
4876 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
4877 wmi_buf_free(buf);
4878 return QDF_STATUS_E_FAILURE;
4879 }
4880
4881 return QDF_STATUS_SUCCESS;
4882}
4883
4884
4885/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304886 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
4887 * @wmi_handle: wmi handle
4888 * @roam_req: Request which contains the filters
4889 *
4890 * There are filters such as whitelist, blacklist and preferred
4891 * list that need to be applied to the scan results to form the
4892 * probable candidates for roaming.
4893 *
4894 * Return: Return success upon succesfully passing the
4895 * parameters to the firmware, otherwise failure.
4896 */
4897QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
4898 struct roam_scan_filter_params *roam_req)
4899{
4900 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304901 QDF_STATUS status;
4902 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304903 uint32_t len;
4904 uint8_t *buf_ptr;
4905 wmi_roam_filter_fixed_param *roam_filter;
4906 uint8_t *bssid_src_ptr = NULL;
4907 wmi_mac_addr *bssid_dst_ptr = NULL;
4908 wmi_ssid *ssid_ptr = NULL;
4909 uint32_t *bssid_preferred_factor_ptr = NULL;
4910
4911 len = sizeof(wmi_roam_filter_fixed_param);
4912 len += WMI_TLV_HDR_SIZE;
4913 len += roam_req->len;
4914
4915 buf = wmi_buf_alloc(wmi_handle, len);
4916 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304917 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304918 return QDF_STATUS_E_NOMEM;
4919 }
4920
4921 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
4922 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
4923 WMITLV_SET_HDR(&roam_filter->tlv_header,
4924 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
4925 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
4926 /* fill in fixed values */
4927 roam_filter->vdev_id = roam_req->session_id;
4928 roam_filter->flags = 0;
4929 roam_filter->op_bitmap = roam_req->op_bitmap;
4930 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
4931 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
4932 roam_filter->num_bssid_preferred_list =
4933 roam_req->num_bssid_preferred_list;
4934 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
4935
4936 WMITLV_SET_HDR((buf_ptr),
4937 WMITLV_TAG_ARRAY_FIXED_STRUC,
4938 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
4939 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
4940 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
4941 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
4942 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
4943 bssid_src_ptr += ATH_MAC_LEN;
4944 bssid_dst_ptr++;
4945 }
4946 buf_ptr += WMI_TLV_HDR_SIZE +
4947 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
4948 WMITLV_SET_HDR((buf_ptr),
4949 WMITLV_TAG_ARRAY_FIXED_STRUC,
4950 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
4951 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
4952 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
4953 qdf_mem_copy(&ssid_ptr->ssid,
4954 &roam_req->ssid_allowed_list[i].mac_ssid,
4955 roam_req->ssid_allowed_list[i].length);
4956 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
4957 ssid_ptr++;
4958 }
4959 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
4960 sizeof(wmi_ssid));
4961 WMITLV_SET_HDR((buf_ptr),
4962 WMITLV_TAG_ARRAY_FIXED_STRUC,
4963 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
4964 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
4965 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
4966 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
4967 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
4968 (wmi_mac_addr *)bssid_dst_ptr);
4969 bssid_src_ptr += ATH_MAC_LEN;
4970 bssid_dst_ptr++;
4971 }
4972 buf_ptr += WMI_TLV_HDR_SIZE +
4973 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
4974 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
4975 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
4976 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
4977 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
4978 *bssid_preferred_factor_ptr =
4979 roam_req->bssid_favored_factor[i];
4980 bssid_preferred_factor_ptr++;
4981 }
4982 buf_ptr += WMI_TLV_HDR_SIZE +
4983 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
4984
4985 status = wmi_unified_cmd_send(wmi_handle, buf,
4986 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304987 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304988 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304989 status);
4990 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304991 }
Govind Singh67922e82016-04-01 16:48:57 +05304992
4993 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304994}
4995
Govind Singh4eacd2b2016-03-07 14:24:22 +05304996/** send_set_epno_network_list_cmd_tlv() - set epno network list
4997 * @wmi_handle: wmi handle
4998 * @req: epno config params request structure
4999 *
5000 * This function reads the incoming epno config request structure
5001 * and constructs the WMI message to the firmware.
5002 *
5003 * Returns: 0 on success, error number otherwise
5004 */
Govind Singhb53420c2016-03-09 14:32:57 +05305005QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305006 struct wifi_enhanched_pno_params *req)
5007{
5008 wmi_nlo_config_cmd_fixed_param *cmd;
5009 nlo_configured_parameters *nlo_list;
5010 u_int8_t i, *buf_ptr;
5011 wmi_buf_t buf;
5012 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305013 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305014
5015 /* TLV place holder for array of structures
5016 * nlo_configured_parameters(nlo_list) */
5017 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5018 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05305019 QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305020 len += WMI_TLV_HDR_SIZE; /* TLV for channel_list */
5021 len += WMI_TLV_HDR_SIZE; /* TLV for channel prediction cfg*/
5022
5023 buf = wmi_buf_alloc(wmi_handle, len);
5024 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305025 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5026 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305027 }
5028
5029 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5030
5031 buf_ptr = (u_int8_t *) cmd;
5032 WMITLV_SET_HDR(&cmd->tlv_header,
5033 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5034 WMITLV_GET_STRUCT_TLVLEN(
5035 wmi_nlo_config_cmd_fixed_param));
5036 cmd->vdev_id = req->session_id;
5037 cmd->flags = WMI_NLO_CONFIG_ENLO;
5038
5039 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5040
Govind Singhb53420c2016-03-09 14:32:57 +05305041 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
5042 WMI_LOGD("SSID count: %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305043 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5044 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5045 buf_ptr += WMI_TLV_HDR_SIZE;
5046
5047 nlo_list = (nlo_configured_parameters *) buf_ptr;
5048 for (i = 0; i < cmd->no_of_ssids; i++) {
5049 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5050 WMITLV_TAG_ARRAY_BYTE,
5051 WMITLV_GET_STRUCT_TLVLEN(nlo_configured_parameters));
5052 /* Copy ssid and it's length */
5053 nlo_list[i].ssid.valid = true;
5054 nlo_list[i].ssid.ssid.ssid_len = req->networks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05305055 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305056 req->networks[i].ssid.mac_ssid,
5057 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05305058 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305059 nlo_list[i].ssid.ssid.ssid_len,
5060 (char *) nlo_list[i].ssid.ssid.ssid,
5061 nlo_list[i].ssid.ssid.ssid_len);
5062
5063 /* Copy rssi threshold */
5064 nlo_list[i].rssi_cond.valid = true;
5065 nlo_list[i].rssi_cond.rssi =
5066 req->networks[i].rssi_threshold;
Govind Singhb53420c2016-03-09 14:32:57 +05305067 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305068 nlo_list[i].rssi_cond.rssi);
5069
5070 /* Copy pno flags */
5071 nlo_list[i].bcast_nw_type.valid = true;
5072 nlo_list[i].bcast_nw_type.bcast_nw_type =
5073 req->networks[i].flags;
Govind Singhb53420c2016-03-09 14:32:57 +05305074 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305075 nlo_list[i].bcast_nw_type.bcast_nw_type);
5076
5077 /* Copy auth bit field */
5078 nlo_list[i].auth_type.valid = true;
5079 nlo_list[i].auth_type.auth_type =
5080 req->networks[i].auth_bit_field;
Govind Singhb53420c2016-03-09 14:32:57 +05305081 WMI_LOGD("Auth bit field (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305082 nlo_list[i].auth_type.auth_type);
5083 }
5084
5085 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5086 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5087 buf_ptr += WMI_TLV_HDR_SIZE;
5088
5089 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5090 buf_ptr += WMI_TLV_HDR_SIZE;
5091 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5092 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305093 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305094 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305095 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305096 }
5097
Govind Singhb53420c2016-03-09 14:32:57 +05305098 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305099 req->session_id);
5100
Govind Singh67922e82016-04-01 16:48:57 +05305101 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305102}
5103
5104/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5105 * @wmi_handle: wmi handle
5106 * @ipa_offload: ipa offload control parameter
5107 *
5108 * Returns: 0 on success, error number otherwise
5109 */
Govind Singhb53420c2016-03-09 14:32:57 +05305110QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305111 struct ipa_offload_control_params *ipa_offload)
5112{
5113 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5114 wmi_buf_t wmi_buf;
5115 uint32_t len;
5116 u_int8_t *buf_ptr;
5117
5118 len = sizeof(*cmd);
5119 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5120 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305121 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5122 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305123 }
5124
Govind Singhb53420c2016-03-09 14:32:57 +05305125 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305126 ipa_offload->offload_type, ipa_offload->enable);
5127
5128 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5129
5130 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5131 WMITLV_SET_HDR(&cmd->tlv_header,
5132 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5133 WMITLV_GET_STRUCT_TLVLEN(
5134 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5135
5136 cmd->offload_type = ipa_offload->offload_type;
5137 cmd->vdev_id = ipa_offload->vdev_id;
5138 cmd->enable = ipa_offload->enable;
5139
5140 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5141 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305142 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305143 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305144 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305145 }
5146
Govind Singhb53420c2016-03-09 14:32:57 +05305147 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305148}
5149
5150/**
5151 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5152 * @wmi_handle: wmi handle
5153 * @pgetcapab: get capabilities params
5154 *
5155 * This function send request to fw to get extscan capabilities.
5156 *
5157 * Return: CDF status
5158 */
Govind Singhb53420c2016-03-09 14:32:57 +05305159QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305160 struct extscan_capabilities_params *pgetcapab)
5161{
5162 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5163 wmi_buf_t wmi_buf;
5164 uint32_t len;
5165 uint8_t *buf_ptr;
5166
5167 len = sizeof(*cmd);
5168 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5169 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305170 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5171 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305172 }
5173 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5174
5175 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5176 WMITLV_SET_HDR(&cmd->tlv_header,
5177 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5178 WMITLV_GET_STRUCT_TLVLEN
5179 (wmi_extscan_get_capabilities_cmd_fixed_param));
5180
5181 cmd->request_id = pgetcapab->request_id;
5182
5183 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5184 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305185 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305186 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305187 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305188 }
Govind Singhb53420c2016-03-09 14:32:57 +05305189 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305190}
5191
5192/**
5193 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5194 * @wmi_handle: wmi handle
5195 * @pcached_results: cached results parameters
5196 *
5197 * This function send request to fw to get cached results.
5198 *
5199 * Return: CDF status
5200 */
Govind Singhb53420c2016-03-09 14:32:57 +05305201QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305202 struct extscan_cached_result_params *pcached_results)
5203{
5204 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5205 wmi_buf_t wmi_buf;
5206 uint32_t len;
5207 uint8_t *buf_ptr;
5208
5209 len = sizeof(*cmd);
5210 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5211 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305212 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5213 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305214 }
5215 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5216
5217 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
5218 WMITLV_SET_HDR(&cmd->tlv_header,
5219 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
5220 WMITLV_GET_STRUCT_TLVLEN
5221 (wmi_extscan_get_cached_results_cmd_fixed_param));
5222
5223 cmd->request_id = pcached_results->request_id;
5224 cmd->vdev_id = pcached_results->session_id;
5225 cmd->control_flags = pcached_results->flush;
5226
5227 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5228 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305229 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305230 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305231 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305232 }
Govind Singhb53420c2016-03-09 14:32:57 +05305233 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305234}
5235
5236/**
5237 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
5238 * @wmi_handle: wmi handle
5239 * @reset_req: Reset change request params
5240 *
5241 * This function sends stop change monitor request to fw.
5242 *
5243 * Return: CDF status
5244 */
Govind Singhb53420c2016-03-09 14:32:57 +05305245QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305246 struct extscan_capabilities_reset_params *reset_req)
5247{
5248 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5249 wmi_buf_t wmi_buf;
5250 uint32_t len;
5251 uint8_t *buf_ptr;
5252 int change_list = 0;
5253
5254 len = sizeof(*cmd);
5255
5256 /* reset significant change tlv is set to 0 */
5257 len += WMI_TLV_HDR_SIZE;
5258 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
5259 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5260 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305261 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5262 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305263 }
5264 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5265
5266 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5267 buf_ptr;
5268 WMITLV_SET_HDR(&cmd->tlv_header,
5269 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5270 WMITLV_GET_STRUCT_TLVLEN
5271 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5272
5273 cmd->request_id = reset_req->request_id;
5274 cmd->vdev_id = reset_req->session_id;
5275 cmd->mode = 0;
5276
5277 buf_ptr += sizeof(*cmd);
5278 WMITLV_SET_HDR(buf_ptr,
5279 WMITLV_TAG_ARRAY_STRUC,
5280 change_list *
5281 sizeof(wmi_extscan_wlan_change_bssid_param));
5282 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
5283 sizeof
5284 (wmi_extscan_wlan_change_bssid_param));
5285
5286 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5287 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305288 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305289 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305290 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305291 }
Govind Singhb53420c2016-03-09 14:32:57 +05305292 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305293}
5294
5295/**
5296 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
5297 * @wmi_handle: wmi handle
5298 * @psigchange: change monitor request params
5299 * @buf: wmi buffer
5300 * @buf_len: buffer length
5301 *
5302 * This function fills elements of change monitor request buffer.
5303 *
5304 * Return: CDF status
5305 */
Govind Singhb53420c2016-03-09 14:32:57 +05305306static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305307 struct extscan_set_sig_changereq_params
5308 *psigchange, wmi_buf_t *buf, int *buf_len)
5309{
5310 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5311 wmi_extscan_wlan_change_bssid_param *dest_chglist;
5312 uint8_t *buf_ptr;
5313 int j;
5314 int len = sizeof(*cmd);
5315 int numap = psigchange->num_ap;
5316 struct ap_threshold_params *src_ap = psigchange->ap;
5317
5318 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +05305319 WMI_LOGE("%s: Invalid number of bssid's", __func__);
5320 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305321 }
5322 len += WMI_TLV_HDR_SIZE;
5323 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
5324
5325 *buf = wmi_buf_alloc(wmi_handle, len);
5326 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305327 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305328 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305329 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305330 }
5331 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5332 cmd =
5333 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5334 buf_ptr;
5335 WMITLV_SET_HDR(&cmd->tlv_header,
5336 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5337 WMITLV_GET_STRUCT_TLVLEN
5338 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5339
5340 cmd->request_id = psigchange->request_id;
5341 cmd->vdev_id = psigchange->session_id;
5342 cmd->total_entries = numap;
5343 cmd->mode = 1;
5344 cmd->num_entries_in_page = numap;
5345 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
5346 cmd->max_rssi_samples = psigchange->rssi_sample_size;
5347 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
5348 cmd->max_out_of_range_count = psigchange->min_breaching;
5349
5350 buf_ptr += sizeof(*cmd);
5351 WMITLV_SET_HDR(buf_ptr,
5352 WMITLV_TAG_ARRAY_STRUC,
5353 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5354 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
5355 (buf_ptr + WMI_TLV_HDR_SIZE);
5356
5357 for (j = 0; j < numap; j++) {
5358 WMITLV_SET_HDR(dest_chglist,
5359 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5360 WMITLV_GET_STRUCT_TLVLEN
5361 (wmi_extscan_wlan_change_bssid_param));
5362
5363 dest_chglist->lower_rssi_limit = src_ap->low;
5364 dest_chglist->upper_rssi_limit = src_ap->high;
5365 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
5366 &dest_chglist->bssid);
5367
Govind Singhb53420c2016-03-09 14:32:57 +05305368 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305369 dest_chglist->lower_rssi_limit);
5370 dest_chglist++;
5371 src_ap++;
5372 }
5373 buf_ptr += WMI_TLV_HDR_SIZE +
5374 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5375 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305376 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305377}
5378
5379/**
5380 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
5381 * @wmi_handle: wmi handle
5382 * @psigchange: change monitor request params
5383 *
5384 * This function sends start change monitor request to fw.
5385 *
5386 * Return: CDF status
5387 */
Govind Singhb53420c2016-03-09 14:32:57 +05305388QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305389 struct extscan_set_sig_changereq_params *
5390 psigchange)
5391{
Govind Singhb53420c2016-03-09 14:32:57 +05305392 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305393 wmi_buf_t buf;
5394 int len;
5395
5396
Govind Singhb53420c2016-03-09 14:32:57 +05305397 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305398 psigchange, &buf,
5399 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305400 if (qdf_status != QDF_STATUS_SUCCESS) {
5401 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305402 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305403 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305404 }
5405 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305406 WMI_LOGE("%s: Failed to get buffer", __func__);
5407 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305408 }
5409 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5410 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305411 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305412 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305413 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305414 }
Govind Singhb53420c2016-03-09 14:32:57 +05305415 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305416}
5417
5418/**
5419 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
5420 * @wmi_handle: wmi handle
5421 * @photlist_reset: hotlist reset params
5422 *
5423 * This function configures hotlist monitor to stop in fw.
5424 *
5425 * Return: CDF status
5426 */
Govind Singhb53420c2016-03-09 14:32:57 +05305427QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305428 struct extscan_bssid_hotlist_reset_params *photlist_reset)
5429{
5430 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
5431 wmi_buf_t wmi_buf;
5432 uint32_t len;
5433 uint8_t *buf_ptr;
5434 int hotlist_entries = 0;
5435
5436 len = sizeof(*cmd);
5437
5438 /* reset bssid hotlist with tlv set to 0 */
5439 len += WMI_TLV_HDR_SIZE;
5440 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
5441
5442 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5443 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305444 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5445 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305446 }
5447
5448 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5449 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
5450 buf_ptr;
5451 WMITLV_SET_HDR(&cmd->tlv_header,
5452 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
5453 WMITLV_GET_STRUCT_TLVLEN
5454 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
5455
5456 cmd->request_id = photlist_reset->request_id;
5457 cmd->vdev_id = photlist_reset->session_id;
5458 cmd->mode = 0;
5459
5460 buf_ptr += sizeof(*cmd);
5461 WMITLV_SET_HDR(buf_ptr,
5462 WMITLV_TAG_ARRAY_STRUC,
5463 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5464 buf_ptr += WMI_TLV_HDR_SIZE +
5465 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5466
5467 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5468 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305469 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305470 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305471 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305472 }
Govind Singhb53420c2016-03-09 14:32:57 +05305473 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305474}
5475
5476/**
5477 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
5478 * @wmi_handle: wmi handle
5479 * @pstopcmd: stop scan command request params
5480 *
5481 * This function sends stop extscan request to fw.
5482 *
5483 * Return: CDF Status.
5484 */
Govind Singhb53420c2016-03-09 14:32:57 +05305485QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305486 struct extscan_stop_req_params *pstopcmd)
5487{
5488 wmi_extscan_stop_cmd_fixed_param *cmd;
5489 wmi_buf_t wmi_buf;
5490 uint32_t len;
5491 uint8_t *buf_ptr;
5492
5493 len = sizeof(*cmd);
5494 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5495 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305496 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5497 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305498 }
5499 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5500 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
5501 WMITLV_SET_HDR(&cmd->tlv_header,
5502 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
5503 WMITLV_GET_STRUCT_TLVLEN
5504 (wmi_extscan_stop_cmd_fixed_param));
5505
5506 cmd->request_id = pstopcmd->request_id;
5507 cmd->vdev_id = pstopcmd->session_id;
5508
5509 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5510 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305511 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305512 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305513 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305514 }
5515
Govind Singhb53420c2016-03-09 14:32:57 +05305516 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305517}
5518
5519/**
5520 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
5521 * @wmi_handle: wmi handle
5522 * @pstart: scan command request params
5523 * @buf: event buffer
5524 * @buf_len: length of buffer
5525 *
5526 * This function fills individual elements of extscan request and
5527 * TLV for buckets, channel list.
5528 *
5529 * Return: CDF Status.
5530 */
Govind Singhb53420c2016-03-09 14:32:57 +05305531QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305532 struct wifi_scan_cmd_req_params *pstart,
5533 wmi_buf_t *buf, int *buf_len)
5534{
5535 wmi_extscan_start_cmd_fixed_param *cmd;
5536 wmi_extscan_bucket *dest_blist;
5537 wmi_extscan_bucket_channel *dest_clist;
5538 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
5539 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
5540 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
5541
5542 uint8_t *buf_ptr;
5543 int i, k, count = 0;
5544 int len = sizeof(*cmd);
5545 int nbuckets = pstart->numBuckets;
5546 int nchannels = 0;
5547
5548 /* These TLV's are are NULL by default */
5549 uint32_t ie_len_with_pad = 0;
5550 int num_ssid = 0;
5551 int num_bssid = 0;
5552 int ie_len = 0;
5553
5554 uint32_t base_period = pstart->basePeriod;
5555
5556 /* TLV placeholder for ssid_list (NULL) */
5557 len += WMI_TLV_HDR_SIZE;
5558 len += num_ssid * sizeof(wmi_ssid);
5559
5560 /* TLV placeholder for bssid_list (NULL) */
5561 len += WMI_TLV_HDR_SIZE;
5562 len += num_bssid * sizeof(wmi_mac_addr);
5563
5564 /* TLV placeholder for ie_data (NULL) */
5565 len += WMI_TLV_HDR_SIZE;
5566 len += ie_len * sizeof(uint32_t);
5567
5568 /* TLV placeholder for bucket */
5569 len += WMI_TLV_HDR_SIZE;
5570 len += nbuckets * sizeof(wmi_extscan_bucket);
5571
5572 /* TLV channel placeholder */
5573 len += WMI_TLV_HDR_SIZE;
5574 for (i = 0; i < nbuckets; i++) {
5575 nchannels += src_bucket->numChannels;
5576 src_bucket++;
5577 }
5578
Govind Singhb53420c2016-03-09 14:32:57 +05305579 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305580 __func__, nbuckets, nchannels);
5581 len += nchannels * sizeof(wmi_extscan_bucket_channel);
5582 /* Allocate the memory */
5583 *buf = wmi_buf_alloc(wmi_handle, len);
5584 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305585 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05305586 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305587 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305588 }
5589 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5590 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
5591 WMITLV_SET_HDR(&cmd->tlv_header,
5592 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
5593 WMITLV_GET_STRUCT_TLVLEN
5594 (wmi_extscan_start_cmd_fixed_param));
5595
5596 cmd->request_id = pstart->requestId;
5597 cmd->vdev_id = pstart->sessionId;
5598 cmd->base_period = pstart->basePeriod;
5599 cmd->num_buckets = nbuckets;
5600 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05305601 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305602 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05305603 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305604 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05305605#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05305606 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
5607 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05305608 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
5609 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
5610#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05305611 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5612
5613 /* The max dwell time is retrieved from the first channel
5614 * of the first bucket and kept common for all channels.
5615 */
5616 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
5617 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
5618 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
5619 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
5620 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5621 cmd->max_table_usage = pstart->report_threshold_percent;
5622 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
5623
5624 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05305625 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305626 cmd->probe_delay = 0;
5627 cmd->probe_spacing_time = 0;
5628 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305629 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
5630 WMI_SCAN_ADD_CCK_RATES |
5631 WMI_SCAN_ADD_OFDM_RATES |
5632 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
5633 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05305634 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
5635 pstart->extscan_adaptive_dwell_mode);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305636 cmd->scan_priority = WMI_SCAN_PRIORITY_HIGH;
5637 cmd->num_ssids = 0;
5638 cmd->num_bssid = 0;
5639 cmd->ie_len = 0;
5640 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
5641 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
5642
5643 buf_ptr += sizeof(*cmd);
5644 WMITLV_SET_HDR(buf_ptr,
5645 WMITLV_TAG_ARRAY_FIXED_STRUC,
5646 num_ssid * sizeof(wmi_ssid));
5647 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
5648
5649 WMITLV_SET_HDR(buf_ptr,
5650 WMITLV_TAG_ARRAY_FIXED_STRUC,
5651 num_bssid * sizeof(wmi_mac_addr));
5652 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
5653
5654 ie_len_with_pad = 0;
5655 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5656 ie_len_with_pad);
5657 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
5658
5659 WMITLV_SET_HDR(buf_ptr,
5660 WMITLV_TAG_ARRAY_STRUC,
5661 nbuckets * sizeof(wmi_extscan_bucket));
5662 dest_blist = (wmi_extscan_bucket *)
5663 (buf_ptr + WMI_TLV_HDR_SIZE);
5664 src_bucket = pstart->buckets;
5665
5666 /* Retrieve scanning information from each bucket and
5667 * channels and send it to the target
5668 */
5669 for (i = 0; i < nbuckets; i++) {
5670 WMITLV_SET_HDR(dest_blist,
5671 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5672 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
5673
5674 dest_blist->bucket_id = src_bucket->bucket;
5675 dest_blist->base_period_multiplier =
5676 src_bucket->period / base_period;
5677 dest_blist->min_period = src_bucket->period;
5678 dest_blist->max_period = src_bucket->max_period;
5679 dest_blist->exp_backoff = src_bucket->exponent;
5680 dest_blist->exp_max_step_count = src_bucket->step_count;
5681 dest_blist->channel_band = src_bucket->band;
5682 dest_blist->num_channels = src_bucket->numChannels;
5683 dest_blist->notify_extscan_events = 0;
5684
5685 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
5686 dest_blist->notify_extscan_events =
5687 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT;
5688
5689 if (src_bucket->reportEvents &
5690 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
5691 dest_blist->forwarding_flags =
5692 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
5693 dest_blist->notify_extscan_events |=
5694 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
5695 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
5696 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
5697 } else {
5698 dest_blist->forwarding_flags =
5699 WMI_EXTSCAN_NO_FORWARDING;
5700 }
5701
5702 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
5703 dest_blist->configuration_flags = 0;
5704 else
5705 dest_blist->configuration_flags =
5706 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
5707
Govind Singhb53420c2016-03-09 14:32:57 +05305708 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305709 __func__, dest_blist->notify_extscan_events,
5710 dest_blist->configuration_flags,
5711 dest_blist->forwarding_flags);
5712
5713 dest_blist->min_dwell_time_active =
5714 src_bucket->min_dwell_time_active;
5715 dest_blist->max_dwell_time_active =
5716 src_bucket->max_dwell_time_active;
5717 dest_blist->min_dwell_time_passive =
5718 src_bucket->min_dwell_time_passive;
5719 dest_blist->max_dwell_time_passive =
5720 src_bucket->max_dwell_time_passive;
5721 src_channel = src_bucket->channels;
5722
5723 /* save the channel info to later populate
5724 * the channel TLV
5725 */
5726 for (k = 0; k < src_bucket->numChannels; k++) {
5727 save_channel[count++].channel = src_channel->channel;
5728 src_channel++;
5729 }
5730 dest_blist++;
5731 src_bucket++;
5732 }
5733 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
5734 WMITLV_SET_HDR(buf_ptr,
5735 WMITLV_TAG_ARRAY_STRUC,
5736 nchannels * sizeof(wmi_extscan_bucket_channel));
5737 dest_clist = (wmi_extscan_bucket_channel *)
5738 (buf_ptr + WMI_TLV_HDR_SIZE);
5739
5740 /* Active or passive scan is based on the bucket dwell time
5741 * and channel specific active,passive scans are not
5742 * supported yet
5743 */
5744 for (i = 0; i < nchannels; i++) {
5745 WMITLV_SET_HDR(dest_clist,
5746 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
5747 WMITLV_GET_STRUCT_TLVLEN
5748 (wmi_extscan_bucket_channel));
5749 dest_clist->channel = save_channel[i].channel;
5750 dest_clist++;
5751 }
5752 buf_ptr += WMI_TLV_HDR_SIZE +
5753 (nchannels * sizeof(wmi_extscan_bucket_channel));
5754 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305755 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305756}
5757
5758/**
5759 * send_start_extscan_cmd_tlv() - start extscan command to fw.
5760 * @wmi_handle: wmi handle
5761 * @pstart: scan command request params
5762 *
5763 * This function sends start extscan request to fw.
5764 *
5765 * Return: CDF Status.
5766 */
Govind Singhb53420c2016-03-09 14:32:57 +05305767QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305768 struct wifi_scan_cmd_req_params *pstart)
5769{
Govind Singhb53420c2016-03-09 14:32:57 +05305770 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305771 wmi_buf_t buf;
5772 int len;
5773
5774 /* Fill individual elements of extscan request and
5775 * TLV for buckets, channel list.
5776 */
Govind Singhb53420c2016-03-09 14:32:57 +05305777 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305778 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305779 if (qdf_status != QDF_STATUS_SUCCESS) {
5780 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
5781 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305782 }
5783 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305784 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05305785 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305786 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305787 }
5788 if (wmi_unified_cmd_send(wmi_handle, buf,
5789 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305790 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305791 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305792 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305793 }
5794
Govind Singhb53420c2016-03-09 14:32:57 +05305795 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305796}
5797
5798/**
5799 * send_plm_stop_cmd_tlv() - plm stop request
5800 * @wmi_handle: wmi handle
5801 * @plm: plm request parameters
5802 *
5803 * This function request FW to stop PLM.
5804 *
5805 * Return: CDF status
5806 */
Govind Singhb53420c2016-03-09 14:32:57 +05305807QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305808 const struct plm_req_params *plm)
5809{
5810 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
5811 int32_t len;
5812 wmi_buf_t buf;
5813 uint8_t *buf_ptr;
5814 int ret;
5815
5816 len = sizeof(*cmd);
5817 buf = wmi_buf_alloc(wmi_handle, len);
5818 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305819 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5820 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305821 }
5822
5823 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
5824
5825 buf_ptr = (uint8_t *) cmd;
5826
5827 WMITLV_SET_HDR(&cmd->tlv_header,
5828 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
5829 WMITLV_GET_STRUCT_TLVLEN
5830 (wmi_vdev_plmreq_stop_cmd_fixed_param));
5831
5832 cmd->vdev_id = plm->session_id;
5833
5834 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05305835 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305836
5837 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5838 WMI_VDEV_PLMREQ_STOP_CMDID);
5839 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305840 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305841 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305842 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305843 }
5844
Govind Singhb53420c2016-03-09 14:32:57 +05305845 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305846}
5847
5848/**
5849 * send_plm_start_cmd_tlv() - plm start request
5850 * @wmi_handle: wmi handle
5851 * @plm: plm request parameters
5852 *
5853 * This function request FW to start PLM.
5854 *
5855 * Return: CDF status
5856 */
Govind Singhb53420c2016-03-09 14:32:57 +05305857QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305858 const struct plm_req_params *plm,
5859 uint32_t *gchannel_list)
5860{
5861 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
5862 uint32_t *channel_list;
5863 int32_t len;
5864 wmi_buf_t buf;
5865 uint8_t *buf_ptr;
5866 uint8_t count;
5867 int ret;
5868
5869 /* TLV place holder for channel_list */
5870 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5871 len += sizeof(uint32_t) * plm->plm_num_ch;
5872
5873 buf = wmi_buf_alloc(wmi_handle, len);
5874 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305875 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5876 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305877 }
5878 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
5879
5880 buf_ptr = (uint8_t *) cmd;
5881
5882 WMITLV_SET_HDR(&cmd->tlv_header,
5883 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
5884 WMITLV_GET_STRUCT_TLVLEN
5885 (wmi_vdev_plmreq_start_cmd_fixed_param));
5886
5887 cmd->vdev_id = plm->session_id;
5888
5889 cmd->meas_token = plm->meas_token;
5890 cmd->dialog_token = plm->diag_token;
5891 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05305892 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305893 cmd->off_duration = plm->meas_duration;
5894 cmd->burst_cycle = plm->burst_len;
5895 cmd->tx_power = plm->desired_tx_pwr;
5896 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
5897 cmd->num_chans = plm->plm_num_ch;
5898
5899 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
5900
Govind Singhb53420c2016-03-09 14:32:57 +05305901 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
5902 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
5903 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
5904 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
5905 WMI_LOGD("off_duration: %d", cmd->off_duration);
5906 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
5907 WMI_LOGD("tx_power: %d", cmd->tx_power);
5908 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305909
5910 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5911 (cmd->num_chans * sizeof(uint32_t)));
5912
5913 buf_ptr += WMI_TLV_HDR_SIZE;
5914 if (cmd->num_chans) {
5915 channel_list = (uint32_t *) buf_ptr;
5916 for (count = 0; count < cmd->num_chans; count++) {
5917 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05305918 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305919 channel_list[count] =
5920 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05305921 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305922 }
5923 buf_ptr += cmd->num_chans * sizeof(uint32_t);
5924 }
5925
5926 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5927 WMI_VDEV_PLMREQ_START_CMDID);
5928 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305929 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305930 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305931 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305932 }
5933
Govind Singhb53420c2016-03-09 14:32:57 +05305934 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305935}
5936
5937/**
5938 * send_pno_stop_cmd_tlv() - PNO stop request
5939 * @wmi_handle: wmi handle
5940 * @vdev_id: vdev id
5941 *
5942 * This function request FW to stop ongoing PNO operation.
5943 *
5944 * Return: CDF status
5945 */
Govind Singhb53420c2016-03-09 14:32:57 +05305946QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305947{
5948 wmi_nlo_config_cmd_fixed_param *cmd;
5949 int32_t len = sizeof(*cmd);
5950 wmi_buf_t buf;
5951 uint8_t *buf_ptr;
5952 int ret;
5953
5954 /*
5955 * TLV place holder for array of structures nlo_configured_parameters
5956 * TLV place holder for array of uint32_t channel_list
5957 * TLV place holder for chnl prediction cfg
5958 */
5959 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
5960 buf = wmi_buf_alloc(wmi_handle, len);
5961 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305962 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5963 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305964 }
5965
5966 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5967 buf_ptr = (uint8_t *) cmd;
5968
5969 WMITLV_SET_HDR(&cmd->tlv_header,
5970 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5971 WMITLV_GET_STRUCT_TLVLEN
5972 (wmi_nlo_config_cmd_fixed_param));
5973
5974 cmd->vdev_id = vdev_id;
5975 cmd->flags = WMI_NLO_CONFIG_STOP;
5976 buf_ptr += sizeof(*cmd);
5977
5978 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5979 buf_ptr += WMI_TLV_HDR_SIZE;
5980
5981 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5982 buf_ptr += WMI_TLV_HDR_SIZE;
5983
5984 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5985 buf_ptr += WMI_TLV_HDR_SIZE;
5986
5987
5988 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5989 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
5990 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305991 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305992 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305993 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305994 }
5995
Govind Singhb53420c2016-03-09 14:32:57 +05305996 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305997}
5998
5999/**
Govind Singhccb0c272016-04-01 16:30:08 +05306000 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6001 * @buf_ptr: Buffer passed by upper layers
6002 * @pno: Buffer to be sent to the firmware
6003 *
6004 * Copy the PNO Channel prediction configuration parameters
6005 * passed by the upper layers to a WMI format TLV and send it
6006 * down to the firmware.
6007 *
6008 * Return: None
6009 */
6010static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6011 struct pno_scan_req_params *pno)
6012{
6013 nlo_channel_prediction_cfg *channel_prediction_cfg =
6014 (nlo_channel_prediction_cfg *) buf_ptr;
6015 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6016 WMITLV_TAG_ARRAY_BYTE,
6017 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306018#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306019 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6020 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6021 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6022 channel_prediction_cfg->full_scan_period_ms =
6023 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306024#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306025 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6026 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6027 channel_prediction_cfg->enable,
6028 channel_prediction_cfg->top_k_num,
6029 channel_prediction_cfg->stationary_threshold,
6030 channel_prediction_cfg->full_scan_period_ms);
6031}
6032
6033/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306034 * send_pno_start_cmd_tlv() - PNO start request
6035 * @wmi_handle: wmi handle
6036 * @pno: PNO request
6037 *
6038 * This function request FW to start PNO request.
6039 * Request: CDF status
6040 */
Govind Singhb53420c2016-03-09 14:32:57 +05306041QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306042 struct pno_scan_req_params *pno,
6043 uint32_t *gchannel_freq_list)
6044{
6045 wmi_nlo_config_cmd_fixed_param *cmd;
6046 nlo_configured_parameters *nlo_list;
6047 uint32_t *channel_list;
6048 int32_t len;
6049 wmi_buf_t buf;
6050 uint8_t *buf_ptr;
6051 uint8_t i;
6052 int ret;
6053
6054 /*
6055 * TLV place holder for array nlo_configured_parameters(nlo_list)
6056 * TLV place holder for array of uint32_t channel_list
6057 * TLV place holder for chnnl prediction cfg
6058 */
6059 len = sizeof(*cmd) +
6060 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6061
Govind Singhb53420c2016-03-09 14:32:57 +05306062 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306063 WMI_NLO_MAX_CHAN);
6064 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306065 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306066 len += sizeof(nlo_channel_prediction_cfg);
6067
6068 buf = wmi_buf_alloc(wmi_handle, len);
6069 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306070 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6071 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306072 }
6073
6074 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6075
6076 buf_ptr = (uint8_t *) cmd;
6077 WMITLV_SET_HDR(&cmd->tlv_header,
6078 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6079 WMITLV_GET_STRUCT_TLVLEN
6080 (wmi_nlo_config_cmd_fixed_param));
6081 cmd->vdev_id = pno->sessionId;
6082 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6083
Govind Singh87542482016-06-08 19:40:11 +05306084#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306085 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6086 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306087#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306088 /* Current FW does not support min-max range for dwell time */
6089 cmd->active_dwell_time = pno->active_max_time;
6090 cmd->passive_dwell_time = pno->passive_max_time;
6091
6092 /* Copy scan interval */
6093 cmd->fast_scan_period = pno->fast_scan_period;
6094 cmd->slow_scan_period = pno->slow_scan_period;
6095 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306096 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306097 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306098 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306099
6100 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6101
Govind Singhb53420c2016-03-09 14:32:57 +05306102 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6103 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306104 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6105 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6106 buf_ptr += WMI_TLV_HDR_SIZE;
6107
6108 nlo_list = (nlo_configured_parameters *) buf_ptr;
6109 for (i = 0; i < cmd->no_of_ssids; i++) {
6110 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6111 WMITLV_TAG_ARRAY_BYTE,
6112 WMITLV_GET_STRUCT_TLVLEN
6113 (nlo_configured_parameters));
6114 /* Copy ssid and it's length */
6115 nlo_list[i].ssid.valid = true;
6116 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306117 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306118 pno->aNetworks[i].ssid.mac_ssid,
6119 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306120 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306121 nlo_list[i].ssid.ssid.ssid_len,
6122 (char *)nlo_list[i].ssid.ssid.ssid,
6123 nlo_list[i].ssid.ssid.ssid_len);
6124
6125 /* Copy rssi threshold */
6126 if (pno->aNetworks[i].rssiThreshold &&
6127 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6128 nlo_list[i].rssi_cond.valid = true;
6129 nlo_list[i].rssi_cond.rssi =
6130 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306131 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306132 nlo_list[i].rssi_cond.rssi);
6133 }
6134 nlo_list[i].bcast_nw_type.valid = true;
6135 nlo_list[i].bcast_nw_type.bcast_nw_type =
6136 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306137 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306138 nlo_list[i].bcast_nw_type.bcast_nw_type);
6139 }
6140 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6141
6142 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306143 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306144 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306145 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306146 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6147 (cmd->num_of_channels * sizeof(uint32_t)));
6148 buf_ptr += WMI_TLV_HDR_SIZE;
6149
6150 channel_list = (uint32_t *) buf_ptr;
6151 for (i = 0; i < cmd->num_of_channels; i++) {
6152 channel_list[i] = pno->aNetworks[0].aChannels[i];
6153
6154 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6155 channel_list[i] = gchannel_freq_list[i];
6156
Govind Singhb53420c2016-03-09 14:32:57 +05306157 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306158 }
6159 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6160 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6161 sizeof(nlo_channel_prediction_cfg));
6162 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306163 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306164 buf_ptr += WMI_TLV_HDR_SIZE;
6165 /** TODO: Discrete firmware doesn't have command/option to configure
6166 * App IE which comes from wpa_supplicant as of part PNO start request.
6167 */
6168 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6169 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6170 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306171 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306172 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306173 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306174 }
6175
Govind Singhb53420c2016-03-09 14:32:57 +05306176 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306177}
6178
6179/* send_set_ric_req_cmd_tlv() - set ric request element
6180 * @wmi_handle: wmi handle
6181 * @msg: message
6182 * @is_add_ts: is addts required
6183 *
6184 * This function sets ric request element for 11r roaming.
6185 *
6186 * Return: CDF status
6187 */
Govind Singhb53420c2016-03-09 14:32:57 +05306188QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306189 void *msg, uint8_t is_add_ts)
6190{
6191 wmi_ric_request_fixed_param *cmd;
6192 wmi_ric_tspec *tspec_param;
6193 wmi_buf_t buf;
6194 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306195 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306196 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6197 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6198
6199 buf = wmi_buf_alloc(wmi_handle, len);
6200 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306201 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6202 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306203 }
6204
6205 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6206
6207 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6208 WMITLV_SET_HDR(&cmd->tlv_header,
6209 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6210 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6211 if (is_add_ts)
6212 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
6213 else
6214 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
6215 cmd->num_ric_request = 1;
6216 cmd->is_add_ric = is_add_ts;
6217
6218 buf_ptr += sizeof(wmi_ric_request_fixed_param);
6219 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
6220
6221 buf_ptr += WMI_TLV_HDR_SIZE;
6222 tspec_param = (wmi_ric_tspec *) buf_ptr;
6223 WMITLV_SET_HDR(&tspec_param->tlv_header,
6224 WMITLV_TAG_STRUC_wmi_ric_tspec,
6225 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
6226
6227 if (is_add_ts)
6228 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05306229#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05306230 else
6231 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05306232#endif
6233 if (ptspecIE) {
6234 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05306235#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05306236 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
6237 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306238#else
Govind Singh87542482016-06-08 19:40:11 +05306239 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
6240 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306241#endif /* ANI_LITTLE_BIT_ENDIAN */
6242
Govind Singh87542482016-06-08 19:40:11 +05306243 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
6244 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
6245 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
6246 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
6247 tspec_param->inactivity_interval = ptspecIE->inactInterval;
6248 tspec_param->suspension_interval = ptspecIE->suspendInterval;
6249 tspec_param->svc_start_time = ptspecIE->svcStartTime;
6250 tspec_param->min_data_rate = ptspecIE->minDataRate;
6251 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
6252 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
6253 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
6254 tspec_param->delay_bound = ptspecIE->delayBound;
6255 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
6256 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
6257 tspec_param->medium_time = 0;
6258 }
Govind Singhb53420c2016-03-09 14:32:57 +05306259 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306260
6261 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6262 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306263 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306264 __func__);
6265 if (is_add_ts)
6266 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05306267 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05306268 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306269 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306270 }
6271
Govind Singhb53420c2016-03-09 14:32:57 +05306272 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306273}
6274
6275/**
6276 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
6277 * @wmi_handle: wmi handle
6278 * @clear_req: ll stats clear request command params
6279 *
Govind Singhb53420c2016-03-09 14:32:57 +05306280 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306281 */
Govind Singhb53420c2016-03-09 14:32:57 +05306282QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306283 const struct ll_stats_clear_params *clear_req,
6284 uint8_t addr[IEEE80211_ADDR_LEN])
6285{
6286 wmi_clear_link_stats_cmd_fixed_param *cmd;
6287 int32_t len;
6288 wmi_buf_t buf;
6289 uint8_t *buf_ptr;
6290 int ret;
6291
6292 len = sizeof(*cmd);
6293 buf = wmi_buf_alloc(wmi_handle, len);
6294
6295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306296 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6297 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306298 }
6299
6300 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306301 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306302 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
6303
6304 WMITLV_SET_HDR(&cmd->tlv_header,
6305 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
6306 WMITLV_GET_STRUCT_TLVLEN
6307 (wmi_clear_link_stats_cmd_fixed_param));
6308
6309 cmd->stop_stats_collection_req = clear_req->stop_req;
6310 cmd->vdev_id = clear_req->sta_id;
6311 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
6312
6313 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6314 &cmd->peer_macaddr);
6315
Govind Singhb53420c2016-03-09 14:32:57 +05306316 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
6317 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
6318 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
6319 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
6320 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306321 cmd->peer_macaddr); */
6322
6323 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6324 WMI_CLEAR_LINK_STATS_CMDID);
6325 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306326 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +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 WMI_LOGD("Clear Link Layer Stats request sent successfully");
6332 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306333}
6334
6335/**
6336 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
6337 * @wmi_handle: wmi handle
6338 * @setReq: ll stats set request command params
6339 *
Govind Singhb53420c2016-03-09 14:32:57 +05306340 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306341 */
Govind Singhb53420c2016-03-09 14:32:57 +05306342QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306343 const struct ll_stats_set_params *set_req)
6344{
6345 wmi_start_link_stats_cmd_fixed_param *cmd;
6346 int32_t len;
6347 wmi_buf_t buf;
6348 uint8_t *buf_ptr;
6349 int ret;
6350
6351 len = sizeof(*cmd);
6352 buf = wmi_buf_alloc(wmi_handle, len);
6353
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 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306360 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306361 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
6362
6363 WMITLV_SET_HDR(&cmd->tlv_header,
6364 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
6365 WMITLV_GET_STRUCT_TLVLEN
6366 (wmi_start_link_stats_cmd_fixed_param));
6367
6368 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
6369 cmd->aggressive_statistics_gathering =
6370 set_req->aggressive_statistics_gathering;
6371
Govind Singhb53420c2016-03-09 14:32:57 +05306372 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
6373 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
6374 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306375
6376 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6377 WMI_START_LINK_STATS_CMDID);
6378 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306379 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306380 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306381 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306382 }
6383
Govind Singhb53420c2016-03-09 14:32:57 +05306384 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306385}
6386
6387/**
6388 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
6389 * @wmi_handle:wmi handle
6390 * @get_req:ll stats get request command params
6391 * @addr: mac address
6392 *
Govind Singhb53420c2016-03-09 14:32:57 +05306393 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306394 */
Govind Singhb53420c2016-03-09 14:32:57 +05306395QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306396 const struct ll_stats_get_params *get_req,
6397 uint8_t addr[IEEE80211_ADDR_LEN])
6398{
6399 wmi_request_link_stats_cmd_fixed_param *cmd;
6400 int32_t len;
6401 wmi_buf_t buf;
6402 uint8_t *buf_ptr;
6403 int ret;
6404
6405 len = sizeof(*cmd);
6406 buf = wmi_buf_alloc(wmi_handle, len);
6407
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05306408 if (!buf) {
6409 WMI_LOGE("%s: buf allocation failed", __func__);
6410 return QDF_STATUS_E_NOMEM;
6411 }
6412
Govind Singh4eacd2b2016-03-07 14:24:22 +05306413 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306414 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306415 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
6416
6417 WMITLV_SET_HDR(&cmd->tlv_header,
6418 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
6419 WMITLV_GET_STRUCT_TLVLEN
6420 (wmi_request_link_stats_cmd_fixed_param));
6421
6422 cmd->request_id = get_req->req_id;
6423 cmd->stats_type = get_req->param_id_mask;
6424 cmd->vdev_id = get_req->sta_id;
6425
6426 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6427 &cmd->peer_macaddr);
6428
Govind Singhb53420c2016-03-09 14:32:57 +05306429 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
6430 WMI_LOGD("Request ID : %d", cmd->request_id);
6431 WMI_LOGD("Stats Type : %d", cmd->stats_type);
6432 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
6433 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306434
6435 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6436 WMI_REQUEST_LINK_STATS_CMDID);
6437 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306438 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306439 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306440 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306441 }
6442
Govind Singhb53420c2016-03-09 14:32:57 +05306443 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306444}
6445
6446/**
6447 * send_get_stats_cmd_tlv() - get stats request
6448 * @wmi_handle: wmi handle
6449 * @get_stats_param: stats params
6450 * @addr: mac address
6451 *
6452 * Return: CDF status
6453 */
Govind Singhb53420c2016-03-09 14:32:57 +05306454QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306455 struct pe_stats_req *get_stats_param,
6456 uint8_t addr[IEEE80211_ADDR_LEN])
6457{
6458 wmi_buf_t buf;
6459 wmi_request_stats_cmd_fixed_param *cmd;
6460 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6461
6462 buf = wmi_buf_alloc(wmi_handle, len);
6463 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306464 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
6465 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306466 }
6467
6468
6469 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6470 WMITLV_SET_HDR(&cmd->tlv_header,
6471 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6472 WMITLV_GET_STRUCT_TLVLEN
6473 (wmi_request_stats_cmd_fixed_param));
6474 cmd->stats_id =
6475 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05306476 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306477 cmd->vdev_id = get_stats_param->session_id;
6478 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05306479 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306480 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6481 WMI_REQUEST_STATS_CMDID)) {
6482
Govind Singhb53420c2016-03-09 14:32:57 +05306483 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306484 __func__);
6485 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306486 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306487 }
6488
Govind Singhb53420c2016-03-09 14:32:57 +05306489 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306490
6491}
6492
Govind Singh20c5dac2016-03-07 15:33:31 +05306493/**
6494 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
6495 * @wmi_handle: wmi handle
6496 * @rssi_req: get RSSI request
6497 *
6498 * Return: CDF status
6499 */
Govind Singhb53420c2016-03-09 14:32:57 +05306500QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05306501{
6502 wmi_buf_t buf;
6503 wmi_request_stats_cmd_fixed_param *cmd;
6504 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6505
6506 buf = wmi_buf_alloc(wmi_handle, len);
6507 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306508 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6509 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306510 }
6511
6512 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6513 WMITLV_SET_HDR(&cmd->tlv_header,
6514 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6515 WMITLV_GET_STRUCT_TLVLEN
6516 (wmi_request_stats_cmd_fixed_param));
6517 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6518 if (wmi_unified_cmd_send
6519 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306520 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306521 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306522 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306523 }
6524
Govind Singhb53420c2016-03-09 14:32:57 +05306525 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306526}
6527
6528/**
6529 * send_snr_cmd_tlv() - get RSSI from fw
6530 * @wmi_handle: wmi handle
6531 * @vdev_id: vdev id
6532 *
6533 * Return: CDF status
6534 */
Govind Singhb53420c2016-03-09 14:32:57 +05306535QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05306536{
6537 wmi_buf_t buf;
6538 wmi_request_stats_cmd_fixed_param *cmd;
6539 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6540
6541 buf = wmi_buf_alloc(wmi_handle, len);
6542 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306543 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6544 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306545 }
6546
6547 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6548 cmd->vdev_id = vdev_id;
6549
6550 WMITLV_SET_HDR(&cmd->tlv_header,
6551 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6552 WMITLV_GET_STRUCT_TLVLEN
6553 (wmi_request_stats_cmd_fixed_param));
6554 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6555 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6556 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306557 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306558 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306559 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306560 }
6561
Govind Singhb53420c2016-03-09 14:32:57 +05306562 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306563}
6564
6565/**
6566 * send_link_status_req_cmd_tlv() - process link status request from UMAC
6567 * @wmi_handle: wmi handle
6568 * @link_status: get link params
6569 *
6570 * Return: CDF status
6571 */
Govind Singhb53420c2016-03-09 14:32:57 +05306572QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306573 struct link_status_params *link_status)
6574{
6575 wmi_buf_t buf;
6576 wmi_request_stats_cmd_fixed_param *cmd;
6577 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6578
6579 buf = wmi_buf_alloc(wmi_handle, len);
6580 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306581 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6582 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306583 }
6584
6585 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6586 WMITLV_SET_HDR(&cmd->tlv_header,
6587 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6588 WMITLV_GET_STRUCT_TLVLEN
6589 (wmi_request_stats_cmd_fixed_param));
6590 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
6591 cmd->vdev_id = link_status->session_id;
6592 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6593 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306594 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306595 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306596 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306597 }
6598
Govind Singhb53420c2016-03-09 14:32:57 +05306599 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306600}
6601
6602#ifdef FEATURE_WLAN_LPHB
6603
6604/**
6605 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
6606 * @wmi_handle: wmi handle
6607 * @lphb_conf_req: configuration info
6608 *
6609 * Return: CDF status
6610 */
Govind Singhb53420c2016-03-09 14:32:57 +05306611QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306612 wmi_hb_set_enable_cmd_fixed_param *params)
6613{
Govind Singh67922e82016-04-01 16:48:57 +05306614 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306615 wmi_buf_t buf = NULL;
6616 uint8_t *buf_ptr;
6617 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
6618 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
6619
6620
6621 buf = wmi_buf_alloc(wmi_handle, len);
6622 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306623 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6624 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306625 }
6626
6627 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6628 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
6629 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
6630 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
6631 WMITLV_GET_STRUCT_TLVLEN
6632 (wmi_hb_set_enable_cmd_fixed_param));
6633
6634 /* fill in values */
6635 hb_enable_fp->vdev_id = params->session;
6636 hb_enable_fp->enable = params->enable;
6637 hb_enable_fp->item = params->item;
6638 hb_enable_fp->session = params->session;
6639
6640 status = wmi_unified_cmd_send(wmi_handle, buf,
6641 len, WMI_HB_SET_ENABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306642 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306643 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_ENABLE returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306644 status);
Govind Singh67922e82016-04-01 16:48:57 +05306645 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306646 }
6647
Govind Singh67922e82016-04-01 16:48:57 +05306648 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306649}
6650
6651/**
6652 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
6653 * @wmi_handle: wmi handle
6654 * @lphb_conf_req: lphb config request
6655 *
6656 * Return: CDF status
6657 */
Govind Singhb53420c2016-03-09 14:32:57 +05306658QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306659 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
6660{
Govind Singh67922e82016-04-01 16:48:57 +05306661 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306662 wmi_buf_t buf = NULL;
6663 uint8_t *buf_ptr;
6664 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
6665 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
6666
6667 buf = wmi_buf_alloc(wmi_handle, len);
6668 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306669 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6670 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306671 }
6672
6673 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6674 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
6675 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
6676 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
6677 WMITLV_GET_STRUCT_TLVLEN
6678 (wmi_hb_set_tcp_params_cmd_fixed_param));
6679
6680 /* fill in values */
6681 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
6682 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
6683 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
6684 hb_tcp_params_fp->seq = lphb_conf_req->seq;
6685 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
6686 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
6687 hb_tcp_params_fp->interval = lphb_conf_req->interval;
6688 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
6689 hb_tcp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05306690 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05306691 &lphb_conf_req->gateway_mac,
6692 sizeof(hb_tcp_params_fp->gateway_mac));
6693
6694 status = wmi_unified_cmd_send(wmi_handle, buf,
6695 len, WMI_HB_SET_TCP_PARAMS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306696 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306697 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306698 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306699 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306700 }
6701
Govind Singh67922e82016-04-01 16:48:57 +05306702 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306703}
6704
6705/**
6706 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
6707 * @wmi_handle: wmi handle
6708 * @lphb_conf_req: lphb config request
6709 *
6710 * Return: CDF status
6711 */
Govind Singhb53420c2016-03-09 14:32:57 +05306712QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306713 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
6714{
Govind Singh67922e82016-04-01 16:48:57 +05306715 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306716 wmi_buf_t buf = NULL;
6717 uint8_t *buf_ptr;
6718 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
6719 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
6720
6721 buf = wmi_buf_alloc(wmi_handle, len);
6722 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306723 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6724 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306725 }
6726
6727 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6728 hb_tcp_filter_fp =
6729 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
6730 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
6731 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
6732 WMITLV_GET_STRUCT_TLVLEN
6733 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
6734
6735 /* fill in values */
6736 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
6737 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
6738 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
6739 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
6740 memcpy((void *)&hb_tcp_filter_fp->filter,
6741 (void *)&g_hb_tcp_filter_fp->filter,
6742 WMI_WLAN_HB_MAX_FILTER_SIZE);
6743
6744 status = wmi_unified_cmd_send(wmi_handle, buf,
6745 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306746 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306747 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306748 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306749 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306750 }
6751
Govind Singh67922e82016-04-01 16:48:57 +05306752 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306753}
6754
6755/**
6756 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
6757 * @wmi_handle: wmi handle
6758 * @lphb_conf_req: lphb config request
6759 *
6760 * Return: CDF status
6761 */
Govind Singhb53420c2016-03-09 14:32:57 +05306762QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306763 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
6764{
Govind Singh67922e82016-04-01 16:48:57 +05306765 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306766 wmi_buf_t buf = NULL;
6767 uint8_t *buf_ptr;
6768 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
6769 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
6770
6771 buf = wmi_buf_alloc(wmi_handle, len);
6772 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306773 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6774 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306775 }
6776
6777 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6778 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
6779 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
6780 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
6781 WMITLV_GET_STRUCT_TLVLEN
6782 (wmi_hb_set_udp_params_cmd_fixed_param));
6783
6784 /* fill in values */
6785 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
6786 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
6787 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
6788 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
6789 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
6790 hb_udp_params_fp->interval = lphb_conf_req->interval;
6791 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
6792 hb_udp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05306793 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05306794 &lphb_conf_req->gateway_mac,
6795 sizeof(lphb_conf_req->gateway_mac));
6796
6797 status = wmi_unified_cmd_send(wmi_handle, buf,
6798 len, WMI_HB_SET_UDP_PARAMS_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306799 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306800 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306801 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306802 wmi_buf_free(buf);
6803 }
Govind Singh20c5dac2016-03-07 15:33:31 +05306804
Govind Singh67922e82016-04-01 16:48:57 +05306805 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306806}
6807
6808/**
6809 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
6810 * @wmi_handle: wmi handle
6811 * @lphb_conf_req: lphb config request
6812 *
6813 * Return: CDF status
6814 */
Govind Singhb53420c2016-03-09 14:32:57 +05306815QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306816 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
6817{
Govind Singh67922e82016-04-01 16:48:57 +05306818 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306819 wmi_buf_t buf = NULL;
6820 uint8_t *buf_ptr;
6821 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
6822 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
6823
6824 buf = wmi_buf_alloc(wmi_handle, len);
6825 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306826 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6827 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306828 }
6829
6830 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6831 hb_udp_filter_fp =
6832 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
6833 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
6834 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
6835 WMITLV_GET_STRUCT_TLVLEN
6836 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
6837
6838 /* fill in values */
6839 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
6840 hb_udp_filter_fp->length = lphb_conf_req->length;
6841 hb_udp_filter_fp->offset = lphb_conf_req->offset;
6842 hb_udp_filter_fp->session = lphb_conf_req->session;
6843 memcpy((void *)&hb_udp_filter_fp->filter,
6844 (void *)&lphb_conf_req->filter,
6845 WMI_WLAN_HB_MAX_FILTER_SIZE);
6846
6847 status = wmi_unified_cmd_send(wmi_handle, buf,
6848 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306849 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306850 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306851 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306852 wmi_buf_free(buf);
6853 }
Govind Singh20c5dac2016-03-07 15:33:31 +05306854
Govind Singh67922e82016-04-01 16:48:57 +05306855 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306856}
6857#endif /* FEATURE_WLAN_LPHB */
6858
6859/**
6860 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
6861 * @wmi_handle: wmi handle
6862 * @ta_dhcp_ind: DHCP indication parameter
6863 *
6864 * Return: CDF Status
6865 */
Govind Singhb53420c2016-03-09 14:32:57 +05306866QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306867 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
6868{
Govind Singh67922e82016-04-01 16:48:57 +05306869 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306870 wmi_buf_t buf = NULL;
6871 uint8_t *buf_ptr;
6872 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
6873 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
6874
6875
6876 buf = wmi_buf_alloc(wmi_handle, len);
6877 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306878 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6879 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306880 }
6881
6882 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6883 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
6884 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
6885 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
6886 WMITLV_GET_STRUCT_TLVLEN
6887 (wmi_peer_set_param_cmd_fixed_param));
6888
6889 /* fill in values */
6890 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
6891 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
6892 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05306893 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05306894 &ta_dhcp_ind->peer_macaddr,
6895 sizeof(ta_dhcp_ind->peer_macaddr));
6896
6897 status = wmi_unified_cmd_send(wmi_handle, buf,
6898 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306899 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306900 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05306901 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306902 wmi_buf_free(buf);
6903 }
Govind Singh20c5dac2016-03-07 15:33:31 +05306904
Govind Singh67922e82016-04-01 16:48:57 +05306905 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306906}
6907
6908/**
6909 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
6910 * @wmi_handle: wmi handle
6911 * @pLinkSpeed: link speed info
6912 *
6913 * Return: CDF status
6914 */
Govind Singhb53420c2016-03-09 14:32:57 +05306915QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306916 wmi_mac_addr peer_macaddr)
6917{
6918 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
6919 wmi_buf_t wmi_buf;
6920 uint32_t len;
6921 uint8_t *buf_ptr;
6922
6923 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
6924 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6925 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306926 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6927 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306928 }
6929 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6930
6931 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
6932 WMITLV_SET_HDR(&cmd->tlv_header,
6933 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
6934 WMITLV_GET_STRUCT_TLVLEN
6935 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
6936
6937 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05306938 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05306939 &peer_macaddr,
6940 sizeof(peer_macaddr));
6941
6942
6943 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6944 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306945 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306946 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306947 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306948 }
Govind Singhb53420c2016-03-09 14:32:57 +05306949 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306950}
6951
6952/**
6953 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
6954 * @wmi_handle: wmi handler
6955 * @egap_params: pointer to egap_params
6956 *
6957 * Return: 0 for success, otherwise appropriate error code
6958 */
Govind Singhb53420c2016-03-09 14:32:57 +05306959QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306960 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
6961{
6962 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
6963 wmi_buf_t buf;
6964 int32_t err;
6965
6966 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
6967 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306968 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
6969 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306970 }
6971 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
6972 WMITLV_SET_HDR(&cmd->tlv_header,
6973 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
6974 WMITLV_GET_STRUCT_TLVLEN(
6975 wmi_ap_ps_egap_param_cmd_fixed_param));
6976
6977 cmd->enable = egap_params->enable;
6978 cmd->inactivity_time = egap_params->inactivity_time;
6979 cmd->wait_time = egap_params->wait_time;
6980 cmd->flags = egap_params->flags;
6981 err = wmi_unified_cmd_send(wmi_handle, buf,
6982 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
6983 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05306984 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05306985 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306986 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306987 }
6988
Govind Singhb53420c2016-03-09 14:32:57 +05306989 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306990}
6991
6992/**
6993 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
6994 * @wmi_handl: wmi handle
6995 * @cmd: Profiling command index
6996 * @value1: parameter1 value
6997 * @value2: parameter2 value
6998 *
Govind Singhe7f2f342016-05-23 12:12:52 +05306999 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307000 */
Govind Singhb53420c2016-03-09 14:32:57 +05307001QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307002 uint32_t cmd, uint32_t value1, uint32_t value2)
7003{
7004 wmi_buf_t buf;
7005 int32_t len = 0;
7006 int ret;
7007 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7008 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7009 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7010 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7011
7012 switch (cmd) {
7013 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7014 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7015 buf = wmi_buf_alloc(wmi_handle, len);
7016 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307017 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307018 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307019 }
7020 prof_trig_cmd =
7021 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7022 wmi_buf_data(buf);
7023 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7024 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7025 WMITLV_GET_STRUCT_TLVLEN
7026 (wmi_wlan_profile_trigger_cmd_fixed_param));
7027 prof_trig_cmd->enable = value1;
7028 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7029 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7030 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307031 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307032 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307033 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307034 return ret;
7035 }
7036 break;
7037
7038 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7039 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7040 buf = wmi_buf_alloc(wmi_handle, len);
7041 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307042 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307043 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307044 }
7045 profile_getdata_cmd =
7046 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7047 wmi_buf_data(buf);
7048 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7049 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7050 WMITLV_GET_STRUCT_TLVLEN
7051 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7052 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7053 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7054 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307055 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307056 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307057 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307058 return ret;
7059 }
7060 break;
7061
7062 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7063 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7064 buf = wmi_buf_alloc(wmi_handle, len);
7065 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307066 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307067 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307068 }
7069 hist_intvl_cmd =
7070 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7071 wmi_buf_data(buf);
7072 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7073 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7074 WMITLV_GET_STRUCT_TLVLEN
7075 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7076 hist_intvl_cmd->profile_id = value1;
7077 hist_intvl_cmd->value = value2;
7078 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7079 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7080 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307081 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307082 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307083 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307084 return ret;
7085 }
7086 break;
7087
7088 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7089 len =
7090 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7091 buf = wmi_buf_alloc(wmi_handle, len);
7092 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307093 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307094 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307095 }
7096 profile_enable_cmd =
7097 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7098 wmi_buf_data(buf);
7099 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7100 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7101 WMITLV_GET_STRUCT_TLVLEN
7102 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7103 profile_enable_cmd->profile_id = value1;
7104 profile_enable_cmd->enable = value2;
7105 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7106 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7107 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307108 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307109 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307110 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307111 return ret;
7112 }
7113 break;
7114
7115 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307116 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307117 break;
7118 }
7119
7120 return 0;
7121}
7122
7123#ifdef FEATURE_WLAN_RA_FILTERING
7124/**
7125 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
7126 * @wmi_handle: wmi handle
7127 * @vdev_id: vdev id
7128 *
7129 * Return: CDF status
7130 */
Govind Singhb53420c2016-03-09 14:32:57 +05307131QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307132 uint8_t vdev_id, uint8_t default_pattern,
7133 uint16_t rate_limit_interval)
7134{
7135
7136 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7137 wmi_buf_t buf;
7138 uint8_t *buf_ptr;
7139 int32_t len;
7140 int ret;
7141
7142 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7143 WMI_TLV_HDR_SIZE +
7144 0 * sizeof(WOW_BITMAP_PATTERN_T) +
7145 WMI_TLV_HDR_SIZE +
7146 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7147 WMI_TLV_HDR_SIZE +
7148 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7149 WMI_TLV_HDR_SIZE +
7150 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7151 WMI_TLV_HDR_SIZE +
7152 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7153
7154 buf = wmi_buf_alloc(wmi_handle, len);
7155 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307156 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7157 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307158 }
7159
7160 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7161 buf_ptr = (uint8_t *) cmd;
7162
7163 WMITLV_SET_HDR(&cmd->tlv_header,
7164 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7165 WMITLV_GET_STRUCT_TLVLEN
7166 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7167 cmd->vdev_id = vdev_id;
7168 cmd->pattern_id = default_pattern,
7169 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
7170 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7171
7172 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
7173 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7174 buf_ptr += WMI_TLV_HDR_SIZE;
7175
7176 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7177 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7178 buf_ptr += WMI_TLV_HDR_SIZE;
7179
7180 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7181 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7182 buf_ptr += WMI_TLV_HDR_SIZE;
7183
7184 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7185 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7186 buf_ptr += WMI_TLV_HDR_SIZE;
7187
7188 /* Fill TLV for pattern_info_timeout but no data. */
7189 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7190 buf_ptr += WMI_TLV_HDR_SIZE;
7191
7192 /* Fill TLV for ra_ratelimit_interval. */
7193 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
7194 buf_ptr += WMI_TLV_HDR_SIZE;
7195
7196 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
7197
Govind Singhb53420c2016-03-09 14:32:57 +05307198 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05307199 rate_limit_interval, vdev_id);
7200
7201 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7202 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7203 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307204 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307205 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307206 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307207 }
7208
Govind Singhb53420c2016-03-09 14:32:57 +05307209 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307210
7211}
7212#endif /* FEATURE_WLAN_RA_FILTERING */
7213
7214/**
7215 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7216 * @wmi_handle: wmi handle
7217 * @vdev_id: vdev id
7218 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307219 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307220 */
Govind Singhb53420c2016-03-09 14:32:57 +05307221QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307222{
7223 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7224 wmi_buf_t buf;
7225 int32_t len = sizeof(*cmd);
7226
Govind Singhb53420c2016-03-09 14:32:57 +05307227 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307228 buf = wmi_buf_alloc(wmi_handle, len);
7229 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307230 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307231 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307232 }
7233 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7234 wmi_buf_data(buf);
7235 WMITLV_SET_HDR(&cmd->tlv_header,
7236 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7237 WMITLV_GET_STRUCT_TLVLEN
7238 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7239 cmd->vdev_id = vdev_id;
7240 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7241 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7242 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307243 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307244 __func__);
7245 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307246 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307247 }
7248
7249 return 0;
7250}
7251
7252/**
7253 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7254 * @wmi_handle: wmi handle
7255 * @vdev_id: vdev id
7256 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307257 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307258 */
Govind Singhb53420c2016-03-09 14:32:57 +05307259QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307260 uint8_t vdev_id)
7261{
7262 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7263 wmi_buf_t buf;
7264 int32_t len = sizeof(*cmd);
7265
Govind Singhb53420c2016-03-09 14:32:57 +05307266 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307267 buf = wmi_buf_alloc(wmi_handle, len);
7268 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307269 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307270 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307271 }
7272 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7273 WMITLV_SET_HDR(&cmd->tlv_header,
7274 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7275 WMITLV_GET_STRUCT_TLVLEN
7276 (wmi_csa_offload_enable_cmd_fixed_param));
7277 cmd->vdev_id = vdev_id;
7278 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7279 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7280 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307281 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307282 __func__);
7283 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307284 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307285 }
7286
7287 return 0;
7288}
7289
7290/**
7291 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7292 * @wmi_handle: wmi handle
7293 * @startOemDataReq: start request params
7294 *
7295 * Return: CDF status
7296 */
Govind Singhb53420c2016-03-09 14:32:57 +05307297QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007298 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307299 uint8_t *data)
7300{
7301 wmi_buf_t buf;
7302 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307303 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307304
7305 buf = wmi_buf_alloc(wmi_handle,
7306 (data_len + WMI_TLV_HDR_SIZE));
7307 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307308 WMI_LOGE(FL("wmi_buf_alloc failed"));
7309 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307310 }
7311
7312 cmd = (uint8_t *) wmi_buf_data(buf);
7313
7314 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7315 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307316 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307317 data_len);
7318
Govind Singhb53420c2016-03-09 14:32:57 +05307319 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307320 data_len);
7321
7322 ret = wmi_unified_cmd_send(wmi_handle, buf,
7323 (data_len +
7324 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7325
Govind Singh67922e82016-04-01 16:48:57 +05307326 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307327 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307328 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307329 }
7330
Govind Singh67922e82016-04-01 16:48:57 +05307331 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307332}
7333
7334/**
7335 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7336 * @wmi_handle: wmi handle
7337 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7338 *
7339 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7340 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7341 * to firmware based on phyerr filtering
7342 * offload status.
7343 *
7344 * Return: 1 success, 0 failure
7345 */
Govind Singhb53420c2016-03-09 14:32:57 +05307346QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307347send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7348 bool dfs_phyerr_filter_offload)
7349{
7350 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7351 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7352 wmi_buf_t buf;
7353 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307354 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307355
7356
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007357 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307358 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307359 __func__);
7360 len = sizeof(*disable_phyerr_offload_cmd);
7361 buf = wmi_buf_alloc(wmi_handle, len);
7362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307363 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307364 return 0;
7365 }
7366 disable_phyerr_offload_cmd =
7367 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7368 wmi_buf_data(buf);
7369
7370 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7371 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7372 WMITLV_GET_STRUCT_TLVLEN
7373 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7374
7375 /*
7376 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7377 * to the firmware to disable the phyerror
7378 * filtering offload.
7379 */
7380 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7381 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307382 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307383 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307384 __func__, ret);
7385 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307386 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307387 }
Govind Singhb53420c2016-03-09 14:32:57 +05307388 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307389 __func__);
7390 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307391 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307392 __func__);
7393
7394 len = sizeof(*enable_phyerr_offload_cmd);
7395 buf = wmi_buf_alloc(wmi_handle, len);
7396 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307397 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7398 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307399 }
7400
7401 enable_phyerr_offload_cmd =
7402 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7403 wmi_buf_data(buf);
7404
7405 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7406 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7407 WMITLV_GET_STRUCT_TLVLEN
7408 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7409
7410 /*
7411 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7412 * to the firmware to enable the phyerror
7413 * filtering offload.
7414 */
7415 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7416 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7417
Govind Singh67922e82016-04-01 16:48:57 +05307418 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307419 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307420 __func__, ret);
7421 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307422 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307423 }
Govind Singhb53420c2016-03-09 14:32:57 +05307424 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307425 __func__);
7426 }
7427
Govind Singhb53420c2016-03-09 14:32:57 +05307428 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307429}
7430
7431#if !defined(REMOVE_PKT_LOG)
7432/**
7433 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7434 * @wmi_handle: wmi handle
7435 * @pktlog_event: pktlog event
7436 * @cmd_id: pktlog cmd id
7437 *
7438 * Return: CDF status
7439 */
Govind Singhb53420c2016-03-09 14:32:57 +05307440QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307441 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307442 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307443{
7444 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7445 WMI_CMD_ID CMD_ID;
7446 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7447 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7448 int len = 0;
7449 wmi_buf_t buf;
7450
7451 PKTLOG_EVENT = pktlog_event;
7452 CMD_ID = cmd_id;
7453
7454 switch (CMD_ID) {
7455 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7456 len = sizeof(*cmd);
7457 buf = wmi_buf_alloc(wmi_handle, len);
7458 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307459 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7460 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307461 }
7462 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7463 wmi_buf_data(buf);
7464 WMITLV_SET_HDR(&cmd->tlv_header,
7465 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7466 WMITLV_GET_STRUCT_TLVLEN
7467 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7468 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307469 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7470 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007471 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307472 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7473 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307474 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307475 goto wmi_send_failed;
7476 }
7477 break;
7478 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7479 len = sizeof(*disable_cmd);
7480 buf = wmi_buf_alloc(wmi_handle, len);
7481 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307482 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7483 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307484 }
7485 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7486 wmi_buf_data(buf);
7487 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7488 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7489 WMITLV_GET_STRUCT_TLVLEN
7490 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007491 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307492 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7493 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307494 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307495 goto wmi_send_failed;
7496 }
7497 break;
7498 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307499 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307500 break;
7501 }
7502
Govind Singhb53420c2016-03-09 14:32:57 +05307503 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307504
7505wmi_send_failed:
7506 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307507 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307508}
7509#endif /* REMOVE_PKT_LOG */
7510
7511/**
7512 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
7513 * @wmi_handle: wmi handle
7514 * @vdev_id: vdev id
7515 * @bitmap: Event bitmap
7516 * @enable: enable/disable
7517 *
7518 * Return: CDF status
7519 */
Govind Singhb53420c2016-03-09 14:32:57 +05307520QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307521 uint32_t vdev_id,
7522 uint32_t bitmap,
7523 bool enable)
7524{
7525 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
7526 uint16_t len;
7527 wmi_buf_t buf;
7528 int ret;
7529
7530 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
7531 buf = wmi_buf_alloc(wmi_handle, len);
7532 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307533 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7534 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307535 }
7536 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
7537 WMITLV_SET_HDR(&cmd->tlv_header,
7538 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
7539 WMITLV_GET_STRUCT_TLVLEN
7540 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
7541 cmd->vdev_id = vdev_id;
7542 cmd->is_add = enable;
7543 cmd->event_bitmap = bitmap;
7544
7545 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7546 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
7547 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307548 WMI_LOGE("Failed to config wow wakeup event");
Govind Singh20c5dac2016-03-07 15:33:31 +05307549 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307550 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307551 }
7552
Govind Singhb53420c2016-03-09 14:32:57 +05307553 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
Govind Singh20c5dac2016-03-07 15:33:31 +05307554 enable ? "enabled" : "disabled");
7555
Govind Singhb53420c2016-03-09 14:32:57 +05307556 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307557}
7558
7559/**
7560 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
7561 * @wmi_handle: wmi handle
7562 * @vdev_id: vdev id
7563 * @ptrn_id: pattern id
7564 * @ptrn: pattern
7565 * @ptrn_len: pattern length
7566 * @ptrn_offset: pattern offset
7567 * @mask: mask
7568 * @mask_len: mask length
7569 * @user: true for user configured pattern and false for default pattern
7570 * @default_patterns: default patterns
7571 *
7572 * Return: CDF status
7573 */
Govind Singhb53420c2016-03-09 14:32:57 +05307574QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307575 uint8_t vdev_id, uint8_t ptrn_id,
7576 const uint8_t *ptrn, uint8_t ptrn_len,
7577 uint8_t ptrn_offset, const uint8_t *mask,
7578 uint8_t mask_len, bool user,
7579 uint8_t default_patterns)
7580{
7581 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7582 WOW_BITMAP_PATTERN_T *bitmap_pattern;
7583 wmi_buf_t buf;
7584 uint8_t *buf_ptr;
7585 int32_t len;
7586 int ret;
7587
7588
7589 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7590 WMI_TLV_HDR_SIZE +
7591 1 * sizeof(WOW_BITMAP_PATTERN_T) +
7592 WMI_TLV_HDR_SIZE +
7593 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7594 WMI_TLV_HDR_SIZE +
7595 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7596 WMI_TLV_HDR_SIZE +
7597 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7598 WMI_TLV_HDR_SIZE +
7599 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7600
7601 buf = wmi_buf_alloc(wmi_handle, len);
7602 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307603 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7604 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307605 }
7606
7607 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7608 buf_ptr = (uint8_t *) cmd;
7609
7610 WMITLV_SET_HDR(&cmd->tlv_header,
7611 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7612 WMITLV_GET_STRUCT_TLVLEN
7613 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7614 cmd->vdev_id = vdev_id;
7615 cmd->pattern_id = ptrn_id;
7616
7617 cmd->pattern_type = WOW_BITMAP_PATTERN;
7618 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7619
7620 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7621 sizeof(WOW_BITMAP_PATTERN_T));
7622 buf_ptr += WMI_TLV_HDR_SIZE;
7623 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
7624
7625 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
7626 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
7627 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
7628
Govind Singhb53420c2016-03-09 14:32:57 +05307629 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
7630 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05307631
7632 bitmap_pattern->pattern_offset = ptrn_offset;
7633 bitmap_pattern->pattern_len = ptrn_len;
7634
7635 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
7636 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
7637
7638 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
7639 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
7640
7641 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
7642 bitmap_pattern->pattern_id = ptrn_id;
7643
Govind Singhb53420c2016-03-09 14:32:57 +05307644 WMI_LOGI("vdev id : %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307645 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
7646 bitmap_pattern->pattern_offset, user);
Govind Singh87542482016-06-08 19:40:11 +05307647#ifdef CONFIG_MCL
Govind Singhb53420c2016-03-09 14:32:57 +05307648 WMI_LOGI("Pattern : ");
7649 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307650 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
7651
Govind Singhb53420c2016-03-09 14:32:57 +05307652 WMI_LOGI("Mask : ");
7653 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307654 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
Govind Singh87542482016-06-08 19:40:11 +05307655#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05307656
7657 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
7658
7659 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7660 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7661 buf_ptr += WMI_TLV_HDR_SIZE;
7662
7663 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7664 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7665 buf_ptr += WMI_TLV_HDR_SIZE;
7666
7667 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7668 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7669 buf_ptr += WMI_TLV_HDR_SIZE;
7670
7671 /* Fill TLV for pattern_info_timeout but no data. */
7672 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7673 buf_ptr += WMI_TLV_HDR_SIZE;
7674
7675 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
7676 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
7677 buf_ptr += WMI_TLV_HDR_SIZE;
7678 *(A_UINT32 *) buf_ptr = 0;
7679
7680 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7681 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7682 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307683 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307684 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307685 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307686 }
7687
Govind Singhb53420c2016-03-09 14:32:57 +05307688 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307689}
7690
7691/**
7692 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
7693 * @wmi_handle: wmi handle
7694 * @ptrn_id: pattern id
7695 * @vdev_id: vdev id
7696 *
7697 * Return: CDF status
7698 */
Govind Singhb53420c2016-03-09 14:32:57 +05307699QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle, uint8_t ptrn_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307700 uint8_t vdev_id)
7701{
7702 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
7703 wmi_buf_t buf;
7704 int32_t len;
7705 int ret;
7706
7707 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
7708
7709
7710 buf = wmi_buf_alloc(wmi_handle, len);
7711 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307712 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7713 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307714 }
7715
7716 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7717
7718 WMITLV_SET_HDR(&cmd->tlv_header,
7719 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
7720 WMITLV_GET_STRUCT_TLVLEN(
7721 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
7722 cmd->vdev_id = vdev_id;
7723 cmd->pattern_id = ptrn_id;
7724 cmd->pattern_type = WOW_BITMAP_PATTERN;
7725
Govind Singhb53420c2016-03-09 14:32:57 +05307726 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05307727 cmd->pattern_id, vdev_id);
7728
7729 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7730 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
7731 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307732 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307733 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307734 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307735 }
7736
Govind Singhb53420c2016-03-09 14:32:57 +05307737 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307738}
7739
7740/**
7741 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
7742 * @wmi_handle: wmi handle
7743 *
7744 * Sends host wakeup indication to FW. On receiving this indication,
7745 * FW will come out of WOW.
7746 *
7747 * Return: CDF status
7748 */
Govind Singhb53420c2016-03-09 14:32:57 +05307749QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307750{
7751 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
7752 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05307753 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307754 int32_t len;
7755 int ret;
7756
7757 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
7758
7759 buf = wmi_buf_alloc(wmi_handle, len);
7760 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307761 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7762 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307763 }
7764
7765 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
7766 wmi_buf_data(buf);
7767 WMITLV_SET_HDR(&cmd->tlv_header,
7768 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
7769 WMITLV_GET_STRUCT_TLVLEN
7770 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
7771
7772
7773 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7774 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
7775 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307776 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307777 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307778 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307779 }
7780
Govind Singhb53420c2016-03-09 14:32:57 +05307781 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307782}
7783
7784/**
7785 * send_del_ts_cmd_tlv() - send DELTS request to fw
7786 * @wmi_handle: wmi handle
7787 * @msg: delts params
7788 *
7789 * Return: CDF status
7790 */
Govind Singhb53420c2016-03-09 14:32:57 +05307791QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307792 uint8_t ac)
7793{
7794 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
7795 wmi_buf_t buf;
7796 int32_t len = sizeof(*cmd);
7797
7798 buf = wmi_buf_alloc(wmi_handle, len);
7799 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307800 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7801 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307802 }
7803 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
7804 WMITLV_SET_HDR(&cmd->tlv_header,
7805 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
7806 WMITLV_GET_STRUCT_TLVLEN
7807 (wmi_vdev_wmm_delts_cmd_fixed_param));
7808 cmd->vdev_id = vdev_id;
7809 cmd->ac = ac;
7810
Govind Singhb53420c2016-03-09 14:32:57 +05307811 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307812 cmd->vdev_id, cmd->ac, __func__, __LINE__);
7813 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7814 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307815 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307816 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307817 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307818 }
7819
Govind Singhb53420c2016-03-09 14:32:57 +05307820 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307821}
7822
7823/**
7824 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
7825 * @wmi_handle: handle to wmi
7826 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
7827 *
Govind Singhb53420c2016-03-09 14:32:57 +05307828 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05307829 * ADD_TS requestes to firmware in loop for all the ACs with
7830 * active flow.
7831 *
7832 * Return: CDF status
7833 */
Govind Singhb53420c2016-03-09 14:32:57 +05307834QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307835 struct aggr_add_ts_param *aggr_qos_rsp_msg)
7836{
7837 int i = 0;
7838 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
7839 wmi_buf_t buf;
7840 int32_t len = sizeof(*cmd);
7841
7842 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
7843 /* if flow in this AC is active */
7844 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
7845 /*
7846 * as per implementation of wma_add_ts_req() we
7847 * are not waiting any response from firmware so
7848 * apart from sending ADDTS to firmware just send
7849 * success to upper layers
7850 */
Govind Singhb53420c2016-03-09 14:32:57 +05307851 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307852
7853 buf = wmi_buf_alloc(wmi_handle, len);
7854 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307855 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7856 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307857 }
7858 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
7859 wmi_buf_data(buf);
7860 WMITLV_SET_HDR(&cmd->tlv_header,
7861 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
7862 WMITLV_GET_STRUCT_TLVLEN
7863 (wmi_vdev_wmm_addts_cmd_fixed_param));
7864 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
7865 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05307866 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05307867 traffic.userPrio);
7868 cmd->medium_time_us =
7869 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
7870 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05307871 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307872 __func__, __LINE__, cmd->vdev_id, cmd->ac,
7873 cmd->medium_time_us, cmd->downgrade_type);
7874 if (wmi_unified_cmd_send
7875 (wmi_handle, buf, len,
7876 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307877 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307878 __func__);
7879 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05307880 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307881 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307882 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307883 }
7884 }
7885 }
7886
Govind Singhb53420c2016-03-09 14:32:57 +05307887 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307888}
7889
7890/**
7891 * send_add_ts_cmd_tlv() - send ADDTS request to fw
7892 * @wmi_handle: wmi handle
7893 * @msg: ADDTS params
7894 *
7895 * Return: CDF status
7896 */
Govind Singhb53420c2016-03-09 14:32:57 +05307897QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307898 struct add_ts_param *msg)
7899{
7900 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
7901 wmi_buf_t buf;
7902 int32_t len = sizeof(*cmd);
7903
Govind Singhb53420c2016-03-09 14:32:57 +05307904 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307905
7906 buf = wmi_buf_alloc(wmi_handle, len);
7907 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307908 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7909 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307910 }
7911 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
7912 WMITLV_SET_HDR(&cmd->tlv_header,
7913 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
7914 WMITLV_GET_STRUCT_TLVLEN
7915 (wmi_vdev_wmm_addts_cmd_fixed_param));
7916 cmd->vdev_id = msg->sme_session_id;
7917 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
7918 cmd->medium_time_us = msg->tspec.mediumTime * 32;
7919 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05307920 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307921 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
7922 cmd->downgrade_type, __func__, __LINE__);
7923 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7924 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307925 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
7926 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307927 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307928 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307929 }
7930
Govind Singhb53420c2016-03-09 14:32:57 +05307931 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307932}
7933
7934/**
7935 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
7936 * @wmi_handle: wmi handle
7937 * @vdev_id: vdev id
7938 * @enable: Flag to enable/disable packet filter
7939 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307940 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307941 */
Govind Singhb53420c2016-03-09 14:32:57 +05307942QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307943 uint8_t vdev_id, bool enable)
7944{
7945 int32_t len;
7946 int ret = 0;
7947 wmi_buf_t buf;
7948 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
7949
7950 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
7951
7952 buf = wmi_buf_alloc(wmi_handle, len);
7953 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307954 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307955 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307956 }
7957
7958 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
7959 WMITLV_SET_HDR(&cmd->tlv_header,
7960 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
7961 WMITLV_GET_STRUCT_TLVLEN(
7962 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
7963
7964 cmd->vdev_id = vdev_id;
7965 if (enable)
7966 cmd->enable = PACKET_FILTER_SET_ENABLE;
7967 else
7968 cmd->enable = PACKET_FILTER_SET_DISABLE;
7969
Govind Singhb53420c2016-03-09 14:32:57 +05307970 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307971 __func__, cmd->enable, vdev_id);
7972
7973 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7974 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307975 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307976 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05307977 wmi_buf_free(buf);
7978 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307979
7980 return ret;
7981}
7982
7983/**
7984 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
7985 * @wmi_handle: wmi handle
7986 * @vdev_id: vdev id
7987 * @rcv_filter_param: Packet filter parameters
7988 * @filter_id: Filter id
7989 * @enable: Flag to add/delete packet filter configuration
7990 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307991 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307992 */
Govind Singhb53420c2016-03-09 14:32:57 +05307993QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307994 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
7995 uint8_t filter_id, bool enable)
7996{
7997 int len, i;
7998 int err = 0;
7999 wmi_buf_t buf;
8000 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8001
8002
8003 /* allocate the memory */
8004 len = sizeof(*cmd);
8005 buf = wmi_buf_alloc(wmi_handle, len);
8006 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308007 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308008 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308009 }
8010
8011 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8012 WMITLV_SET_HDR(&cmd->tlv_header,
8013 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8014 WMITLV_GET_STRUCT_TLVLEN
8015 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8016
8017 cmd->vdev_id = vdev_id;
8018 cmd->filter_id = filter_id;
8019 if (enable)
8020 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8021 else
8022 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8023
8024 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308025 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308026 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8027 rcv_filter_param->numFieldParams);
8028 cmd->filter_type = rcv_filter_param->filterType;
8029 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8030
8031 for (i = 0; i < cmd->num_params; i++) {
8032 cmd->paramsData[i].proto_type =
8033 rcv_filter_param->paramsData[i].protocolLayer;
8034 cmd->paramsData[i].cmp_type =
8035 rcv_filter_param->paramsData[i].cmpFlag;
8036 cmd->paramsData[i].data_length =
8037 rcv_filter_param->paramsData[i].dataLength;
8038 cmd->paramsData[i].data_offset =
8039 rcv_filter_param->paramsData[i].dataOffset;
8040 memcpy(&cmd->paramsData[i].compareData,
8041 rcv_filter_param->paramsData[i].compareData,
8042 sizeof(cmd->paramsData[i].compareData));
8043 memcpy(&cmd->paramsData[i].dataMask,
8044 rcv_filter_param->paramsData[i].dataMask,
8045 sizeof(cmd->paramsData[i].dataMask));
8046 }
8047 }
8048
Govind Singhb53420c2016-03-09 14:32:57 +05308049 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308050 cmd->filter_action, cmd->filter_id, cmd->num_params);
8051 /* send the command along with data */
8052 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8053 WMI_PACKET_FILTER_CONFIG_CMDID);
8054 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308055 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308056 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308057 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308058 }
8059
8060
8061 return 0;
8062}
8063
8064/**
8065 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
8066 * @wmi_handle: wmi handle
8067 * @vdev_id: vdev id
8068 * @multicastAddr: mcast address
8069 * @clearList: clear list flag
8070 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308071 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308072 */
Govind Singhb53420c2016-03-09 14:32:57 +05308073QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308074 uint8_t vdev_id,
Govind Singhb53420c2016-03-09 14:32:57 +05308075 struct qdf_mac_addr multicast_addr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308076 bool clearList)
8077{
8078 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
8079 wmi_buf_t buf;
8080 int err;
8081
8082 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8083 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308084 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308085 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308086 }
8087
8088 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308089 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308090
8091 WMITLV_SET_HDR(&cmd->tlv_header,
8092 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
8093 WMITLV_GET_STRUCT_TLVLEN
8094 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
8095 cmd->action =
8096 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
8097 cmd->vdev_id = vdev_id;
8098 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
8099 err = wmi_unified_cmd_send(wmi_handle, buf,
8100 sizeof(*cmd),
8101 WMI_SET_MCASTBCAST_FILTER_CMDID);
8102 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308103 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308104 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308105 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308106 }
Govind Singhb53420c2016-03-09 14:32:57 +05308107 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308108 cmd->action, vdev_id, clearList);
Govind Singh224a7312016-06-21 14:33:26 +05308109 WMI_LOGD("MCBC MAC Addr: %pM", multicast_addr.bytes);
Govind Singh20c5dac2016-03-07 15:33:31 +05308110
8111 return 0;
8112}
8113
8114/**
8115 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
8116 * @wmi_handle: wmi handle
8117 * @vdev_id: vdev id
8118 * @params: GTK offload parameters
8119 *
8120 * Return: CDF status
8121 */
Govind Singhb53420c2016-03-09 14:32:57 +05308122QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308123 struct gtk_offload_params *params,
8124 bool enable_offload,
8125 uint32_t gtk_offload_opcode)
8126{
8127 int len;
8128 wmi_buf_t buf;
8129 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308130 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308131
Govind Singhb53420c2016-03-09 14:32:57 +05308132 WMI_LOGD("%s Enter", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308133
8134 len = sizeof(*cmd);
8135
8136 /* alloc wmi buffer */
8137 buf = wmi_buf_alloc(wmi_handle, len);
8138 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308139 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8140 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308141 goto out;
8142 }
8143
8144 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8145 WMITLV_SET_HDR(&cmd->tlv_header,
8146 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8147 WMITLV_GET_STRUCT_TLVLEN
8148 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8149
8150 cmd->vdev_id = vdev_id;
8151
8152 /* Request target to enable GTK offload */
Siddarth Poddar9500f2e2016-04-01 17:45:06 +05308153 if (enable_offload == WMI_GTK_OFFLOAD_ENABLE) {
Govind Singh20c5dac2016-03-07 15:33:31 +05308154 cmd->flags = gtk_offload_opcode;
8155
8156 /* Copy the keys and replay counter */
Govind Singhb53420c2016-03-09 14:32:57 +05308157 qdf_mem_copy(cmd->KCK, params->aKCK, WMI_GTK_OFFLOAD_KCK_BYTES);
8158 qdf_mem_copy(cmd->KEK, params->aKEK, WMI_GTK_OFFLOAD_KEK_BYTES);
8159 qdf_mem_copy(cmd->replay_counter, &params->ullKeyReplayCounter,
Govind Singh20c5dac2016-03-07 15:33:31 +05308160 GTK_REPLAY_COUNTER_BYTES);
8161 } else {
8162 cmd->flags = gtk_offload_opcode;
8163 }
8164
8165 /* send the wmi command */
8166 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8167 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308168 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
Govind Singh20c5dac2016-03-07 15:33:31 +05308169 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308170 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308171 }
8172
Govind Singhb53420c2016-03-09 14:32:57 +05308173 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
Govind Singh20c5dac2016-03-07 15:33:31 +05308174out:
Govind Singhb53420c2016-03-09 14:32:57 +05308175 WMI_LOGD("%s Exit", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308176 return status;
8177}
8178
8179/**
8180 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
8181 * @wmi_handle: wmi handle
8182 * @params: GTK offload params
8183 *
8184 * Return: CDF status
8185 */
Govind Singhb53420c2016-03-09 14:32:57 +05308186QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308187 uint8_t vdev_id,
8188 uint64_t offload_req_opcode)
8189{
8190 int len;
8191 wmi_buf_t buf;
8192 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308193 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308194
8195 len = sizeof(*cmd);
8196
8197 /* alloc wmi buffer */
8198 buf = wmi_buf_alloc(wmi_handle, len);
8199 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308200 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8201 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308202 goto out;
8203 }
8204
8205 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8206 WMITLV_SET_HDR(&cmd->tlv_header,
8207 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8208 WMITLV_GET_STRUCT_TLVLEN
8209 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8210
8211 /* Request for GTK offload status */
8212 cmd->flags = offload_req_opcode;
8213 cmd->vdev_id = vdev_id;
8214
8215 /* send the wmi command */
8216 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8217 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308218 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
Govind Singh20c5dac2016-03-07 15:33:31 +05308219 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308220 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308221 }
8222
8223out:
8224 return status;
8225}
8226
8227/**
8228 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8229 * @wmi_handle: wmi handle
8230 * @pAddPeriodicTxPtrnParams: tx ptrn params
8231 *
8232 * Retrun: CDF status
8233 */
Govind Singhb53420c2016-03-09 14:32:57 +05308234QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308235 struct periodic_tx_pattern *
8236 pAddPeriodicTxPtrnParams,
8237 uint8_t vdev_id)
8238{
8239 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8240 wmi_buf_t wmi_buf;
8241 uint32_t len;
8242 uint8_t *buf_ptr;
8243 uint32_t ptrn_len, ptrn_len_aligned;
8244 int j;
8245
8246 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8247 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8248 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8249 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8250
8251 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8252 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308253 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8254 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308255 }
8256
8257 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8258
8259 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8260 WMITLV_SET_HDR(&cmd->tlv_header,
8261 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8262 WMITLV_GET_STRUCT_TLVLEN
8263 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8264
8265 /* Pass the pattern id to delete for the corresponding vdev id */
8266 cmd->vdev_id = vdev_id;
8267 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8268 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8269 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8270
8271 /* Pattern info */
8272 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8273 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8274 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308275 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308276 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308277 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308278
Govind Singhb53420c2016-03-09 14:32:57 +05308279 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308280 __func__, cmd->pattern_id, cmd->vdev_id);
8281
8282 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8283 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308284 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308285 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308286 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308287 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308288 }
Govind Singhb53420c2016-03-09 14:32:57 +05308289 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308290}
8291
8292/**
8293 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8294 * @wmi_handle: wmi handle
8295 * @vdev_id: vdev id
8296 * @pattern_id: pattern id
8297 *
8298 * Retrun: CDF status
8299 */
Govind Singhb53420c2016-03-09 14:32:57 +05308300QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308301 uint8_t vdev_id,
8302 uint8_t pattern_id)
8303{
8304 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8305 wmi_buf_t wmi_buf;
8306 uint32_t len =
8307 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8308
8309 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8310 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308311 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8312 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308313 }
8314
8315 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8316 wmi_buf_data(wmi_buf);
8317 WMITLV_SET_HDR(&cmd->tlv_header,
8318 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8319 WMITLV_GET_STRUCT_TLVLEN
8320 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8321
8322 /* Pass the pattern id to delete for the corresponding vdev id */
8323 cmd->vdev_id = vdev_id;
8324 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308325 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308326 __func__, cmd->pattern_id, cmd->vdev_id);
8327
8328 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8329 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308330 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308331 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308332 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308333 }
Govind Singhb53420c2016-03-09 14:32:57 +05308334 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308335}
8336
8337/**
8338 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8339 * @wmi_handle: wmi handle
8340 * @preq: stats ext params
8341 *
8342 * Return: CDF status
8343 */
Govind Singhb53420c2016-03-09 14:32:57 +05308344QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308345 struct stats_ext_params *preq)
8346{
Govind Singh67922e82016-04-01 16:48:57 +05308347 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308348 wmi_req_stats_ext_cmd_fixed_param *cmd;
8349 wmi_buf_t buf;
8350 uint16_t len;
8351 uint8_t *buf_ptr;
8352
8353 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8354
8355 buf = wmi_buf_alloc(wmi_handle, len);
8356 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308357 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308358 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308359 }
8360
8361 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8362 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8363
8364 WMITLV_SET_HDR(&cmd->tlv_header,
8365 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8366 WMITLV_GET_STRUCT_TLVLEN
8367 (wmi_req_stats_ext_cmd_fixed_param));
8368 cmd->vdev_id = preq->vdev_id;
8369 cmd->data_len = preq->request_data_len;
8370
Govind Singhb53420c2016-03-09 14:32:57 +05308371 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308372 __func__, preq->request_data_len, preq->vdev_id);
8373
8374 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8375 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8376
8377 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308378 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308379
8380 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8381 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308382 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308383 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308384 ret);
8385 wmi_buf_free(buf);
8386 }
8387
8388 return ret;
8389}
8390
8391/**
8392 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8393 * @wmi_handle: wmi handle
8394 * @params: ext wow params
8395 *
8396 * Return:0 for success or error code
8397 */
Govind Singhb53420c2016-03-09 14:32:57 +05308398QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308399 struct ext_wow_params *params)
8400{
8401 wmi_extwow_enable_cmd_fixed_param *cmd;
8402 wmi_buf_t buf;
8403 int32_t len;
8404 int ret;
8405
8406 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8407 buf = wmi_buf_alloc(wmi_handle, len);
8408 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308409 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8410 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308411 }
8412
8413 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8414
8415 WMITLV_SET_HDR(&cmd->tlv_header,
8416 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8417 WMITLV_GET_STRUCT_TLVLEN
8418 (wmi_extwow_enable_cmd_fixed_param));
8419
8420 cmd->vdev_id = params->vdev_id;
8421 cmd->type = params->type;
8422 cmd->wakeup_pin_num = params->wakeup_pin_num;
8423
Govind Singhb53420c2016-03-09 14:32:57 +05308424 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308425 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8426
8427 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8428 WMI_EXTWOW_ENABLE_CMDID);
8429 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308430 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308431 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308432 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308433 }
8434
Govind Singhb53420c2016-03-09 14:32:57 +05308435 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308436
8437}
8438
8439/**
8440 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8441 * @wmi_handle: wmi handle
8442 * @app_type1_params: app type1 params
8443 *
8444 * Return: CDF status
8445 */
Govind Singhb53420c2016-03-09 14:32:57 +05308446QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308447 struct app_type1_params *app_type1_params)
8448{
8449 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8450 wmi_buf_t buf;
8451 int32_t len;
8452 int ret;
8453
8454 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8455 buf = wmi_buf_alloc(wmi_handle, len);
8456 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308457 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8458 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308459 }
8460
8461 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8462 wmi_buf_data(buf);
8463
8464 WMITLV_SET_HDR(&cmd->tlv_header,
8465 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8466 WMITLV_GET_STRUCT_TLVLEN
8467 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8468
8469 cmd->vdev_id = app_type1_params->vdev_id;
8470 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8471 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308472 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308473 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308474 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308475 cmd->passwd_len = app_type1_params->pass_length;
8476
Govind Singhb53420c2016-03-09 14:32:57 +05308477 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308478 "identification_id %.8s id_length %u "
8479 "password %.16s pass_length %u",
8480 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8481 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8482
8483 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8484 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8485 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308486 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308487 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308488 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308489 }
8490
Govind Singhb53420c2016-03-09 14:32:57 +05308491 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308492}
8493
8494/**
8495 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8496 * @wmi_handle: wmi handle
8497 * @appType2Params: app type2 params
8498 *
8499 * Return: CDF status
8500 */
Govind Singhb53420c2016-03-09 14:32:57 +05308501QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308502 struct app_type2_params *appType2Params)
8503{
8504 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8505 wmi_buf_t buf;
8506 int32_t len;
8507 int ret;
8508
8509 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8510 buf = wmi_buf_alloc(wmi_handle, len);
8511 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308512 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8513 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308514 }
8515
8516 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8517 wmi_buf_data(buf);
8518
8519 WMITLV_SET_HDR(&cmd->tlv_header,
8520 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8521 WMITLV_GET_STRUCT_TLVLEN
8522 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8523
8524 cmd->vdev_id = appType2Params->vdev_id;
8525
Govind Singhb53420c2016-03-09 14:32:57 +05308526 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308527 cmd->rc4_key_len = appType2Params->rc4_key_len;
8528
8529 cmd->ip_id = appType2Params->ip_id;
8530 cmd->ip_device_ip = appType2Params->ip_device_ip;
8531 cmd->ip_server_ip = appType2Params->ip_server_ip;
8532
8533 cmd->tcp_src_port = appType2Params->tcp_src_port;
8534 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8535 cmd->tcp_seq = appType2Params->tcp_seq;
8536 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8537
8538 cmd->keepalive_init = appType2Params->keepalive_init;
8539 cmd->keepalive_min = appType2Params->keepalive_min;
8540 cmd->keepalive_max = appType2Params->keepalive_max;
8541 cmd->keepalive_inc = appType2Params->keepalive_inc;
8542
8543 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8544 &cmd->gateway_mac);
8545 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8546 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8547
Govind Singhb53420c2016-03-09 14:32:57 +05308548 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308549 "rc4_key %.16s rc4_key_len %u "
8550 "ip_id %x ip_device_ip %x ip_server_ip %x "
8551 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8552 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8553 "keepalive_max %u keepalive_inc %u "
8554 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8555 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8556 cmd->rc4_key, cmd->rc4_key_len,
8557 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8558 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8559 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8560 cmd->keepalive_max, cmd->keepalive_inc,
8561 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8562
8563 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8564 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8565 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308566 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308567 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308568 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308569 }
8570
Govind Singhb53420c2016-03-09 14:32:57 +05308571 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308572
8573}
8574
8575/**
8576 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8577 * @wmi_handle: wmi handle
8578 * @timer_val: auto shutdown timer value
8579 *
8580 * Return: CDF status
8581 */
Govind Singhb53420c2016-03-09 14:32:57 +05308582QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308583 uint32_t timer_val)
8584{
Govind Singh67922e82016-04-01 16:48:57 +05308585 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308586 wmi_buf_t buf = NULL;
8587 uint8_t *buf_ptr;
8588 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8589 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8590
Govind Singhb53420c2016-03-09 14:32:57 +05308591 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308592 __func__, timer_val);
8593
8594 buf = wmi_buf_alloc(wmi_handle, len);
8595 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308596 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8597 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308598 }
8599
8600 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8601 wmi_auto_sh_cmd =
8602 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8603 wmi_auto_sh_cmd->timer_value = timer_val;
8604
8605 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8606 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8607 WMITLV_GET_STRUCT_TLVLEN
8608 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8609
8610 status = wmi_unified_cmd_send(wmi_handle, buf,
8611 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308612 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308613 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308614 __func__, status);
8615 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308616 }
8617
Govind Singh67922e82016-04-01 16:48:57 +05308618 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308619}
8620
8621/**
8622 * send_nan_req_cmd_tlv() - to send nan request to target
8623 * @wmi_handle: wmi handle
8624 * @nan_req: request data which will be non-null
8625 *
8626 * Return: CDF status
8627 */
Govind Singhb53420c2016-03-09 14:32:57 +05308628QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308629 struct nan_req_params *nan_req)
8630{
Govind Singh67922e82016-04-01 16:48:57 +05308631 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308632 wmi_nan_cmd_param *cmd;
8633 wmi_buf_t buf;
8634 uint16_t len = sizeof(*cmd);
8635 uint16_t nan_data_len, nan_data_len_aligned;
8636 uint8_t *buf_ptr;
8637
8638 /*
8639 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8640 * +------------+----------+-----------------------+--------------+
8641 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8642 * +------------+----------+-----------------------+--------------+
8643 */
8644 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308645 WMI_LOGE("%s:nan req is not valid", __func__);
8646 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308647 }
8648 nan_data_len = nan_req->request_data_len;
8649 nan_data_len_aligned = roundup(nan_req->request_data_len,
8650 sizeof(uint32_t));
8651 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8652 buf = wmi_buf_alloc(wmi_handle, len);
8653 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308654 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8655 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308656 }
8657 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8658 cmd = (wmi_nan_cmd_param *) buf_ptr;
8659 WMITLV_SET_HDR(&cmd->tlv_header,
8660 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8661 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8662 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308663 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308664 __func__, nan_req->request_data_len);
8665 buf_ptr += sizeof(wmi_nan_cmd_param);
8666 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8667 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308668 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308669
8670 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8671 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308672 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308673 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308674 __func__, ret);
8675 wmi_buf_free(buf);
8676 }
8677
8678 return ret;
8679}
8680
8681/**
8682 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8683 * @wmi_handle: wmi handle
8684 * @pDhcpSrvOffloadInfo: DHCP server offload info
8685 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308686 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308687 */
Govind Singhb53420c2016-03-09 14:32:57 +05308688QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308689 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8690{
8691 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8692 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308693 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308694
8695 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8696 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308697 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308698 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308699 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308700 }
8701
8702 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308703 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308704
8705 WMITLV_SET_HDR(&cmd->tlv_header,
8706 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8707 WMITLV_GET_STRUCT_TLVLEN
8708 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8709 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8710 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8711 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8712 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8713 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308714 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308715 sizeof(*cmd),
8716 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308717 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308718 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308719 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308720 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308721 }
Govind Singhb53420c2016-03-09 14:32:57 +05308722 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308723 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308724
8725 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308726}
8727
8728/**
8729 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8730 * @wmi_handle: wmi handle
8731 * @flashing: flashing request
8732 *
8733 * Return: CDF status
8734 */
Govind Singhb53420c2016-03-09 14:32:57 +05308735QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308736 struct flashing_req_params *flashing)
8737{
8738 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308739 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308740 wmi_buf_t buf;
8741 uint8_t *buf_ptr;
8742 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8743
8744 buf = wmi_buf_alloc(wmi_handle, len);
8745 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308746 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308747 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308748 }
8749 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8750 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8751 WMITLV_SET_HDR(&cmd->tlv_header,
8752 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8753 WMITLV_GET_STRUCT_TLVLEN
8754 (wmi_set_led_flashing_cmd_fixed_param));
8755 cmd->pattern_id = flashing->pattern_id;
8756 cmd->led_x0 = flashing->led_x0;
8757 cmd->led_x1 = flashing->led_x1;
8758
8759 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8760 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308761 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308762 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308763 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308764 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308765 }
Govind Singh67922e82016-04-01 16:48:57 +05308766
8767 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308768}
8769
8770/**
8771 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8772 * @wmi_handle: wmi handle
8773 * @ch_avoid_update_req: channel avoid update params
8774 *
8775 * Return: CDF status
8776 */
Govind Singhb53420c2016-03-09 14:32:57 +05308777QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308778{
Govind Singh67922e82016-04-01 16:48:57 +05308779 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308780 wmi_buf_t buf = NULL;
8781 uint8_t *buf_ptr;
8782 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
8783 int len = sizeof(wmi_chan_avoid_update_cmd_param);
8784
8785
8786 buf = wmi_buf_alloc(wmi_handle, len);
8787 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308788 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8789 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308790 }
8791
8792 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8793 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
8794 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
8795 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
8796 WMITLV_GET_STRUCT_TLVLEN
8797 (wmi_chan_avoid_update_cmd_param));
8798
8799 status = wmi_unified_cmd_send(wmi_handle, buf,
8800 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308801 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308802 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05308803 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
8804 " returned Error %d", status);
8805 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308806 }
8807
Govind Singh67922e82016-04-01 16:48:57 +05308808 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308809}
8810
8811/**
8812 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
8813 * @wmi_handle: wmi handle
8814 * @reg_dmn: reg domain
8815 * @regdmn2G: 2G reg domain
8816 * @regdmn5G: 5G reg domain
8817 * @ctl2G: 2G test limit
8818 * @ctl5G: 5G test limit
8819 *
8820 * Return: none
8821 */
Govind Singhb53420c2016-03-09 14:32:57 +05308822QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308823 uint32_t reg_dmn, uint16_t regdmn2G,
8824 uint16_t regdmn5G, int8_t ctl2G,
8825 int8_t ctl5G)
8826{
8827 wmi_buf_t buf;
8828 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8829 int32_t len = sizeof(*cmd);
8830
8831
8832 buf = wmi_buf_alloc(wmi_handle, len);
8833 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308834 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8835 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308836 }
8837 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8838 WMITLV_SET_HDR(&cmd->tlv_header,
8839 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8840 WMITLV_GET_STRUCT_TLVLEN
8841 (wmi_pdev_set_regdomain_cmd_fixed_param));
8842 cmd->reg_domain = reg_dmn;
8843 cmd->reg_domain_2G = regdmn2G;
8844 cmd->reg_domain_5G = regdmn5G;
8845 cmd->conformance_test_limit_2G = ctl2G;
8846 cmd->conformance_test_limit_5G = ctl5G;
8847
8848 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8849 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308850 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308851 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308852 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308853 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308854 }
8855
Govind Singhb53420c2016-03-09 14:32:57 +05308856 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308857}
8858
8859
8860/**
8861 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
8862 * @wmi_handle: wmi handle
8863 * @chan_switch_params: Pointer to tdls channel switch parameter structure
8864 *
8865 * This function sets tdls off channel mode
8866 *
8867 * Return: 0 on success; Negative errno otherwise
8868 */
Govind Singhb53420c2016-03-09 14:32:57 +05308869QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308870 struct tdls_channel_switch_params *chan_switch_params)
8871{
8872 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
8873 wmi_buf_t wmi_buf;
8874 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
8875
8876 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8877 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308878 WMI_LOGE(FL("wmi_buf_alloc failed"));
8879 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308880 }
8881 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
8882 wmi_buf_data(wmi_buf);
8883 WMITLV_SET_HDR(&cmd->tlv_header,
8884 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
8885 WMITLV_GET_STRUCT_TLVLEN(
8886 wmi_tdls_set_offchan_mode_cmd_fixed_param));
8887
8888 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
8889 &cmd->peer_macaddr);
8890 cmd->vdev_id = chan_switch_params->vdev_id;
8891 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
8892 cmd->is_peer_responder = chan_switch_params->is_responder;
8893 cmd->offchan_num = chan_switch_params->tdls_off_ch;
8894 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
8895 cmd->offchan_oper_class = chan_switch_params->oper_class;
8896
Govind Singhb53420c2016-03-09 14:32:57 +05308897 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308898 cmd->peer_macaddr.mac_addr31to0,
8899 cmd->peer_macaddr.mac_addr47to32);
8900
Govind Singhb53420c2016-03-09 14:32:57 +05308901 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05308902 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
8903 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
8904 ),
8905 cmd->vdev_id,
8906 cmd->offchan_mode,
8907 cmd->offchan_num,
8908 cmd->offchan_bw_bitmap,
8909 cmd->is_peer_responder,
8910 cmd->offchan_oper_class);
8911
8912 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8913 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308914 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308915 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308916 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308917 }
8918
8919
Govind Singhb53420c2016-03-09 14:32:57 +05308920 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308921}
8922
8923/**
8924 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
8925 * @wmi_handle: wmi handle
8926 * @pwmaTdlsparams: TDLS params
8927 *
8928 * Return: 0 for sucess or error code
8929 */
Govind Singhb53420c2016-03-09 14:32:57 +05308930QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308931 void *tdls_param, uint8_t tdls_state)
8932{
8933 wmi_tdls_set_state_cmd_fixed_param *cmd;
8934 wmi_buf_t wmi_buf;
8935
8936 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
8937 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
8938
8939 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8940 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308941 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
8942 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308943 }
8944 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
8945 WMITLV_SET_HDR(&cmd->tlv_header,
8946 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
8947 WMITLV_GET_STRUCT_TLVLEN
8948 (wmi_tdls_set_state_cmd_fixed_param));
8949 cmd->vdev_id = wmi_tdls->vdev_id;
8950 cmd->state = tdls_state;
8951 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
8952 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
8953 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
8954 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
8955 cmd->rssi_delta = wmi_tdls->rssi_delta;
8956 cmd->tdls_options = wmi_tdls->tdls_options;
8957 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
8958 cmd->tdls_peer_traffic_response_timeout_ms =
8959 wmi_tdls->peer_traffic_response_timeout;
8960 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
8961 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
8962 cmd->tdls_puapsd_rx_frame_threshold =
8963 wmi_tdls->puapsd_rx_frame_threshold;
8964 cmd->teardown_notification_ms =
8965 wmi_tdls->teardown_notification_ms;
8966 cmd->tdls_peer_kickout_threshold =
8967 wmi_tdls->tdls_peer_kickout_threshold;
8968
Govind Singhb53420c2016-03-09 14:32:57 +05308969 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05308970 "notification_interval_ms: %d, "
8971 "tx_discovery_threshold: %d, "
8972 "tx_teardown_threshold: %d, "
8973 "rssi_teardown_threshold: %d, "
8974 "rssi_delta: %d, "
8975 "tdls_options: 0x%x, "
8976 "tdls_peer_traffic_ind_window: %d, "
8977 "tdls_peer_traffic_response_timeout: %d, "
8978 "tdls_puapsd_mask: 0x%x, "
8979 "tdls_puapsd_inactivity_time: %d, "
8980 "tdls_puapsd_rx_frame_threshold: %d, "
8981 "teardown_notification_ms: %d, "
8982 "tdls_peer_kickout_threshold: %d",
8983 __func__, tdls_state, cmd->state,
8984 cmd->notification_interval_ms,
8985 cmd->tx_discovery_threshold,
8986 cmd->tx_teardown_threshold,
8987 cmd->rssi_teardown_threshold,
8988 cmd->rssi_delta,
8989 cmd->tdls_options,
8990 cmd->tdls_peer_traffic_ind_window,
8991 cmd->tdls_peer_traffic_response_timeout_ms,
8992 cmd->tdls_puapsd_mask,
8993 cmd->tdls_puapsd_inactivity_time_ms,
8994 cmd->tdls_puapsd_rx_frame_threshold,
8995 cmd->teardown_notification_ms,
8996 cmd->tdls_peer_kickout_threshold);
8997
8998 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8999 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309000 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309001 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309002 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309003 }
Govind Singhb53420c2016-03-09 14:32:57 +05309004 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309005
Govind Singhb53420c2016-03-09 14:32:57 +05309006 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309007}
9008
9009/**
9010 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9011 * @wmi_handle: wmi handle
9012 * @peerStateParams: TDLS peer state params
9013 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309014 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309015 */
Govind Singhb53420c2016-03-09 14:32:57 +05309016QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309017 struct tdls_peer_state_params *peerStateParams,
9018 uint32_t *ch_mhz)
9019{
9020 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9021 wmi_tdls_peer_capabilities *peer_cap;
9022 wmi_channel *chan_info;
9023 wmi_buf_t wmi_buf;
9024 uint8_t *buf_ptr;
9025 uint32_t i;
9026 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9027 sizeof(wmi_tdls_peer_capabilities);
9028
9029
9030 len += WMI_TLV_HDR_SIZE +
9031 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9032
9033 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9034 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309035 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9036 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309037 }
9038
9039 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9040 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9041 WMITLV_SET_HDR(&cmd->tlv_header,
9042 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9043 WMITLV_GET_STRUCT_TLVLEN
9044 (wmi_tdls_peer_update_cmd_fixed_param));
9045
9046 cmd->vdev_id = peerStateParams->vdevId;
9047 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9048 &cmd->peer_macaddr);
9049
9050
9051 cmd->peer_state = peerStateParams->peerState;
9052
Govind Singhb53420c2016-03-09 14:32:57 +05309053 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309054 "peer_macaddr.mac_addr31to0: 0x%x, "
9055 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9056 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9057 cmd->peer_macaddr.mac_addr31to0,
9058 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9059
9060 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9061 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9062 WMITLV_SET_HDR(&peer_cap->tlv_header,
9063 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9064 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9065
9066 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9067 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9068 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9069 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9070 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9071 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9072 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9073 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9074
9075 /* Ack and More Data Ack are sent as 0, so no need to set
9076 * but fill SP
9077 */
9078 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9079 peerStateParams->peerCap.peerMaxSp);
9080
9081 peer_cap->buff_sta_support =
9082 peerStateParams->peerCap.peerBuffStaSupport;
9083 peer_cap->off_chan_support =
9084 peerStateParams->peerCap.peerOffChanSupport;
9085 peer_cap->peer_curr_operclass =
9086 peerStateParams->peerCap.peerCurrOperClass;
9087 /* self curr operclass is not being used and so pass op class for
9088 * preferred off chan in it.
9089 */
9090 peer_cap->self_curr_operclass =
9091 peerStateParams->peerCap.opClassForPrefOffChan;
9092 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9093 peer_cap->peer_operclass_len =
9094 peerStateParams->peerCap.peerOperClassLen;
9095
Govind Singhb53420c2016-03-09 14:32:57 +05309096 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309097 __func__, peer_cap->peer_operclass_len);
9098 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9099 peer_cap->peer_operclass[i] =
9100 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309101 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309102 __func__, i, peer_cap->peer_operclass[i]);
9103 }
9104
9105 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9106 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9107 peer_cap->pref_offchan_bw =
9108 peerStateParams->peerCap.prefOffChanBandwidth;
9109
Govind Singhb53420c2016-03-09 14:32:57 +05309110 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309111 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9112 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9113 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9114 " %d, pref_offchan_bw: %d",
9115 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9116 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9117 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9118 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9119 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9120
9121 /* next fill variable size array of peer chan info */
9122 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9123 WMITLV_SET_HDR(buf_ptr,
9124 WMITLV_TAG_ARRAY_STRUC,
9125 sizeof(wmi_channel) *
9126 peerStateParams->peerCap.peerChanLen);
9127 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9128
9129 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9130 WMITLV_SET_HDR(&chan_info->tlv_header,
9131 WMITLV_TAG_STRUC_wmi_channel,
9132 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9133 chan_info->mhz = ch_mhz[i];
9134 chan_info->band_center_freq1 = chan_info->mhz;
9135 chan_info->band_center_freq2 = 0;
9136
Govind Singhb53420c2016-03-09 14:32:57 +05309137 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309138
9139 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9140 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309141 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309142 peerStateParams->peerCap.peerChan[i].chanId,
9143 peerStateParams->peerCap.peerChan[i].dfsSet);
9144 }
9145
9146 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9147 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9148 else
9149 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9150
9151 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9152 peerStateParams->peerCap.
9153 peerChan[i].pwr);
9154
9155 WMI_SET_CHANNEL_REG_POWER(chan_info,
9156 peerStateParams->peerCap.peerChan[i].
9157 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309158 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309159 peerStateParams->peerCap.peerChan[i].pwr);
9160
9161 chan_info++;
9162 }
9163
9164 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9165 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309166 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309167 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309168 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309169 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309170 }
9171
9172
Govind Singhb53420c2016-03-09 14:32:57 +05309173 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309174}
9175
9176/*
9177 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9178 * firmware
9179 * @wmi_handle: Pointer to wmi handle
9180 * @mem_dump_req: Pointer for mem_dump_req
9181 *
9182 * This function sends memory dump request to firmware
9183 *
Govind Singhb53420c2016-03-09 14:32:57 +05309184 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309185 *
9186 */
Govind Singhb53420c2016-03-09 14:32:57 +05309187QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309188 struct fw_dump_req_param *mem_dump_req)
9189{
9190 wmi_get_fw_mem_dump_fixed_param *cmd;
9191 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309192 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309193 int32_t len;
9194 wmi_buf_t buf;
9195 u_int8_t *buf_ptr;
9196 int ret, loop;
9197
9198 /*
9199 * len = sizeof(fixed param) that includes tlv header +
9200 * tlv header for array of struc +
9201 * sizeof (each struct)
9202 */
9203 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9204 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9205 buf = wmi_buf_alloc(wmi_handle, len);
9206
9207 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309208 WMI_LOGE(FL("Failed allocate wmi buffer"));
9209 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309210 }
9211
9212 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309213 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309214 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9215
9216 WMITLV_SET_HDR(&cmd->tlv_header,
9217 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9218 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9219
9220 cmd->request_id = mem_dump_req->request_id;
9221 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9222
9223 /* TLV indicating array of structures to follow */
9224 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9225 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9226 sizeof(wmi_fw_mem_dump) *
9227 cmd->num_fw_mem_dump_segs);
9228
9229 buf_ptr += WMI_TLV_HDR_SIZE;
9230 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9231
Govind Singhb53420c2016-03-09 14:32:57 +05309232 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309233 mem_dump_req->request_id, mem_dump_req->num_seg);
9234 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309235 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309236 ((uint8_t *)(mem_dump_req->segment) +
9237 loop * sizeof(*seg_req));
9238 WMITLV_SET_HDR(&dump_params->tlv_header,
9239 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9240 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9241 dump_params->seg_id = seg_req->seg_id;
9242 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9243 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9244 dump_params->seg_length = seg_req->seg_length;
9245 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9246 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309247 WMI_LOGI(FL("seg_number:%d"), loop);
9248 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309249 dump_params->seg_id, dump_params->seg_start_addr_lo,
9250 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309251 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309252 dump_params->seg_length, dump_params->dest_addr_lo,
9253 dump_params->dest_addr_hi);
9254 dump_params++;
9255 }
9256
9257 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9258 WMI_GET_FW_MEM_DUMP_CMDID);
9259 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309260 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309261 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309262 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309263 }
9264
Govind Singhb53420c2016-03-09 14:32:57 +05309265 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9266 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309267}
9268
9269/*
9270 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9271 * @wmi_handle: Pointer to WMi handle
9272 * @ie_data: Pointer for ie data
9273 *
9274 * This function sends IE information to firmware
9275 *
Govind Singhb53420c2016-03-09 14:32:57 +05309276 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309277 *
9278 */
Govind Singhb53420c2016-03-09 14:32:57 +05309279QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309280 struct vdev_ie_info_param *ie_info)
9281{
9282 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9283 wmi_buf_t buf;
9284 uint8_t *buf_ptr;
9285 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309286 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309287
9288
9289 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9290 /* Allocate memory for the WMI command */
9291 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9292
9293 buf = wmi_buf_alloc(wmi_handle, len);
9294 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309295 WMI_LOGE(FL("wmi_buf_alloc failed"));
9296 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309297 }
9298
9299 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309300 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309301
9302 /* Populate the WMI command */
9303 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9304
9305 WMITLV_SET_HDR(&cmd->tlv_header,
9306 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9307 WMITLV_GET_STRUCT_TLVLEN(
9308 wmi_vdev_set_ie_cmd_fixed_param));
9309 cmd->vdev_id = ie_info->vdev_id;
9310 cmd->ie_id = ie_info->ie_id;
9311 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009312 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309313
Govind Singhb53420c2016-03-09 14:32:57 +05309314 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309315 ie_info->length, ie_info->vdev_id);
9316
9317 buf_ptr += sizeof(*cmd);
9318 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9319 buf_ptr += WMI_TLV_HDR_SIZE;
9320
Govind Singhb53420c2016-03-09 14:32:57 +05309321 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309322
9323 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9324 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309325 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309326 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309327 wmi_buf_free(buf);
9328 }
9329
9330 return ret;
9331}
9332
Govind Singh9ddd5162016-03-07 16:30:32 +05309333
9334void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05309335 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05309336{
Govind Singhe7f2f342016-05-23 12:12:52 +05309337 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05309338 resource_cfg->num_peers = tgt_res_cfg->num_peers;
9339 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
9340 resource_cfg->num_offload_reorder_buffs =
9341 tgt_res_cfg->num_offload_reorder_buffs;
9342 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
9343 resource_cfg->num_tids = tgt_res_cfg->num_tids;
9344 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
9345 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
9346 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
9347 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
9348 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
9349 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
9350 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
9351 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
9352 resource_cfg->scan_max_pending_req =
9353 tgt_res_cfg->scan_max_pending_req;
9354 resource_cfg->bmiss_offload_max_vdev =
9355 tgt_res_cfg->bmiss_offload_max_vdev;
9356 resource_cfg->roam_offload_max_vdev =
9357 tgt_res_cfg->roam_offload_max_vdev;
9358 resource_cfg->roam_offload_max_ap_profiles =
9359 tgt_res_cfg->roam_offload_max_ap_profiles;
9360 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
9361 resource_cfg->num_mcast_table_elems =
9362 tgt_res_cfg->num_mcast_table_elems;
9363 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
9364 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
9365 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
9366 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
9367 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
9368 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
9369 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
9370 resource_cfg->vow_config = tgt_res_cfg->vow_config;
9371 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
9372 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
9373 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
9374 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
9375 resource_cfg->num_tdls_conn_table_entries =
9376 tgt_res_cfg->num_tdls_conn_table_entries;
9377 resource_cfg->beacon_tx_offload_max_vdev =
9378 tgt_res_cfg->beacon_tx_offload_max_vdev;
9379 resource_cfg->num_multicast_filter_entries =
9380 tgt_res_cfg->num_multicast_filter_entries;
9381 resource_cfg->num_wow_filters =
9382 tgt_res_cfg->num_wow_filters;
9383 resource_cfg->num_keep_alive_pattern =
9384 tgt_res_cfg->num_keep_alive_pattern;
9385 resource_cfg->keep_alive_pattern_size =
9386 tgt_res_cfg->keep_alive_pattern_size;
9387 resource_cfg->max_tdls_concurrent_sleep_sta =
9388 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
9389 resource_cfg->max_tdls_concurrent_buffer_sta =
9390 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
9391 resource_cfg->wmi_send_separate =
9392 tgt_res_cfg->wmi_send_separate;
9393 resource_cfg->num_ocb_vdevs =
9394 tgt_res_cfg->num_ocb_vdevs;
9395 resource_cfg->num_ocb_channels =
9396 tgt_res_cfg->num_ocb_channels;
9397 resource_cfg->num_ocb_schedules =
9398 tgt_res_cfg->num_ocb_schedules;
9399
9400}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309401#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309402/**
9403 * send_init_cmd_tlv() - wmi init command
9404 * @wmi_handle: pointer to wmi handle
9405 * @res_cfg: resource config
9406 * @num_mem_chunks: no of mem chunck
9407 * @mem_chunk: pointer to mem chunck structure
9408 *
9409 * This function sends IE information to firmware
9410 *
Govind Singhb53420c2016-03-09 14:32:57 +05309411 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309412 *
9413 */
Govind Singhb53420c2016-03-09 14:32:57 +05309414QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309415 wmi_resource_config *tgt_res_cfg,
9416 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
9417 bool action)
9418{
9419 wmi_buf_t buf;
9420 wmi_init_cmd_fixed_param *cmd;
9421 wmi_abi_version my_vers;
9422 int num_whitelist;
9423 uint8_t *buf_ptr;
9424 wmi_resource_config *resource_cfg;
9425 wlan_host_memory_chunk *host_mem_chunks;
9426 uint32_t mem_chunk_len = 0;
9427 uint16_t idx;
9428 int len;
9429 int ret;
9430
9431 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
9432 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
9433 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
9434 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309435 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
9436 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309437 }
9438
9439 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9440 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
9441 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
9442
9443 host_mem_chunks = (wlan_host_memory_chunk *)
9444 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
9445 + WMI_TLV_HDR_SIZE);
9446
9447 WMITLV_SET_HDR(&cmd->tlv_header,
9448 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
9449 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
9450
Govind Singhb53420c2016-03-09 14:32:57 +05309451 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +05309452 WMITLV_SET_HDR(&resource_cfg->tlv_header,
9453 WMITLV_TAG_STRUC_wmi_resource_config,
9454 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
9455
9456 for (idx = 0; idx < num_mem_chunks; ++idx) {
9457 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
9458 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
9459 WMITLV_GET_STRUCT_TLVLEN
9460 (wlan_host_memory_chunk));
9461 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
9462 host_mem_chunks[idx].size = mem_chunks[idx].len;
9463 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309464 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +05309465 idx, host_mem_chunks[idx].size,
9466 host_mem_chunks[idx].ptr);
9467 }
9468 cmd->num_host_mem_chunks = num_mem_chunks;
9469 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
9470 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
9471 WMITLV_TAG_ARRAY_STRUC,
9472 (sizeof(wlan_host_memory_chunk) *
9473 num_mem_chunks));
9474
9475 num_whitelist = sizeof(version_whitelist) /
9476 sizeof(wmi_whitelist_version_info);
9477 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
9478 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
9479 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
9480 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
9481 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
9482 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +05309483#ifdef CONFIG_MCL
9484 /* This needs to be enabled for WIN Lithium after removing dependency
9485 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +05309486 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
9487 &my_vers,
9488 &wmi_handle->fw_abi_version,
9489 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +05309490#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309491 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05309492 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
9493 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
9494 cmd->host_abi_vers.abi_version_ns_0,
9495 cmd->host_abi_vers.abi_version_ns_1,
9496 cmd->host_abi_vers.abi_version_ns_2,
9497 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +05309498#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309499 /* Save version sent from host -
9500 * Will be used to check ready event
9501 */
Govind Singhb53420c2016-03-09 14:32:57 +05309502 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309503 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309504#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309505 if (action) {
9506 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9507 WMI_INIT_CMDID);
9508 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309509 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +05309510 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309511 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309512 }
9513 } else {
9514 wmi_handle->saved_wmi_init_cmd.buf = buf;
9515 wmi_handle->saved_wmi_init_cmd.buf_len = len;
9516 }
9517
Govind Singhb53420c2016-03-09 14:32:57 +05309518 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309519
9520}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309521#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309522/**
9523 * send_saved_init_cmd_tlv() - wmi init command
9524 * @wmi_handle: pointer to wmi handle
9525 *
9526 * This function sends IE information to firmware
9527 *
Govind Singhb53420c2016-03-09 14:32:57 +05309528 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309529 *
9530 */
Govind Singhb53420c2016-03-09 14:32:57 +05309531QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +05309532{
9533 int status;
9534
9535 if (!wmi_handle->saved_wmi_init_cmd.buf ||
9536 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05309537 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
9538 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309539 }
9540 status = wmi_unified_cmd_send(wmi_handle,
9541 wmi_handle->saved_wmi_init_cmd.buf,
9542 wmi_handle->saved_wmi_init_cmd.buf_len,
9543 WMI_INIT_CMDID);
9544 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +05309545 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +05309546 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309547 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309548 }
9549 wmi_handle->saved_wmi_init_cmd.buf = NULL;
9550 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
9551
Govind Singhb53420c2016-03-09 14:32:57 +05309552 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309553}
9554
Govind Singhb53420c2016-03-09 14:32:57 +05309555QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05309556{
9557 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
9558 wmi_service_ready_event_fixed_param *ev;
9559
9560
9561 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
9562
9563 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
9564 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05309565 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309566
Govind Singh87542482016-06-08 19:40:11 +05309567#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309568 /*Save fw version from service ready message */
9569 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05309570 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309571 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309572#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309573 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309574}
9575
9576/**
9577 * wmi_unified_save_fw_version_cmd() - save fw version
9578 * @wmi_handle: pointer to wmi handle
9579 * @res_cfg: resource config
9580 * @num_mem_chunks: no of mem chunck
9581 * @mem_chunk: pointer to mem chunck structure
9582 *
9583 * This function sends IE information to firmware
9584 *
Govind Singhb53420c2016-03-09 14:32:57 +05309585 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309586 *
9587 */
Govind Singhb53420c2016-03-09 14:32:57 +05309588QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309589 void *evt_buf)
9590{
9591 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
9592 wmi_ready_event_fixed_param *ev = NULL;
9593
9594 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
9595 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +05309596#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309597 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
9598 &ev->fw_abi_vers)) {
9599 /*
9600 * Error: Our host version and the given firmware version
9601 * are incompatible.
9602 **/
Govind Singhb53420c2016-03-09 14:32:57 +05309603 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +05309604 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
9605 __func__,
9606 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
9607 abi_version_0),
9608 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
9609 abi_version_0),
9610 wmi_handle->final_abi_vers.abi_version_ns_0,
9611 wmi_handle->final_abi_vers.abi_version_ns_1,
9612 wmi_handle->final_abi_vers.abi_version_ns_2,
9613 wmi_handle->final_abi_vers.abi_version_ns_3,
9614 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
9615 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
9616 ev->fw_abi_vers.abi_version_ns_0,
9617 ev->fw_abi_vers.abi_version_ns_1,
9618 ev->fw_abi_vers.abi_version_ns_2,
9619 ev->fw_abi_vers.abi_version_ns_3);
9620
Govind Singhb53420c2016-03-09 14:32:57 +05309621 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309622 }
Govind Singhb53420c2016-03-09 14:32:57 +05309623 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309624 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +05309625 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309626 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309627#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309628
Govind Singhb53420c2016-03-09 14:32:57 +05309629 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309630}
Govind Singha4836fd2016-03-07 16:45:38 +05309631
9632/**
9633 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
9634 * @wmi_handle: wmi handle
9635 * @custom_addr: base mac address
9636 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309637 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +05309638 */
Govind Singhb53420c2016-03-09 14:32:57 +05309639QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309640 uint8_t *custom_addr)
9641{
9642 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
9643 wmi_buf_t buf;
9644 int err;
9645
9646 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9647 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309648 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309649 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309650 }
9651
9652 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309653 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +05309654
9655 WMITLV_SET_HDR(&cmd->tlv_header,
9656 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
9657 WMITLV_GET_STRUCT_TLVLEN
9658 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
9659 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -07009660 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +05309661 err = wmi_unified_cmd_send(wmi_handle, buf,
9662 sizeof(*cmd),
9663 WMI_PDEV_SET_BASE_MACADDR_CMDID);
9664 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05309665 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05309666 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309667 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309668 }
9669
9670 return 0;
9671}
9672
9673/**
9674 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
9675 * @handle: wmi handle
9676 * @event: Event received from FW
9677 * @len: Length of the event
9678 *
9679 * Enables the low frequency events and disables the high frequency
9680 * events. Bit 17 indicates if the event if low/high frequency.
9681 * 1 - high frequency, 0 - low frequency
9682 *
9683 * Return: 0 on successfully enabling/disabling the events
9684 */
Govind Singhb53420c2016-03-09 14:32:57 +05309685QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309686 uint8_t *event,
9687 uint32_t len)
9688{
9689 uint32_t num_of_diag_events_logs;
9690 wmi_diag_event_log_config_fixed_param *cmd;
9691 wmi_buf_t buf;
9692 uint8_t *buf_ptr;
9693 uint32_t *cmd_args, *evt_args;
9694 uint32_t buf_len, i;
9695
9696 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
9697 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
9698
Govind Singhb53420c2016-03-09 14:32:57 +05309699 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +05309700
9701 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
9702 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309703 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +05309704 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309705 }
9706 wmi_event = param_buf->fixed_param;
9707 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
9708 evt_args = param_buf->diag_events_logs_list;
9709 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +05309710 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309711 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +05309712 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309713 }
9714
Govind Singhb53420c2016-03-09 14:32:57 +05309715 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309716 __func__, num_of_diag_events_logs);
9717
9718 /* Free any previous allocation */
9719 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +05309720 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309721
9722 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +05309723 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +05309724 sizeof(uint32_t));
9725 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +05309726 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +05309727 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309728 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309729 }
9730 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
9731
9732 /* Prepare the send buffer */
9733 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
9734 (num_of_diag_events_logs * sizeof(uint32_t));
9735
9736 buf = wmi_buf_alloc(wmi_handle, buf_len);
9737 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309738 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9739 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309740 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05309741 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309742 }
9743
9744 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
9745 buf_ptr = (uint8_t *) cmd;
9746
9747 WMITLV_SET_HDR(&cmd->tlv_header,
9748 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
9749 WMITLV_GET_STRUCT_TLVLEN(
9750 wmi_diag_event_log_config_fixed_param));
9751
9752 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
9753
9754 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
9755
9756 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9757 (num_of_diag_events_logs * sizeof(uint32_t)));
9758
9759 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
9760
9761 /* Populate the events */
9762 for (i = 0; i < num_of_diag_events_logs; i++) {
9763 /* Low freq (0) - Enable (1) the event
9764 * High freq (1) - Disable (0) the event
9765 */
9766 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
9767 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
9768 /* Set the event ID */
9769 WMI_DIAG_ID_SET(cmd_args[i],
9770 WMI_DIAG_ID_GET(evt_args[i]));
9771 /* Set the type */
9772 WMI_DIAG_TYPE_SET(cmd_args[i],
9773 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +05309774 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +05309775 wmi_handle->events_logs_list[i] = evt_args[i];
9776 }
9777
9778 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
9779 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309780 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +05309781 __func__);
9782 wmi_buf_free(buf);
9783 /* Not clearing events_logs_list, though wmi cmd failed.
9784 * Host can still have this list
9785 */
Govind Singh67922e82016-04-01 16:48:57 +05309786 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309787 }
9788
9789 return 0;
9790}
9791
9792/**
9793 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
9794 * @wmi_handle: wmi handle
9795 * @start_log: Start logging related parameters
9796 *
9797 * Send the command to the FW based on which specific logging of diag
9798 * event/log id can be started/stopped
9799 *
9800 * Return: None
9801 */
Govind Singhb53420c2016-03-09 14:32:57 +05309802QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309803 struct wmi_wifi_start_log *start_log)
9804{
9805 wmi_diag_event_log_config_fixed_param *cmd;
9806 wmi_buf_t buf;
9807 uint8_t *buf_ptr;
9808 uint32_t len, count, log_level, i;
9809 uint32_t *cmd_args;
9810 uint32_t total_len;
9811 count = 0;
9812
9813 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +05309814 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +05309815 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309816 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309817 }
9818 /* total_len stores the number of events where BITS 17 and 18 are set.
9819 * i.e., events of high frequency (17) and for extended debugging (18)
9820 */
9821 total_len = 0;
9822 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
9823 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
9824 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
9825 total_len++;
9826 }
9827
9828 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
9829 (total_len * sizeof(uint32_t));
9830
9831 buf = wmi_buf_alloc(wmi_handle, len);
9832 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309833 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309834 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309835 }
9836 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
9837 buf_ptr = (uint8_t *) cmd;
9838
9839 WMITLV_SET_HDR(&cmd->tlv_header,
9840 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
9841 WMITLV_GET_STRUCT_TLVLEN(
9842 wmi_diag_event_log_config_fixed_param));
9843
9844 cmd->num_of_diag_events_logs = total_len;
9845
9846 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
9847
9848 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9849 (total_len * sizeof(uint32_t)));
9850
9851 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
9852
Govind Singh224a7312016-06-21 14:33:26 +05309853 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +05309854 log_level = 1;
9855 else
9856 log_level = 0;
9857
Govind Singhb53420c2016-03-09 14:32:57 +05309858 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +05309859 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
9860 uint32_t val = wmi_handle->events_logs_list[i];
9861 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
9862 (WMI_DIAG_EXT_FEATURE_GET(val))) {
9863
9864 WMI_DIAG_ID_SET(cmd_args[count],
9865 WMI_DIAG_ID_GET(val));
9866 WMI_DIAG_TYPE_SET(cmd_args[count],
9867 WMI_DIAG_TYPE_GET(val));
9868 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
9869 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +05309870 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +05309871 count++;
9872 }
9873 }
9874
9875 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9876 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309877 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +05309878 __func__);
9879 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309880 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309881 }
9882
Govind Singhb53420c2016-03-09 14:32:57 +05309883 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309884}
9885
9886/**
9887 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
9888 * @wmi_handle: WMI handle
9889 *
9890 * This function is used to send the flush command to the FW,
9891 * that will flush the fw logs that are residue in the FW
9892 *
9893 * Return: None
9894 */
Govind Singhb53420c2016-03-09 14:32:57 +05309895QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +05309896{
9897 wmi_debug_mesg_flush_fixed_param *cmd;
9898 wmi_buf_t buf;
9899 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +05309900 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +05309901
9902 buf = wmi_buf_alloc(wmi_handle, len);
9903 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309904 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309905 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309906 }
9907
9908 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
9909 WMITLV_SET_HDR(&cmd->tlv_header,
9910 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
9911 WMITLV_GET_STRUCT_TLVLEN(
9912 wmi_debug_mesg_flush_fixed_param));
9913 cmd->reserved0 = 0;
9914
9915 ret = wmi_unified_cmd_send(wmi_handle,
9916 buf,
9917 len,
9918 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309919 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309920 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +05309921 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309922 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309923 }
Govind Singhb53420c2016-03-09 14:32:57 +05309924 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +05309925
Govind Singh67922e82016-04-01 16:48:57 +05309926 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +05309927}
9928
9929/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309930 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +05309931 * @wmi_handle: wmi handle
9932 * @msg: PCL structure containing the PCL and the number of channels
9933 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309934 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +05309935 * firmware. The DBS Manager is the consumer of this information in the WLAN
9936 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
9937 * to migrate to a new channel without host driver involvement. An example of
9938 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
9939 * manage the channel selection without firmware involvement.
9940 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309941 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
9942 * channel list. The weights corresponds to the channels sent in
9943 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
9944 * weightage compared to the non PCL channels.
9945 *
Govind Singha4836fd2016-03-07 16:45:38 +05309946 * Return: Success if the cmd is sent successfully to the firmware
9947 */
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309948QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
9949 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +05309950{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309951 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +05309952 wmi_buf_t buf;
9953 uint8_t *buf_ptr;
9954 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309955 uint32_t chan_len;
9956
9957 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +05309958
9959 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309960 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +05309961
9962 buf = wmi_buf_alloc(wmi_handle, len);
9963 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309964 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9965 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309966 }
9967
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309968 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +05309969 buf_ptr = (uint8_t *) cmd;
9970 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309971 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
9972 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +05309973
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309974 cmd->pdev_id = WMI_PDEV_ID_SOC;
9975 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +05309976 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309977
9978 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +05309979 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309980 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +05309981 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309982 for (i = 0; i < chan_len ; i++) {
9983 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +05309984 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309985 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +05309986 }
9987 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309988 WMI_PDEV_SET_PCL_CMDID)) {
9989 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309990 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309991 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309992 }
Govind Singhb53420c2016-03-09 14:32:57 +05309993 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309994}
9995
9996/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +05309997 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +05309998 * @wmi_handle: wmi handle
9999 * @msg: Structure containing the following parameters
10000 *
10001 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
10002 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
10003 *
10004 * Provides notification to the WLAN firmware that host driver is requesting a
10005 * HardWare (HW) Mode change. This command is needed to support iHelium in the
10006 * configurations that include the Dual Band Simultaneous (DBS) feature.
10007 *
10008 * Return: Success if the cmd is sent successfully to the firmware
10009 */
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010010QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010011 uint32_t hw_mode_index)
10012{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010013 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010014 wmi_buf_t buf;
10015 uint32_t len;
10016
10017 len = sizeof(*cmd);
10018
10019 buf = wmi_buf_alloc(wmi_handle, len);
10020 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010021 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10022 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010023 }
10024
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010025 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010026 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010027 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
10028 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
10029
10030 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010031 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053010032 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053010033
10034 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010035 WMI_PDEV_SET_HW_MODE_CMDID)) {
10036 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010037 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010038 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010039 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010040 }
10041
Govind Singhb53420c2016-03-09 14:32:57 +053010042 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010043}
10044
10045/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010046 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010047 * @wmi_handle: wmi handle
10048 * @msg: Dual MAC config parameters
10049 *
10050 * Configures WLAN firmware with the dual MAC features
10051 *
Govind Singhb53420c2016-03-09 14:32:57 +053010052 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053010053 */
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010054QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010055 struct wmi_dual_mac_config *msg)
10056{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010057 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010058 wmi_buf_t buf;
10059 uint32_t len;
10060
10061 len = sizeof(*cmd);
10062
10063 buf = wmi_buf_alloc(wmi_handle, len);
10064 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010065 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10066 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010067 }
10068
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010069 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010070 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010071 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053010072 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010073 wmi_pdev_set_mac_config_cmd_fixed_param));
10074
10075 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010076 cmd->concurrent_scan_config_bits = msg->scan_config;
10077 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053010078 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053010079 __func__, msg->scan_config, msg->fw_mode_config);
10080
10081 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010082 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
10083 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010084 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010085 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010086 }
Govind Singhb53420c2016-03-09 14:32:57 +053010087 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010088}
10089
10090/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010091 * fill_arp_offload_params_tlv() - Fill ARP offload data
10092 * @wmi_handle: wmi handle
10093 * @offload_req: offload request
10094 * @buf_ptr: buffer pointer
10095 *
10096 * To fill ARP offload data to firmware
10097 * when target goes to wow mode.
10098 *
10099 * Return: None
10100 */
10101static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
10102 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10103{
10104
10105 int i;
10106 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
10107 bool enable_or_disable = offload_req->enableOrDisable;
10108
10109 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10110 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
10111 *buf_ptr += WMI_TLV_HDR_SIZE;
10112 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
10113 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
10114 WMITLV_SET_HDR(&arp_tuple->tlv_header,
10115 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
10116 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
10117
10118 /* Fill data for ARP and NS in the first tupple for LA */
10119 if ((enable_or_disable & WMI_OFFLOAD_ENABLE) && (i == 0)) {
10120 /* Copy the target ip addr and flags */
10121 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
10122 qdf_mem_copy(&arp_tuple->target_ipaddr,
10123 offload_req->params.hostIpv4Addr,
10124 WMI_IPV4_ADDR_LEN);
10125 WMI_LOGD("ARPOffload IP4 address: %pI4",
10126 offload_req->params.hostIpv4Addr);
10127 }
10128 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
10129 }
10130}
10131
10132#ifdef WLAN_NS_OFFLOAD
10133/**
10134 * fill_ns_offload_params_tlv() - Fill NS offload data
10135 * @wmi|_handle: wmi handle
10136 * @offload_req: offload request
10137 * @buf_ptr: buffer pointer
10138 *
10139 * To fill NS offload data to firmware
10140 * when target goes to wow mode.
10141 *
10142 * Return: None
10143 */
10144static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10145 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10146{
10147
10148 int i;
10149 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10150 struct ns_offload_req_params ns_req;
10151
10152 ns_req = offload_req->nsOffloadInfo;
10153 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10154 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10155 *buf_ptr += WMI_TLV_HDR_SIZE;
10156 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
10157 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10158 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10159 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10160 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
10161
10162 /*
10163 * Fill data only for NS offload in the first ARP tuple for LA
10164 */
10165 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10166 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10167 /* Copy the target/solicitation/remote ip addr */
10168 if (ns_req.targetIPv6AddrValid[i])
10169 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10170 &ns_req.targetIPv6Addr[i],
10171 sizeof(WMI_IPV6_ADDR));
10172 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10173 &ns_req.selfIPv6Addr[i],
10174 sizeof(WMI_IPV6_ADDR));
10175 if (ns_req.target_ipv6_addr_ac_type[i]) {
10176 ns_tuple->flags |=
10177 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10178 }
10179 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10180 i, &ns_req.selfIPv6Addr[i],
10181 &ns_req.targetIPv6Addr[i]);
10182
10183 /* target MAC is optional, check if it is valid,
10184 * if this is not valid, the target will use the known
10185 * local MAC address rather than the tuple
10186 */
10187 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10188 ns_req.self_macaddr.bytes,
10189 &ns_tuple->target_mac);
10190 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10191 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10192 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10193 }
10194 }
10195 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10196 }
10197}
10198
10199
10200/**
10201 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
10202 * @wmi: wmi handle
10203 * @offload_req: offload request
10204 * @buf_ptr: buffer pointer
10205 *
10206 * To fill extended NS offload extended data to firmware
10207 * when target goes to wow mode.
10208 *
10209 * Return: None
10210 */
10211static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10212 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10213{
10214 int i;
10215 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10216 uint32_t count, num_ns_ext_tuples;
10217 struct ns_offload_req_params ns_req;
10218
10219 ns_req = offload_req->nsOffloadInfo;
10220 count = offload_req->num_ns_offload_count;
10221 num_ns_ext_tuples = offload_req->num_ns_offload_count -
10222 WMI_MAX_NS_OFFLOADS;
10223
10224 /* Populate extended NS offload tuples */
10225 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10226 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10227 *buf_ptr += WMI_TLV_HDR_SIZE;
10228 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
10229 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10230 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10231 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10232 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
10233
10234 /*
10235 * Fill data only for NS offload in the first ARP tuple for LA
10236 */
10237 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10238 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10239 /* Copy the target/solicitation/remote ip addr */
10240 if (ns_req.targetIPv6AddrValid[i])
10241 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10242 &ns_req.targetIPv6Addr[i],
10243 sizeof(WMI_IPV6_ADDR));
10244 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10245 &ns_req.selfIPv6Addr[i],
10246 sizeof(WMI_IPV6_ADDR));
10247 if (ns_req.target_ipv6_addr_ac_type[i]) {
10248 ns_tuple->flags |=
10249 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10250 }
10251 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10252 i, &ns_req.selfIPv6Addr[i],
10253 &ns_req.targetIPv6Addr[i]);
10254
10255 /* target MAC is optional, check if it is valid,
10256 * if this is not valid, the target will use the
10257 * known local MAC address rather than the tuple
10258 */
10259 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10260 ns_req.self_macaddr.bytes,
10261 &ns_tuple->target_mac);
10262 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10263 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10264 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10265 }
10266 }
10267 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10268 }
10269}
10270#else
10271static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10272 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10273{
10274 return;
10275}
10276
10277static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10278 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10279{
10280 return;
10281}
10282#endif
10283
10284/**
Govind Singha4836fd2016-03-07 16:45:38 +053010285 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
10286 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010287 * @arp_offload_req: arp offload request
10288 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053010289 * @arp_only: flag
10290 *
10291 * To configure ARP NS off load data to firmware
10292 * when target goes to wow mode.
10293 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010294 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053010295 */
Govind Singhb53420c2016-03-09 14:32:57 +053010296QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010297 struct host_offload_req_param *arp_offload_req,
10298 struct host_offload_req_param *ns_offload_req,
10299 bool arp_only,
Govind Singha4836fd2016-03-07 16:45:38 +053010300 uint8_t vdev_id)
10301{
Govind Singha4836fd2016-03-07 16:45:38 +053010302 int32_t res;
10303 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010304 A_UINT8 *buf_ptr;
10305 wmi_buf_t buf;
10306 int32_t len;
10307 uint32_t count = 0, num_ns_ext_tuples = 0;
10308
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010309 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053010310
Govind Singha4836fd2016-03-07 16:45:38 +053010311 /*
10312 * TLV place holder size for array of NS tuples
10313 * TLV place holder size for array of ARP tuples
10314 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010315 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
10316 WMI_TLV_HDR_SIZE +
10317 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
10318 WMI_TLV_HDR_SIZE +
10319 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010320
10321 /*
10322 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
10323 * extra length for extended NS offload tuples which follows ARP offload
10324 * tuples. Host needs to fill this structure in following format:
10325 * 2 NS ofload tuples
10326 * 2 ARP offload tuples
10327 * N numbers of extended NS offload tuples if HDD has given more than
10328 * 2 NS offload addresses
10329 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010330 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053010331 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010332 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
10333 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010334 }
10335
10336 buf = wmi_buf_alloc(wmi_handle, len);
10337 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010338 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053010339 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010340 }
10341
10342 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
10343 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
10344 WMITLV_SET_HDR(&cmd->tlv_header,
10345 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
10346 WMITLV_GET_STRUCT_TLVLEN
10347 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
10348 cmd->flags = 0;
10349 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010350 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053010351
Govind Singhb53420c2016-03-09 14:32:57 +053010352 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053010353
Govind Singha4836fd2016-03-07 16:45:38 +053010354 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010355 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
10356 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
10357 if (num_ns_ext_tuples)
10358 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053010359
10360 res = wmi_unified_cmd_send(wmi_handle, buf, len,
10361 WMI_SET_ARP_NS_OFFLOAD_CMDID);
10362 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053010363 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053010364 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010365 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010366 }
10367
Govind Singhb53420c2016-03-09 14:32:57 +053010368 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010369}
10370
10371/**
10372 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
10373 * @wmi_handle: wmi handle
10374 * @request: SSID hotlist set request
10375 *
Govind Singhb53420c2016-03-09 14:32:57 +053010376 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053010377 */
Govind Singhb53420c2016-03-09 14:32:57 +053010378QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053010379send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
10380 struct ssid_hotlist_request_params *request)
10381{
10382 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
10383 wmi_buf_t wmi_buf;
10384 uint32_t len;
10385 uint32_t array_size;
10386 uint8_t *buf_ptr;
10387
10388 /* length of fixed portion */
10389 len = sizeof(*cmd);
10390
10391 /* length of variable portion */
10392 array_size =
10393 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
10394 len += WMI_TLV_HDR_SIZE + array_size;
10395
10396 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10397 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010398 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10399 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010400 }
10401
10402 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10403 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
10404 buf_ptr;
10405 WMITLV_SET_HDR
10406 (&cmd->tlv_header,
10407 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
10408 WMITLV_GET_STRUCT_TLVLEN
10409 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
10410
10411 cmd->request_id = request->request_id;
10412 cmd->requestor_id = 0;
10413 cmd->vdev_id = request->session_id;
10414 cmd->table_id = 0;
10415 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
10416 cmd->total_entries = request->ssid_count;
10417 cmd->num_entries_in_page = request->ssid_count;
10418 cmd->first_entry_index = 0;
10419
10420 buf_ptr += sizeof(*cmd);
10421 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
10422
10423 if (request->ssid_count) {
10424 wmi_extscan_hotlist_ssid_entry *entry;
10425 int i;
10426
10427 buf_ptr += WMI_TLV_HDR_SIZE;
10428 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
10429 for (i = 0; i < request->ssid_count; i++) {
10430 WMITLV_SET_HDR
10431 (entry,
10432 WMITLV_TAG_ARRAY_STRUC,
10433 WMITLV_GET_STRUCT_TLVLEN
10434 (wmi_extscan_hotlist_ssid_entry));
10435 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053010436 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053010437 request->ssids[i].ssid.mac_ssid,
10438 request->ssids[i].ssid.length);
10439 entry->band = request->ssids[i].band;
10440 entry->min_rssi = request->ssids[i].rssi_low;
10441 entry->max_rssi = request->ssids[i].rssi_high;
10442 entry++;
10443 }
10444 cmd->mode = WMI_EXTSCAN_MODE_START;
10445 } else {
10446 cmd->mode = WMI_EXTSCAN_MODE_STOP;
10447 }
10448
10449 if (wmi_unified_cmd_send
10450 (wmi_handle, wmi_buf, len,
10451 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010452 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053010453 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010454 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010455 }
10456
Govind Singhb53420c2016-03-09 14:32:57 +053010457 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010458}
10459
10460/**
10461 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
10462 * @wmi_handle: wmi handle
10463 * @vdev_id: vdev id
10464 *
10465 * This function sends roam synch complete event to fw.
10466 *
10467 * Return: CDF STATUS
10468 */
Govind Singhb53420c2016-03-09 14:32:57 +053010469QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010470 uint8_t vdev_id)
10471{
10472 wmi_roam_synch_complete_fixed_param *cmd;
10473 wmi_buf_t wmi_buf;
10474 uint8_t *buf_ptr;
10475 uint16_t len;
10476 len = sizeof(wmi_roam_synch_complete_fixed_param);
10477
10478 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10479 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010480 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10481 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010482 }
10483 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
10484 buf_ptr = (uint8_t *) cmd;
10485 WMITLV_SET_HDR(&cmd->tlv_header,
10486 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
10487 WMITLV_GET_STRUCT_TLVLEN
10488 (wmi_roam_synch_complete_fixed_param));
10489 cmd->vdev_id = vdev_id;
10490 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10491 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010492 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053010493 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010494 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010495 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010496 }
10497
Govind Singhb53420c2016-03-09 14:32:57 +053010498 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010499}
10500
10501/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053010502 * send_fw_test_cmd_tlv() - send fw test command to fw.
10503 * @wmi_handle: wmi handle
10504 * @wmi_fwtest: fw test command
10505 *
10506 * This function sends fw test command to fw.
10507 *
10508 * Return: CDF STATUS
10509 */
10510QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
10511 struct set_fwtest_params *wmi_fwtest)
10512{
10513 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10514 wmi_buf_t wmi_buf;
10515 uint16_t len;
10516
10517 len = sizeof(*cmd);
10518
10519 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10520 if (!wmi_buf) {
10521 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10522 return QDF_STATUS_E_NOMEM;
10523 }
10524
10525 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10526 WMITLV_SET_HDR(&cmd->tlv_header,
10527 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10528 WMITLV_GET_STRUCT_TLVLEN(
10529 wmi_fwtest_set_param_cmd_fixed_param));
10530 cmd->param_id = wmi_fwtest->arg;
10531 cmd->param_value = wmi_fwtest->value;
10532
10533 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10534 WMI_FWTEST_CMDID)) {
10535 WMI_LOGP("%s: failed to send fw test command", __func__);
10536 qdf_nbuf_free(wmi_buf);
10537 return QDF_STATUS_E_FAILURE;
10538 }
10539
10540 return QDF_STATUS_SUCCESS;
10541}
10542
10543/**
Govind Singha4836fd2016-03-07 16:45:38 +053010544 * send_unit_test_cmd_tlv() - send unit test command to fw.
10545 * @wmi_handle: wmi handle
10546 * @wmi_utest: unit test command
10547 *
10548 * This function send unit test command to fw.
10549 *
10550 * Return: CDF STATUS
10551 */
Govind Singhb53420c2016-03-09 14:32:57 +053010552QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010553 struct wmi_unit_test_cmd *wmi_utest)
10554{
10555 wmi_unit_test_cmd_fixed_param *cmd;
10556 wmi_buf_t wmi_buf;
10557 uint8_t *buf_ptr;
10558 int i;
10559 uint16_t len, args_tlv_len;
10560 A_UINT32 *unit_test_cmd_args;
10561
10562 args_tlv_len =
10563 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
10564 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
10565
10566 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10567 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010568 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10569 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010570 }
10571
10572 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10573 buf_ptr = (uint8_t *) cmd;
10574 WMITLV_SET_HDR(&cmd->tlv_header,
10575 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
10576 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
10577 cmd->vdev_id = wmi_utest->vdev_id;
10578 cmd->module_id = wmi_utest->module_id;
10579 cmd->num_args = wmi_utest->num_args;
10580 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
10581 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10582 (wmi_utest->num_args * sizeof(uint32_t)));
10583 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053010584 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053010585 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
10586 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010587 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010588 }
10589 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10590 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010591 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010592 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010593 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010594 }
10595
Govind Singhb53420c2016-03-09 14:32:57 +053010596 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010597}
10598
10599/**
10600 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
10601 * @wmi_handle: wma handle
10602 * @roaminvoke: roam invoke command
10603 *
10604 * Send roam invoke command to fw for fastreassoc.
10605 *
10606 * Return: CDF STATUS
10607 */
Govind Singhb53420c2016-03-09 14:32:57 +053010608QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010609 struct wmi_roam_invoke_cmd *roaminvoke,
10610 uint32_t ch_hz)
10611{
10612 wmi_roam_invoke_cmd_fixed_param *cmd;
10613 wmi_buf_t wmi_buf;
10614 u_int8_t *buf_ptr;
10615 u_int16_t len, args_tlv_len;
10616 A_UINT32 *channel_list;
10617 wmi_mac_addr *bssid_list;
10618
10619 /* Host sends only one channel and one bssid */
10620 args_tlv_len = 2 * WMI_TLV_HDR_SIZE + sizeof(A_UINT32) +
10621 sizeof(wmi_mac_addr);
10622 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
10623 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10624 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010625 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10626 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010627 }
10628
10629 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
10630 buf_ptr = (u_int8_t *) cmd;
10631 WMITLV_SET_HDR(&cmd->tlv_header,
10632 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
10633 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
10634 cmd->vdev_id = roaminvoke->vdev_id;
10635 cmd->flags = 0;
10636 cmd->roam_scan_mode = 0;
10637 cmd->roam_ap_sel_mode = 0;
10638 cmd->roam_delay = 0;
10639 cmd->num_chan = 1;
10640 cmd->num_bssid = 1;
10641 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
10642 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10643 (sizeof(u_int32_t)));
10644 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
10645 *channel_list = ch_hz;
10646 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
10647 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
10648 (sizeof(wmi_mac_addr)));
10649 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
10650 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
10651 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10652 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010653 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053010654 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010655 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010656 }
10657
Govind Singhb53420c2016-03-09 14:32:57 +053010658 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010659}
10660
10661/**
10662 * send_roam_scan_offload_cmd_tlv() - set roam offload command
10663 * @wmi_handle: wmi handle
10664 * @command: command
10665 * @vdev_id: vdev id
10666 *
10667 * This function set roam offload command to fw.
10668 *
10669 * Return: CDF status
10670 */
Govind Singhb53420c2016-03-09 14:32:57 +053010671QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010672 uint32_t command, uint32_t vdev_id)
10673{
Govind Singh67922e82016-04-01 16:48:57 +053010674 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010675 wmi_roam_scan_cmd_fixed_param *cmd_fp;
10676 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053010677 int len;
10678 uint8_t *buf_ptr;
10679
10680 len = sizeof(wmi_roam_scan_cmd_fixed_param);
10681 buf = wmi_buf_alloc(wmi_handle, len);
10682 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010683 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10684 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010685 }
10686
10687 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10688
10689 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
10690 WMITLV_SET_HDR(&cmd_fp->tlv_header,
10691 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
10692 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
10693 cmd_fp->vdev_id = vdev_id;
10694 cmd_fp->command_arg = command;
10695
10696 status = wmi_unified_cmd_send(wmi_handle, buf,
10697 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053010698 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010699 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010700 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010701 goto error;
10702 }
10703
Govind Singhb53420c2016-03-09 14:32:57 +053010704 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
10705 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010706
10707error:
10708 wmi_buf_free(buf);
10709
Govind Singh67922e82016-04-01 16:48:57 +053010710 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010711}
10712
10713/**
10714 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
10715 * @wmi_handle: wmi handle
10716 * @ap_profile_p: ap profile
10717 * @vdev_id: vdev id
10718 *
10719 * Send WMI_ROAM_AP_PROFILE to firmware
10720 *
10721 * Return: CDF status
10722 */
Govind Singhb53420c2016-03-09 14:32:57 +053010723QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010724 wmi_ap_profile *ap_profile_p,
10725 uint32_t vdev_id)
10726{
Govind Singha4836fd2016-03-07 16:45:38 +053010727 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010728 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010729 int len;
10730 uint8_t *buf_ptr;
10731 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
10732
10733 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
10734
10735 buf = wmi_buf_alloc(wmi_handle, len);
10736 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010737 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10738 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010739 }
10740
10741 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10742 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
10743 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
10744 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
10745 WMITLV_GET_STRUCT_TLVLEN
10746 (wmi_roam_ap_profile_fixed_param));
10747 /* fill in threshold values */
10748 roam_ap_profile_fp->vdev_id = vdev_id;
10749 roam_ap_profile_fp->id = 0;
10750 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
10751
Govind Singhb53420c2016-03-09 14:32:57 +053010752 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053010753 WMITLV_SET_HDR(buf_ptr,
10754 WMITLV_TAG_STRUC_wmi_ap_profile,
10755 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
10756 status = wmi_unified_cmd_send(wmi_handle, buf,
10757 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053010758 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010759 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010760 status);
Govind Singh67922e82016-04-01 16:48:57 +053010761 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010762 }
10763
Govind Singhb53420c2016-03-09 14:32:57 +053010764 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053010765
Govind Singh67922e82016-04-01 16:48:57 +053010766 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010767}
10768
10769/**
10770 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
10771 * @wmi_handle: wmi handle
10772 * @scan_period: scan period
10773 * @scan_age: scan age
10774 * @vdev_id: vdev id
10775 *
10776 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
10777 *
10778 * Return: CDF status
10779 */
Govind Singhb53420c2016-03-09 14:32:57 +053010780QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010781 uint32_t scan_period,
10782 uint32_t scan_age,
10783 uint32_t vdev_id)
10784{
Govind Singh67922e82016-04-01 16:48:57 +053010785 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010786 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053010787 int len;
10788 uint8_t *buf_ptr;
10789 wmi_roam_scan_period_fixed_param *scan_period_fp;
10790
10791 /* Send scan period values */
10792 len = sizeof(wmi_roam_scan_period_fixed_param);
10793 buf = wmi_buf_alloc(wmi_handle, len);
10794 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010795 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10796 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010797 }
10798
10799 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10800 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
10801 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
10802 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
10803 WMITLV_GET_STRUCT_TLVLEN
10804 (wmi_roam_scan_period_fixed_param));
10805 /* fill in scan period values */
10806 scan_period_fp->vdev_id = vdev_id;
10807 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
10808 scan_period_fp->roam_scan_age = scan_age;
10809
10810 status = wmi_unified_cmd_send(wmi_handle, buf,
10811 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053010812 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010813 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010814 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010815 goto error;
10816 }
10817
Govind Singhb53420c2016-03-09 14:32:57 +053010818 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010819 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053010820 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010821error:
10822 wmi_buf_free(buf);
10823
Govind Singh67922e82016-04-01 16:48:57 +053010824 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010825}
10826
10827/**
10828 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
10829 * @wmi_handle: wmi handle
10830 * @chan_count: channel count
10831 * @chan_list: channel list
10832 * @list_type: list type
10833 * @vdev_id: vdev id
10834 *
10835 * Set roam offload channel list.
10836 *
10837 * Return: CDF status
10838 */
Govind Singhb53420c2016-03-09 14:32:57 +053010839QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010840 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070010841 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053010842 uint8_t list_type, uint32_t vdev_id)
10843{
Govind Singha4836fd2016-03-07 16:45:38 +053010844 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010845 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010846 int len, list_tlv_len;
10847 int i;
10848 uint8_t *buf_ptr;
10849 wmi_roam_chan_list_fixed_param *chan_list_fp;
10850 A_UINT32 *roam_chan_list_array;
10851
10852 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053010853 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053010854 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053010855 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053010856 }
10857 /* Channel list is a table of 2 TLV's */
10858 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
10859 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
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_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010864 }
10865
10866 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10867 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
10868 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
10869 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
10870 WMITLV_GET_STRUCT_TLVLEN
10871 (wmi_roam_chan_list_fixed_param));
10872 chan_list_fp->vdev_id = vdev_id;
10873 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053010874 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053010875 /* external app is controlling channel list */
10876 chan_list_fp->chan_list_type =
10877 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
10878 } else {
10879 /* umac supplied occupied channel list in LFR */
10880 chan_list_fp->chan_list_type =
10881 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
10882 }
10883
10884 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
10885 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10886 (chan_list_fp->num_chan * sizeof(uint32_t)));
10887 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053010888 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053010889 for (i = 0; ((i < chan_list_fp->num_chan) &&
10890 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
10891 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010892 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010893 }
10894
10895 status = wmi_unified_cmd_send(wmi_handle, buf,
10896 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053010897 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010898 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010899 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010900 goto error;
10901 }
10902
Govind Singhb53420c2016-03-09 14:32:57 +053010903 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
10904 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010905error:
10906 wmi_buf_free(buf);
10907
Govind Singh67922e82016-04-01 16:48:57 +053010908 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010909}
10910
10911/**
10912 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
10913 * @wmi_handle: wmi handle
10914 * @rssi_change_thresh: RSSI Change threshold
10915 * @bcn_rssi_weight: beacon RSSI weight
10916 * @vdev_id: vdev id
10917 *
10918 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
10919 *
10920 * Return: CDF status
10921 */
Govind Singhb53420c2016-03-09 14:32:57 +053010922QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010923 uint32_t vdev_id,
10924 int32_t rssi_change_thresh,
10925 uint32_t bcn_rssi_weight,
10926 uint32_t hirssi_delay_btw_scans)
10927{
Govind Singha4836fd2016-03-07 16:45:38 +053010928 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010929 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010930 int len;
10931 uint8_t *buf_ptr;
10932 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
10933
10934 /* Send rssi change parameters */
10935 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
10936 buf = wmi_buf_alloc(wmi_handle, len);
10937 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010938 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10939 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010940 }
10941
10942 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10943 rssi_change_fp =
10944 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
10945 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
10946 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
10947 WMITLV_GET_STRUCT_TLVLEN
10948 (wmi_roam_scan_rssi_change_threshold_fixed_param));
10949 /* fill in rssi change threshold (hysteresis) values */
10950 rssi_change_fp->vdev_id = vdev_id;
10951 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
10952 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
10953 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
10954
10955 status = wmi_unified_cmd_send(wmi_handle, buf,
10956 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053010957 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010958 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010959 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010960 goto error;
10961 }
10962
Govind Singhb53420c2016-03-09 14:32:57 +053010963 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053010964 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053010965 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
10966 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010967error:
10968 wmi_buf_free(buf);
10969
Govind Singh67922e82016-04-01 16:48:57 +053010970 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010971}
10972
10973/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
10974 * @wmi_handle: wmi handle.
10975 * @cmd: size of command structure.
10976 * @per_entry_size: per entry size.
10977 *
10978 * This utility function calculates how many hotlist entries can
10979 * fit in one page.
10980 *
10981 * Return: number of entries
10982 */
10983static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
10984 size_t cmd_size,
10985 size_t per_entry_size)
10986{
10987 uint32_t avail_space = 0;
10988 int num_entries = 0;
10989 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
10990
10991 /* Calculate number of hotlist entries that can
10992 * be passed in wma message request.
10993 */
10994 avail_space = max_msg_len - cmd_size;
10995 num_entries = avail_space / per_entry_size;
10996 return num_entries;
10997}
10998
10999/**
11000 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
11001 * @wmi_handle: wmi handle
11002 * @photlist: hotlist command params
11003 * @buf_len: buffer length
11004 *
11005 * This function fills individual elements for hotlist request and
11006 * TLV for bssid entries
11007 *
11008 * Return: CDF Status.
11009 */
Govind Singhb53420c2016-03-09 14:32:57 +053011010QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011011 struct ext_scan_setbssi_hotlist_params *
11012 photlist, int *buf_len)
11013{
11014 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
11015 wmi_extscan_hotlist_entry *dest_hotlist;
11016 struct ap_threshold_params *src_ap = photlist->ap;
11017 wmi_buf_t buf;
11018 uint8_t *buf_ptr;
11019
11020 int j, index = 0;
11021 int cmd_len = 0;
11022 int num_entries;
11023 int min_entries = 0;
11024 int numap = photlist->numAp;
11025 int len = sizeof(*cmd);
11026
11027 len += WMI_TLV_HDR_SIZE;
11028 cmd_len = len;
11029
11030 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
11031 cmd_len,
11032 sizeof(*dest_hotlist));
11033 /* setbssid hotlist expects the bssid list
11034 * to be non zero value
11035 */
11036 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011037 WMI_LOGE("%s: Invalid number of bssid's", __func__);
11038 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011039 }
11040
11041 /* Split the hot list entry pages and send multiple command
11042 * requests if the buffer reaches the maximum request size
11043 */
11044 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011045 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053011046 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
11047 buf = wmi_buf_alloc(wmi_handle, len);
11048 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011049 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
11050 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011051 }
11052 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11053 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
11054 buf_ptr;
11055 WMITLV_SET_HDR(&cmd->tlv_header,
11056 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
11057 WMITLV_GET_STRUCT_TLVLEN
11058 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
11059
11060 /* Multiple requests are sent until the num_entries_in_page
11061 * matches the total_entries
11062 */
11063 cmd->request_id = photlist->requestId;
11064 cmd->vdev_id = photlist->sessionId;
11065 cmd->total_entries = numap;
11066 cmd->mode = 1;
11067 cmd->num_entries_in_page = min_entries;
11068 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
11069 cmd->first_entry_index = index;
11070
Govind Singhb53420c2016-03-09 14:32:57 +053011071 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011072 __func__, cmd->vdev_id, cmd->total_entries,
11073 cmd->num_entries_in_page,
11074 cmd->lost_ap_scan_count);
11075
11076 buf_ptr += sizeof(*cmd);
11077 WMITLV_SET_HDR(buf_ptr,
11078 WMITLV_TAG_ARRAY_STRUC,
11079 min_entries * sizeof(wmi_extscan_hotlist_entry));
11080 dest_hotlist = (wmi_extscan_hotlist_entry *)
11081 (buf_ptr + WMI_TLV_HDR_SIZE);
11082
11083 /* Populate bssid, channel info and rssi
11084 * for the bssid's that are sent as hotlists.
11085 */
11086 for (j = 0; j < min_entries; j++) {
11087 WMITLV_SET_HDR(dest_hotlist,
11088 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
11089 WMITLV_GET_STRUCT_TLVLEN
11090 (wmi_extscan_hotlist_entry));
11091
11092 dest_hotlist->min_rssi = src_ap->low;
11093 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
11094 &dest_hotlist->bssid);
11095
Govind Singhb53420c2016-03-09 14:32:57 +053011096 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011097 __func__, dest_hotlist->channel,
11098 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053011099 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053011100 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
11101 __func__, dest_hotlist->bssid.mac_addr31to0,
11102 dest_hotlist->bssid.mac_addr47to32);
11103 dest_hotlist++;
11104 src_ap++;
11105 }
11106 buf_ptr += WMI_TLV_HDR_SIZE +
11107 (min_entries * sizeof(wmi_extscan_hotlist_entry));
11108
11109 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11110 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011111 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011112 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011113 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011114 }
11115 index = index + min_entries;
11116 num_entries = numap - min_entries;
11117 len = cmd_len;
11118 }
Govind Singhb53420c2016-03-09 14:32:57 +053011119 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011120}
11121
Govind Singhbca3b1b2016-05-02 17:59:24 +053011122/**
11123 * send_power_dbg_cmd_tlv() - send power debug commands
11124 * @wmi_handle: wmi handle
11125 * @param: wmi power debug parameter
11126 *
11127 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
11128 *
11129 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
11130 */
11131QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
11132 struct wmi_power_dbg_params *param)
11133{
11134 wmi_buf_t buf = NULL;
11135 QDF_STATUS status;
11136 int len, args_tlv_len;
11137 uint8_t *buf_ptr;
11138 uint8_t i;
11139 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
11140 uint32_t *cmd_args;
11141
11142 /* Prepare and send power debug cmd parameters */
11143 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
11144 len = sizeof(*cmd) + args_tlv_len;
11145 buf = wmi_buf_alloc(wmi_handle, len);
11146 if (!buf) {
11147 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11148 return QDF_STATUS_E_NOMEM;
11149 }
11150
11151 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11152 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
11153 WMITLV_SET_HDR(&cmd->tlv_header,
11154 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
11155 WMITLV_GET_STRUCT_TLVLEN
11156 (wmi_pdev_wal_power_debug_cmd_fixed_param));
11157
11158 cmd->pdev_id = param->pdev_id;
11159 cmd->module_id = param->module_id;
11160 cmd->num_args = param->num_args;
11161 buf_ptr += sizeof(*cmd);
11162 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11163 (param->num_args * sizeof(uint32_t)));
11164 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11165 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
11166 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
11167 cmd_args[i] = param->args[i];
11168 WMI_LOGI("%d,", param->args[i]);
11169 }
11170
11171 status = wmi_unified_cmd_send(wmi_handle, buf,
11172 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
11173 if (QDF_IS_STATUS_ERROR(status)) {
11174 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
11175 status);
11176 goto error;
11177 }
11178
11179 return QDF_STATUS_SUCCESS;
11180error:
11181 wmi_buf_free(buf);
11182
11183 return status;
11184}
11185
Govind Singhe7f2f342016-05-23 12:12:52 +053011186/**
11187 * init_cmd_send_tlv() - send initialization cmd to fw
11188 * @wmi_handle: wmi handle
11189 * @param tgt_res_cfg: pointer to target resource configuration
11190 * @param num_mem_chunks: Number of memory chunks
11191 * @param mem_chunks: pointer to target memory chunks
11192 *
11193 * Return: QDF_STATUS_SUCCESS for success or error code
11194 */
11195static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
11196 target_resource_config *tgt_res_cfg, uint8_t num_mem_chunks,
11197 struct wmi_host_mem_chunk *mem_chunks)
11198{
11199 wmi_buf_t buf;
11200 wmi_init_cmd_fixed_param *cmd;
11201 wmi_abi_version my_vers;
11202 int num_whitelist;
11203 uint8_t *buf_ptr;
11204 wmi_resource_config *resource_cfg;
11205 wlan_host_memory_chunk *host_mem_chunks;
11206 uint32_t mem_chunk_len = 0;
11207 uint16_t idx;
11208 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053011209 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053011210
11211 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11212 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11213 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11214 if (!buf) {
11215 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11216 return QDF_STATUS_E_FAILURE;
11217 }
11218
11219 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11220 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11221 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11222
11223 host_mem_chunks = (wlan_host_memory_chunk *)
11224 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11225 + WMI_TLV_HDR_SIZE);
11226
11227 WMITLV_SET_HDR(&cmd->tlv_header,
11228 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11229 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11230
11231 wmi_copy_resource_config(resource_cfg, tgt_res_cfg);
11232 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11233 WMITLV_TAG_STRUC_wmi_resource_config,
11234 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11235
11236 for (idx = 0; idx < num_mem_chunks; ++idx) {
11237 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11238 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11239 WMITLV_GET_STRUCT_TLVLEN
11240 (wlan_host_memory_chunk));
11241 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11242 host_mem_chunks[idx].size = mem_chunks[idx].len;
11243 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
11244 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
11245 idx, host_mem_chunks[idx].size,
11246 host_mem_chunks[idx].ptr);
11247 }
11248 cmd->num_host_mem_chunks = num_mem_chunks;
11249 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11250 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11251 WMITLV_TAG_ARRAY_STRUC,
11252 (sizeof(wlan_host_memory_chunk) *
11253 num_mem_chunks));
11254
11255 num_whitelist = sizeof(version_whitelist) /
11256 sizeof(wmi_whitelist_version_info);
11257 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11258 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11259 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11260 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11261 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11262 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
11263
Govind Singh87542482016-06-08 19:40:11 +053011264#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011265 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11266 &my_vers,
11267 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
11268 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011269#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011270 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
11271 __func__,
11272 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11273 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11274 cmd->host_abi_vers.abi_version_ns_0,
11275 cmd->host_abi_vers.abi_version_ns_1,
11276 cmd->host_abi_vers.abi_version_ns_2,
11277 cmd->host_abi_vers.abi_version_ns_3);
11278
11279 /* Save version sent from host -
11280 * Will be used to check ready event
11281 */
Govind Singh87542482016-06-08 19:40:11 +053011282#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011283 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
11284 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011285#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053011286 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
11287 if (QDF_IS_STATUS_ERROR(ret)) {
11288 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
11289 ret);
11290 wmi_buf_free(buf);
11291 }
11292 return ret;
11293
Govind Singhe7f2f342016-05-23 12:12:52 +053011294}
11295
11296/**
11297 * save_service_bitmap_tlv() - save service bitmap
11298 * @wmi_handle: wmi handle
11299 * @param evt_buf: pointer to event buffer
11300 *
11301 * Return: None
11302 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011303#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011304void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11305{
11306 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11307 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11308
11309 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
11310 param_buf->wmi_service_bitmap,
11311 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
11312}
11313#else
11314void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11315{
11316 return;
11317}
11318
11319#endif
11320
11321/**
11322 * is_service_enabled_tlv() - Check if service enabled
11323 * @param wmi_handle: wmi handle
11324 * @param service_id: service identifier
11325 *
11326 * Return: 1 enabled, 0 disabled
11327 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011328#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011329static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11330 uint32_t service_id)
11331{
11332 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
11333 service_id);
11334}
11335#else
11336static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11337 uint32_t service_id)
11338{
11339 return false;
11340}
11341#endif
11342
11343/**
11344 * extract_service_ready_tlv() - extract service ready event
11345 * @wmi_handle: wmi handle
11346 * @param evt_buf: pointer to received event buffer
11347 * @param cap: pointer to hold target capability information extracted from even
11348 *
11349 * Return: QDF_STATUS_SUCCESS for success or error code
11350 */
11351static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
11352 void *evt_buf, target_capability_info *cap)
11353{
11354 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11355 wmi_service_ready_event_fixed_param *ev;
11356
11357
11358 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11359
11360 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11361 if (!ev) {
11362 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11363 return QDF_STATUS_E_FAILURE;
11364 }
11365
11366 cap->phy_capability = ev->phy_capability;
11367 cap->max_frag_entry = ev->max_frag_entry;
11368 cap->num_rf_chains = ev->num_rf_chains;
11369 cap->ht_cap_info = ev->ht_cap_info;
11370 cap->vht_cap_info = ev->vht_cap_info;
11371 cap->vht_supp_mcs = ev->vht_supp_mcs;
11372 cap->hw_min_tx_power = ev->hw_min_tx_power;
11373 cap->hw_max_tx_power = ev->hw_max_tx_power;
11374 cap->sys_cap_info = ev->sys_cap_info;
11375 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
11376 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
11377 cap->max_num_scan_channels = ev->max_num_scan_channels;
11378 cap->max_supported_macs = ev->max_supported_macs;
11379 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
11380 cap->txrx_chainmask = ev->txrx_chainmask;
11381 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
11382 cap->num_msdu_desc = ev->num_msdu_desc;
11383
11384 return QDF_STATUS_SUCCESS;
11385}
11386
11387/**
11388 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
11389 * @wmi_handle: wmi handle
11390 * @param evt_buf: Pointer to event buffer
11391 * @param cap: pointer to hold HAL reg capabilities
11392 *
11393 * Return: QDF_STATUS_SUCCESS for success or error code
11394 */
11395static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
11396 void *evt_buf, TARGET_HAL_REG_CAPABILITIES *cap)
11397{
11398 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11399
11400 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11401
11402 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
11403 sizeof(uint32_t)),
11404 sizeof(TARGET_HAL_REG_CAPABILITIES));
11405
11406 return QDF_STATUS_SUCCESS;
11407}
11408
11409/**
11410 * extract_host_mem_req_tlv() - Extract host memory request event
11411 * @wmi_handle: wmi handle
11412 * @param evt_buf: pointer to event buffer
11413 * @param num_entries: pointer to hold number of entries requested
11414 *
11415 * Return: Number of entries requested
11416 */
11417static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
11418 void *evt_buf, uint8_t *num_entries)
11419{
11420 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11421 wmi_service_ready_event_fixed_param *ev;
11422
11423 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11424
11425 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11426 if (!ev) {
11427 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11428 return NULL;
11429 }
11430
11431 *num_entries = ev->num_mem_reqs;
11432
11433 return (host_mem_req *)param_buf->mem_reqs;
11434}
11435
11436/**
11437 * save_fw_version_in_service_ready_tlv() - Save fw version in service
11438 * ready function
11439 * @wmi_handle: wmi handle
11440 * @param evt_buf: pointer to event buffer
11441 *
11442 * Return: QDF_STATUS_SUCCESS for success or error code
11443 */
11444static QDF_STATUS
11445save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11446{
11447 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11448 wmi_service_ready_event_fixed_param *ev;
11449
11450
11451 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11452
11453 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11454 if (!ev) {
11455 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11456 return QDF_STATUS_E_FAILURE;
11457 }
11458
Govind Singh87542482016-06-08 19:40:11 +053011459#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011460 /*Save fw version from service ready message */
11461 /*This will be used while sending INIT message */
11462 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
11463 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011464#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011465 return QDF_STATUS_SUCCESS;
11466}
11467
11468/**
11469 * ready_extract_init_status_tlv() - Extract init status from ready event
11470 * @wmi_handle: wmi handle
11471 * @param evt_buf: Pointer to event buffer
11472 *
11473 * Return: ready status
11474 */
11475static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
11476 void *evt_buf)
11477{
11478 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11479 wmi_ready_event_fixed_param *ev = NULL;
11480
11481
11482 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11483 ev = param_buf->fixed_param;
11484
11485 qdf_print("%s:%d\n", __func__, ev->status);
11486
11487 return ev->status;
11488}
11489
11490/**
11491 * ready_extract_mac_addr_tlv() - extract mac address from ready event
11492 * @wmi_handle: wmi handle
11493 * @param evt_buf: pointer to event buffer
11494 * @param macaddr: Pointer to hold MAC address
11495 *
11496 * Return: QDF_STATUS_SUCCESS for success or error code
11497 */
11498static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
11499 void *evt_buf, uint8_t *macaddr)
11500{
11501 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11502 wmi_ready_event_fixed_param *ev = NULL;
11503
11504
11505 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11506 ev = param_buf->fixed_param;
11507
11508 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
11509
11510 return QDF_STATUS_SUCCESS;
11511}
11512
11513/**
11514 * extract_dbglog_data_len_tlv() - extract debuglog data length
11515 * @wmi_handle: wmi handle
11516 * @param evt_buf: pointer to event buffer
11517 *
11518 * Return: length
11519 */
11520static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
11521 void *evt_buf, uint16_t *len)
11522{
11523 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
11524
11525 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
11526
11527 *len = param_buf->num_bufp;
11528
11529 return param_buf->bufp;
11530}
11531
11532/**
11533 * extract_vdev_start_resp_tlv() - extract vdev start response
11534 * @wmi_handle: wmi handle
11535 * @param evt_buf: pointer to event buffer
11536 * @param vdev_rsp: Pointer to hold vdev response
11537 *
11538 * Return: QDF_STATUS_SUCCESS for success or error code
11539 */
11540static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
11541 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
11542{
11543 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
11544 wmi_vdev_start_response_event_fixed_param *ev;
11545
11546 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
11547 if (!param_buf) {
11548 qdf_print("Invalid start response event buffer\n");
11549 return QDF_STATUS_E_INVAL;
11550 }
11551
11552 ev = param_buf->fixed_param;
11553 if (!ev) {
11554 qdf_print("Invalid start response event buffer\n");
11555 return QDF_STATUS_E_INVAL;
11556 }
11557
11558 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
11559
11560 vdev_rsp->vdev_id = ev->vdev_id;
11561 vdev_rsp->requestor_id = ev->requestor_id;
11562 vdev_rsp->resp_type = ev->resp_type;
11563 vdev_rsp->status = ev->status;
11564 vdev_rsp->chain_mask = ev->chain_mask;
11565 vdev_rsp->smps_mode = ev->smps_mode;
11566 vdev_rsp->mac_id = ev->mac_id;
11567 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
11568 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
11569
11570 return QDF_STATUS_SUCCESS;
11571}
11572
11573/**
11574 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
11575 * @wmi_handle: wmi handle
11576 * @param evt_buf: pointer to event buffer
11577 * @param vdev_map: Pointer to hold vdev map
11578 * @param tbttoffset_list: Pointer to tbtt offset list
11579 *
11580 * Return: QDF_STATUS_SUCCESS for success or error code
11581 */
11582static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
11583 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
11584{
11585 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
11586 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
11587
11588 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
11589 if (!param_buf) {
11590 qdf_print("Invalid tbtt update event buffer\n");
11591 return QDF_STATUS_E_INVAL;
11592 }
11593 tbtt_offset_event = param_buf->fixed_param;
11594
11595 *vdev_map = tbtt_offset_event->vdev_map;
11596 *tbttoffset_list = param_buf->tbttoffset_list;
11597
11598 return QDF_STATUS_SUCCESS;
11599}
11600
11601/**
11602 * extract_mgmt_rx_params_tlv() - extract management rx params from event
11603 * @wmi_handle: wmi handle
11604 * @param evt_buf: pointer to event buffer
11605 * @param hdr: Pointer to hold header
11606 * @param bufp: Pointer to hold pointer to rx param buffer
11607 *
11608 * Return: QDF_STATUS_SUCCESS for success or error code
11609 */
11610static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
11611 void *evt_buf, wmi_host_mgmt_rx_hdr *hdr, uint8_t **bufp)
11612{
11613 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
11614 wmi_mgmt_rx_hdr *ev_hdr = NULL;
11615
11616 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
11617 if (!param_tlvs) {
11618 WMI_LOGE("Get NULL point message from FW");
11619 return QDF_STATUS_E_INVAL;
11620 }
11621
11622 ev_hdr = param_tlvs->hdr;
11623 if (!hdr) {
11624 WMI_LOGE("Rx event is NULL");
11625 return QDF_STATUS_E_INVAL;
11626 }
11627
11628
11629 hdr->channel = ev_hdr->channel;
11630 hdr->snr = ev_hdr->snr;
11631 hdr->rate = ev_hdr->rate;
11632 hdr->phy_mode = ev_hdr->phy_mode;
11633 hdr->buf_len = ev_hdr->buf_len;
11634 hdr->status = ev_hdr->status;
11635 hdr->flags = ev_hdr->flags;
11636 hdr->rssi = ev_hdr->rssi;
11637 hdr->tsf_delta = ev_hdr->tsf_delta;
11638 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
11639
11640 *bufp = param_tlvs->bufp;
11641
11642 return QDF_STATUS_SUCCESS;
11643}
11644
11645/**
11646 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
11647 * @wmi_handle: wmi handle
11648 * @param evt_buf: pointer to event buffer
11649 * @param vdev_id: Pointer to hold vdev identifier
11650 *
11651 * Return: QDF_STATUS_SUCCESS for success or error code
11652 */
11653static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
11654 void *evt_buf, uint32_t *vdev_id)
11655{
11656 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
11657 wmi_vdev_stopped_event_fixed_param *resp_event;
11658
11659 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
11660 if (!param_buf) {
11661 WMI_LOGE("Invalid event buffer");
11662 return QDF_STATUS_E_INVAL;
11663 }
11664 resp_event = param_buf->fixed_param;
11665 *vdev_id = resp_event->vdev_id;
11666
11667 return QDF_STATUS_SUCCESS;
11668}
11669
11670/**
11671 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
11672 * @wmi_handle: wmi handle
11673 * @param evt_buf: pointer to event buffer
11674 * @param param: Pointer to hold roam param
11675 *
11676 * Return: QDF_STATUS_SUCCESS for success or error code
11677 */
11678static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
11679 void *evt_buf, wmi_host_roam_event *param)
11680{
11681 WMI_ROAM_EVENTID_param_tlvs *param_buf;
11682 wmi_roam_event_fixed_param *evt;
11683
11684 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
11685 if (!param_buf) {
11686 WMI_LOGE("Invalid roam event buffer");
11687 return QDF_STATUS_E_INVAL;
11688 }
11689
11690 evt = param_buf->fixed_param;
11691 qdf_mem_zero(param, sizeof(*param));
11692
11693 param->vdev_id = evt->vdev_id;
11694 param->reason = evt->reason;
11695 param->rssi = evt->rssi;
11696
11697 return QDF_STATUS_SUCCESS;
11698}
11699
11700/**
11701 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
11702 * @wmi_handle: wmi handle
11703 * @param evt_buf: pointer to event buffer
11704 * @param param: Pointer to hold vdev scan param
11705 *
11706 * Return: QDF_STATUS_SUCCESS for success or error code
11707 */
11708static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
11709 void *evt_buf, wmi_host_scan_event *param)
11710{
11711 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
11712 wmi_scan_event_fixed_param *evt = NULL;
11713
11714 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
11715 evt = param_buf->fixed_param;
11716
11717 qdf_mem_zero(param, sizeof(*param));
11718 switch (evt->event) {
11719 case WMI_SCAN_EVENT_STARTED:
11720 param->event = WMI_HOST_SCAN_EVENT_STARTED;
11721 break;
11722 case WMI_SCAN_EVENT_COMPLETED:
11723 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
11724 break;
11725 case WMI_SCAN_EVENT_BSS_CHANNEL:
11726 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
11727 break;
11728 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
11729 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
11730 break;
11731 case WMI_SCAN_EVENT_DEQUEUED:
11732 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
11733 break;
11734 case WMI_SCAN_EVENT_PREEMPTED:
11735 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
11736 break;
11737 case WMI_SCAN_EVENT_START_FAILED:
11738 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
11739 break;
11740 case WMI_SCAN_EVENT_RESTARTED:
11741 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
11742 break;
11743 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
11744 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
11745 break;
11746 case WMI_SCAN_EVENT_MAX:
11747 default:
11748 param->event = WMI_HOST_SCAN_EVENT_MAX;
11749 break;
11750 };
11751
11752 switch (evt->reason) {
11753 case WMI_SCAN_REASON_NONE:
11754 param->reason = WMI_HOST_SCAN_REASON_NONE;
11755 break;
11756 case WMI_SCAN_REASON_COMPLETED:
11757 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
11758 break;
11759 case WMI_SCAN_REASON_CANCELLED:
11760 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
11761 break;
11762 case WMI_SCAN_REASON_PREEMPTED:
11763 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
11764 break;
11765 case WMI_SCAN_REASON_TIMEDOUT:
11766 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
11767 break;
11768 case WMI_SCAN_REASON_INTERNAL_FAILURE:
11769 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
11770 break;
11771 case WMI_SCAN_REASON_MAX:
11772 default:
11773 param->reason = WMI_HOST_SCAN_REASON_MAX;
11774 break;
11775 };
11776
11777 param->channel_freq = evt->channel_freq;
11778 param->requestor = evt->requestor;
11779 param->scan_id = evt->scan_id;
11780 param->vdev_id = evt->vdev_id;
11781
11782 return QDF_STATUS_SUCCESS;
11783}
11784
11785/**
11786 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
11787 * @wmi_handle: wmi handle
11788 * @param evt_buf: pointer to event buffer
11789 * @param param: Pointer to hold MGMT TX completion params
11790 *
11791 * Return: QDF_STATUS_SUCCESS for success or error code
11792 */
11793static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
11794 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
11795{
11796 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
11797 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
11798
11799 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
11800 evt_buf;
11801 if (!param_buf) {
11802 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
11803 return QDF_STATUS_E_INVAL;
11804 }
11805 cmpl_params = param_buf->fixed_param;
11806
11807 param->desc_id = cmpl_params->desc_id;
11808 param->status = cmpl_params->status;
11809
11810 return QDF_STATUS_SUCCESS;
11811}
11812
11813/**
11814 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
11815 * @wmi_handle: wmi handle
11816 * @param evt_buf: pointer to event buffer
11817 * @param vdev_map: Pointer to hold vdev map
11818 *
11819 * Return: QDF_STATUS_SUCCESS for success or error code
11820 */
11821static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
11822 void *evt_buf, uint32_t *vdev_map)
11823{
11824 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
11825 wmi_host_swba_event_fixed_param *swba_event;
11826
11827 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
11828 if (!param_buf) {
11829 WMI_LOGE("Invalid swba event buffer");
11830 return QDF_STATUS_E_INVAL;
11831 }
11832 swba_event = param_buf->fixed_param;
11833 *vdev_map = swba_event->vdev_map;
11834
11835 return QDF_STATUS_SUCCESS;
11836}
11837
11838/**
11839 * extract_swba_tim_info_tlv() - extract swba tim info from event
11840 * @wmi_handle: wmi handle
11841 * @param evt_buf: pointer to event buffer
11842 * @param idx: Index to bcn info
11843 * @param tim_info: Pointer to hold tim info
11844 *
11845 * Return: QDF_STATUS_SUCCESS for success or error code
11846 */
11847static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
11848 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
11849{
11850 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
11851 wmi_tim_info *tim_info_ev;
11852
11853 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
11854 if (!param_buf) {
11855 WMI_LOGE("Invalid swba event buffer");
11856 return QDF_STATUS_E_INVAL;
11857 }
11858
11859 tim_info_ev = &param_buf->tim_info[idx];
11860
11861 tim_info->tim_len = tim_info_ev->tim_len;
11862 tim_info->tim_mcast = tim_info_ev->tim_mcast;
11863 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
11864 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
11865 tim_info->tim_changed = tim_info_ev->tim_changed;
11866 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
11867
11868 return QDF_STATUS_SUCCESS;
11869}
11870
11871/**
11872 * extract_swba_noa_info_tlv() - extract swba NoA information from event
11873 * @wmi_handle: wmi handle
11874 * @param evt_buf: pointer to event buffer
11875 * @param idx: Index to bcn info
11876 * @param p2p_desc: Pointer to hold p2p NoA info
11877 *
11878 * Return: QDF_STATUS_SUCCESS for success or error code
11879 */
11880static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
11881 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
11882{
11883 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
11884 wmi_p2p_noa_info *p2p_noa_info;
11885 uint8_t i = 0;
11886
11887 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
11888 if (!param_buf) {
11889 WMI_LOGE("Invalid swba event buffer");
11890 return QDF_STATUS_E_INVAL;
11891 }
11892
11893 p2p_noa_info = &param_buf->p2p_noa_info[idx];
11894
11895 p2p_desc->modified = false;
11896 p2p_desc->num_descriptors = 0;
11897 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
11898 p2p_desc->modified = true;
11899 p2p_desc->index =
11900 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
11901 p2p_desc->oppPS =
11902 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
11903 p2p_desc->ctwindow =
11904 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
11905 p2p_desc->num_descriptors =
11906 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
11907 (p2p_noa_info);
11908 for (i = 0; i < p2p_desc->num_descriptors; i++) {
11909 p2p_desc->noa_descriptors[i].type_count =
11910 (uint8_t) p2p_noa_info->noa_descriptors[i].
11911 type_count;
11912 p2p_desc->noa_descriptors[i].duration =
11913 p2p_noa_info->noa_descriptors[i].duration;
11914 p2p_desc->noa_descriptors[i].interval =
11915 p2p_noa_info->noa_descriptors[i].interval;
11916 p2p_desc->noa_descriptors[i].start_time =
11917 p2p_noa_info->noa_descriptors[i].start_time;
11918 }
11919 }
11920
11921 return QDF_STATUS_SUCCESS;
11922}
11923
11924/**
11925 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
11926 * @wmi_handle: wmi handle
11927 * @param evt_buf: pointer to event buffer
11928 * @param ev: Pointer to hold peer param
11929 *
11930 * Return: QDF_STATUS_SUCCESS for success or error code
11931 */
11932static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
11933 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
11934{
11935 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
11936 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
11937
11938 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
11939 kickout_event = param_buf->fixed_param;
11940
11941 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
11942 ev->peer_macaddr);
11943
11944 ev->reason = kickout_event->reason;
11945 ev->rssi = kickout_event->rssi;
11946
11947 return QDF_STATUS_SUCCESS;
11948}
11949
11950/**
11951 * extract_all_stats_counts_tlv() - extract all stats count from event
11952 * @wmi_handle: wmi handle
11953 * @param evt_buf: pointer to event buffer
11954 * @param stats_param: Pointer to hold stats count
11955 *
11956 * Return: QDF_STATUS_SUCCESS for success or error code
11957 */
11958static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
11959 void *evt_buf, wmi_host_stats_event *stats_param)
11960{
11961 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
11962 wmi_stats_event_fixed_param *ev;
11963
11964 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
11965
11966 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
11967 if (!ev) {
11968 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
11969 return QDF_STATUS_E_FAILURE;
11970 }
11971
11972 switch (ev->stats_id) {
11973 case WMI_REQUEST_PEER_STAT:
11974 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
11975 break;
11976
11977 case WMI_REQUEST_AP_STAT:
11978 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
11979 break;
11980
11981 case WMI_REQUEST_PDEV_STAT:
11982 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
11983 break;
11984
11985 case WMI_REQUEST_VDEV_STAT:
11986 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
11987 break;
11988
11989 case WMI_REQUEST_BCNFLT_STAT:
11990 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
11991 break;
11992
11993 case WMI_REQUEST_VDEV_RATE_STAT:
11994 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
11995 break;
11996
11997 default:
11998 stats_param->stats_id = 0;
11999 break;
12000
12001 }
12002
12003 stats_param->num_pdev_stats = ev->num_pdev_stats;
12004 stats_param->num_pdev_ext_stats = 0;
12005 stats_param->num_vdev_stats = ev->num_vdev_stats;
12006 stats_param->num_peer_stats = ev->num_peer_stats;
12007 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
12008 stats_param->num_chan_stats = ev->num_chan_stats;
12009
12010 return QDF_STATUS_SUCCESS;
12011}
12012
12013/**
12014 * extract_pdev_stats_tlv() - extract pdev stats from event
12015 * @wmi_handle: wmi handle
12016 * @param evt_buf: pointer to event buffer
12017 * @param index: Index into pdev stats
12018 * @param pdev_stats: Pointer to hold pdev stats
12019 *
12020 * Return: QDF_STATUS_SUCCESS for success or error code
12021 */
12022static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
12023 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
12024{
12025 return QDF_STATUS_SUCCESS;
12026}
12027
12028/**
12029 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
12030 * @wmi_handle: wmi handle
12031 * @param evt_buf: pointer to event buffer
12032 * @param index: Index into extended pdev stats
12033 * @param pdev_ext_stats: Pointer to hold extended pdev stats
12034 *
12035 * Return: QDF_STATUS_SUCCESS for success or error code
12036 */
12037static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
12038 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
12039{
12040 return QDF_STATUS_SUCCESS;
12041}
12042
12043/**
12044 * extract_vdev_stats_tlv() - extract vdev stats from event
12045 * @wmi_handle: wmi handle
12046 * @param evt_buf: pointer to event buffer
12047 * @param index: Index into vdev stats
12048 * @param vdev_stats: Pointer to hold vdev stats
12049 *
12050 * Return: QDF_STATUS_SUCCESS for success or error code
12051 */
12052static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
12053 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
12054{
12055 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12056 wmi_stats_event_fixed_param *ev_param;
12057 uint8_t *data;
12058
12059 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12060 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12061 data = (uint8_t *) param_buf->data;
12062
12063 if (index < ev_param->num_vdev_stats) {
12064 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
12065 ((ev_param->num_pdev_stats) *
12066 sizeof(wmi_pdev_stats)) +
12067 (index * sizeof(wmi_vdev_stats)));
12068
12069 vdev_stats->vdev_id = ev->vdev_id;
12070 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
12071 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
12072
12073 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
12074 sizeof(ev->tx_frm_cnt));
12075 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
12076 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
12077 ev->multiple_retry_cnt,
12078 sizeof(ev->multiple_retry_cnt));
12079 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
12080 sizeof(ev->fail_cnt));
12081 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
12082 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
12083 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
12084 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
12085 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
12086 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
12087 sizeof(ev->tx_rate_history));
12088 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
12089 sizeof(ev->bcn_rssi_history));
12090
12091 }
12092
12093 return QDF_STATUS_SUCCESS;
12094}
12095
12096/**
12097 * extract_peer_stats_tlv() - extract peer stats from event
12098 * @wmi_handle: wmi handle
12099 * @param evt_buf: pointer to event buffer
12100 * @param index: Index into peer stats
12101 * @param peer_stats: Pointer to hold peer stats
12102 *
12103 * Return: QDF_STATUS_SUCCESS for success or error code
12104 */
12105static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
12106 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
12107{
12108 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12109 wmi_stats_event_fixed_param *ev_param;
12110 uint8_t *data;
12111
12112 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12113 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12114 data = (uint8_t *) param_buf->data;
12115
12116 if (index < ev_param->num_peer_stats) {
12117 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
12118 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12119 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12120 (index * sizeof(wmi_peer_stats)));
12121
12122 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
12123
12124 OS_MEMCPY(&(peer_stats->peer_macaddr),
12125 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
12126
12127 peer_stats->peer_rssi = ev->peer_rssi;
12128 peer_stats->peer_tx_rate = ev->peer_tx_rate;
12129 peer_stats->peer_rx_rate = ev->peer_rx_rate;
12130 }
12131
12132 return QDF_STATUS_SUCCESS;
12133}
12134
12135/**
12136 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
12137 * @wmi_handle: wmi handle
12138 * @param evt_buf: pointer to event buffer
12139 * @param index: Index into bcn fault stats
12140 * @param bcnflt_stats: Pointer to hold bcn fault stats
12141 *
12142 * Return: QDF_STATUS_SUCCESS for success or error code
12143 */
12144static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
12145 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
12146{
12147 return QDF_STATUS_SUCCESS;
12148}
12149
12150/**
12151 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
12152 * @wmi_handle: wmi handle
12153 * @param evt_buf: pointer to event buffer
12154 * @param index: Index into extended peer stats
12155 * @param peer_extd_stats: Pointer to hold extended peer stats
12156 *
12157 * Return: QDF_STATUS_SUCCESS for success or error code
12158 */
12159static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
12160 void *evt_buf, uint32_t index,
12161 wmi_host_peer_extd_stats *peer_extd_stats)
12162{
12163 return QDF_STATUS_SUCCESS;
12164}
12165
12166/**
12167 * extract_chan_stats_tlv() - extract chan stats from event
12168 * @wmi_handle: wmi handle
12169 * @param evt_buf: pointer to event buffer
12170 * @param index: Index into chan stats
12171 * @param vdev_extd_stats: Pointer to hold chan stats
12172 *
12173 * Return: QDF_STATUS_SUCCESS for success or error code
12174 */
12175static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
12176 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
12177{
12178 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12179 wmi_stats_event_fixed_param *ev_param;
12180 uint8_t *data;
12181
12182 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12183 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12184 data = (uint8_t *) param_buf->data;
12185
12186 if (index < ev_param->num_chan_stats) {
12187 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
12188 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12189 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12190 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
12191 (index * sizeof(wmi_chan_stats)));
12192
12193
12194 /* Non-TLV doesnt have num_chan_stats */
12195 chan_stats->chan_mhz = ev->chan_mhz;
12196 chan_stats->sampling_period_us = ev->sampling_period_us;
12197 chan_stats->rx_clear_count = ev->rx_clear_count;
12198 chan_stats->tx_duration_us = ev->tx_duration_us;
12199 chan_stats->rx_duration_us = ev->rx_duration_us;
12200 }
12201
12202 return QDF_STATUS_SUCCESS;
12203}
12204
12205/**
12206 * extract_profile_ctx_tlv() - extract profile context from event
12207 * @wmi_handle: wmi handle
12208 * @param evt_buf: pointer to event buffer
12209 * @idx: profile stats index to extract
12210 * @param profile_ctx: Pointer to hold profile context
12211 *
12212 * Return: QDF_STATUS_SUCCESS for success or error code
12213 */
12214static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
12215 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
12216{
12217 return QDF_STATUS_SUCCESS;
12218}
12219
12220/**
12221 * extract_profile_data_tlv() - extract profile data from event
12222 * @wmi_handle: wmi handle
12223 * @param evt_buf: pointer to event buffer
12224 * @param profile_data: Pointer to hold profile data
12225 *
12226 * Return: QDF_STATUS_SUCCESS for success or error code
12227 */
12228static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
12229 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
12230{
12231
12232 return QDF_STATUS_SUCCESS;
12233}
12234
12235/**
12236 * extract_chan_info_event_tlv() - extract chan information from event
12237 * @wmi_handle: wmi handle
12238 * @param evt_buf: pointer to event buffer
12239 * @param chan_info: Pointer to hold chan information
12240 *
12241 * Return: QDF_STATUS_SUCCESS for success or error code
12242 */
12243static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
12244 void *evt_buf, wmi_host_chan_info_event *chan_info)
12245{
12246 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
12247 wmi_chan_info_event_fixed_param *ev;
12248
12249 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
12250
12251 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
12252 if (!ev) {
12253 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
12254 return QDF_STATUS_E_FAILURE;
12255 }
12256
12257 chan_info->err_code = ev->err_code;
12258 chan_info->freq = ev->freq;
12259 chan_info->cmd_flags = ev->cmd_flags;
12260 chan_info->noise_floor = ev->noise_floor;
12261 chan_info->rx_clear_count = ev->rx_clear_count;
12262 chan_info->cycle_count = ev->cycle_count;
12263
12264 return QDF_STATUS_SUCCESS;
12265}
12266
12267/**
12268 * extract_channel_hopping_event_tlv() - extract channel hopping param
12269 * from event
12270 * @wmi_handle: wmi handle
12271 * @param evt_buf: pointer to event buffer
12272 * @param ch_hopping: Pointer to hold channel hopping param
12273 *
12274 * Return: QDF_STATUS_SUCCESS for success or error code
12275 */
12276static QDF_STATUS extract_channel_hopping_event_tlv(wmi_unified_t wmi_handle,
12277 void *evt_buf, wmi_host_pdev_channel_hopping_event *chan_info)
12278{
12279 return QDF_STATUS_SUCCESS;
12280}
12281
Govind Singh06c18392016-06-10 10:33:19 +053012282#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhecf03cd2016-05-12 12:45:51 +053012283static bool is_management_record_tlv(uint32_t cmd_id)
12284{
12285 if ((cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
12286 (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID))
12287 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053012288
Govind Singhecf03cd2016-05-12 12:45:51 +053012289 return false;
12290}
Govind Singh06c18392016-06-10 10:33:19 +053012291#endif
Govind Singhecf03cd2016-05-12 12:45:51 +053012292
Govind Singh5eb51532016-03-09 11:34:12 +053012293struct wmi_ops tlv_ops = {
12294 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
12295 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
12296 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053012297 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
12298 .send_hidden_ssid_vdev_restart_cmd =
12299 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012300 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
12301 .send_peer_param_cmd = send_peer_param_cmd_tlv,
12302 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012303 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012304 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012305 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012306 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
12307 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
12308 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
12309 .send_suspend_cmd = send_suspend_cmd_tlv,
12310 .send_resume_cmd = send_resume_cmd_tlv,
12311 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
12312 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
12313 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
12314 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
12315 .send_dbglog_cmd = send_dbglog_cmd_tlv,
12316 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
12317 .send_stats_request_cmd = send_stats_request_cmd_tlv,
12318 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
12319 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012320#ifndef CONFIG_MCL
12321 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
12322#endif
Govind Singh5eb51532016-03-09 11:34:12 +053012323 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
12324 .send_scan_start_cmd = send_scan_start_cmd_tlv,
12325 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
12326 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012327 .send_mgmt_cmd = send_mgmt_cmd_tlv,
12328 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
12329 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012330 .send_set_sta_uapsd_auto_trig_cmd =
12331 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012332 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
12333 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
12334 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
12335 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
12336 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053012337 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
12338 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
12339 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
12340 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
12341 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
12342 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
12343 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012344 .send_ocb_start_timing_advert_cmd =
12345 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053012346 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
12347 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
12348 .send_set_mcc_channel_time_latency_cmd =
12349 send_set_mcc_channel_time_latency_cmd_tlv,
12350 .send_set_mcc_channel_time_quota_cmd =
12351 send_set_mcc_channel_time_quota_cmd_tlv,
12352 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
12353 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053012354 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012355 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
12356 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
12357 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012358 .send_probe_rsp_tmpl_send_cmd =
12359 send_probe_rsp_tmpl_send_cmd_tlv,
12360 .send_p2p_go_set_beacon_ie_cmd =
12361 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053012362 .send_setup_install_key_cmd =
12363 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012364 .send_set_gateway_params_cmd =
12365 send_set_gateway_params_cmd_tlv,
12366 .send_set_rssi_monitoring_cmd =
12367 send_set_rssi_monitoring_cmd_tlv,
12368 .send_scan_probe_setoui_cmd =
12369 send_scan_probe_setoui_cmd_tlv,
12370 .send_reset_passpoint_network_list_cmd =
12371 send_reset_passpoint_network_list_cmd_tlv,
12372 .send_set_passpoint_network_list_cmd =
12373 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053012374 .send_roam_scan_offload_rssi_thresh_cmd =
12375 send_roam_scan_offload_rssi_thresh_cmd_tlv,
12376 .send_roam_scan_filter_cmd =
12377 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012378 .send_set_epno_network_list_cmd =
12379 send_set_epno_network_list_cmd_tlv,
12380 .send_ipa_offload_control_cmd =
12381 send_ipa_offload_control_cmd_tlv,
12382 .send_extscan_get_capabilities_cmd =
12383 send_extscan_get_capabilities_cmd_tlv,
12384 .send_extscan_get_cached_results_cmd =
12385 send_extscan_get_cached_results_cmd_tlv,
12386 .send_extscan_stop_change_monitor_cmd =
12387 send_extscan_stop_change_monitor_cmd_tlv,
12388 .send_extscan_start_change_monitor_cmd =
12389 send_extscan_start_change_monitor_cmd_tlv,
12390 .send_extscan_stop_hotlist_monitor_cmd =
12391 send_extscan_stop_hotlist_monitor_cmd_tlv,
12392 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
12393 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
12394 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
12395 .send_plm_start_cmd = send_plm_start_cmd_tlv,
12396 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012397#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053012398 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012399#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053012400 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
12401 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
12402 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
12403 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
12404 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053012405 .send_snr_request_cmd = send_snr_request_cmd_tlv,
12406 .send_snr_cmd = send_snr_cmd_tlv,
12407 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012408#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053012409 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
12410 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
12411 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
12412 .send_lphb_config_udp_pkt_filter_cmd =
12413 send_lphb_config_udp_pkt_filter_cmd_tlv,
12414 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
12415 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
12416 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012417 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
12418 .send_process_update_edca_param_cmd =
12419 send_process_update_edca_param_cmd_tlv,
12420 .send_roam_scan_offload_mode_cmd =
12421 send_roam_scan_offload_mode_cmd_tlv,
12422 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
12423 .send_roam_scan_offload_ap_profile_cmd =
12424 send_roam_scan_offload_ap_profile_cmd_tlv,
12425#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053012426 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
12427 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012428#ifdef FEATURE_WLAN_RA_FILTERING
Govind Singh20c5dac2016-03-07 15:33:31 +053012429 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012430#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053012431 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
12432 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
12433 .send_dfs_phyerr_filter_offload_en_cmd =
12434 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053012435 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
12436 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
12437 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
12438 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
12439 .send_del_ts_cmd = send_del_ts_cmd_tlv,
12440 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
12441 .send_add_ts_cmd = send_add_ts_cmd_tlv,
12442 .send_enable_disable_packet_filter_cmd =
12443 send_enable_disable_packet_filter_cmd_tlv,
12444 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
12445 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
12446 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
12447 .send_process_gtk_offload_getinfo_cmd =
12448 send_process_gtk_offload_getinfo_cmd_tlv,
12449 .send_process_add_periodic_tx_ptrn_cmd =
12450 send_process_add_periodic_tx_ptrn_cmd_tlv,
12451 .send_process_del_periodic_tx_ptrn_cmd =
12452 send_process_del_periodic_tx_ptrn_cmd_tlv,
12453 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
12454 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
12455 .send_set_app_type2_params_in_fw_cmd =
12456 send_set_app_type2_params_in_fw_cmd_tlv,
12457 .send_set_auto_shutdown_timer_cmd =
12458 send_set_auto_shutdown_timer_cmd_tlv,
12459 .send_nan_req_cmd = send_nan_req_cmd_tlv,
12460 .send_process_dhcpserver_offload_cmd =
12461 send_process_dhcpserver_offload_cmd_tlv,
12462 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
12463 .send_process_ch_avoid_update_cmd =
12464 send_process_ch_avoid_update_cmd_tlv,
12465 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
12466 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
12467 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
12468 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
12469 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
12470 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012471#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012472 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012473#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012474 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053012475 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053012476 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053012477 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012478 .send_set_base_macaddr_indicate_cmd =
12479 send_set_base_macaddr_indicate_cmd_tlv,
12480 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
12481 .send_enable_specific_fw_logs_cmd =
12482 send_enable_specific_fw_logs_cmd_tlv,
12483 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012484 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012485 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012486 .send_pdev_set_dual_mac_config_cmd =
12487 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012488 .send_enable_arp_ns_offload_cmd =
12489 send_enable_arp_ns_offload_cmd_tlv,
12490 .send_app_type1_params_in_fw_cmd =
12491 send_app_type1_params_in_fw_cmd_tlv,
12492 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
12493 .send_process_roam_synch_complete_cmd =
12494 send_process_roam_synch_complete_cmd_tlv,
12495 .send_unit_test_cmd = send_unit_test_cmd_tlv,
12496 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
12497 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012498 .send_roam_scan_offload_scan_period_cmd =
12499 send_roam_scan_offload_scan_period_cmd_tlv,
12500 .send_roam_scan_offload_chan_list_cmd =
12501 send_roam_scan_offload_chan_list_cmd_tlv,
12502 .send_roam_scan_offload_rssi_change_cmd =
12503 send_roam_scan_offload_rssi_change_cmd_tlv,
12504 .send_get_buf_extscan_hotlist_cmd =
12505 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053012506 .send_adapt_dwelltime_params_cmd =
12507 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053012508 .init_cmd_send = init_cmd_send_tlv,
12509 .get_target_cap_from_service_ready = extract_service_ready_tlv,
12510 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
12511 .extract_host_mem_req = extract_host_mem_req_tlv,
12512 .save_service_bitmap = save_service_bitmap_tlv,
12513 .is_service_enabled = is_service_enabled_tlv,
12514 .save_fw_version = save_fw_version_in_service_ready_tlv,
12515 .ready_extract_init_status = ready_extract_init_status_tlv,
12516 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
12517 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
12518 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
12519 .extract_tbttoffset_update_params =
12520 extract_tbttoffset_update_params_tlv,
12521 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
12522 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
12523 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
12524 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
12525 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
12526 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
12527 .extract_swba_tim_info = extract_swba_tim_info_tlv,
12528 .extract_swba_noa_info = extract_swba_noa_info_tlv,
12529 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
12530 .extract_all_stats_count = extract_all_stats_counts_tlv,
12531 .extract_pdev_stats = extract_pdev_stats_tlv,
12532 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
12533 .extract_vdev_stats = extract_vdev_stats_tlv,
12534 .extract_peer_stats = extract_peer_stats_tlv,
12535 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
12536 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
12537 .extract_chan_stats = extract_chan_stats_tlv,
12538 .extract_profile_ctx = extract_profile_ctx_tlv,
12539 .extract_profile_data = extract_profile_data_tlv,
12540 .extract_chan_info_event = extract_chan_info_event_tlv,
12541 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053012542 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012543};
12544
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053012545#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053012546/**
12547 * populate_tlv_service() - populates wmi services
12548 *
12549 * @param wmi_service: Pointer to hold wmi_service
12550 * Return: None
12551 */
12552static void populate_tlv_service(uint32_t *wmi_service)
12553{
12554 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
12555 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
12556 wmi_service[wmi_service_roam_scan_offload] =
12557 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
12558 wmi_service[wmi_service_bcn_miss_offload] =
12559 WMI_SERVICE_BCN_MISS_OFFLOAD;
12560 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
12561 wmi_service[wmi_service_sta_advanced_pwrsave] =
12562 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
12563 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
12564 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
12565 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
12566 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
12567 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
12568 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
12569 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
12570 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
12571 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
12572 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
12573 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
12574 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
12575 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
12576 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
12577 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
12578 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
12579 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
12580 wmi_service[wmi_service_packet_power_save] =
12581 WMI_SERVICE_PACKET_POWER_SAVE;
12582 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
12583 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
12584 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
12585 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
12586 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
12587 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
12588 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
12589 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
12590 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
12591 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
12592 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
12593 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
12594 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
12595 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
12596 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
12597 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
12598 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
12599 wmi_service[wmi_service_mcc_bcn_interval_change] =
12600 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
12601 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
12602 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
12603 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
12604 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
12605 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
12606 wmi_service[wmi_service_lte_ant_share_support] =
12607 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
12608 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
12609 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
12610 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
12611 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
12612 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
12613 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
12614 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
12615 wmi_service[wmi_service_bcn_txrate_override] =
12616 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
12617 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
12618 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
12619 wmi_service[wmi_service_estimate_linkspeed] =
12620 WMI_SERVICE_ESTIMATE_LINKSPEED;
12621 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
12622 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
12623 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
12624 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
12625 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
12626 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
12627 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
12628 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
12629 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
12630 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
12631 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
12632 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
12633 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
12634 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
12635 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
12636 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
12637 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
12638 wmi_service[wmi_service_sap_auth_offload] =
12639 WMI_SERVICE_SAP_AUTH_OFFLOAD;
12640 wmi_service[wmi_service_dual_band_simultaneous_support] =
12641 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
12642 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
12643 wmi_service[wmi_service_ap_arpns_offload] =
12644 WMI_SERVICE_AP_ARPNS_OFFLOAD;
12645 wmi_service[wmi_service_per_band_chainmask_support] =
12646 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
12647 wmi_service[wmi_service_packet_filter_offload] =
12648 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
12649 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
12650 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
12651 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
12652 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
12653
12654 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
12655 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
12656 wmi_service[wmi_service_smart_antenna_sw_support] =
12657 WMI_SERVICE_UNAVAILABLE;
12658 wmi_service[wmi_service_smart_antenna_hw_support] =
12659 WMI_SERVICE_UNAVAILABLE;
12660 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
12661 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
12662 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
12663 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
12664 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
12665 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
12666 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
12667 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
12668 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
12669 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
12670 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
12671
12672 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
12673 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
12674 wmi_service[wmi_service_periodic_chan_stat_support] =
12675 WMI_SERVICE_UNAVAILABLE;
12676 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
12677 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
12678 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
12679}
12680
12681/**
12682 * populate_tlv_event_id() - populates wmi event ids
12683 *
12684 * @param event_ids: Pointer to hold event ids
12685 * Return: None
12686 */
12687static void populate_tlv_events_id(uint32_t *event_ids)
12688{
12689 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
12690 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
12691 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
12692 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
12693 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
12694 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
12695 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
12696 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
12697 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
12698 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
12699 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
12700 event_ids[wmi_service_ready_ext_event_id] =
12701 WMI_SERVICE_READY_EXT_EVENTID;
12702 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
12703 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
12704 event_ids[wmi_vdev_install_key_complete_event_id] =
12705 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
12706 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
12707 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
12708
12709 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
12710 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
12711 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
12712 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
12713 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
12714 event_ids[wmi_peer_estimated_linkspeed_event_id] =
12715 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
12716 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
12717 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
12718 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
12719 event_ids[wmi_tbttoffset_update_event_id] =
12720 WMI_TBTTOFFSET_UPDATE_EVENTID;
12721 event_ids[wmi_offload_bcn_tx_status_event_id] =
12722 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
12723 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
12724 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
12725 event_ids[wmi_mgmt_tx_completion_event_id] =
12726 WMI_MGMT_TX_COMPLETION_EVENTID;
12727
12728 event_ids[wmi_tx_delba_complete_event_id] =
12729 WMI_TX_DELBA_COMPLETE_EVENTID;
12730 event_ids[wmi_tx_addba_complete_event_id] =
12731 WMI_TX_ADDBA_COMPLETE_EVENTID;
12732 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
12733
12734 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
12735
12736 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
12737 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
12738
12739 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
12740
12741 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
12742
12743 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
12744
12745 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
12746 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
12747 event_ids[wmi_do_wow_disable_ack_event_id] =
12748 WMI_D0_WOW_DISABLE_ACK_EVENTID;
12749 event_ids[wmi_wow_initial_wakeup_event_id] =
12750 WMI_WOW_INITIAL_WAKEUP_EVENTID;
12751
12752 event_ids[wmi_rtt_meas_report_event_id] =
12753 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
12754 event_ids[wmi_tsf_meas_report_event_id] =
12755 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
12756 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
12757 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
12758 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
12759 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
12760 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
12761 event_ids[wmi_update_fw_mem_dump_event_id] =
12762 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
12763 event_ids[wmi_diag_event_id_log_supported_event_id] =
12764 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
12765 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
12766 event_ids[wmi_nlo_scan_complete_event_id] =
12767 WMI_NLO_SCAN_COMPLETE_EVENTID;
12768 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
12769 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
12770
12771 event_ids[wmi_gtk_offload_status_event_id] =
12772 WMI_GTK_OFFLOAD_STATUS_EVENTID;
12773 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
12774 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
12775 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
12776
12777 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
12778
12779 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
12780
12781 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
12782 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
12783 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
12784 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
12785 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
12786 event_ids[wmi_wlan_profile_data_event_id] =
12787 WMI_WLAN_PROFILE_DATA_EVENTID;
12788 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
12789 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
12790 event_ids[wmi_vdev_get_keepalive_event_id] =
12791 WMI_VDEV_GET_KEEPALIVE_EVENTID;
12792 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
12793
12794 event_ids[wmi_diag_container_event_id] =
12795 WMI_DIAG_DATA_CONTAINER_EVENTID;
12796
12797 event_ids[wmi_host_auto_shutdown_event_id] =
12798 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
12799
12800 event_ids[wmi_update_whal_mib_stats_event_id] =
12801 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
12802
12803 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
12804 event_ids[wmi_update_vdev_rate_stats_event_id] =
12805 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
12806
12807 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
12808
12809 /** Set OCB Sched Response, deprecated */
12810 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
12811
12812 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
12813 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
12814 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
12815
12816 /* GPIO Event */
12817 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
12818 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
12819
12820 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
12821 event_ids[wmi_rfkill_state_change_event_id] =
12822 WMI_RFKILL_STATE_CHANGE_EVENTID;
12823
12824 /* TDLS Event */
12825 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
12826
12827 event_ids[wmi_batch_scan_enabled_event_id] =
12828 WMI_BATCH_SCAN_ENABLED_EVENTID;
12829 event_ids[wmi_batch_scan_result_event_id] =
12830 WMI_BATCH_SCAN_RESULT_EVENTID;
12831 /* OEM Event */
12832 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
12833 event_ids[wmi_oem_meas_report_event_id] =
12834 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
12835 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
12836
12837 /* NAN Event */
12838 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
12839
12840 /* LPI Event */
12841 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
12842 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
12843 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
12844
12845 /* ExtScan events */
12846 event_ids[wmi_extscan_start_stop_event_id] =
12847 WMI_EXTSCAN_START_STOP_EVENTID;
12848 event_ids[wmi_extscan_operation_event_id] =
12849 WMI_EXTSCAN_OPERATION_EVENTID;
12850 event_ids[wmi_extscan_table_usage_event_id] =
12851 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
12852 event_ids[wmi_extscan_cached_results_event_id] =
12853 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
12854 event_ids[wmi_extscan_wlan_change_results_event_id] =
12855 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
12856 event_ids[wmi_extscan_hotlist_match_event_id] =
12857 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
12858 event_ids[wmi_extscan_capabilities_event_id] =
12859 WMI_EXTSCAN_CAPABILITIES_EVENTID;
12860 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
12861 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
12862
12863 /* mDNS offload events */
12864 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
12865
12866 /* SAP Authentication offload events */
12867 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
12868 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
12869
12870 /** Out-of-context-of-bss (OCB) events */
12871 event_ids[wmi_ocb_set_config_resp_event_id] =
12872 WMI_OCB_SET_CONFIG_RESP_EVENTID;
12873 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
12874 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
12875 event_ids[wmi_dcc_get_stats_resp_event_id] =
12876 WMI_DCC_GET_STATS_RESP_EVENTID;
12877 event_ids[wmi_dcc_update_ndl_resp_event_id] =
12878 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
12879 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
12880 /* System-On-Chip events */
12881 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
12882 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
12883 event_ids[wmi_soc_hw_mode_transition_event_id] =
12884 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
12885 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
12886 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
12887}
12888
12889/**
12890 * populate_pdev_param_tlv() - populates pdev params
12891 *
12892 * @param pdev_param: Pointer to hold pdev params
12893 * Return: None
12894 */
12895static void populate_pdev_param_tlv(uint32_t *pdev_param)
12896{
12897 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
12898 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
12899 pdev_param[wmi_pdev_param_txpower_limit2g] =
12900 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
12901 pdev_param[wmi_pdev_param_txpower_limit5g] =
12902 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
12903 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
12904 pdev_param[wmi_pdev_param_beacon_gen_mode] =
12905 WMI_PDEV_PARAM_BEACON_GEN_MODE;
12906 pdev_param[wmi_pdev_param_beacon_tx_mode] =
12907 WMI_PDEV_PARAM_BEACON_TX_MODE;
12908 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
12909 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
12910 pdev_param[wmi_pdev_param_protection_mode] =
12911 WMI_PDEV_PARAM_PROTECTION_MODE;
12912 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
12913 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
12914 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
12915 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
12916 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
12917 pdev_param[wmi_pdev_param_sta_kickout_th] =
12918 WMI_PDEV_PARAM_STA_KICKOUT_TH;
12919 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
12920 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
12921 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
12922 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
12923 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
12924 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
12925 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
12926 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
12927 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
12928 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
12929 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
12930 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
12931 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
12932 pdev_param[wmi_pdev_param_ltr_sleep_override] =
12933 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
12934 pdev_param[wmi_pdev_param_ltr_rx_override] =
12935 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
12936 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
12937 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
12938 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
12939 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
12940 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
12941 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
12942 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
12943 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
12944 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
12945 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
12946 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
12947 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
12948 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
12949 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
12950 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
12951 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
12952 pdev_param[wmi_pdev_param_peer_stats_update_period] =
12953 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
12954 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
12955 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
12956 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
12957 pdev_param[wmi_pdev_param_arp_ac_override] =
12958 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
12959 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
12960 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
12961 pdev_param[wmi_pdev_param_ani_poll_period] =
12962 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
12963 pdev_param[wmi_pdev_param_ani_listen_period] =
12964 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
12965 pdev_param[wmi_pdev_param_ani_ofdm_level] =
12966 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
12967 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
12968 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
12969 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
12970 pdev_param[wmi_pdev_param_idle_ps_config] =
12971 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
12972 pdev_param[wmi_pdev_param_power_gating_sleep] =
12973 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
12974 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
12975 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
12976 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
12977 pdev_param[wmi_pdev_param_hw_rfkill_config] =
12978 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
12979 pdev_param[wmi_pdev_param_low_power_rf_enable] =
12980 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
12981 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
12982 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
12983 pdev_param[wmi_pdev_param_power_collapse_enable] =
12984 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
12985 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
12986 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
12987 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
12988 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
12989 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
12990 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
12991 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
12992 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
12993 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
12994 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
12995 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
12996 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
12997 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
12998 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
12999 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
13000 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
13001 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
13002 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
13003 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
13004 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
13005 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
13006 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
13007 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
13008 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
13009 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
13010 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
13011 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
13012 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
13013 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
13014 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
13015 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
13016 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
13017 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
13018 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
13019 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
13020 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
13021 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
13022 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
13023 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
13024 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
13025 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
13026 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
13027 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
13028 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
13029 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
13030 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
13031 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
13032 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
13033 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
13034 WMI_UNAVAILABLE_PARAM;
13035 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
13036 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
13037 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
13038 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
13039 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
13040 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
13041 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
13042 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
13043 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
13044 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
13045 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
13046 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
13047 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
13048 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
13049 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
13050 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
13051 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
13052 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
13053 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
13054 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
13055 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
13056 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
13057 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
13058 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
13059 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
13060 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
13061 WMI_UNAVAILABLE_PARAM;
13062 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
13063 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
13064 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
13065 WMI_UNAVAILABLE_PARAM;
13066 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
13067 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
13068 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
13069 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
13070 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
13071 WMI_UNAVAILABLE_PARAM;
13072 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
13073 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
13074 WMI_UNAVAILABLE_PARAM;
13075 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] = WMI_UNAVAILABLE_PARAM;
13076 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
13077}
13078
13079/**
13080 * populate_vdev_param_tlv() - populates vdev params
13081 *
13082 * @param vdev_param: Pointer to hold vdev params
13083 * Return: None
13084 */
13085static void populate_vdev_param_tlv(uint32_t *vdev_param)
13086{
13087 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
13088 vdev_param[wmi_vdev_param_fragmentation_threshold] =
13089 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
13090 vdev_param[wmi_vdev_param_beacon_interval] =
13091 WMI_VDEV_PARAM_BEACON_INTERVAL;
13092 vdev_param[wmi_vdev_param_listen_interval] =
13093 WMI_VDEV_PARAM_LISTEN_INTERVAL;
13094 vdev_param[wmi_vdev_param_multicast_rate] =
13095 WMI_VDEV_PARAM_MULTICAST_RATE;
13096 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
13097 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
13098 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
13099 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
13100 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
13101 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
13102 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
13103 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
13104 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
13105 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
13106 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
13107 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
13108 vdev_param[wmi_vdev_param_bmiss_count_max] =
13109 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
13110 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
13111 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
13112 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
13113 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
13114 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
13115 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
13116 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
13117 vdev_param[wmi_vdev_param_disable_htprotection] =
13118 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
13119 vdev_param[wmi_vdev_param_sta_quickkickout] =
13120 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
13121 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
13122 vdev_param[wmi_vdev_param_protection_mode] =
13123 WMI_VDEV_PARAM_PROTECTION_MODE;
13124 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
13125 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
13126 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
13127 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
13128 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
13129 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
13130 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
13131 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
13132 vdev_param[wmi_vdev_param_bcast_data_rate] =
13133 WMI_VDEV_PARAM_BCAST_DATA_RATE;
13134 vdev_param[wmi_vdev_param_mcast_data_rate] =
13135 WMI_VDEV_PARAM_MCAST_DATA_RATE;
13136 vdev_param[wmi_vdev_param_mcast_indicate] =
13137 WMI_VDEV_PARAM_MCAST_INDICATE;
13138 vdev_param[wmi_vdev_param_dhcp_indicate] =
13139 WMI_VDEV_PARAM_DHCP_INDICATE;
13140 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
13141 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
13142 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
13143 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
13144 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
13145 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
13146 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
13147 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
13148 vdev_param[wmi_vdev_param_ap_enable_nawds] =
13149 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
13150 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
13151 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
13152 vdev_param[wmi_vdev_param_packet_powersave] =
13153 WMI_VDEV_PARAM_PACKET_POWERSAVE;
13154 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
13155 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
13156 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
13157 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
13158 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
13159 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
13160 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
13161 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
13162 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
13163 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
13164 vdev_param[wmi_vdev_param_early_rx_slop_step] =
13165 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
13166 vdev_param[wmi_vdev_param_early_rx_init_slop] =
13167 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
13168 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
13169 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
13170 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
13171 vdev_param[wmi_vdev_param_snr_num_for_cal] =
13172 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
13173 vdev_param[wmi_vdev_param_roam_fw_offload] =
13174 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
13175 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
13176 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
13177 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
13178 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
13179 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
13180 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
13181 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
13182 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
13183 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
13184 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
13185 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
13186 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
13187 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
13188 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
13189 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
13190 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
13191 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
13192 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
13193 vdev_param[wmi_vdev_param_inactivity_cnt] =
13194 WMI_VDEV_PARAM_INACTIVITY_CNT;
13195 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
13196 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
13197 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
13198 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
13199 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
13200 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
13201 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
13202 vdev_param[wmi_vdev_param_rx_leak_window] =
13203 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
13204 vdev_param[wmi_vdev_param_stats_avg_factor] =
13205 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
13206 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
13207 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
13208 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
13209 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
13210 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
13211 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
13212}
13213#endif
13214
Govind Singh5eb51532016-03-09 11:34:12 +053013215/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013216 * wmi_tlv_attach() - Attach TLV APIs
Govind Singh5eb51532016-03-09 11:34:12 +053013217 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013218 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053013219 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013220#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013221void wmi_tlv_attach(wmi_unified_t wmi_handle)
13222{
13223 wmi_handle->ops = &tlv_ops;
13224#ifdef WMI_INTERFACE_EVENT_LOGGING
13225 wmi_handle->log_info.buf_offset_command = 2;
13226 wmi_handle->log_info.buf_offset_event = 4;
13227 wmi_handle->log_info.is_management_record =
13228 is_management_record_tlv;
13229#endif
13230 populate_tlv_service(wmi_handle->services);
13231 populate_tlv_events_id(wmi_handle->wmi_events);
13232 populate_pdev_param_tlv(wmi_handle->pdev_param);
13233 populate_vdev_param_tlv(wmi_handle->vdev_param);
13234}
13235#else
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013236void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053013237{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013238 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053013239#ifdef WMI_INTERFACE_EVENT_LOGGING
13240 wmi_handle->log_info.buf_offset_command = 2;
13241 wmi_handle->log_info.buf_offset_event = 4;
13242 wmi_handle->log_info.is_management_record =
13243 is_management_record_tlv;
13244#endif
Govind Singh5eb51532016-03-09 11:34:12 +053013245}
Govind Singhe7f2f342016-05-23 12:12:52 +053013246#endif