blob: 46aa8a24fc84d375413a8910486eab5cf021b51f [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/**
Leo Changeee40872016-09-28 13:43:36 -0700725 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
726 * command to fw
727 * @wmi: wmi handle
728 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
729 *
730 * Return: 0 for success or error code
731 */
732QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
733 struct rx_reorder_queue_setup_params *param)
734{
735 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
736 wmi_buf_t buf;
737 int32_t len = sizeof(*cmd);
738
739 buf = wmi_buf_alloc(wmi, len);
740 if (!buf) {
741 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
742 return QDF_STATUS_E_NOMEM;
743 }
744 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
745 WMITLV_SET_HDR(&cmd->tlv_header,
746 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
747 WMITLV_GET_STRUCT_TLVLEN
748 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
749 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
750 cmd->vdev_id = param->vdev_id;
751 cmd->tid = param->tid;
752 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
753 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
754 cmd->queue_no = param->queue_no;
755
756 if (wmi_unified_cmd_send(wmi, buf, len,
757 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
758 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
759 __func__);
760 qdf_nbuf_free(buf);
761 return QDF_STATUS_E_FAILURE;
762 }
763 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
764 param->peer_macaddr, param->vdev_id, param->tid);
765
766 return QDF_STATUS_SUCCESS;
767}
768
769/**
770 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
771 * command to fw
772 * @wmi: wmi handle
773 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
774 *
775 * Return: 0 for success or error code
776 */
777QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
778 struct rx_reorder_queue_remove_params *param)
779{
780 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
781 wmi_buf_t buf;
782 int32_t len = sizeof(*cmd);
783
784 buf = wmi_buf_alloc(wmi, len);
785 if (!buf) {
786 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
787 return QDF_STATUS_E_NOMEM;
788 }
789 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
790 wmi_buf_data(buf);
791 WMITLV_SET_HDR(&cmd->tlv_header,
792 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
793 WMITLV_GET_STRUCT_TLVLEN
794 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
795 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
796 cmd->vdev_id = param->vdev_id;
797 cmd->tid_mask = param->peer_tid_bitmap;
798
799 if (wmi_unified_cmd_send(wmi, buf, len,
800 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
801 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
802 __func__);
803 qdf_nbuf_free(buf);
804 return QDF_STATUS_E_FAILURE;
805 }
806 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
807 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
808
809 return QDF_STATUS_SUCCESS;
810}
811
812/**
Govind Singh5eb51532016-03-09 11:34:12 +0530813 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
814 * @wmi_handle: wmi handle
815 * @value: value
816 * @mac_id: mac id to have radio context
817 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530818 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530819 */
Govind Singhb53420c2016-03-09 14:32:57 +0530820QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530821 uint32_t value, uint8_t mac_id)
822{
823 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
824 wmi_buf_t buf;
825 int32_t len = sizeof(*cmd);
826
Govind Singhb53420c2016-03-09 14:32:57 +0530827 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530828
829 buf = wmi_buf_alloc(wmi_handle, len);
830 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530831 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530832 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530833 }
834
835 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
836 WMITLV_SET_HDR(&cmd->tlv_header,
837 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
838 WMITLV_GET_STRUCT_TLVLEN
839 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530840 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530841 cmd->enable = value;
842
843 if (wmi_unified_cmd_send(wmi_handle, buf, len,
844 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530845 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530846 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530847 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530848 }
849
850 return 0;
851}
852
853/**
854 * send_pdev_utf_cmd_tlv() - send utf command to fw
855 * @wmi_handle: wmi handle
856 * @param: pointer to pdev_utf_params
857 * @mac_id: mac id to have radio context
858 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530859 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530860 */
Govind Singhb53420c2016-03-09 14:32:57 +0530861QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530862send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
863 struct pdev_utf_params *param,
864 uint8_t mac_id)
865{
866 wmi_buf_t buf;
867 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -0700868 /* if param->len is 0 no data is sent, return error */
869 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +0530870 static uint8_t msgref = 1;
871 uint8_t segNumber = 0, segInfo, numSegments;
872 uint16_t chunk_len, total_bytes;
873 uint8_t *bufpos;
874 struct seg_hdr_info segHdrInfo;
875
876 bufpos = param->utf_payload;
877 total_bytes = param->len;
878 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
879 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
880 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
881
882 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
883 numSegments++;
884
885 while (param->len) {
886 if (param->len > MAX_WMI_UTF_LEN)
887 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
888 else
889 chunk_len = param->len;
890
891 buf = wmi_buf_alloc(wmi_handle,
892 (chunk_len + sizeof(segHdrInfo) +
893 WMI_TLV_HDR_SIZE));
894 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530895 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530896 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530897 }
898
899 cmd = (uint8_t *) wmi_buf_data(buf);
900
901 segHdrInfo.len = total_bytes;
902 segHdrInfo.msgref = msgref;
903 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
904 segHdrInfo.segmentInfo = segInfo;
905 segHdrInfo.pad = 0;
906
Govind Singhb53420c2016-03-09 14:32:57 +0530907 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +0530908 " segHdrInfo.segmentInfo = %d",
909 __func__, segHdrInfo.len, segHdrInfo.msgref,
910 segHdrInfo.segmentInfo);
911
Govind Singhb53420c2016-03-09 14:32:57 +0530912 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +0530913 "chunk len %d", __func__, total_bytes, segNumber,
914 numSegments, chunk_len);
915
916 segNumber++;
917
918 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
919 (chunk_len + sizeof(segHdrInfo)));
920 cmd += WMI_TLV_HDR_SIZE;
921 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
922 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
923
924 ret = wmi_unified_cmd_send(wmi_handle, buf,
925 (chunk_len + sizeof(segHdrInfo) +
926 WMI_TLV_HDR_SIZE),
927 WMI_PDEV_UTF_CMDID);
928
Govind Singh67922e82016-04-01 16:48:57 +0530929 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530930 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530931 wmi_buf_free(buf);
932 break;
933 }
934
935 param->len -= chunk_len;
936 bufpos += chunk_len;
937 }
938
939 msgref++;
940
941 return ret;
942}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530943#ifdef CONFIG_MCL
944static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
945 uint32_t host_param)
946{
947 return host_param;
948}
949#else
950static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
951 uint32_t host_param)
952{
953 if (host_param < wmi_pdev_param_max)
954 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +0530955
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530956 return WMI_UNAVAILABLE_PARAM;
957}
958#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530959/**
960 * send_pdev_param_cmd_tlv() - set pdev parameters
961 * @wmi_handle: wmi handle
962 * @param: pointer to pdev parameter
963 * @mac_id: radio context
964 *
965 * Return: 0 on success, errno on failure
966 */
Govind Singhb53420c2016-03-09 14:32:57 +0530967QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530968send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
969 struct pdev_params *param,
970 uint8_t mac_id)
971{
Govind Singh67922e82016-04-01 16:48:57 +0530972 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530973 wmi_pdev_set_param_cmd_fixed_param *cmd;
974 wmi_buf_t buf;
975 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530976 uint32_t pdev_param;
977
978 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
979 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
980 WMI_LOGW("%s: Unavailable param %d\n",
981 __func__, param->param_id);
982 return QDF_STATUS_E_INVAL;
983 }
Govind Singh5eb51532016-03-09 11:34:12 +0530984
985 buf = wmi_buf_alloc(wmi_handle, len);
986 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530987 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530988 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530989 }
990 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
991 WMITLV_SET_HDR(&cmd->tlv_header,
992 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
993 WMITLV_GET_STRUCT_TLVLEN
994 (wmi_pdev_set_param_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530995 cmd->pdev_id = 0;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530996 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +0530997 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +0530998 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530999 param->param_value);
1000 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1001 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301002 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301003 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301004 wmi_buf_free(buf);
1005 }
1006 return ret;
1007}
1008
1009/**
1010 * send_suspend_cmd_tlv() - WMI suspend function
1011 * @param wmi_handle : handle to WMI.
1012 * @param param : pointer to hold suspend parameter
1013 * @mac_id: radio context
1014 *
1015 * Return 0 on success and -ve on failure.
1016 */
Govind Singhb53420c2016-03-09 14:32:57 +05301017QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301018 struct suspend_params *param,
1019 uint8_t mac_id)
1020{
1021 wmi_pdev_suspend_cmd_fixed_param *cmd;
1022 wmi_buf_t wmibuf;
1023 uint32_t len = sizeof(*cmd);
1024 int32_t ret;
1025
1026 /*
1027 * send the comand to Target to ignore the
1028 * PCIE reset so as to ensure that Host and target
1029 * states are in sync
1030 */
1031 wmibuf = wmi_buf_alloc(wmi_handle, len);
1032 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301033 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301034
1035 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1036 WMITLV_SET_HDR(&cmd->tlv_header,
1037 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1038 WMITLV_GET_STRUCT_TLVLEN
1039 (wmi_pdev_suspend_cmd_fixed_param));
1040 if (param->disable_target_intr)
1041 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1042 else
1043 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1044 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1045 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301046 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301047 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301048 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301049 }
1050
1051 return ret;
1052}
1053
1054/**
1055 * send_resume_cmd_tlv() - WMI resume function
1056 * @param wmi_handle : handle to WMI.
1057 * @mac_id: radio context
1058 *
1059 * Return: 0 on success and -ve on failure.
1060 */
Govind Singhb53420c2016-03-09 14:32:57 +05301061QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301062 uint8_t mac_id)
1063{
1064 wmi_buf_t wmibuf;
1065 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301066 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301067
1068 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1069 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301070 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301071 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1072 WMITLV_SET_HDR(&cmd->tlv_header,
1073 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1074 WMITLV_GET_STRUCT_TLVLEN
1075 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07001076 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +05301077 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1078 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301079 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301080 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301081 wmi_buf_free(wmibuf);
1082 }
1083
1084 return ret;
1085}
1086
1087/**
1088 * send_wow_enable_cmd_tlv() - WMI wow enable function
1089 * @param wmi_handle : handle to WMI.
1090 * @param param : pointer to hold wow enable parameter
1091 * @mac_id: radio context
1092 *
1093 * Return: 0 on success and -ve on failure.
1094 */
Govind Singhb53420c2016-03-09 14:32:57 +05301095QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301096 struct wow_cmd_params *param,
1097 uint8_t mac_id)
1098{
1099 wmi_wow_enable_cmd_fixed_param *cmd;
1100 wmi_buf_t buf;
1101 int32_t len;
1102 int32_t ret;
1103
1104 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1105
1106 buf = wmi_buf_alloc(wmi_handle, len);
1107 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301108 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1109 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301110 }
1111 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1112 WMITLV_SET_HDR(&cmd->tlv_header,
1113 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1114 WMITLV_GET_STRUCT_TLVLEN
1115 (wmi_wow_enable_cmd_fixed_param));
1116 cmd->enable = param->enable;
1117 if (param->can_suspend_link)
1118 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1119 else
1120 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
1121
Govind Singhb53420c2016-03-09 14:32:57 +05301122 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301123 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1124 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1125
1126 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1127 WMI_WOW_ENABLE_CMDID);
1128 if (ret)
1129 wmi_buf_free(buf);
1130
1131 return ret;
1132}
1133
1134/**
1135 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301136 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301137 * @peer_addr: peer mac address
1138 * @param: pointer to ap_ps parameter structure
1139 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301140 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301141 */
Govind Singhb53420c2016-03-09 14:32:57 +05301142QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301143 uint8_t *peer_addr,
1144 struct ap_ps_params *param)
1145{
1146 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1147 wmi_buf_t buf;
1148 int32_t err;
1149
1150 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1151 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301152 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301153 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301154 }
1155 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1156 WMITLV_SET_HDR(&cmd->tlv_header,
1157 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1158 WMITLV_GET_STRUCT_TLVLEN
1159 (wmi_ap_ps_peer_cmd_fixed_param));
1160 cmd->vdev_id = param->vdev_id;
1161 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1162 cmd->param = param->param;
1163 cmd->value = param->value;
1164 err = wmi_unified_cmd_send(wmi_handle, buf,
1165 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1166 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301167 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301168 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301169 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301170 }
1171
1172 return 0;
1173}
1174
1175/**
1176 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301177 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301178 * @peer_addr: peer mac address
1179 * @param: pointer to sta_ps parameter structure
1180 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301181 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301182 */
Govind Singhb53420c2016-03-09 14:32:57 +05301183QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301184 struct sta_ps_params *param)
1185{
1186 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1187 wmi_buf_t buf;
1188 int32_t len = sizeof(*cmd);
1189
1190 buf = wmi_buf_alloc(wmi_handle, len);
1191 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301192 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301193 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301194 }
1195
1196 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1197 WMITLV_SET_HDR(&cmd->tlv_header,
1198 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1199 WMITLV_GET_STRUCT_TLVLEN
1200 (wmi_sta_powersave_param_cmd_fixed_param));
1201 cmd->vdev_id = param->vdev_id;
1202 cmd->param = param->param;
1203 cmd->value = param->value;
1204
1205 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1206 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301207 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301208 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301209 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301210 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301211 }
1212
1213 return 0;
1214}
1215
1216/**
1217 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301218 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301219 * @param: ponirt to crash inject paramter structure
1220 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301221 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301222 */
Govind Singhb53420c2016-03-09 14:32:57 +05301223QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301224 struct crash_inject *param)
1225{
1226 int32_t ret = 0;
1227 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1228 uint16_t len = sizeof(*cmd);
1229 wmi_buf_t buf;
1230
1231 buf = wmi_buf_alloc(wmi_handle, len);
1232 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301233 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301234 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301235 }
1236
1237 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1238 WMITLV_SET_HDR(&cmd->tlv_header,
1239 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1240 WMITLV_GET_STRUCT_TLVLEN
1241 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1242 cmd->type = param->type;
1243 cmd->delay_time_ms = param->delay_time_ms;
1244
1245 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1246 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301247 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301248 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301249 __func__, ret);
1250 wmi_buf_free(buf);
1251 }
1252
1253 return ret;
1254}
1255
1256/**
1257 * send_dbglog_cmd_tlv() - set debug log level
1258 * @param wmi_handle : handle to WMI.
1259 * @param param : pointer to hold dbglog level parameter
1260 *
1261 * Return: 0 on success and -ve on failure.
1262 */
Govind Singhb53420c2016-03-09 14:32:57 +05301263QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301264send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1265 struct dbglog_params *dbglog_param)
1266{
1267 wmi_buf_t buf;
1268 wmi_debug_log_config_cmd_fixed_param *configmsg;
1269 A_STATUS status = A_OK;
1270 int32_t i;
1271 int32_t len;
1272 int8_t *buf_ptr;
1273 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1274
1275 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1276
1277 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1278 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1279 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1280 buf = wmi_buf_alloc(wmi_handle, len);
1281 if (buf == NULL)
1282 return A_NO_MEMORY;
1283
1284 configmsg =
1285 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1286 buf_ptr = (int8_t *) configmsg;
1287 WMITLV_SET_HDR(&configmsg->tlv_header,
1288 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1289 WMITLV_GET_STRUCT_TLVLEN
1290 (wmi_debug_log_config_cmd_fixed_param));
1291 configmsg->dbg_log_param = dbglog_param->param;
1292 configmsg->value = dbglog_param->val;
1293 /* Filling in the data part of second tlv -- should
1294 * follow first tlv _ WMI_TLV_HDR_SIZE */
1295 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1296 sizeof
1297 (wmi_debug_log_config_cmd_fixed_param)
1298 + WMI_TLV_HDR_SIZE);
1299 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1300 WMITLV_TAG_ARRAY_UINT32,
1301 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1302 if (dbglog_param->module_id_bitmap) {
1303 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1304 module_id_bitmap_array[i] =
1305 dbglog_param->module_id_bitmap[i];
1306 }
1307 }
1308
1309 status = wmi_unified_cmd_send(wmi_handle, buf,
1310 len, WMI_DBGLOG_CFG_CMDID);
1311
1312 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301313 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301314
1315 return status;
1316}
1317
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301318#ifdef CONFIG_MCL
1319static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1320 uint32_t host_param)
1321{
1322 return host_param;
1323}
1324#else
1325static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1326 uint32_t host_param)
1327{
1328 if (host_param < wmi_vdev_param_max)
1329 return wmi_handle->vdev_param[host_param];
1330
1331 return WMI_UNAVAILABLE_PARAM;
1332}
1333#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301334/**
1335 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1336 * @param wmi_handle : handle to WMI.
1337 * @param macaddr : MAC address
1338 * @param param : pointer to hold vdev set parameter
1339 *
1340 * Return: 0 on success and -ve on failure.
1341 */
Govind Singhb53420c2016-03-09 14:32:57 +05301342QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301343 struct vdev_set_params *param)
1344{
Govind Singh67922e82016-04-01 16:48:57 +05301345 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301346 wmi_vdev_set_param_cmd_fixed_param *cmd;
1347 wmi_buf_t buf;
1348 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301349 uint32_t vdev_param;
1350
1351 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1352 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1353 WMI_LOGW("%s:Vdev param %d not available", __func__,
1354 param->param_id);
1355 return QDF_STATUS_E_INVAL;
1356
1357 }
Govind Singh5eb51532016-03-09 11:34:12 +05301358
1359 buf = wmi_buf_alloc(wmi_handle, len);
1360 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301361 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301362 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301363 }
1364 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1365 WMITLV_SET_HDR(&cmd->tlv_header,
1366 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1367 WMITLV_GET_STRUCT_TLVLEN
1368 (wmi_vdev_set_param_cmd_fixed_param));
1369 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301370 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301371 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301372 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301373 param->if_id, param->param_id, param->param_value);
1374 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1375 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301376 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301377 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301378 wmi_buf_free(buf);
1379 }
1380
1381 return ret;
1382}
1383
1384/**
1385 * send_stats_request_cmd_tlv() - WMI request stats function
1386 * @param wmi_handle : handle to WMI.
1387 * @param macaddr : MAC address
1388 * @param param : pointer to hold stats request parameter
1389 *
1390 * Return: 0 on success and -ve on failure.
1391 */
Govind Singhb53420c2016-03-09 14:32:57 +05301392QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301393 uint8_t macaddr[IEEE80211_ADDR_LEN],
1394 struct stats_request_params *param)
1395{
Govind Singhd3156eb2016-02-26 17:50:39 +05301396 int32_t ret;
1397 wmi_request_stats_cmd_fixed_param *cmd;
1398 wmi_buf_t buf;
1399 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1400
1401 buf = wmi_buf_alloc(wmi_handle, len);
1402 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301403 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1404 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301405 }
1406
1407 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1408 WMITLV_SET_HDR(&cmd->tlv_header,
1409 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1410 WMITLV_GET_STRUCT_TLVLEN
1411 (wmi_request_stats_cmd_fixed_param));
1412 cmd->stats_id = param->stats_id;
1413 cmd->vdev_id = param->vdev_id;
1414 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1415 WMI_REQUEST_STATS_CMDID);
1416 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301417 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301418 wmi_buf_free(buf);
1419 }
1420
1421 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301422}
1423
Govind Singh87542482016-06-08 19:40:11 +05301424#ifdef CONFIG_WIN
1425/**
1426 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1427 * @param wmi_handle : handle to WMI.
1428 * @param macaddr : MAC address
1429 * @param param : pointer to hold stats request parameter
1430 *
1431 * Return: 0 on success and -ve on failure.
1432 */
1433QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
1434 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1435{
1436 return 0;
1437}
1438#else
Govind Singh5eb51532016-03-09 11:34:12 +05301439/**
1440 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1441 * @param wmi_handle : handle to WMI.
1442 * @param macaddr : MAC address
1443 * @param param : pointer to hold stats request parameter
1444 *
1445 * Return: 0 on success and -ve on failure.
1446 */
Govind Singhb53420c2016-03-09 14:32:57 +05301447QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301448 uint8_t macaddr[IEEE80211_ADDR_LEN],
1449 struct packet_enable_params *param)
1450{
1451 return 0;
1452}
Govind Singh87542482016-06-08 19:40:11 +05301453#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301454
Govind Singh87542482016-06-08 19:40:11 +05301455#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301456/**
1457 * send_beacon_send_cmd_tlv() - WMI beacon send function
1458 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301459 * @param param : pointer to hold beacon send cmd parameter
1460 *
1461 * Return: 0 on success and -ve on failure.
1462 */
Govind Singhb53420c2016-03-09 14:32:57 +05301463QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301464 struct beacon_params *param)
1465{
Govind Singhd3156eb2016-02-26 17:50:39 +05301466 int32_t ret;
1467 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1468 wmi_bcn_prb_info *bcn_prb_info;
1469 wmi_buf_t wmi_buf;
1470 uint8_t *buf_ptr;
1471 uint32_t wmi_buf_len;
1472
1473 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1474 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1475 param->tmpl_len_aligned;
1476 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1477 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301478 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301479 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301480 }
1481 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1482 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1483 WMITLV_SET_HDR(&cmd->tlv_header,
1484 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1485 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1486 cmd->vdev_id = param->vdev_id;
1487 cmd->tim_ie_offset = param->tim_ie_offset;
1488 cmd->buf_len = param->tmpl_len;
1489 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1490
1491 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1492 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1493 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1494 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1495 bcn_prb_info->caps = 0;
1496 bcn_prb_info->erp = 0;
1497 buf_ptr += sizeof(wmi_bcn_prb_info);
1498
1499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1500 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301501 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301502
1503 ret = wmi_unified_cmd_send(wmi_handle,
1504 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1505 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301506 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301507 wmi_buf_free(wmi_buf);
1508 }
Govind Singh5eb51532016-03-09 11:34:12 +05301509 return 0;
1510}
Govind Singh87542482016-06-08 19:40:11 +05301511#else
1512QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
1513 struct beacon_params *param)
1514{
1515 return 0;
1516}
1517
1518/**
1519 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1520 * @param wmi_handle : handle to WMI.
1521 * @param param : pointer to hold beacon send cmd parameter
1522 *
1523 * Return: 0 on success and -ve on failure.
1524 */
1525QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
1526 struct beacon_tmpl_params *param)
1527{
1528 int32_t ret;
1529 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1530 wmi_bcn_prb_info *bcn_prb_info;
1531 wmi_buf_t wmi_buf;
1532 uint8_t *buf_ptr;
1533 uint32_t wmi_buf_len;
1534
1535 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1536 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1537 param->tmpl_len_aligned;
1538 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1539 if (!wmi_buf) {
1540 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1541 return QDF_STATUS_E_NOMEM;
1542 }
1543 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1544 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1545 WMITLV_SET_HDR(&cmd->tlv_header,
1546 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1547 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1548 cmd->vdev_id = param->vdev_id;
1549 cmd->tim_ie_offset = param->tim_ie_offset;
1550 cmd->buf_len = param->tmpl_len;
1551 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1552
1553 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1554 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1555 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1556 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1557 bcn_prb_info->caps = 0;
1558 bcn_prb_info->erp = 0;
1559 buf_ptr += sizeof(wmi_bcn_prb_info);
1560
1561 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1562 buf_ptr += WMI_TLV_HDR_SIZE;
1563 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1564
1565 ret = wmi_unified_cmd_send(wmi_handle,
1566 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1567 if (ret) {
1568 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1569 wmi_buf_free(wmi_buf);
1570 }
1571 return 0;
1572}
1573#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301574
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301575#ifdef CONFIG_MCL
1576static inline void copy_peer_flags_tlv(
1577 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1578 struct peer_assoc_params *param)
1579{
1580 cmd->peer_flags = param->peer_flags;
1581}
1582#else
1583static inline void copy_peer_flags_tlv(
1584 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1585 struct peer_assoc_params *param)
1586{
1587 /*
1588 * The target only needs a subset of the flags maintained in the host.
1589 * Just populate those flags and send it down
1590 */
1591 cmd->peer_flags = 0;
1592
1593 /*
1594 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1595 */
1596 if (param->is_wme_set) {
1597
1598 if (param->qos_flag)
1599 cmd->peer_flags |= WMI_PEER_QOS;
1600 if (param->apsd_flag)
1601 cmd->peer_flags |= WMI_PEER_APSD;
1602 if (param->ht_flag)
1603 cmd->peer_flags |= WMI_PEER_HT;
1604 if (param->bw_40)
1605 cmd->peer_flags |= WMI_PEER_40MHZ;
1606 if (param->bw_80)
1607 cmd->peer_flags |= WMI_PEER_80MHZ;
1608 if (param->bw_160)
1609 cmd->peer_flags |= WMI_PEER_160MHZ;
1610
1611 /* Typically if STBC is enabled for VHT it should be enabled
1612 * for HT as well
1613 **/
1614 if (param->stbc_flag)
1615 cmd->peer_flags |= WMI_PEER_STBC;
1616
1617 /* Typically if LDPC is enabled for VHT it should be enabled
1618 * for HT as well
1619 **/
1620 if (param->ldpc_flag)
1621 cmd->peer_flags |= WMI_PEER_LDPC;
1622
1623 if (param->static_mimops_flag)
1624 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1625 if (param->dynamic_mimops_flag)
1626 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1627 if (param->spatial_mux_flag)
1628 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1629 if (param->vht_flag)
1630 cmd->peer_flags |= WMI_PEER_VHT;
1631 }
1632 /*
1633 * Suppress authorization for all AUTH modes that need 4-way handshake
1634 * (during re-association).
1635 * Authorization will be done for these modes on key installation.
1636 */
1637 if (param->auth_flag)
1638 cmd->peer_flags |= WMI_PEER_AUTH;
1639 if (param->need_ptk_4_way)
1640 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1641 else
1642 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1643 if (param->need_gtk_2_way)
1644 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1645 /* safe mode bypass the 4-way handshake */
1646 if (param->safe_mode_enabled)
1647 cmd->peer_flags &=
1648 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1649 /* Disable AMSDU for station transmit, if user configures it */
1650 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1651 * it
1652 * if (param->amsdu_disable) Add after FW support
1653 **/
1654
1655 /* Target asserts if node is marked HT and all MCS is set to 0.
1656 * Mark the node as non-HT if all the mcs rates are disabled through
1657 * iwpriv
1658 **/
1659 if (param->peer_ht_rates.num_rates == 0)
1660 cmd->peer_flags &= ~WMI_PEER_HT;
1661}
1662#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301663/**
1664 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1665 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301666 * @param param : pointer to peer assoc parameter
1667 *
1668 * Return: 0 on success and -ve on failure.
1669 */
Govind Singhb53420c2016-03-09 14:32:57 +05301670QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301671 struct peer_assoc_params *param)
1672{
Govind Singhd3156eb2016-02-26 17:50:39 +05301673 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1674 wmi_vht_rate_set *mcs;
1675 wmi_buf_t buf;
1676 int32_t len;
1677 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301678 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301679 uint32_t peer_legacy_rates_align;
1680 uint32_t peer_ht_rates_align;
1681
1682
1683 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1684 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301685
1686 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301687 (peer_legacy_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301688 WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301689 (peer_ht_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301690 sizeof(wmi_vht_rate_set);
1691
1692 buf = wmi_buf_alloc(wmi_handle, len);
1693 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301694 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301695 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301696 }
1697
1698 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1699 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1700 WMITLV_SET_HDR(&cmd->tlv_header,
1701 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1702 WMITLV_GET_STRUCT_TLVLEN
1703 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301704
Govind Singhd3156eb2016-02-26 17:50:39 +05301705 cmd->vdev_id = param->vdev_id;
Govind Singh3419aea2016-03-28 22:02:42 +05301706 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1707 sizeof(param->peer_macaddr));
Govind Singhd3156eb2016-02-26 17:50:39 +05301708 cmd->peer_new_assoc = param->peer_new_assoc;
1709 cmd->peer_associd = param->peer_associd;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301710 copy_peer_flags_tlv(cmd, param);
Govind Singhd3156eb2016-02-26 17:50:39 +05301711 cmd->peer_rate_caps = param->peer_rate_caps;
1712 cmd->peer_caps = param->peer_caps;
1713 cmd->peer_listen_intval = param->peer_listen_intval;
1714 cmd->peer_ht_caps = param->peer_ht_caps;
1715 cmd->peer_max_mpdu = param->peer_max_mpdu;
1716 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301717 cmd->peer_vht_caps = param->peer_vht_caps;
1718 cmd->peer_phymode = param->peer_phymode;
1719
1720 /* Update peer legacy rate information */
1721 buf_ptr += sizeof(*cmd);
1722 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301723 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301724 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301725 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301726 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301727 param->peer_legacy_rates.num_rates);
1728
1729 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001730 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301731 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301732 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301733 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301734 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301735 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301736 param->peer_ht_rates.num_rates);
1737
1738 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001739 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301740 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1741 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1742
1743 cmd->peer_nss = param->peer_nss;
1744 mcs = (wmi_vht_rate_set *) buf_ptr;
1745 if (param->vht_capable) {
1746 mcs->rx_max_rate = param->rx_max_rate;
1747 mcs->rx_mcs_set = param->rx_mcs_set;
1748 mcs->tx_max_rate = param->tx_max_rate;
1749 mcs->tx_mcs_set = param->tx_mcs_set;
1750 }
1751
Govind Singhb53420c2016-03-09 14:32:57 +05301752 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301753 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1754 "nss %d phymode %d peer_mpdu_density %d "
1755 "cmd->peer_vht_caps %x", __func__,
1756 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1757 cmd->peer_rate_caps, cmd->peer_caps,
1758 cmd->peer_listen_intval, cmd->peer_ht_caps,
1759 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1760 cmd->peer_mpdu_density,
1761 cmd->peer_vht_caps);
1762
1763 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1764 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301765 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301766 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301767 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301768 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301769 }
1770
1771 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301772}
1773
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301774/* copy_scan_notify_events() - Helper routine to copy scan notify events
1775 */
1776#ifdef CONFIG_MCL
1777static inline void copy_scan_notify_ev_flags(
1778 wmi_start_scan_cmd_fixed_param * cmd,
1779 struct scan_start_params *params)
1780{
1781 cmd->notify_scan_events = params->notify_scan_events;
1782 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1783}
1784#else
1785static inline void copy_scan_notify_ev_flags(
1786 wmi_start_scan_cmd_fixed_param * cmd,
1787 struct scan_start_params *params)
1788{
1789 cmd->notify_scan_events = WMI_SCAN_EVENT_STARTED |
1790 WMI_SCAN_EVENT_COMPLETED |
1791 WMI_SCAN_EVENT_BSS_CHANNEL |
1792 WMI_SCAN_EVENT_FOREIGN_CHANNEL |
1793 WMI_SCAN_EVENT_DEQUEUED
1794 ;
1795 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1796 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
1797
1798 if (params->is_phy_error)
1799 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
1800}
1801#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301802/**
1803 * send_scan_start_cmd_tlv() - WMI scan start function
1804 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301805 * @param param : pointer to hold scan start cmd parameter
1806 *
1807 * Return: 0 on success and -ve on failure.
1808 */
Govind Singhb53420c2016-03-09 14:32:57 +05301809QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301810 struct scan_start_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05301811{
Govind Singhd3156eb2016-02-26 17:50:39 +05301812 int32_t ret = 0;
1813 int32_t i;
1814 wmi_buf_t wmi_buf;
1815 wmi_start_scan_cmd_fixed_param *cmd;
1816 uint8_t *buf_ptr;
1817 uint32_t *tmp_ptr;
1818 wmi_ssid *ssid = NULL;
1819 wmi_mac_addr *bssid;
1820 int len = sizeof(*cmd);
1821
1822 /* Length TLV placeholder for array of uint32_t */
1823 len += WMI_TLV_HDR_SIZE;
1824 /* calculate the length of buffer required */
1825 if (params->num_chan)
1826 len += params->num_chan * sizeof(uint32_t);
1827
1828 /* Length TLV placeholder for array of wmi_ssid structures */
1829 len += WMI_TLV_HDR_SIZE;
1830 if (params->num_ssids)
1831 len += params->num_ssids * sizeof(wmi_ssid);
1832
1833 /* Length TLV placeholder for array of wmi_mac_addr structures */
1834 len += WMI_TLV_HDR_SIZE;
1835 len += sizeof(wmi_mac_addr);
1836
1837 /* Length TLV placeholder for array of bytes */
1838 len += WMI_TLV_HDR_SIZE;
1839 if (params->ie_len)
1840 len += roundup(params->ie_len, sizeof(uint32_t));
1841
1842 /* Allocate the memory */
1843 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1844 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301845 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301846 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05301847 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05301848 }
1849 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1850 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
1851 WMITLV_SET_HDR(&cmd->tlv_header,
1852 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
1853 WMITLV_GET_STRUCT_TLVLEN
1854 (wmi_start_scan_cmd_fixed_param));
1855
1856 cmd->scan_id = params->scan_id;
1857 cmd->scan_req_id = params->scan_req_id;
1858 cmd->vdev_id = params->vdev_id;
1859 cmd->scan_priority = params->scan_priority;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301860 copy_scan_notify_ev_flags(cmd, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05301861 cmd->dwell_time_active = params->dwell_time_active;
1862 cmd->dwell_time_passive = params->dwell_time_passive;
1863 cmd->min_rest_time = params->min_rest_time;
1864 cmd->max_rest_time = params->max_rest_time;
1865 cmd->repeat_probe_time = params->repeat_probe_time;
1866 cmd->probe_spacing_time = params->probe_spacing_time;
1867 cmd->idle_time = params->idle_time;
1868 cmd->max_scan_time = params->max_scan_time;
1869 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05301870 cmd->burst_duration = params->burst_duration;
1871 cmd->num_chan = params->num_chan;
1872 cmd->num_bssid = params->num_bssid;
1873 cmd->num_ssids = params->num_ssids;
1874 cmd->ie_len = params->ie_len;
1875 cmd->n_probes = params->n_probes;
1876 buf_ptr += sizeof(*cmd);
1877 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
1878 for (i = 0; i < params->num_chan; ++i)
1879 tmp_ptr[i] = params->chan_list[i];
1880
1881 WMITLV_SET_HDR(buf_ptr,
1882 WMITLV_TAG_ARRAY_UINT32,
1883 (params->num_chan * sizeof(uint32_t)));
1884 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05301885 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05301886 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05301887 goto error;
1888 }
1889
1890 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1891 (params->num_ssids * sizeof(wmi_ssid)));
1892
1893 if (params->num_ssids) {
1894 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
1895 for (i = 0; i < params->num_ssids; ++i) {
1896 ssid->ssid_len = params->ssid[i].length;
Govind Singhb53420c2016-03-09 14:32:57 +05301897 qdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05301898 params->ssid[i].length);
1899 ssid++;
1900 }
1901 }
1902 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
1903
1904 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1905 (params->num_bssid * sizeof(wmi_mac_addr)));
1906 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
1907 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
1908 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
1909
1910 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, params->ie_len_with_pad);
1911 if (params->ie_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05301912 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singhd3156eb2016-02-26 17:50:39 +05301913 (uint8_t *) params->ie_base +
1914 (params->uie_fieldOffset), params->ie_len);
1915 }
1916 buf_ptr += WMI_TLV_HDR_SIZE + params->ie_len_with_pad;
1917
1918 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1919 len, WMI_START_SCAN_CMDID);
1920 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301921 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301922 wmi_buf_free(wmi_buf);
1923 }
1924 return ret;
1925error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05301926 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05301927 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301928}
1929
1930/**
1931 * send_scan_stop_cmd_tlv() - WMI scan start function
1932 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301933 * @param param : pointer to hold scan start cmd parameter
1934 *
1935 * Return: 0 on success and -ve on failure.
1936 */
Govind Singhb53420c2016-03-09 14:32:57 +05301937QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301938 struct scan_stop_params *param)
1939{
Govind Singhd3156eb2016-02-26 17:50:39 +05301940 wmi_stop_scan_cmd_fixed_param *cmd;
1941 int ret;
1942 int len = sizeof(*cmd);
1943 wmi_buf_t wmi_buf;
1944
1945 /* Allocate the memory */
1946 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1947 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301948 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301949 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301950 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301951 goto error;
1952 }
1953
1954 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1955 WMITLV_SET_HDR(&cmd->tlv_header,
1956 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
1957 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
1958 cmd->vdev_id = param->vdev_id;
1959 cmd->requestor = param->requestor;
1960 cmd->scan_id = param->scan_id;
1961 /* stop the scan with the corresponding scan_id */
1962 cmd->req_type = param->req_type;
1963 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1964 len, WMI_STOP_SCAN_CMDID);
1965 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301966 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301967 wmi_buf_free(wmi_buf);
1968 }
1969
1970error:
1971 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301972}
1973
Govind Singh87542482016-06-08 19:40:11 +05301974#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301975/**
1976 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
1977 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301978 * @param param : pointer to hold scan channel list parameter
1979 *
1980 * Return: 0 on success and -ve on failure.
1981 */
Govind Singhb53420c2016-03-09 14:32:57 +05301982QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301983 struct scan_chan_list_params *chan_list)
1984{
1985 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05301986 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05301987 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301988 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05301989 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05301990 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05301991 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
1992
1993 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
1994 buf = wmi_buf_alloc(wmi_handle, len);
1995 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301996 WMI_LOGE("Failed to allocate memory");
1997 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301998 goto end;
1999 }
2000
2001 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2002 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2003 WMITLV_SET_HDR(&cmd->tlv_header,
2004 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2005 WMITLV_GET_STRUCT_TLVLEN
2006 (wmi_scan_chan_list_cmd_fixed_param));
2007
Govind Singhb53420c2016-03-09 14:32:57 +05302008 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302009
2010 cmd->num_scan_chans = chan_list->num_scan_chans;
2011 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2012 WMITLV_TAG_ARRAY_STRUC,
2013 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302014 chan_info = (wmi_channel_param *)
2015 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302016 tchan_info = chan_list->chan_info;
2017
2018 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2019 WMITLV_SET_HDR(&chan_info->tlv_header,
2020 WMITLV_TAG_STRUC_wmi_channel,
2021 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2022 chan_info->mhz = tchan_info->mhz;
2023 chan_info->band_center_freq1 =
2024 tchan_info->band_center_freq1;
2025 chan_info->band_center_freq2 =
2026 tchan_info->band_center_freq2;
2027 chan_info->info = tchan_info->info;
2028 chan_info->reg_info_1 = tchan_info->reg_info_1;
2029 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302030 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302031
2032 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2033 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2034 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2035 tchan_info++;
2036 chan_info++;
2037 }
2038
Govind Singh67922e82016-04-01 16:48:57 +05302039 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singhd3156eb2016-02-26 17:50:39 +05302040 WMI_SCAN_CHAN_LIST_CMDID);
2041
Govind Singh67922e82016-04-01 16:48:57 +05302042 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302043 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302044 wmi_buf_free(buf);
2045 }
Govind Singh67922e82016-04-01 16:48:57 +05302046
Govind Singhd3156eb2016-02-26 17:50:39 +05302047end:
Govind Singhb53420c2016-03-09 14:32:57 +05302048 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302049}
Govind Singh87542482016-06-08 19:40:11 +05302050#else
2051QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
2052 struct scan_chan_list_params *chan_list)
2053{
2054 wmi_buf_t buf;
2055 QDF_STATUS qdf_status;
2056 wmi_scan_chan_list_cmd_fixed_param *cmd;
2057 int i;
2058 uint8_t *buf_ptr;
2059 wmi_channel *chan_info;
2060 struct channel_param *tchan_info;
2061 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302062
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302063 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302064 buf = wmi_buf_alloc(wmi_handle, len);
2065 if (!buf) {
2066 WMI_LOGE("Failed to allocate memory");
2067 qdf_status = QDF_STATUS_E_NOMEM;
2068 goto end;
2069 }
2070
2071 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2072 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2073 WMITLV_SET_HDR(&cmd->tlv_header,
2074 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2075 WMITLV_GET_STRUCT_TLVLEN
2076 (wmi_scan_chan_list_cmd_fixed_param));
2077
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302078 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302079
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302080 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302081 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2082 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302083 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302084 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2085 tchan_info = &(chan_list->ch_param[0]);
2086
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302087 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302088 WMITLV_SET_HDR(&chan_info->tlv_header,
2089 WMITLV_TAG_STRUC_wmi_channel,
2090 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2091 chan_info->mhz = tchan_info->mhz;
2092 chan_info->band_center_freq1 =
2093 tchan_info->cfreq1;
2094 chan_info->band_center_freq2 =
2095 tchan_info->cfreq2;
2096
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302097 if (tchan_info->is_chan_passive)
2098 WMI_SET_CHANNEL_FLAG(chan_info,
2099 WMI_CHAN_FLAG_PASSIVE);
2100
2101 if (tchan_info->allow_vht)
2102 WMI_SET_CHANNEL_FLAG(chan_info,
2103 WMI_CHAN_FLAG_ALLOW_VHT);
2104 else if (tchan_info->allow_ht)
2105 WMI_SET_CHANNEL_FLAG(chan_info,
2106 WMI_CHAN_FLAG_ALLOW_HT);
2107 WMI_SET_CHANNEL_MODE(chan_info,
2108 tchan_info->phy_mode);
2109
2110 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2111 * after FW support
2112 */
2113
2114 /* also fill in power information */
2115 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2116 tchan_info->minpower);
2117 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2118 tchan_info->maxpower);
2119 WMI_SET_CHANNEL_REG_POWER(chan_info,
2120 tchan_info->maxregpower);
2121 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2122 tchan_info->antennamax);
2123 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2124 tchan_info->reg_class_id);
2125
Govind Singh87542482016-06-08 19:40:11 +05302126 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2127
Govind Singh87542482016-06-08 19:40:11 +05302128 tchan_info++;
2129 chan_info++;
2130 }
2131
2132 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
2133 WMI_SCAN_CHAN_LIST_CMDID);
2134
2135 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2136 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2137 wmi_buf_free(buf);
2138 }
2139
2140end:
2141 return qdf_status;
2142}
2143#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302144/**
2145 * send_mgmt_cmd_tlv() - WMI scan start function
2146 * @wmi_handle : handle to WMI.
2147 * @param : pointer to hold mgmt cmd parameter
2148 *
2149 * Return: 0 on success and -ve on failure.
2150 */
Govind Singhb53420c2016-03-09 14:32:57 +05302151QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302152 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302153{
Govind Singh427ee5a2016-02-26 18:09:36 +05302154 wmi_buf_t buf;
2155 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2156 int32_t cmd_len;
2157 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302158 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302159 uint8_t *bufp;
2160 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2161 mgmt_tx_dl_frm_len;
2162
2163 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2164 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2165
2166 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2167 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302168 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2169 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302170 }
2171
2172 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2173 bufp = (uint8_t *) cmd;
2174 WMITLV_SET_HDR(&cmd->tlv_header,
2175 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2176 WMITLV_GET_STRUCT_TLVLEN
2177 (wmi_mgmt_tx_send_cmd_fixed_param));
2178
2179 cmd->vdev_id = param->vdev_id;
2180
Govind Singh224a7312016-06-21 14:33:26 +05302181 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302182 cmd->chanfreq = param->chanfreq;
2183 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2184 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2185 sizeof(uint32_t)));
2186 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302187 qdf_mem_copy(bufp, param->pdata, bufp_len);
2188 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2189 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302190 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2191#if defined(HELIUMPLUS_PADDR64)
2192 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2193#endif
2194 cmd->frame_len = param->frm_len;
2195 cmd->buf_len = bufp_len;
2196
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002197 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002198 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002199
Govind Singh427ee5a2016-02-26 18:09:36 +05302200 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2201 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302202 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302203 goto err1;
2204 }
Govind Singhb53420c2016-03-09 14:32:57 +05302205 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302206
2207err1:
2208 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302209 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302210}
2211
2212/**
2213 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2214 * @wmi_handle: wmi handle
2215 * @param_value: parameter value
2216 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302217 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302218 */
Govind Singhb53420c2016-03-09 14:32:57 +05302219QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302220 uint32_t param_value)
2221{
Govind Singh67922e82016-04-01 16:48:57 +05302222 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302223 wmi_modem_power_state_cmd_param *cmd;
2224 wmi_buf_t buf;
2225 uint16_t len = sizeof(*cmd);
2226
2227 buf = wmi_buf_alloc(wmi_handle, len);
2228 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302229 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302230 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302231 }
2232 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2233 WMITLV_SET_HDR(&cmd->tlv_header,
2234 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2235 WMITLV_GET_STRUCT_TLVLEN
2236 (wmi_modem_power_state_cmd_param));
2237 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302238 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302239 param_value);
2240 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2241 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302242 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302243 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302244 wmi_buf_free(buf);
2245 }
Govind Singh67922e82016-04-01 16:48:57 +05302246
Govind Singh427ee5a2016-02-26 18:09:36 +05302247 return ret;
2248}
2249
2250/**
2251 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2252 * @wmi_handle: wmi handle
2253 * @vdev_id: vdev id
2254 * @val: value
2255 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302256 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302257 */
Govind Singhb53420c2016-03-09 14:32:57 +05302258QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302259 uint32_t vdev_id, uint8_t val)
2260{
2261 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2262 wmi_buf_t buf;
2263 int32_t len = sizeof(*cmd);
2264
Govind Singhb53420c2016-03-09 14:32:57 +05302265 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302266
2267 buf = wmi_buf_alloc(wmi_handle, len);
2268 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302269 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302270 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302271 }
2272 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2273 WMITLV_SET_HDR(&cmd->tlv_header,
2274 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2275 WMITLV_GET_STRUCT_TLVLEN
2276 (wmi_sta_powersave_mode_cmd_fixed_param));
2277 cmd->vdev_id = vdev_id;
2278 if (val)
2279 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2280 else
2281 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2282
2283 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2284 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302285 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302286 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302287 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302288 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302289 }
Govind Singh5eb51532016-03-09 11:34:12 +05302290 return 0;
2291}
2292
Govind Singh427ee5a2016-02-26 18:09:36 +05302293/**
2294 * send_set_mimops_cmd_tlv() - set MIMO powersave
2295 * @wmi_handle: wmi handle
2296 * @vdev_id: vdev id
2297 * @value: value
2298 *
Govind Singhb53420c2016-03-09 14:32:57 +05302299 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302300 */
Govind Singhb53420c2016-03-09 14:32:57 +05302301QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302302 uint8_t vdev_id, int value)
2303{
Govind Singh67922e82016-04-01 16:48:57 +05302304 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302305 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2306 wmi_buf_t buf;
2307 uint16_t len = sizeof(*cmd);
2308
2309 buf = wmi_buf_alloc(wmi_handle, len);
2310 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302311 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302312 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302313 }
2314 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2315 WMITLV_SET_HDR(&cmd->tlv_header,
2316 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2317 WMITLV_GET_STRUCT_TLVLEN
2318 (wmi_sta_smps_force_mode_cmd_fixed_param));
2319
2320 cmd->vdev_id = vdev_id;
2321
Houston Hoffmanb5168052016-04-14 02:18:01 -07002322 /* WMI_SMPS_FORCED_MODE values do not directly map
2323 * to SM power save values defined in the specification.
2324 * Make sure to send the right mapping.
2325 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302326 switch (value) {
2327 case 0:
2328 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2329 break;
2330 case 1:
2331 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2332 break;
2333 case 2:
2334 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2335 break;
2336 case 3:
2337 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2338 break;
2339 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302340 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2341 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302342 }
2343
Govind Singhb53420c2016-03-09 14:32:57 +05302344 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302345
2346 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2347 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302348 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302349 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302350 wmi_buf_free(buf);
2351 }
2352
2353 return ret;
2354}
2355
2356/**
2357 * send_set_smps_params_cmd_tlv() - set smps params
2358 * @wmi_handle: wmi handle
2359 * @vdev_id: vdev id
2360 * @value: value
2361 *
Govind Singhb53420c2016-03-09 14:32:57 +05302362 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302363 */
Govind Singhb53420c2016-03-09 14:32:57 +05302364QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302365 int value)
2366{
Govind Singh67922e82016-04-01 16:48:57 +05302367 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302368 wmi_sta_smps_param_cmd_fixed_param *cmd;
2369 wmi_buf_t buf;
2370 uint16_t len = sizeof(*cmd);
2371
2372 buf = wmi_buf_alloc(wmi_handle, len);
2373 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302374 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302375 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302376 }
2377 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2378 WMITLV_SET_HDR(&cmd->tlv_header,
2379 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2380 WMITLV_GET_STRUCT_TLVLEN
2381 (wmi_sta_smps_param_cmd_fixed_param));
2382
2383 cmd->vdev_id = vdev_id;
2384 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2385 cmd->param =
2386 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2387
Govind Singhb53420c2016-03-09 14:32:57 +05302388 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302389 cmd->param);
2390
2391 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2392 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302393 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302394 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302395 wmi_buf_free(buf);
2396 }
2397
2398 return ret;
2399}
2400
2401/**
2402 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2403 * @wmi_handle: wmi handle
2404 * @noa: p2p power save parameters
2405 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302406 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302407 */
Govind Singhb53420c2016-03-09 14:32:57 +05302408QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302409 struct p2p_ps_params *noa)
2410{
2411 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2412 wmi_p2p_noa_descriptor *noa_discriptor;
2413 wmi_buf_t buf;
2414 uint8_t *buf_ptr;
2415 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302416 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302417 uint32_t duration;
2418
Govind Singhb53420c2016-03-09 14:32:57 +05302419 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302420 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2421 buf = wmi_buf_alloc(wmi_handle, len);
2422 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302423 WMI_LOGE("Failed to allocate memory");
2424 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302425 goto end;
2426 }
2427
2428 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2429 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2430 WMITLV_SET_HDR(&cmd->tlv_header,
2431 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2432 WMITLV_GET_STRUCT_TLVLEN
2433 (wmi_p2p_set_noa_cmd_fixed_param));
2434 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2435 cmd->vdev_id = noa->session_id;
2436 cmd->enable = (duration) ? true : false;
2437 cmd->num_noa = 1;
2438
2439 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2440 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2441 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2442 sizeof
2443 (wmi_p2p_set_noa_cmd_fixed_param)
2444 + WMI_TLV_HDR_SIZE);
2445 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2446 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2447 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2448 noa_discriptor->type_count = noa->count;
2449 noa_discriptor->duration = duration;
2450 noa_discriptor->interval = noa->interval;
2451 noa_discriptor->start_time = 0;
2452
Govind Singhb53420c2016-03-09 14:32:57 +05302453 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302454 cmd->vdev_id, noa->count, noa_discriptor->duration,
2455 noa->interval);
2456 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2457 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302458 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302459 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302460 wmi_buf_free(buf);
2461 }
2462
2463end:
Govind Singhb53420c2016-03-09 14:32:57 +05302464 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302465 return status;
2466}
2467
2468
2469/**
2470 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2471 * @wmi_handle: wmi handle
2472 * @noa: p2p opp power save parameters
2473 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302474 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302475 */
Govind Singhb53420c2016-03-09 14:32:57 +05302476QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302477 struct p2p_ps_params *oppps)
2478{
2479 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2480 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302481 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302482
Govind Singhb53420c2016-03-09 14:32:57 +05302483 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302484 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2485 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302486 WMI_LOGE("Failed to allocate memory");
2487 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302488 goto end;
2489 }
2490
2491 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2492 WMITLV_SET_HDR(&cmd->tlv_header,
2493 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2494 WMITLV_GET_STRUCT_TLVLEN
2495 (wmi_p2p_set_oppps_cmd_fixed_param));
2496 cmd->vdev_id = oppps->session_id;
2497 if (oppps->ctwindow)
2498 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2499
2500 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302501 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302502 cmd->vdev_id, oppps->ctwindow);
2503 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2504 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302505 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302506 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302507 wmi_buf_free(buf);
2508 }
2509
2510end:
Govind Singhb53420c2016-03-09 14:32:57 +05302511 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302512 return status;
2513}
2514
2515/**
2516 * send_get_temperature_cmd_tlv() - get pdev temperature req
2517 * @wmi_handle: wmi handle
2518 *
Govind Singhb53420c2016-03-09 14:32:57 +05302519 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302520 */
Govind Singhb53420c2016-03-09 14:32:57 +05302521QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05302522{
2523 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
2524 wmi_buf_t wmi_buf;
2525 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
2526 uint8_t *buf_ptr;
2527
2528 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05302529 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
2530 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05302531 }
2532
2533 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2534 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302535 WMI_LOGE(FL("wmi_buf_alloc failed"));
2536 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302537 }
2538
2539 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2540
2541 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
2542 WMITLV_SET_HDR(&cmd->tlv_header,
2543 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
2544 WMITLV_GET_STRUCT_TLVLEN
2545 (wmi_pdev_get_temperature_cmd_fixed_param));
2546
2547 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
2548 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302549 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05302550 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302551 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302552 }
Govind Singh2edc80f2016-03-01 15:30:53 +05302553
Govind Singhb53420c2016-03-09 14:32:57 +05302554 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302555}
2556
2557/**
2558 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
2559 * @wmi_handle: wmi handle
2560 * @vdevid: vdev id
2561 * @peer_addr: peer mac address
2562 * @auto_triggerparam: auto trigger parameters
2563 * @num_ac: number of access category
2564 *
2565 * This function sets the trigger
2566 * uapsd params such as service interval, delay interval
2567 * and suspend interval which will be used by the firmware
2568 * to send trigger frames periodically when there is no
2569 * traffic on the transmit side.
2570 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302571 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302572 */
Govind Singhb53420c2016-03-09 14:32:57 +05302573QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302574 struct sta_uapsd_trig_params *param)
2575{
2576 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302577 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302578 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
2579 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
2580 uint32_t i;
2581 wmi_buf_t buf;
2582 uint8_t *buf_ptr;
2583
2584 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2585 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302586 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302587 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302588 }
2589
2590 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2591 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
2592 WMITLV_SET_HDR(&cmd->tlv_header,
2593 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
2594 WMITLV_GET_STRUCT_TLVLEN
2595 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
2596 cmd->vdev_id = param->vdevid;
2597 cmd->num_ac = param->num_ac;
2598 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
2599
2600 /* TLV indicating array of structures to follow */
2601 buf_ptr += sizeof(*cmd);
2602 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
2603
2604 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302605 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302606
2607 /*
2608 * Update tag and length for uapsd auto trigger params (this will take
2609 * care of updating tag and length if it is not pre-filled by caller).
2610 */
2611 for (i = 0; i < param->num_ac; i++) {
2612 WMITLV_SET_HDR((buf_ptr +
2613 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
2614 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
2615 WMITLV_GET_STRUCT_TLVLEN
2616 (wmi_sta_uapsd_auto_trig_param));
2617 }
2618
2619 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2620 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302621 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302622 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302623 wmi_buf_free(buf);
2624 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05302625
Govind Singh427ee5a2016-02-26 18:09:36 +05302626 return ret;
2627}
2628
Govind Singh2edc80f2016-03-01 15:30:53 +05302629/**
2630 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
2631 * @wmi_handle: pointer to the wmi handle
2632 * @utc: pointer to the UTC time struct
2633 *
2634 * Return: 0 on succes
2635 */
Govind Singhb53420c2016-03-09 14:32:57 +05302636QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302637 struct ocb_utc_param *utc)
2638{
Govind Singh67922e82016-04-01 16:48:57 +05302639 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302640 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
2641 uint8_t *buf_ptr;
2642 uint32_t len, i;
2643 wmi_buf_t buf;
2644
2645 len = sizeof(*cmd);
2646 buf = wmi_buf_alloc(wmi_handle, len);
2647 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302648 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302649 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302650 }
2651
2652 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2653 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
2654 WMITLV_SET_HDR(&cmd->tlv_header,
2655 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
2656 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
2657 cmd->vdev_id = utc->vdev_id;
2658
2659 for (i = 0; i < SIZE_UTC_TIME; i++)
2660 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
2661
2662 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
2663 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
2664
2665 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2666 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302667 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302668 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302669 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302670 }
2671
Govind Singh67922e82016-04-01 16:48:57 +05302672 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302673}
2674
2675/**
2676 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
2677 * frames on a channel
2678 * @wmi_handle: pointer to the wmi handle
2679 * @timing_advert: pointer to the timing advertisement struct
2680 *
2681 * Return: 0 on succes
2682 */
Govind Singhb53420c2016-03-09 14:32:57 +05302683QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302684 struct ocb_timing_advert_param *timing_advert)
2685{
Govind Singh67922e82016-04-01 16:48:57 +05302686 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302687 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
2688 uint8_t *buf_ptr;
2689 uint32_t len, len_template;
2690 wmi_buf_t buf;
2691
2692 len = sizeof(*cmd) +
2693 WMI_TLV_HDR_SIZE;
2694
2695 len_template = timing_advert->template_length;
2696 /* Add padding to the template if needed */
2697 if (len_template % 4 != 0)
2698 len_template += 4 - (len_template % 4);
2699 len += len_template;
2700
2701 buf = wmi_buf_alloc(wmi_handle, len);
2702 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302703 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302704 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302705 }
2706
2707 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2708 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
2709 WMITLV_SET_HDR(&cmd->tlv_header,
2710 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
2711 WMITLV_GET_STRUCT_TLVLEN(
2712 wmi_ocb_start_timing_advert_cmd_fixed_param));
2713 cmd->vdev_id = timing_advert->vdev_id;
2714 cmd->repeat_rate = timing_advert->repeat_rate;
2715 cmd->channel_freq = timing_advert->chan_freq;
2716 cmd->timestamp_offset = timing_advert->timestamp_offset;
2717 cmd->time_value_offset = timing_advert->time_value_offset;
2718 cmd->timing_advert_template_length = timing_advert->template_length;
2719 buf_ptr += sizeof(*cmd);
2720
2721 /* Add the timing advert template */
2722 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2723 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05302724 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05302725 (uint8_t *)timing_advert->template_value,
2726 timing_advert->template_length);
2727
2728 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2729 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302730 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302731 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302732 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302733 }
2734
Govind Singh67922e82016-04-01 16:48:57 +05302735 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302736}
2737
2738/**
2739 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
2740 * on a channel
2741 * @wmi_handle: pointer to the wmi handle
2742 * @timing_advert: pointer to the timing advertisement struct
2743 *
2744 * Return: 0 on succes
2745 */
Govind Singhb53420c2016-03-09 14:32:57 +05302746QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302747 struct ocb_timing_advert_param *timing_advert)
2748{
Govind Singh67922e82016-04-01 16:48:57 +05302749 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302750 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
2751 uint8_t *buf_ptr;
2752 uint32_t len;
2753 wmi_buf_t buf;
2754
2755 len = sizeof(*cmd);
2756 buf = wmi_buf_alloc(wmi_handle, len);
2757 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302758 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302759 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302760 }
2761
2762 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2763 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
2764 WMITLV_SET_HDR(&cmd->tlv_header,
2765 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
2766 WMITLV_GET_STRUCT_TLVLEN(
2767 wmi_ocb_stop_timing_advert_cmd_fixed_param));
2768 cmd->vdev_id = timing_advert->vdev_id;
2769 cmd->channel_freq = timing_advert->chan_freq;
2770
2771 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2772 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302773 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302774 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302775 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302776 }
2777
Govind Singh67922e82016-04-01 16:48:57 +05302778 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302779}
2780
2781/**
2782 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
2783 * @wmi_handle: pointer to the wmi handle
2784 * @request: pointer to the request
2785 *
2786 * Return: 0 on succes
2787 */
Govind Singhb53420c2016-03-09 14:32:57 +05302788QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302789 uint8_t vdev_id)
2790{
Govind Singhb53420c2016-03-09 14:32:57 +05302791 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302792 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
2793 uint8_t *buf_ptr;
2794 wmi_buf_t buf;
2795 int32_t len;
2796
2797 len = sizeof(*cmd);
2798 buf = wmi_buf_alloc(wmi_handle, len);
2799 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302800 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302801 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302802 }
2803 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2804
2805 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302806 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302807 WMITLV_SET_HDR(&cmd->tlv_header,
2808 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
2809 WMITLV_GET_STRUCT_TLVLEN(
2810 wmi_ocb_get_tsf_timer_cmd_fixed_param));
2811 cmd->vdev_id = vdev_id;
2812
2813 /* Send the WMI command */
2814 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2815 WMI_OCB_GET_TSF_TIMER_CMDID);
2816 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05302817 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302818 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302819 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302820 }
2821
Govind Singh67922e82016-04-01 16:48:57 +05302822 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302823}
2824
2825/**
2826 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
2827 * @wmi_handle: pointer to the wmi handle
2828 * @get_stats_param: pointer to the dcc stats
2829 *
2830 * Return: 0 on succes
2831 */
Govind Singhb53420c2016-03-09 14:32:57 +05302832QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302833 struct dcc_get_stats_param *get_stats_param)
2834{
Govind Singh67922e82016-04-01 16:48:57 +05302835 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302836 wmi_dcc_get_stats_cmd_fixed_param *cmd;
2837 wmi_dcc_channel_stats_request *channel_stats_array;
2838 wmi_buf_t buf;
2839 uint8_t *buf_ptr;
2840 uint32_t len;
2841 uint32_t i;
2842
2843 /* Validate the input */
2844 if (get_stats_param->request_array_len !=
2845 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302846 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05302847 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302848 }
2849
2850 /* Allocate memory for the WMI command */
2851 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
2852 get_stats_param->request_array_len;
2853
2854 buf = wmi_buf_alloc(wmi_handle, len);
2855 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302856 WMI_LOGE(FL("wmi_buf_alloc failed"));
2857 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302858 }
2859
2860 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302861 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302862
2863 /* Populate the WMI command */
2864 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
2865 buf_ptr += sizeof(*cmd);
2866
2867 WMITLV_SET_HDR(&cmd->tlv_header,
2868 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
2869 WMITLV_GET_STRUCT_TLVLEN(
2870 wmi_dcc_get_stats_cmd_fixed_param));
2871 cmd->vdev_id = get_stats_param->vdev_id;
2872 cmd->num_channels = get_stats_param->channel_count;
2873
2874 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2875 get_stats_param->request_array_len);
2876 buf_ptr += WMI_TLV_HDR_SIZE;
2877
2878 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302879 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05302880 get_stats_param->request_array_len);
2881 for (i = 0; i < cmd->num_channels; i++)
2882 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
2883 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
2884 WMITLV_GET_STRUCT_TLVLEN(
2885 wmi_dcc_channel_stats_request));
2886
2887 /* Send the WMI command */
2888 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2889 WMI_DCC_GET_STATS_CMDID);
2890
Govind Singh67922e82016-04-01 16:48:57 +05302891 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302892 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302893 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302894 }
2895
Govind Singh67922e82016-04-01 16:48:57 +05302896 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302897}
2898
2899/**
2900 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
2901 * @wmi_handle: pointer to the wmi handle
2902 * @vdev_id: vdev id
2903 * @dcc_stats_bitmap: dcc status bitmap
2904 *
2905 * Return: 0 on succes
2906 */
Govind Singhb53420c2016-03-09 14:32:57 +05302907QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302908 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
2909{
Govind Singh67922e82016-04-01 16:48:57 +05302910 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302911 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
2912 wmi_buf_t buf;
2913 uint8_t *buf_ptr;
2914 uint32_t len;
2915
2916 /* Allocate memory for the WMI command */
2917 len = sizeof(*cmd);
2918
2919 buf = wmi_buf_alloc(wmi_handle, len);
2920 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302921 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302922 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302923 }
2924
2925 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302926 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302927
2928 /* Populate the WMI command */
2929 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
2930
2931 WMITLV_SET_HDR(&cmd->tlv_header,
2932 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
2933 WMITLV_GET_STRUCT_TLVLEN(
2934 wmi_dcc_clear_stats_cmd_fixed_param));
2935 cmd->vdev_id = vdev_id;
2936 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
2937
2938 /* Send the WMI command */
2939 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2940 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302941 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302942 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302943 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302944 }
2945
Govind Singh67922e82016-04-01 16:48:57 +05302946 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302947}
2948
2949/**
2950 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
2951 * @wmi_handle: pointer to the wmi handle
2952 * @update_ndl_param: pointer to the request parameters
2953 *
2954 * Return: 0 on success
2955 */
Govind Singhb53420c2016-03-09 14:32:57 +05302956QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302957 struct dcc_update_ndl_param *update_ndl_param)
2958{
Govind Singhb53420c2016-03-09 14:32:57 +05302959 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05302960 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
2961 wmi_dcc_ndl_chan *ndl_chan_array;
2962 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
2963 uint32_t active_state_count;
2964 wmi_buf_t buf;
2965 uint8_t *buf_ptr;
2966 uint32_t len;
2967 uint32_t i;
2968
2969 /* validate the input */
2970 if (update_ndl_param->dcc_ndl_chan_list_len !=
2971 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302972 WMI_LOGE(FL("Invalid parameter"));
2973 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302974 }
2975 active_state_count = 0;
2976 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
2977 for (i = 0; i < update_ndl_param->channel_count; i++)
2978 active_state_count +=
2979 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
2980 if (update_ndl_param->dcc_ndl_active_state_list_len !=
2981 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302982 WMI_LOGE(FL("Invalid parameter"));
2983 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302984 }
2985
2986 /* Allocate memory for the WMI command */
2987 len = sizeof(*cmd) +
2988 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
2989 WMI_TLV_HDR_SIZE +
2990 update_ndl_param->dcc_ndl_active_state_list_len;
2991
2992 buf = wmi_buf_alloc(wmi_handle, len);
2993 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302994 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302995 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302996 }
2997
2998 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302999 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303000
3001 /* Populate the WMI command */
3002 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3003 buf_ptr += sizeof(*cmd);
3004
3005 WMITLV_SET_HDR(&cmd->tlv_header,
3006 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3007 WMITLV_GET_STRUCT_TLVLEN(
3008 wmi_dcc_update_ndl_cmd_fixed_param));
3009 cmd->vdev_id = update_ndl_param->vdev_id;
3010 cmd->num_channel = update_ndl_param->channel_count;
3011
3012 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3013 update_ndl_param->dcc_ndl_chan_list_len);
3014 buf_ptr += WMI_TLV_HDR_SIZE;
3015
3016 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303017 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303018 update_ndl_param->dcc_ndl_chan_list_len);
3019 for (i = 0; i < cmd->num_channel; i++)
3020 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3021 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3022 WMITLV_GET_STRUCT_TLVLEN(
3023 wmi_dcc_ndl_chan));
3024 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3025
3026 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3027 update_ndl_param->dcc_ndl_active_state_list_len);
3028 buf_ptr += WMI_TLV_HDR_SIZE;
3029
3030 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303031 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303032 update_ndl_param->dcc_ndl_active_state_list,
3033 update_ndl_param->dcc_ndl_active_state_list_len);
3034 for (i = 0; i < active_state_count; i++) {
3035 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3036 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3037 WMITLV_GET_STRUCT_TLVLEN(
3038 wmi_dcc_ndl_active_state_config));
3039 }
3040 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3041
3042 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303043 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303044 WMI_DCC_UPDATE_NDL_CMDID);
3045 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303046 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303047 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303048 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303049 }
3050
Govind Singh67922e82016-04-01 16:48:57 +05303051 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303052}
3053
3054/**
3055 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3056 * @wmi_handle: pointer to the wmi handle
3057 * @config: the OCB configuration
3058 *
3059 * Return: 0 on success
3060 */
Govind Singhb53420c2016-03-09 14:32:57 +05303061QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303062 struct ocb_config_param *config, uint32_t *ch_mhz)
3063{
Govind Singh67922e82016-04-01 16:48:57 +05303064 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303065 wmi_ocb_set_config_cmd_fixed_param *cmd;
3066 wmi_channel *chan;
3067 wmi_ocb_channel *ocb_chan;
3068 wmi_qos_parameter *qos_param;
3069 wmi_dcc_ndl_chan *ndl_chan;
3070 wmi_dcc_ndl_active_state_config *ndl_active_config;
3071 wmi_ocb_schedule_element *sched_elem;
3072 uint8_t *buf_ptr;
3073 wmi_buf_t buf;
3074 int32_t len;
3075 int32_t i, j, active_state_count;
3076
3077 /*
3078 * Validate the dcc_ndl_chan_list_len and count the number of active
3079 * states. Validate dcc_ndl_active_state_list_len.
3080 */
3081 active_state_count = 0;
3082 if (config->dcc_ndl_chan_list_len) {
3083 if (!config->dcc_ndl_chan_list ||
3084 config->dcc_ndl_chan_list_len !=
3085 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303086 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303087 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303088 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303089 }
3090
3091 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3092 i < config->channel_count; ++i, ++ndl_chan)
3093 active_state_count +=
3094 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3095
3096 if (active_state_count) {
3097 if (!config->dcc_ndl_active_state_list ||
3098 config->dcc_ndl_active_state_list_len !=
3099 active_state_count *
3100 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303101 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303102 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303103 }
3104 }
3105 }
3106
3107 len = sizeof(*cmd) +
3108 WMI_TLV_HDR_SIZE + config->channel_count *
3109 sizeof(wmi_channel) +
3110 WMI_TLV_HDR_SIZE + config->channel_count *
3111 sizeof(wmi_ocb_channel) +
3112 WMI_TLV_HDR_SIZE + config->channel_count *
3113 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3114 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3115 WMI_TLV_HDR_SIZE + active_state_count *
3116 sizeof(wmi_dcc_ndl_active_state_config) +
3117 WMI_TLV_HDR_SIZE + config->schedule_size *
3118 sizeof(wmi_ocb_schedule_element);
3119 buf = wmi_buf_alloc(wmi_handle, len);
3120 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303121 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303122 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303123 }
3124
3125 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3126 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3127 WMITLV_SET_HDR(&cmd->tlv_header,
3128 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3129 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3130 cmd->vdev_id = config->session_id;
3131 cmd->channel_count = config->channel_count;
3132 cmd->schedule_size = config->schedule_size;
3133 cmd->flags = config->flags;
3134 buf_ptr += sizeof(*cmd);
3135
3136 /* Add the wmi_channel info */
3137 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3138 config->channel_count*sizeof(wmi_channel));
3139 buf_ptr += WMI_TLV_HDR_SIZE;
3140 for (i = 0; i < config->channel_count; i++) {
3141 chan = (wmi_channel *)buf_ptr;
3142 WMITLV_SET_HDR(&chan->tlv_header,
3143 WMITLV_TAG_STRUC_wmi_channel,
3144 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3145 chan->mhz = config->channels[i].chan_freq;
3146 chan->band_center_freq1 = config->channels[i].chan_freq;
3147 chan->band_center_freq2 = 0;
3148 chan->info = 0;
3149
3150 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3151 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3152 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3153 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3154 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3155 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3156 config->channels[i].antenna_max);
3157
3158 if (config->channels[i].bandwidth < 10)
3159 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3160 else if (config->channels[i].bandwidth < 20)
3161 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3162 buf_ptr += sizeof(*chan);
3163 }
3164
3165 /* Add the wmi_ocb_channel info */
3166 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3167 config->channel_count*sizeof(wmi_ocb_channel));
3168 buf_ptr += WMI_TLV_HDR_SIZE;
3169 for (i = 0; i < config->channel_count; i++) {
3170 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3171 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3172 WMITLV_TAG_STRUC_wmi_ocb_channel,
3173 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3174 ocb_chan->bandwidth = config->channels[i].bandwidth;
3175 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3176 config->channels[i].mac_address.bytes,
3177 &ocb_chan->mac_address);
3178 buf_ptr += sizeof(*ocb_chan);
3179 }
3180
3181 /* Add the wmi_qos_parameter info */
3182 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3183 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3184 buf_ptr += WMI_TLV_HDR_SIZE;
3185 /* WMI_MAX_NUM_AC parameters for each channel */
3186 for (i = 0; i < config->channel_count; i++) {
3187 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3188 qos_param = (wmi_qos_parameter *)buf_ptr;
3189 WMITLV_SET_HDR(&qos_param->tlv_header,
3190 WMITLV_TAG_STRUC_wmi_qos_parameter,
3191 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3192 qos_param->aifsn =
3193 config->channels[i].qos_params[j].aifsn;
3194 qos_param->cwmin =
3195 config->channels[i].qos_params[j].cwmin;
3196 qos_param->cwmax =
3197 config->channels[i].qos_params[j].cwmax;
3198 buf_ptr += sizeof(*qos_param);
3199 }
3200 }
3201
3202 /* Add the wmi_dcc_ndl_chan (per channel) */
3203 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3204 config->dcc_ndl_chan_list_len);
3205 buf_ptr += WMI_TLV_HDR_SIZE;
3206 if (config->dcc_ndl_chan_list_len) {
3207 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303208 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303209 config->dcc_ndl_chan_list_len);
3210 for (i = 0; i < config->channel_count; i++)
3211 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3212 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3213 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3214 buf_ptr += config->dcc_ndl_chan_list_len;
3215 }
3216
3217 /* Add the wmi_dcc_ndl_active_state_config */
3218 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3219 sizeof(wmi_dcc_ndl_active_state_config));
3220 buf_ptr += WMI_TLV_HDR_SIZE;
3221 if (active_state_count) {
3222 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303223 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303224 config->dcc_ndl_active_state_list,
3225 active_state_count * sizeof(*ndl_active_config));
3226 for (i = 0; i < active_state_count; ++i)
3227 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3228 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3229 WMITLV_GET_STRUCT_TLVLEN(
3230 wmi_dcc_ndl_active_state_config));
3231 buf_ptr += active_state_count *
3232 sizeof(*ndl_active_config);
3233 }
3234
3235 /* Add the wmi_ocb_schedule_element info */
3236 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3237 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3238 buf_ptr += WMI_TLV_HDR_SIZE;
3239 for (i = 0; i < config->schedule_size; i++) {
3240 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3241 WMITLV_SET_HDR(&sched_elem->tlv_header,
3242 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3243 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3244 sched_elem->channel_freq = config->schedule[i].chan_freq;
3245 sched_elem->total_duration = config->schedule[i].total_duration;
3246 sched_elem->guard_interval = config->schedule[i].guard_interval;
3247 buf_ptr += sizeof(*sched_elem);
3248 }
3249
3250
3251 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3252 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303253 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303254 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303255 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303256 }
3257
Govind Singh67922e82016-04-01 16:48:57 +05303258 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303259}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303260
3261/**
3262 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3263 * @wmi_handle: wmi handle
3264 * @mcc_adaptive_scheduler: enable/disable
3265 *
3266 * This function enable/disable mcc adaptive scheduler in fw.
3267 *
Govind Singhb53420c2016-03-09 14:32:57 +05303268 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303269 */
Govind Singhb53420c2016-03-09 14:32:57 +05303270QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003271 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3272 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303273{
Govind Singh67922e82016-04-01 16:48:57 +05303274 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303275 wmi_buf_t buf = 0;
3276 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3277 uint16_t len =
3278 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3279
3280 buf = wmi_buf_alloc(wmi_handle, len);
3281 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303282 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3283 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303284 }
3285 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3286 wmi_buf_data(buf);
3287
3288 WMITLV_SET_HDR(&cmd->tlv_header,
3289 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3290 WMITLV_GET_STRUCT_TLVLEN
3291 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3292 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003293 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303294
3295 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3296 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303297 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303298 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303299 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303300 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303301 }
Govind Singh67922e82016-04-01 16:48:57 +05303302
3303 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303304}
3305
3306/**
3307 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3308 * @wmi: wmi handle
3309 * @mcc_channel: mcc channel
3310 * @mcc_channel_time_latency: MCC channel time latency.
3311 *
3312 * Currently used to set time latency for an MCC vdev/adapter using operating
3313 * channel of it and channel number. The info is provided run time using
3314 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3315 *
3316 * Return: CDF status
3317 */
Govind Singhb53420c2016-03-09 14:32:57 +05303318QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303319 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3320{
Govind Singh67922e82016-04-01 16:48:57 +05303321 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303322 wmi_buf_t buf = 0;
3323 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3324 uint16_t len = 0;
3325 uint8_t *buf_ptr = NULL;
3326 wmi_resmgr_chan_latency chan_latency;
3327 /* Note: we only support MCC time latency for a single channel */
3328 uint32_t num_channels = 1;
3329 uint32_t chan1_freq = mcc_channel_freq;
3330 uint32_t latency_chan1 = mcc_channel_time_latency;
3331
3332
3333 /* If 0ms latency is provided, then FW will set to a default.
3334 * Otherwise, latency must be at least 30ms.
3335 */
3336 if ((latency_chan1 > 0) &&
3337 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303338 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303339 "Minimum is 30ms (or 0 to use default value by "
3340 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303341 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303342 }
3343
3344 /* Set WMI CMD for channel time latency here */
3345 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3346 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3347 num_channels * sizeof(wmi_resmgr_chan_latency);
3348 buf = wmi_buf_alloc(wmi_handle, len);
3349 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303350 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3351 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303352 }
3353 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3354 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3355 wmi_buf_data(buf);
3356 WMITLV_SET_HDR(&cmdTL->tlv_header,
3357 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3358 WMITLV_GET_STRUCT_TLVLEN
3359 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3360 cmdTL->num_chans = num_channels;
3361 /* Update channel time latency information for home channel(s) */
3362 buf_ptr += sizeof(*cmdTL);
3363 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3364 num_channels * sizeof(wmi_resmgr_chan_latency));
3365 buf_ptr += WMI_TLV_HDR_SIZE;
3366 chan_latency.chan_mhz = chan1_freq;
3367 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303368 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303369 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3370 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303371 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303372 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303373 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303374 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303375 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303376 }
Govind Singh67922e82016-04-01 16:48:57 +05303377
3378 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303379}
3380
3381/**
3382 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3383 * @wmi: wmi handle
3384 * @adapter_1_chan_number: adapter 1 channel number
3385 * @adapter_1_quota: adapter 1 quota
3386 * @adapter_2_chan_number: adapter 2 channel number
3387 *
3388 * Return: CDF status
3389 */
Govind Singhb53420c2016-03-09 14:32:57 +05303390QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303391 uint32_t adapter_1_chan_freq,
3392 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3393{
Govind Singh67922e82016-04-01 16:48:57 +05303394 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303395 wmi_buf_t buf = 0;
3396 uint16_t len = 0;
3397 uint8_t *buf_ptr = NULL;
3398 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3399 wmi_resmgr_chan_time_quota chan_quota;
3400 uint32_t quota_chan1 = adapter_1_quota;
3401 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3402 uint32_t quota_chan2 = 100 - quota_chan1;
3403 /* Note: setting time quota for MCC requires info for 2 channels */
3404 uint32_t num_channels = 2;
3405 uint32_t chan1_freq = adapter_1_chan_freq;
3406 uint32_t chan2_freq = adapter_2_chan_freq;
3407
Govind Singhb53420c2016-03-09 14:32:57 +05303408 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303409 "freq2:%dMHz, Quota2:%dms", __func__,
3410 chan1_freq, quota_chan1, chan2_freq,
3411 quota_chan2);
3412
3413 /*
3414 * Perform sanity check on time quota values provided.
3415 */
3416 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3417 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303418 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303419 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303420 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303421 }
3422 /* Set WMI CMD for channel time quota here */
3423 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3424 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3425 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3426 buf = wmi_buf_alloc(wmi_handle, len);
3427 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303428 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3429 QDF_ASSERT(0);
3430 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303431 }
3432 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3433 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3434 wmi_buf_data(buf);
3435 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3436 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3437 WMITLV_GET_STRUCT_TLVLEN
3438 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3439 cmdTQ->num_chans = num_channels;
3440
3441 /* Update channel time quota information for home channel(s) */
3442 buf_ptr += sizeof(*cmdTQ);
3443 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3444 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3445 buf_ptr += WMI_TLV_HDR_SIZE;
3446 chan_quota.chan_mhz = chan1_freq;
3447 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303448 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303449 /* Construct channel and quota record for the 2nd MCC mode. */
3450 buf_ptr += sizeof(chan_quota);
3451 chan_quota.chan_mhz = chan2_freq;
3452 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05303453 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303454
3455 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3456 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303457 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303458 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303459 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303460 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303461 }
Govind Singh67922e82016-04-01 16:48:57 +05303462
3463 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303464}
3465
3466/**
3467 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3468 * @wmi_handle: Pointer to wmi handle
3469 * @thermal_info: Thermal command information
3470 *
3471 * This function sends the thermal management command
3472 * to the firmware
3473 *
Govind Singhb53420c2016-03-09 14:32:57 +05303474 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303475 */
Govind Singhb53420c2016-03-09 14:32:57 +05303476QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303477 struct thermal_cmd_params *thermal_info)
3478{
3479 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3480 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303481 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303482 uint32_t len = 0;
3483
3484 len = sizeof(*cmd);
3485
3486 buf = wmi_buf_alloc(wmi_handle, len);
3487 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303488 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3489 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303490 }
3491
3492 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3493
3494 WMITLV_SET_HDR(&cmd->tlv_header,
3495 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3496 WMITLV_GET_STRUCT_TLVLEN
3497 (wmi_thermal_mgmt_cmd_fixed_param));
3498
3499 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3500 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3501 cmd->enable = thermal_info->thermal_enable;
3502
Govind Singhb53420c2016-03-09 14:32:57 +05303503 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303504 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3505
3506 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3507 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303508 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303509 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303510 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303511 }
3512
Govind Singh67922e82016-04-01 16:48:57 +05303513 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303514}
3515
3516
3517/**
3518 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303519 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303520 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3521 *
3522 * This function sends down the LRO configuration parameters to
3523 * the firmware to enable LRO, sets the TCP flags and sets the
3524 * seed values for the toeplitz hash generation
3525 *
Govind Singhb53420c2016-03-09 14:32:57 +05303526 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303527 */
Govind Singhb53420c2016-03-09 14:32:57 +05303528QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303529 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3530{
3531 wmi_lro_info_cmd_fixed_param *cmd;
3532 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303533 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303534
3535
3536 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3537 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303538 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3539 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303540 }
3541
3542 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3543
3544 WMITLV_SET_HDR(&cmd->tlv_header,
3545 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3546 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3547
3548 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3549 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3550 wmi_lro_cmd->tcp_flag);
3551 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3552 wmi_lro_cmd->tcp_flag_mask);
3553 cmd->toeplitz_hash_ipv4_0_3 =
3554 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3555 cmd->toeplitz_hash_ipv4_4_7 =
3556 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3557 cmd->toeplitz_hash_ipv4_8_11 =
3558 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3559 cmd->toeplitz_hash_ipv4_12_15 =
3560 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3561 cmd->toeplitz_hash_ipv4_16 =
3562 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3563
3564 cmd->toeplitz_hash_ipv6_0_3 =
3565 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3566 cmd->toeplitz_hash_ipv6_4_7 =
3567 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3568 cmd->toeplitz_hash_ipv6_8_11 =
3569 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3570 cmd->toeplitz_hash_ipv6_12_15 =
3571 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3572 cmd->toeplitz_hash_ipv6_16_19 =
3573 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3574 cmd->toeplitz_hash_ipv6_20_23 =
3575 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3576 cmd->toeplitz_hash_ipv6_24_27 =
3577 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3578 cmd->toeplitz_hash_ipv6_28_31 =
3579 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3580 cmd->toeplitz_hash_ipv6_32_35 =
3581 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3582 cmd->toeplitz_hash_ipv6_36_39 =
3583 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3584 cmd->toeplitz_hash_ipv6_40 =
3585 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3586
Govind Singhb53420c2016-03-09 14:32:57 +05303587 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303588 cmd->lro_enable, cmd->tcp_flag_u32);
3589
3590 status = wmi_unified_cmd_send(wmi_handle, buf,
3591 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303592 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303593 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303594 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303595 }
3596
Govind Singh67922e82016-04-01 16:48:57 +05303597 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303598}
3599
Govind Singh4eacd2b2016-03-07 14:24:22 +05303600/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303601 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3602 * @wmi_handle: Pointer to wmi handle
3603 * @rate_report_params: Pointer to peer rate report parameters
3604 *
3605 *
3606 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3607 */
3608QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
3609 struct wmi_peer_rate_report_params *rate_report_params)
3610{
3611 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3612 wmi_buf_t buf = NULL;
3613 QDF_STATUS status = 0;
3614 uint32_t len = 0;
3615 uint32_t i, j;
3616
3617 len = sizeof(*cmd);
3618
3619 buf = wmi_buf_alloc(wmi_handle, len);
3620 if (!buf) {
3621 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
3622 return QDF_STATUS_E_FAILURE;
3623 }
3624
3625 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3626 wmi_buf_data(buf);
3627
3628 WMITLV_SET_HDR(
3629 &cmd->tlv_header,
3630 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3631 WMITLV_GET_STRUCT_TLVLEN(
3632 wmi_peer_set_rate_report_condition_fixed_param));
3633
3634 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3635 cmd->report_backoff_time = rate_report_params->backoff_time;
3636 cmd->report_timer_period = rate_report_params->timer_period;
3637 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
3638 cmd->cond_per_phy[i].val_cond_flags =
3639 rate_report_params->report_per_phy[i].cond_flags;
3640 cmd->cond_per_phy[i].rate_delta.min_delta =
3641 rate_report_params->report_per_phy[i].delta.delta_min;
3642 cmd->cond_per_phy[i].rate_delta.percentage =
3643 rate_report_params->report_per_phy[i].delta.percent;
3644 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3645 cmd->cond_per_phy[i].rate_threshold[j] =
3646 rate_report_params->report_per_phy[i].
3647 report_rate_threshold[j];
3648 }
3649 }
3650
3651 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
3652 cmd->enable_rate_report,
3653 cmd->report_backoff_time, cmd->report_timer_period);
3654
3655 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3656 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3657 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303658 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303659 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3660 __func__);
3661 }
3662 return status;
3663}
3664
3665/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303666 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3667 * @wmi_handle: wmi handle
3668 * @param: bcn ll cmd parameter
3669 *
Govind Singhb53420c2016-03-09 14:32:57 +05303670 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303671 */
Govind Singhb53420c2016-03-09 14:32:57 +05303672QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303673 wmi_bcn_send_from_host_cmd_fixed_param *param)
3674{
3675 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3676 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303677 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303678
3679 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3680 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303681 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3682 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303683 }
3684
3685 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3686 WMITLV_SET_HDR(&cmd->tlv_header,
3687 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3688 WMITLV_GET_STRUCT_TLVLEN
3689 (wmi_bcn_send_from_host_cmd_fixed_param));
3690 cmd->vdev_id = param->vdev_id;
3691 cmd->data_len = param->data_len;
3692 cmd->frame_ctrl = param->frame_ctrl;
3693 cmd->frag_ptr = param->frag_ptr;
3694 cmd->dtim_flag = param->dtim_flag;
3695
3696 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3697 WMI_PDEV_SEND_BCN_CMDID);
3698
Govind Singh67922e82016-04-01 16:48:57 +05303699 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303700 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303701 wmi_buf_free(wmi_buf);
3702 }
3703
3704 return ret;
3705}
3706
3707/**
3708 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
3709 * @wmi_handle: wmi handle
3710 * @vdev_id: vdev id
3711 * @max_retries: max retries
3712 * @retry_interval: retry interval
3713 * This function sets sta query related parameters in fw.
3714 *
Govind Singhb53420c2016-03-09 14:32:57 +05303715 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303716 */
3717
Govind Singhb53420c2016-03-09 14:32:57 +05303718QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303719 uint8_t vdev_id, uint32_t max_retries,
3720 uint32_t retry_interval)
3721{
3722 wmi_buf_t buf;
3723 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
3724 int len;
3725
3726 len = sizeof(*cmd);
3727 buf = wmi_buf_alloc(wmi_handle, len);
3728 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303729 WMI_LOGE(FL("wmi_buf_alloc failed"));
3730 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303731 }
3732
3733 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
3734 WMITLV_SET_HDR(&cmd->tlv_header,
3735 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
3736 WMITLV_GET_STRUCT_TLVLEN
3737 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
3738
3739
3740 cmd->vdev_id = vdev_id;
3741 cmd->sa_query_max_retry_count = max_retries;
3742 cmd->sa_query_retry_interval = retry_interval;
3743
Govind Singhb53420c2016-03-09 14:32:57 +05303744 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303745 vdev_id, retry_interval, max_retries);
3746
3747 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3748 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303749 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05303750 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303751 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303752 }
3753
Govind Singhb53420c2016-03-09 14:32:57 +05303754 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303755 return 0;
3756}
3757
3758/**
3759 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
3760 * @wmi_handle: wmi handle
3761 * @params: sta keep alive parameter
3762 *
3763 * This function sets keep alive related parameters in fw.
3764 *
3765 * Return: CDF status
3766 */
Govind Singhb53420c2016-03-09 14:32:57 +05303767QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303768 struct sta_params *params)
3769{
3770 wmi_buf_t buf;
3771 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
3772 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
3773 uint8_t *buf_ptr;
3774 int len;
Govind Singh67922e82016-04-01 16:48:57 +05303775 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303776
Govind Singhb53420c2016-03-09 14:32:57 +05303777 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303778
Govind Singh4eacd2b2016-03-07 14:24:22 +05303779 len = sizeof(*cmd) + sizeof(*arp_rsp);
3780 buf = wmi_buf_alloc(wmi_handle, len);
3781 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303782 WMI_LOGE("wmi_buf_alloc failed");
3783 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303784 }
3785
3786 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
3787 buf_ptr = (uint8_t *) cmd;
3788 WMITLV_SET_HDR(&cmd->tlv_header,
3789 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
3790 WMITLV_GET_STRUCT_TLVLEN
3791 (WMI_STA_KEEPALIVE_CMD_fixed_param));
3792 cmd->interval = params->timeperiod;
3793 cmd->enable = (params->timeperiod) ? 1 : 0;
3794 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05303795 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303796 params->timeperiod, params->method);
3797 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
3798 WMITLV_SET_HDR(&arp_rsp->tlv_header,
3799 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
3800 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
3801
3802 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
3803 if ((NULL == params->hostv4addr) ||
3804 (NULL == params->destv4addr) ||
3805 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303806 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05303807 "destv4addr:%p destmac:%p ", __func__,
3808 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303809 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303810 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303811 }
3812 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05303813 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303814 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05303815 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303816 WMI_IPV4_ADDR_LEN);
3817 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
3818 } else {
3819 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
3820 }
3821
Govind Singh67922e82016-04-01 16:48:57 +05303822 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3823 WMI_STA_KEEPALIVE_CMDID);
3824 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303825 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303826 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303827 }
3828
Govind Singhb53420c2016-03-09 14:32:57 +05303829 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303830 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303831}
3832
3833/**
3834 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
3835 * @wmi_handle: wmi handle
3836 * @if_id: vdev id
3837 * @gtx_info: GTX config params
3838 *
3839 * This function set GTX related params in firmware.
3840 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303841 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303842 */
Govind Singhb53420c2016-03-09 14:32:57 +05303843QDF_STATUS send_vdev_set_gtx_cfg_cmd_tlv(wmi_unified_t wmi_handle, uint32_t if_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303844 struct wmi_gtx_config *gtx_info)
3845{
3846 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
3847 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05303848 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303849 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303850
Govind Singh4eacd2b2016-03-07 14:24:22 +05303851 buf = wmi_buf_alloc(wmi_handle, len);
3852 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303853 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303854 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303855 }
3856 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
3857 WMITLV_SET_HDR(&cmd->tlv_header,
3858 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
3859 WMITLV_GET_STRUCT_TLVLEN
3860 (wmi_vdev_set_gtx_params_cmd_fixed_param));
3861 cmd->vdev_id = if_id;
3862
3863 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
3864 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
3865 cmd->userGtxMask = gtx_info->gtx_usrcfg;
3866 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
3867 cmd->gtxPERMargin = gtx_info->gtx_margin;
3868 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
3869 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
3870 cmd->gtxBWMask = gtx_info->gtx_bwmask;
3871
Govind Singhb53420c2016-03-09 14:32:57 +05303872 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05303873 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
3874 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
3875 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
3876 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
3877
Abhishek Singh716c46c2016-05-04 16:24:07 +05303878 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303879 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303880 if (QDF_IS_STATUS_ERROR(ret)) {
3881 WMI_LOGE("Failed to set GTX PARAMS");
3882 wmi_buf_free(buf);
3883 }
3884 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303885}
3886
3887/**
3888 * send_process_update_edca_param_cmd_tlv() - update EDCA params
3889 * @wmi_handle: wmi handle
3890 * @edca_params: edca parameters
3891 *
3892 * This function updates EDCA parameters to the target
3893 *
3894 * Return: CDF Status
3895 */
Govind Singhb53420c2016-03-09 14:32:57 +05303896QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303897 uint8_t vdev_id,
3898 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
3899{
3900 uint8_t *buf_ptr;
3901 wmi_buf_t buf;
3902 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
3903 wmi_wmm_vparams *wmm_param, *twmm_param;
3904 int len = sizeof(*cmd);
3905 int ac;
3906
3907 buf = wmi_buf_alloc(wmi_handle, len);
3908
3909 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303910 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3911 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303912 }
3913
3914 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3915 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
3916 WMITLV_SET_HDR(&cmd->tlv_header,
3917 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3918 WMITLV_GET_STRUCT_TLVLEN
3919 (wmi_vdev_set_wmm_params_cmd_fixed_param));
3920 cmd->vdev_id = vdev_id;
3921
3922 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
3923 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
3924 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
3925 WMITLV_SET_HDR(&wmm_param->tlv_header,
3926 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3927 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
3928 wmm_param->cwmin = twmm_param->cwmin;
3929 wmm_param->cwmax = twmm_param->cwmax;
3930 wmm_param->aifs = twmm_param->aifs;
3931 wmm_param->txoplimit = twmm_param->txoplimit;
3932 wmm_param->acm = twmm_param->acm;
3933 wmm_param->no_ack = twmm_param->no_ack;
3934 }
3935
3936 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3937 WMI_VDEV_SET_WMM_PARAMS_CMDID))
3938 goto fail;
3939
Govind Singhb53420c2016-03-09 14:32:57 +05303940 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303941
3942fail:
3943 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303944 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
3945 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303946}
3947
3948/**
3949 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
3950 * @wmi_handle: wmi handle
3951 * @vdev_id: vdev id
3952 * @probe_rsp_info: probe response info
3953 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303954 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303955 */
Govind Singhb53420c2016-03-09 14:32:57 +05303956QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303957 uint8_t vdev_id,
3958 struct wmi_probe_resp_params *probe_rsp_info,
3959 uint8_t *frm)
3960{
3961 wmi_prb_tmpl_cmd_fixed_param *cmd;
3962 wmi_bcn_prb_info *bcn_prb_info;
3963 wmi_buf_t wmi_buf;
3964 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
3965 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05303966 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303967
Govind Singhb53420c2016-03-09 14:32:57 +05303968 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303969
3970 tmpl_len = probe_rsp_info->probeRespTemplateLen;
3971 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
3972
3973 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
3974 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
3975 tmpl_len_aligned;
3976
3977 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05303978 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303979 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05303980 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303981 }
3982
3983 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3984 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303985 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303986 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303987 }
3988
3989 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3990
3991 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
3992 WMITLV_SET_HDR(&cmd->tlv_header,
3993 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
3994 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
3995 cmd->vdev_id = vdev_id;
3996 cmd->buf_len = tmpl_len;
3997 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
3998
3999 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4000 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4001 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4002 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4003 bcn_prb_info->caps = 0;
4004 bcn_prb_info->erp = 0;
4005 buf_ptr += sizeof(wmi_bcn_prb_info);
4006
4007 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4008 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304009 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304010
4011 ret = wmi_unified_cmd_send(wmi_handle,
4012 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304013 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304014 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304015 wmi_buf_free(wmi_buf);
4016 }
4017
4018 return ret;
4019}
4020
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304021#ifdef FEATURE_WLAN_WAPI
4022#define WPI_IV_LEN 16
4023
4024/**
4025 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4026 *
4027 * @dest_tx: destination address of tsc key counter
4028 * @src_tx: source address of tsc key counter
4029 * @dest_rx: destination address of rsc key counter
4030 * @src_rx: source address of rsc key counter
4031 *
4032 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4033 *
4034 * Return: None
4035 *
4036 */
4037static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4038 uint8_t *dest_rx, uint8_t *src_rx)
4039{
4040 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4041 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4042}
4043#else
4044static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4045 uint8_t *dest_rx, uint8_t *src_rx)
4046{
4047 return;
4048}
4049#endif
4050
4051/**
4052 * send_setup_install_key_cmd_tlv() - set key parameters
4053 * @wmi_handle: wmi handle
4054 * @key_params: key parameters
4055 *
4056 * This function fills structure from information
4057 * passed in key_params.
4058 *
4059 * Return: QDF_STATUS_SUCCESS - success
4060 * QDF_STATUS_E_FAILURE - failure
4061 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4062 */
4063QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
4064 struct set_key_params *key_params)
4065{
4066 wmi_vdev_install_key_cmd_fixed_param *cmd;
4067 wmi_buf_t buf;
4068 uint8_t *buf_ptr;
4069 uint32_t len;
4070 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304071 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304072
4073 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4074 WMI_TLV_HDR_SIZE;
4075
4076 buf = wmi_buf_alloc(wmi_handle, len);
4077 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304078 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304079 return QDF_STATUS_E_NOMEM;
4080 }
4081
4082 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4083 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4084 WMITLV_SET_HDR(&cmd->tlv_header,
4085 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4086 WMITLV_GET_STRUCT_TLVLEN
4087 (wmi_vdev_install_key_cmd_fixed_param));
4088 cmd->vdev_id = key_params->vdev_id;
4089 cmd->key_ix = key_params->key_idx;
4090 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4091 cmd->key_flags |= key_params->key_flags;
4092 cmd->key_cipher = key_params->key_cipher;
4093 if ((key_params->key_txmic_len) &&
4094 (key_params->key_rxmic_len)) {
4095 cmd->key_txmic_len = key_params->key_txmic_len;
4096 cmd->key_rxmic_len = key_params->key_rxmic_len;
4097 }
Govind Singh87542482016-06-08 19:40:11 +05304098#ifdef FEATURE_WLAN_WAPI
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304099 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4100 key_params->tx_iv,
4101 cmd->wpi_key_rsc_counter,
4102 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304103#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304104 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4105 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4106 roundup(key_params->key_len, sizeof(uint32_t)));
4107 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4108 qdf_mem_copy((void *)key_data,
4109 (const void *)key_params->key_data, key_params->key_len);
4110 cmd->key_len = key_params->key_len;
4111
4112 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4113 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304114 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304115 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304116
Govind Singh67922e82016-04-01 16:48:57 +05304117 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304118}
4119
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304120/**
4121 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4122 * @wmi_handle: wmi handle
4123 * @params: encrypt/decrypt params
4124 *
4125 * Return: QDF_STATUS_SUCCESS for success or error code
4126 */
4127QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4128 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4129{
4130 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4131 wmi_buf_t wmi_buf;
4132 uint8_t *buf_ptr;
4133 QDF_STATUS ret;
4134 uint32_t len;
4135
4136 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4137
4138 len = sizeof(*cmd) +
4139 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4140 WMI_TLV_HDR_SIZE;
4141 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4142 if (!wmi_buf) {
4143 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4144 __func__);
4145 return QDF_STATUS_E_NOMEM;
4146 }
4147
4148 buf_ptr = wmi_buf_data(wmi_buf);
4149 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4150
4151 WMITLV_SET_HDR(&cmd->tlv_header,
4152 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4153 WMITLV_GET_STRUCT_TLVLEN(
4154 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4155
4156 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4157 cmd->key_flag = encrypt_decrypt_params->key_flag;
4158 cmd->key_idx = encrypt_decrypt_params->key_idx;
4159 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4160 cmd->key_len = encrypt_decrypt_params->key_len;
4161 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4162 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4163
4164 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4165 encrypt_decrypt_params->key_len);
4166
4167 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4168 MAX_MAC_HEADER_LEN);
4169
4170 cmd->data_len = encrypt_decrypt_params->data_len;
4171
4172 if (cmd->data_len) {
4173 buf_ptr += sizeof(*cmd);
4174 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4175 roundup(encrypt_decrypt_params->data_len,
4176 sizeof(A_UINT32)));
4177 buf_ptr += WMI_TLV_HDR_SIZE;
4178 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4179 encrypt_decrypt_params->data_len);
4180 }
4181
4182 /* This conversion is to facilitate data to FW in little endian */
4183 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4184 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4185 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4186 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4187 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4188 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4189
4190 ret = wmi_unified_cmd_send(wmi_handle,
4191 wmi_buf, len,
4192 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4193 if (QDF_IS_STATUS_ERROR(ret)) {
4194 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4195 wmi_buf_free(wmi_buf);
4196 }
4197
4198 return ret;
4199}
4200
4201
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304202
Govind Singh4eacd2b2016-03-07 14:24:22 +05304203/**
4204 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4205 * @wmi_handle: wmi handle
4206 * @vdev_id: vdev id
4207 * @p2p_ie: p2p IE
4208 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304209 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304210 */
Govind Singhb53420c2016-03-09 14:32:57 +05304211QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304212 A_UINT32 vdev_id, uint8_t *p2p_ie)
4213{
Govind Singh67922e82016-04-01 16:48:57 +05304214 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304215 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4216 wmi_buf_t wmi_buf;
4217 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4218 uint8_t *buf_ptr;
4219
4220 ie_len = (uint32_t) (p2p_ie[1] + 2);
4221
4222 /* More than one P2P IE may be included in a single frame.
4223 If multiple P2P IEs are present, the complete P2P attribute
4224 data consists of the concatenation of the P2P Attribute
4225 fields of the P2P IEs. The P2P Attributes field of each
4226 P2P IE may be any length up to the maximum (251 octets).
4227 In this case host sends one P2P IE to firmware so the length
4228 should not exceed more than 251 bytes
4229 */
4230 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304231 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304232 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304233 }
4234
4235 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4236
4237 wmi_buf_len =
4238 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4239 WMI_TLV_HDR_SIZE;
4240
4241 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4242 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304243 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304244 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304245 }
4246
4247 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4248
4249 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4250 WMITLV_SET_HDR(&cmd->tlv_header,
4251 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4252 WMITLV_GET_STRUCT_TLVLEN
4253 (wmi_p2p_go_set_beacon_ie_fixed_param));
4254 cmd->vdev_id = vdev_id;
4255 cmd->ie_buf_len = ie_len;
4256
4257 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4258 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4259 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304260 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304261
Govind Singhb53420c2016-03-09 14:32:57 +05304262 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304263
4264 ret = wmi_unified_cmd_send(wmi_handle,
4265 wmi_buf, wmi_buf_len,
4266 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304267 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304268 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304269 wmi_buf_free(wmi_buf);
4270 }
4271
Govind Singhb53420c2016-03-09 14:32:57 +05304272 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304273 return ret;
4274}
4275
4276/**
4277 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4278 * @wmi_handle: wmi handle
4279 * @req: gateway parameter update request structure
4280 *
4281 * This function reads the incoming @req and fill in the destination
4282 * WMI structure and sends down the gateway configs down to the firmware
4283 *
Govind Singhb53420c2016-03-09 14:32:57 +05304284 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304285 */
Govind Singhb53420c2016-03-09 14:32:57 +05304286QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304287 struct gateway_update_req_param *req)
4288{
4289 wmi_roam_subnet_change_config_fixed_param *cmd;
4290 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304291 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304292 int len = sizeof(*cmd);
4293
4294 buf = wmi_buf_alloc(wmi_handle, len);
4295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304296 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4297 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304298 }
4299
4300 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4301 WMITLV_SET_HDR(&cmd->tlv_header,
4302 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4303 WMITLV_GET_STRUCT_TLVLEN(
4304 wmi_roam_subnet_change_config_fixed_param));
4305
4306 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304307 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4308 QDF_IPV4_ADDR_SIZE);
4309 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4310 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304311 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4312 &cmd->inet_gw_mac_addr);
4313 cmd->max_retries = req->max_retries;
4314 cmd->timeout = req->timeout;
4315 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4316 cmd->flag = 0;
4317 if (req->ipv4_addr_type)
4318 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4319
4320 if (req->ipv6_addr_type)
4321 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4322
4323 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4324 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304325 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304326 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304327 ret);
4328 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304329 }
4330
Govind Singh67922e82016-04-01 16:48:57 +05304331 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304332}
4333
4334/**
4335 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4336 * @wmi_handle: wmi handle
4337 * @req: rssi monitoring request structure
4338 *
4339 * This function reads the incoming @req and fill in the destination
4340 * WMI structure and send down the rssi monitoring configs down to the firmware
4341 *
4342 * Return: 0 on success; error number otherwise
4343 */
Govind Singhb53420c2016-03-09 14:32:57 +05304344QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304345 struct rssi_monitor_param *req)
4346{
4347 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4348 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304349 QDF_STATUS ret;
4350 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304351
4352 buf = wmi_buf_alloc(wmi_handle, len);
4353 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304354 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4355 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304356 }
4357
4358 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4359 WMITLV_SET_HDR(&cmd->tlv_header,
4360 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4361 WMITLV_GET_STRUCT_TLVLEN(
4362 wmi_rssi_breach_monitor_config_fixed_param));
4363
4364 cmd->vdev_id = req->session_id;
4365 cmd->request_id = req->request_id;
4366 cmd->lo_rssi_reenable_hysteresis = 0;
4367 cmd->hi_rssi_reenable_histeresis = 0;
4368 cmd->min_report_interval = 0;
4369 cmd->max_num_report = 1;
4370 if (req->control) {
4371 /* enable one threshold for each min/max */
4372 cmd->enabled_bitmap = 0x09;
4373 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4374 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4375 } else {
4376 cmd->enabled_bitmap = 0;
4377 cmd->low_rssi_breach_threshold[0] = 0;
4378 cmd->hi_rssi_breach_threshold[0] = 0;
4379 }
4380
4381 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4382 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304383 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304384 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304385 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304386 }
4387
Govind Singhb53420c2016-03-09 14:32:57 +05304388 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304389 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304390}
4391
4392/**
4393 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4394 * @wmi_handle: wmi handle
4395 * @psetoui: OUI parameters
4396 *
4397 * set scan probe OUI parameters in firmware
4398 *
4399 * Return: CDF status
4400 */
Govind Singhb53420c2016-03-09 14:32:57 +05304401QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304402 struct scan_mac_oui *psetoui)
4403{
4404 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4405 wmi_buf_t wmi_buf;
4406 uint32_t len;
4407 uint8_t *buf_ptr;
4408 uint32_t *oui_buf;
4409
4410 len = sizeof(*cmd);
4411 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4412 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304413 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4414 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304415 }
4416 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4417 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4418 WMITLV_SET_HDR(&cmd->tlv_header,
4419 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4420 WMITLV_GET_STRUCT_TLVLEN
4421 (wmi_scan_prob_req_oui_cmd_fixed_param));
4422
4423 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304424 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304425 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4426 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304427 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304428 cmd->prob_req_oui);
4429
4430 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4431 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304432 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304433 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304434 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304435 }
Govind Singhb53420c2016-03-09 14:32:57 +05304436 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304437}
4438
4439/**
4440 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
4441 * @wmi_handle: wmi handle
4442 * @req: passpoint network request structure
4443 *
4444 * This function sends down WMI command with network id set to wildcard id.
4445 * firmware shall clear all the config entries
4446 *
Govind Singhb53420c2016-03-09 14:32:57 +05304447 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304448 */
Govind Singhb53420c2016-03-09 14:32:57 +05304449QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304450 struct wifi_passpoint_req_param *req)
4451{
4452 wmi_passpoint_config_cmd_fixed_param *cmd;
4453 wmi_buf_t buf;
4454 uint32_t len;
4455 int ret;
4456
4457 len = sizeof(*cmd);
4458 buf = wmi_buf_alloc(wmi_handle, len);
4459 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304460 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4461 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304462 }
4463
4464 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
4465
4466 WMITLV_SET_HDR(&cmd->tlv_header,
4467 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4468 WMITLV_GET_STRUCT_TLVLEN(
4469 wmi_passpoint_config_cmd_fixed_param));
4470 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
4471
4472 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4473 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4474 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304475 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304476 __func__);
4477 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304478 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304479 }
4480
Govind Singhb53420c2016-03-09 14:32:57 +05304481 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304482}
4483
4484/**
4485 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
4486 * @wmi_handle: wmi handle
4487 * @req: passpoint network request structure
4488 *
4489 * This function reads the incoming @req and fill in the destination
4490 * WMI structure and send down the passpoint configs down to the firmware
4491 *
Govind Singhb53420c2016-03-09 14:32:57 +05304492 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304493 */
Govind Singhb53420c2016-03-09 14:32:57 +05304494QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304495 struct wifi_passpoint_req_param *req)
4496{
4497 wmi_passpoint_config_cmd_fixed_param *cmd;
4498 u_int8_t i, j, *bytes;
4499 wmi_buf_t buf;
4500 uint32_t len;
4501 int ret;
4502
4503 len = sizeof(*cmd);
4504 for (i = 0; i < req->num_networks; i++) {
4505 buf = wmi_buf_alloc(wmi_handle, len);
4506 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304507 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4508 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304509 }
4510
4511 cmd = (wmi_passpoint_config_cmd_fixed_param *)
4512 wmi_buf_data(buf);
4513
4514 WMITLV_SET_HDR(&cmd->tlv_header,
4515 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4516 WMITLV_GET_STRUCT_TLVLEN(
4517 wmi_passpoint_config_cmd_fixed_param));
4518 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05304519 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
4520 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304521 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05304522 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304523 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
4524 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05304525 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304526 j, bytes[0], bytes[1], bytes[2], bytes[3],
4527 bytes[4], bytes[5], bytes[6], bytes[7]);
4528
Govind Singhb53420c2016-03-09 14:32:57 +05304529 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05304530 &req->networks[i].roaming_consortium_ids[j],
4531 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
4532 }
Govind Singhb53420c2016-03-09 14:32:57 +05304533 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304534 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304535 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304536 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
4537
4538 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4539 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4540 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304541 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304542 __func__);
4543 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304544 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304545 }
4546 }
4547
Govind Singhb53420c2016-03-09 14:32:57 +05304548 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304549}
4550
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304551/**
4552 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
4553 * @wmi_handle: wmi handle
4554 * @scan_cmd_fp: start scan command ptr
4555 * @roam_req: roam request param
4556 *
4557 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
4558 * of WMI_ROAM_SCAN_MODE.
4559 *
4560 * Return: QDF status
4561 */
4562QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
4563 wmi_start_scan_cmd_fixed_param *
4564 scan_cmd_fp,
4565 struct roam_offload_scan_params *roam_req)
4566{
4567 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304568 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304569 int len;
4570 uint8_t *buf_ptr;
4571 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05304572
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304573#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4574 int auth_mode = roam_req->auth_mode;
4575 wmi_roam_offload_tlv_param *roam_offload_params;
4576 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
4577 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
4578 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304579 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304580#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4581 /* Need to create a buf with roam_scan command at
4582 * front and piggyback with scan command */
4583 len = sizeof(wmi_roam_scan_mode_fixed_param) +
4584#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4585 (2 * WMI_TLV_HDR_SIZE) +
4586#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4587 sizeof(wmi_start_scan_cmd_fixed_param);
4588#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4589 if (roam_req->is_roam_req_valid &&
4590 roam_req->roam_offload_enabled) {
4591 len += sizeof(wmi_roam_offload_tlv_param);
4592 len += WMI_TLV_HDR_SIZE;
4593 if ((auth_mode != WMI_AUTH_NONE) &&
4594 ((auth_mode != WMI_AUTH_OPEN) ||
4595 (auth_mode == WMI_AUTH_OPEN &&
4596 roam_req->mdid.mdie_present) ||
4597 roam_req->is_ese_assoc)) {
4598 len += WMI_TLV_HDR_SIZE;
4599 if (roam_req->is_ese_assoc)
4600 len +=
4601 sizeof(wmi_roam_ese_offload_tlv_param);
4602 else if (auth_mode == WMI_AUTH_FT_RSNA ||
4603 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
4604 (auth_mode == WMI_AUTH_OPEN &&
4605 roam_req->mdid.mdie_present))
4606 len +=
4607 sizeof(wmi_roam_11r_offload_tlv_param);
4608 else
4609 len +=
4610 sizeof(wmi_roam_11i_offload_tlv_param);
4611 } else {
4612 len += WMI_TLV_HDR_SIZE;
4613 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304614
4615 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
4616 + roundup(roam_req->assoc_ie_length,
4617 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304618 } else {
4619 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05304620 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304621 __func__, roam_req->roam_offload_enabled);
4622 else
Govind Singhe7f2f342016-05-23 12:12:52 +05304623 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304624 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304625 }
4626 if (roam_req->is_roam_req_valid &&
4627 roam_req->roam_offload_enabled) {
4628 roam_req->mode = roam_req->mode |
4629 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
4630 }
4631#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4632
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304633 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4634 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4635 len = sizeof(wmi_roam_scan_mode_fixed_param);
4636
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304637 buf = wmi_buf_alloc(wmi_handle, len);
4638 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304639 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304640 return QDF_STATUS_E_NOMEM;
4641 }
4642
4643 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304644
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304645 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
4646 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
4647 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
4648 WMITLV_GET_STRUCT_TLVLEN
4649 (wmi_roam_scan_mode_fixed_param));
4650
4651 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
4652 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304653 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4654 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4655 goto send_roam_scan_mode_cmd;
4656
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304657 /* Fill in scan parameters suitable for roaming scan */
4658 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304659
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304660 qdf_mem_copy(buf_ptr, scan_cmd_fp,
4661 sizeof(wmi_start_scan_cmd_fixed_param));
4662 /* Ensure there is no additional IEs */
4663 scan_cmd_fp->ie_len = 0;
4664 WMITLV_SET_HDR(buf_ptr,
4665 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
4666 WMITLV_GET_STRUCT_TLVLEN
4667 (wmi_start_scan_cmd_fixed_param));
4668#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4669 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
4670 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
4671 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4672 sizeof(wmi_roam_offload_tlv_param));
4673 buf_ptr += WMI_TLV_HDR_SIZE;
4674 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
4675 WMITLV_SET_HDR(buf_ptr,
4676 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
4677 WMITLV_GET_STRUCT_TLVLEN
4678 (wmi_roam_offload_tlv_param));
4679 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
4680 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
4681 roam_offload_params->select_5g_margin =
4682 roam_req->select_5ghz_margin;
4683 roam_offload_params->reassoc_failure_timeout =
4684 roam_req->reassoc_failure_timeout;
4685
4686 /* Fill the capabilities */
4687 roam_offload_params->capability =
4688 roam_req->roam_offload_params.capability;
4689 roam_offload_params->ht_caps_info =
4690 roam_req->roam_offload_params.ht_caps_info;
4691 roam_offload_params->ampdu_param =
4692 roam_req->roam_offload_params.ampdu_param;
4693 roam_offload_params->ht_ext_cap =
4694 roam_req->roam_offload_params.ht_ext_cap;
4695 roam_offload_params->ht_txbf =
4696 roam_req->roam_offload_params.ht_txbf;
4697 roam_offload_params->asel_cap =
4698 roam_req->roam_offload_params.asel_cap;
4699 roam_offload_params->qos_caps =
4700 roam_req->roam_offload_params.qos_caps;
4701 roam_offload_params->wmm_caps =
4702 roam_req->roam_offload_params.wmm_caps;
4703 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
4704 (uint8_t *)roam_req->roam_offload_params.mcsset,
4705 ROAM_OFFLOAD_NUM_MCS_SET);
4706
4707 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
4708 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
4709 * they are filled in the same order.Depending on the
4710 * authentication type, the other mode TLV's are nullified
4711 * and only headers are filled.*/
4712 if ((auth_mode != WMI_AUTH_NONE) &&
4713 ((auth_mode != WMI_AUTH_OPEN) ||
4714 (auth_mode == WMI_AUTH_OPEN
4715 && roam_req->mdid.mdie_present) ||
4716 roam_req->is_ese_assoc)) {
4717 if (roam_req->is_ese_assoc) {
4718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4719 WMITLV_GET_STRUCT_TLVLEN(0));
4720 buf_ptr += WMI_TLV_HDR_SIZE;
4721 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4722 WMITLV_GET_STRUCT_TLVLEN(0));
4723 buf_ptr += WMI_TLV_HDR_SIZE;
4724 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4725 sizeof(wmi_roam_ese_offload_tlv_param));
4726 buf_ptr += WMI_TLV_HDR_SIZE;
4727 roam_offload_ese =
4728 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
4729 qdf_mem_copy(roam_offload_ese->krk,
4730 roam_req->krk,
4731 sizeof(roam_req->krk));
4732 qdf_mem_copy(roam_offload_ese->btk,
4733 roam_req->btk,
4734 sizeof(roam_req->btk));
4735 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
4736 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
4737 WMITLV_GET_STRUCT_TLVLEN
4738 (wmi_roam_ese_offload_tlv_param));
4739 buf_ptr +=
4740 sizeof(wmi_roam_ese_offload_tlv_param);
4741 } else if (auth_mode == WMI_AUTH_FT_RSNA
4742 || auth_mode == WMI_AUTH_FT_RSNA_PSK
4743 || (auth_mode == WMI_AUTH_OPEN
4744 && roam_req->mdid.mdie_present)) {
4745 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4746 0);
4747 buf_ptr += WMI_TLV_HDR_SIZE;
4748 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4749 sizeof(wmi_roam_11r_offload_tlv_param));
4750 buf_ptr += WMI_TLV_HDR_SIZE;
4751 roam_offload_11r =
4752 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
4753 roam_offload_11r->r0kh_id_len =
4754 roam_req->rokh_id_length;
4755 qdf_mem_copy(roam_offload_11r->r0kh_id,
4756 roam_req->rokh_id,
4757 roam_offload_11r->r0kh_id_len);
4758 qdf_mem_copy(roam_offload_11r->psk_msk,
4759 roam_req->psk_pmk,
4760 sizeof(roam_req->psk_pmk));
4761 roam_offload_11r->psk_msk_len =
4762 roam_req->pmk_len;
4763 roam_offload_11r->mdie_present =
4764 roam_req->mdid.mdie_present;
4765 roam_offload_11r->mdid =
4766 roam_req->mdid.mobility_domain;
4767 if (auth_mode == WMI_AUTH_OPEN) {
4768 /* If FT-Open ensure pmk length
4769 and r0khid len are zero */
4770 roam_offload_11r->r0kh_id_len = 0;
4771 roam_offload_11r->psk_msk_len = 0;
4772 }
4773 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
4774 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
4775 WMITLV_GET_STRUCT_TLVLEN
4776 (wmi_roam_11r_offload_tlv_param));
4777 buf_ptr +=
4778 sizeof(wmi_roam_11r_offload_tlv_param);
4779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4780 WMITLV_GET_STRUCT_TLVLEN(0));
4781 buf_ptr += WMI_TLV_HDR_SIZE;
4782 } else {
4783 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4784 sizeof(wmi_roam_11i_offload_tlv_param));
4785 buf_ptr += WMI_TLV_HDR_SIZE;
4786 roam_offload_11i =
4787 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07004788 if (roam_req->roam_key_mgmt_offload_enabled &&
4789 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304790 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
4791 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304792 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304793 } else {
4794 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
4795 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304796 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304797 }
4798
4799 qdf_mem_copy(roam_offload_11i->pmk,
4800 roam_req->psk_pmk,
4801 sizeof(roam_req->psk_pmk));
4802 roam_offload_11i->pmk_len = roam_req->pmk_len;
4803 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
4804 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
4805 WMITLV_GET_STRUCT_TLVLEN
4806 (wmi_roam_11i_offload_tlv_param));
4807 buf_ptr +=
4808 sizeof(wmi_roam_11i_offload_tlv_param);
4809 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4810 0);
4811 buf_ptr += WMI_TLV_HDR_SIZE;
4812 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4813 0);
4814 buf_ptr += WMI_TLV_HDR_SIZE;
4815 }
4816 } else {
4817 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4818 WMITLV_GET_STRUCT_TLVLEN(0));
4819 buf_ptr += WMI_TLV_HDR_SIZE;
4820 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4821 WMITLV_GET_STRUCT_TLVLEN(0));
4822 buf_ptr += WMI_TLV_HDR_SIZE;
4823 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4824 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304825 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304826 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304827
4828 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4829 sizeof(*assoc_ies));
4830 buf_ptr += WMI_TLV_HDR_SIZE;
4831
4832 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
4833 WMITLV_SET_HDR(&assoc_ies->tlv_header,
4834 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
4835 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
4836 assoc_ies->buf_len = roam_req->assoc_ie_length;
4837
4838 buf_ptr += sizeof(*assoc_ies);
4839
4840 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4841 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
4842 buf_ptr += WMI_TLV_HDR_SIZE;
4843
4844 if (assoc_ies->buf_len != 0) {
4845 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
4846 assoc_ies->buf_len);
4847 }
4848
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304849 } else {
4850 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4851 WMITLV_GET_STRUCT_TLVLEN(0));
4852 buf_ptr += WMI_TLV_HDR_SIZE;
4853 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4854 WMITLV_GET_STRUCT_TLVLEN(0));
4855 buf_ptr += WMI_TLV_HDR_SIZE;
4856 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4857 WMITLV_GET_STRUCT_TLVLEN(0));
4858 buf_ptr += WMI_TLV_HDR_SIZE;
4859 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4860 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304861 buf_ptr += WMI_TLV_HDR_SIZE;
4862 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4863 WMITLV_GET_STRUCT_TLVLEN(0));
4864 buf_ptr += WMI_TLV_HDR_SIZE;
4865 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4866 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304867 }
4868#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304869
4870send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304871 status = wmi_unified_cmd_send(wmi_handle, buf,
4872 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05304873 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304874 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304875 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
4876 status);
4877 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304878 }
4879
Govind Singh67922e82016-04-01 16:48:57 +05304880 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304881}
4882
4883
4884/**
4885 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
4886 * rssi threashold
4887 * @wmi_handle: wmi handle
4888 * @roam_req: Roaming request buffer
4889 *
4890 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
4891 *
4892 * Return: QDF status
4893 */
4894QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
4895 struct roam_offload_scan_rssi_params *roam_req)
4896{
4897 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304898 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304899 int len;
4900 uint8_t *buf_ptr;
4901 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
4902 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
4903 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05304904 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304905
4906 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4907 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
4908 len += sizeof(wmi_roam_scan_extended_threshold_param);
4909 len += WMI_TLV_HDR_SIZE;
4910 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05304911 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
4912 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304913 buf = wmi_buf_alloc(wmi_handle, len);
4914 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304915 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304916 return QDF_STATUS_E_NOMEM;
4917 }
4918
4919 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4920 rssi_threshold_fp =
4921 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
4922 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
4923 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
4924 WMITLV_GET_STRUCT_TLVLEN
4925 (wmi_roam_scan_rssi_threshold_fixed_param));
4926 /* fill in threshold values */
4927 rssi_threshold_fp->vdev_id = roam_req->session_id;
4928 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
4929 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
4930 rssi_threshold_fp->hirssi_scan_max_count =
4931 roam_req->hi_rssi_scan_max_count;
4932 rssi_threshold_fp->hirssi_scan_delta =
4933 roam_req->hi_rssi_scan_rssi_delta;
4934 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
4935
4936 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4937 WMITLV_SET_HDR(buf_ptr,
4938 WMITLV_TAG_ARRAY_STRUC,
4939 sizeof(wmi_roam_scan_extended_threshold_param));
4940 buf_ptr += WMI_TLV_HDR_SIZE;
4941 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
4942
4943 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
4944 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
4945 ext_thresholds->boost_threshold_5g =
4946 roam_req->boost_threshold_5g;
4947
4948 ext_thresholds->boost_algorithm_5g =
4949 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4950 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
4951 ext_thresholds->penalty_algorithm_5g =
4952 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4953 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
4954 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
4955 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
4956 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
4957
4958 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
4959 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
4960 WMITLV_GET_STRUCT_TLVLEN
4961 (wmi_roam_scan_extended_threshold_param));
4962 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
4963 WMITLV_SET_HDR(buf_ptr,
4964 WMITLV_TAG_ARRAY_STRUC,
4965 sizeof(wmi_roam_earlystop_rssi_thres_param));
4966 buf_ptr += WMI_TLV_HDR_SIZE;
4967 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
4968 early_stop_thresholds->roam_earlystop_thres_min =
4969 roam_req->roam_earlystop_thres_min;
4970 early_stop_thresholds->roam_earlystop_thres_max =
4971 roam_req->roam_earlystop_thres_max;
4972 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
4973 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
4974 WMITLV_GET_STRUCT_TLVLEN
4975 (wmi_roam_earlystop_rssi_thres_param));
4976
Gupta, Kapil7e652922016-04-12 15:02:00 +05304977 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
4978 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4979 sizeof(wmi_roam_dense_thres_param));
4980 buf_ptr += WMI_TLV_HDR_SIZE;
4981 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
4982 dense_thresholds->roam_dense_rssi_thres_offset =
4983 roam_req->dense_rssi_thresh_offset;
4984 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
4985 dense_thresholds->roam_dense_traffic_thres =
4986 roam_req->traffic_threshold;
4987 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
4988 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
4989 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
4990 WMITLV_GET_STRUCT_TLVLEN
4991 (wmi_roam_dense_thres_param));
4992
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304993 status = wmi_unified_cmd_send(wmi_handle, buf,
4994 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05304995 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304996 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304997 status);
4998 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304999 }
5000
Govind Singh67922e82016-04-01 16:48:57 +05305001 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305002}
5003
5004/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305005 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5006 * configuration params
5007 * @wma_handle: wma handler
5008 * @dwelltime_params: pointer to dwelltime_params
5009 *
5010 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5011 */
5012QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5013 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5014{
5015 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5016 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5017 wmi_buf_t buf;
5018 uint8_t *buf_ptr;
5019 int32_t err;
5020 int len;
5021
5022 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5023 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5024 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5025 buf = wmi_buf_alloc(wmi_handle, len);
5026 if (!buf) {
5027 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5028 __func__);
5029 return QDF_STATUS_E_NOMEM;
5030 }
5031 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5032 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5033 WMITLV_SET_HDR(&dwell_param->tlv_header,
5034 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5035 WMITLV_GET_STRUCT_TLVLEN
5036 (wmi_scan_adaptive_dwell_config_fixed_param));
5037
5038 dwell_param->enable = dwelltime_params->is_enabled;
5039 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5040 WMITLV_SET_HDR(buf_ptr,
5041 WMITLV_TAG_ARRAY_STRUC,
5042 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5043 buf_ptr += WMI_TLV_HDR_SIZE;
5044
5045 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5046 WMITLV_SET_HDR(&cmd->tlv_header,
5047 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5048 WMITLV_GET_STRUCT_TLVLEN(
5049 wmi_scan_adaptive_dwell_parameters_tlv));
5050
5051 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5052 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5053 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5054 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5055 err = wmi_unified_cmd_send(wmi_handle, buf,
5056 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5057 if (err) {
5058 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5059 wmi_buf_free(buf);
5060 return QDF_STATUS_E_FAILURE;
5061 }
5062
5063 return QDF_STATUS_SUCCESS;
5064}
5065
5066
5067/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305068 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5069 * @wmi_handle: wmi handle
5070 * @roam_req: Request which contains the filters
5071 *
5072 * There are filters such as whitelist, blacklist and preferred
5073 * list that need to be applied to the scan results to form the
5074 * probable candidates for roaming.
5075 *
5076 * Return: Return success upon succesfully passing the
5077 * parameters to the firmware, otherwise failure.
5078 */
5079QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
5080 struct roam_scan_filter_params *roam_req)
5081{
5082 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305083 QDF_STATUS status;
5084 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305085 uint32_t len;
5086 uint8_t *buf_ptr;
5087 wmi_roam_filter_fixed_param *roam_filter;
5088 uint8_t *bssid_src_ptr = NULL;
5089 wmi_mac_addr *bssid_dst_ptr = NULL;
5090 wmi_ssid *ssid_ptr = NULL;
5091 uint32_t *bssid_preferred_factor_ptr = NULL;
5092
5093 len = sizeof(wmi_roam_filter_fixed_param);
5094 len += WMI_TLV_HDR_SIZE;
5095 len += roam_req->len;
5096
5097 buf = wmi_buf_alloc(wmi_handle, len);
5098 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305099 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305100 return QDF_STATUS_E_NOMEM;
5101 }
5102
5103 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5104 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5105 WMITLV_SET_HDR(&roam_filter->tlv_header,
5106 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5107 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5108 /* fill in fixed values */
5109 roam_filter->vdev_id = roam_req->session_id;
5110 roam_filter->flags = 0;
5111 roam_filter->op_bitmap = roam_req->op_bitmap;
5112 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5113 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5114 roam_filter->num_bssid_preferred_list =
5115 roam_req->num_bssid_preferred_list;
5116 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5117
5118 WMITLV_SET_HDR((buf_ptr),
5119 WMITLV_TAG_ARRAY_FIXED_STRUC,
5120 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5121 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5122 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5123 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5124 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5125 bssid_src_ptr += ATH_MAC_LEN;
5126 bssid_dst_ptr++;
5127 }
5128 buf_ptr += WMI_TLV_HDR_SIZE +
5129 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5130 WMITLV_SET_HDR((buf_ptr),
5131 WMITLV_TAG_ARRAY_FIXED_STRUC,
5132 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5133 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5134 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5135 qdf_mem_copy(&ssid_ptr->ssid,
5136 &roam_req->ssid_allowed_list[i].mac_ssid,
5137 roam_req->ssid_allowed_list[i].length);
5138 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5139 ssid_ptr++;
5140 }
5141 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5142 sizeof(wmi_ssid));
5143 WMITLV_SET_HDR((buf_ptr),
5144 WMITLV_TAG_ARRAY_FIXED_STRUC,
5145 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5146 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5147 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5148 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5149 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5150 (wmi_mac_addr *)bssid_dst_ptr);
5151 bssid_src_ptr += ATH_MAC_LEN;
5152 bssid_dst_ptr++;
5153 }
5154 buf_ptr += WMI_TLV_HDR_SIZE +
5155 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5156 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5157 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5158 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5159 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5160 *bssid_preferred_factor_ptr =
5161 roam_req->bssid_favored_factor[i];
5162 bssid_preferred_factor_ptr++;
5163 }
5164 buf_ptr += WMI_TLV_HDR_SIZE +
5165 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5166
5167 status = wmi_unified_cmd_send(wmi_handle, buf,
5168 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305169 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305170 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305171 status);
5172 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305173 }
Govind Singh67922e82016-04-01 16:48:57 +05305174
5175 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305176}
5177
Govind Singh4eacd2b2016-03-07 14:24:22 +05305178/** send_set_epno_network_list_cmd_tlv() - set epno network list
5179 * @wmi_handle: wmi handle
5180 * @req: epno config params request structure
5181 *
5182 * This function reads the incoming epno config request structure
5183 * and constructs the WMI message to the firmware.
5184 *
5185 * Returns: 0 on success, error number otherwise
5186 */
Govind Singhb53420c2016-03-09 14:32:57 +05305187QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305188 struct wifi_enhanched_pno_params *req)
5189{
5190 wmi_nlo_config_cmd_fixed_param *cmd;
5191 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305192 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305193 u_int8_t i, *buf_ptr;
5194 wmi_buf_t buf;
5195 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305196 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305197
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305198 /* Fixed Params */
5199 len = sizeof(*cmd);
5200 if (req->num_networks) {
5201 /* TLV place holder for array of structures
5202 * then each nlo_configured_parameters(nlo_list) TLV.
5203 */
5204 len += WMI_TLV_HDR_SIZE;
5205 len += (sizeof(nlo_configured_parameters)
5206 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5207 /* TLV for array of uint32 channel_list */
5208 len += WMI_TLV_HDR_SIZE;
5209 /* TLV for nlo_channel_prediction_cfg */
5210 len += WMI_TLV_HDR_SIZE;
5211 /* TLV for candidate score params */
5212 len += sizeof(enlo_candidate_score_params);
5213 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305214
5215 buf = wmi_buf_alloc(wmi_handle, len);
5216 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305217 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5218 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305219 }
5220
5221 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5222
5223 buf_ptr = (u_int8_t *) cmd;
5224 WMITLV_SET_HDR(&cmd->tlv_header,
5225 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5226 WMITLV_GET_STRUCT_TLVLEN(
5227 wmi_nlo_config_cmd_fixed_param));
5228 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305229
5230 /* set flag to reset if num of networks are 0 */
5231 cmd->flags = (req->num_networks == 0 ?
5232 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305233
5234 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5235
Govind Singhb53420c2016-03-09 14:32:57 +05305236 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305237 WMI_LOGD("SSID count: %d flags: %d",
5238 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305239
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305240 /* Fill nlo_config only when num_networks are non zero */
5241 if (cmd->no_of_ssids) {
5242 /* Fill networks */
5243 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5244 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5245 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305246
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305247 nlo_list = (nlo_configured_parameters *) buf_ptr;
5248 for (i = 0; i < cmd->no_of_ssids; i++) {
5249 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5250 WMITLV_TAG_ARRAY_BYTE,
5251 WMITLV_GET_STRUCT_TLVLEN(
5252 nlo_configured_parameters));
5253 /* Copy ssid and it's length */
5254 nlo_list[i].ssid.valid = true;
5255 nlo_list[i].ssid.ssid.ssid_len =
5256 req->networks[i].ssid.length;
5257 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5258 req->networks[i].ssid.mac_ssid,
5259 nlo_list[i].ssid.ssid.ssid_len);
5260 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5261 nlo_list[i].ssid.ssid.ssid_len,
5262 (char *) nlo_list[i].ssid.ssid.ssid,
5263 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305264
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305265 /* Copy pno flags */
5266 nlo_list[i].bcast_nw_type.valid = true;
5267 nlo_list[i].bcast_nw_type.bcast_nw_type =
5268 req->networks[i].flags;
5269 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305270 nlo_list[i].bcast_nw_type.bcast_nw_type);
5271
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305272 /* Copy auth bit field */
5273 nlo_list[i].auth_type.valid = true;
5274 nlo_list[i].auth_type.auth_type =
5275 req->networks[i].auth_bit_field;
5276 WMI_LOGD("Auth bit field (%u)",
5277 nlo_list[i].auth_type.auth_type);
5278 }
5279
5280 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5281 /* Fill the channel list */
5282 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5283 buf_ptr += WMI_TLV_HDR_SIZE;
5284
5285 /* Fill prediction_param */
5286 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5287 buf_ptr += WMI_TLV_HDR_SIZE;
5288
5289 /* Fill epno candidate score params */
5290 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5291 WMITLV_SET_HDR(buf_ptr,
5292 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5293 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5294 cand_score_params->min5GHz_rssi =
5295 req->min_5ghz_rssi;
5296 cand_score_params->min24GHz_rssi =
5297 req->min_24ghz_rssi;
5298 cand_score_params->initial_score_max =
5299 req->initial_score_max;
5300 cand_score_params->current_connection_bonus =
5301 req->current_connection_bonus;
5302 cand_score_params->same_network_bonus =
5303 req->same_network_bonus;
5304 cand_score_params->secure_bonus =
5305 req->secure_bonus;
5306 cand_score_params->band5GHz_bonus =
5307 req->band_5ghz_bonus;
5308 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305309 }
5310
Govind Singh4eacd2b2016-03-07 14:24:22 +05305311 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305312 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305313 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305314 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305315 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305316 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305317 }
5318
Govind Singhb53420c2016-03-09 14:32:57 +05305319 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305320 req->session_id);
5321
Govind Singh67922e82016-04-01 16:48:57 +05305322 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305323}
5324
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305325
Govind Singh4eacd2b2016-03-07 14:24:22 +05305326/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5327 * @wmi_handle: wmi handle
5328 * @ipa_offload: ipa offload control parameter
5329 *
5330 * Returns: 0 on success, error number otherwise
5331 */
Govind Singhb53420c2016-03-09 14:32:57 +05305332QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305333 struct ipa_offload_control_params *ipa_offload)
5334{
5335 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5336 wmi_buf_t wmi_buf;
5337 uint32_t len;
5338 u_int8_t *buf_ptr;
5339
5340 len = sizeof(*cmd);
5341 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5342 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305343 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5344 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305345 }
5346
Govind Singhb53420c2016-03-09 14:32:57 +05305347 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305348 ipa_offload->offload_type, ipa_offload->enable);
5349
5350 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5351
5352 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5353 WMITLV_SET_HDR(&cmd->tlv_header,
5354 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5355 WMITLV_GET_STRUCT_TLVLEN(
5356 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5357
5358 cmd->offload_type = ipa_offload->offload_type;
5359 cmd->vdev_id = ipa_offload->vdev_id;
5360 cmd->enable = ipa_offload->enable;
5361
5362 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5363 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305364 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305365 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305366 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305367 }
5368
Govind Singhb53420c2016-03-09 14:32:57 +05305369 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305370}
5371
5372/**
5373 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5374 * @wmi_handle: wmi handle
5375 * @pgetcapab: get capabilities params
5376 *
5377 * This function send request to fw to get extscan capabilities.
5378 *
5379 * Return: CDF status
5380 */
Govind Singhb53420c2016-03-09 14:32:57 +05305381QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305382 struct extscan_capabilities_params *pgetcapab)
5383{
5384 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5385 wmi_buf_t wmi_buf;
5386 uint32_t len;
5387 uint8_t *buf_ptr;
5388
5389 len = sizeof(*cmd);
5390 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5391 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305392 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5393 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305394 }
5395 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5396
5397 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5398 WMITLV_SET_HDR(&cmd->tlv_header,
5399 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5400 WMITLV_GET_STRUCT_TLVLEN
5401 (wmi_extscan_get_capabilities_cmd_fixed_param));
5402
5403 cmd->request_id = pgetcapab->request_id;
5404
5405 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5406 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305407 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305408 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305409 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305410 }
Govind Singhb53420c2016-03-09 14:32:57 +05305411 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305412}
5413
5414/**
5415 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5416 * @wmi_handle: wmi handle
5417 * @pcached_results: cached results parameters
5418 *
5419 * This function send request to fw to get cached results.
5420 *
5421 * Return: CDF status
5422 */
Govind Singhb53420c2016-03-09 14:32:57 +05305423QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305424 struct extscan_cached_result_params *pcached_results)
5425{
5426 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5427 wmi_buf_t wmi_buf;
5428 uint32_t len;
5429 uint8_t *buf_ptr;
5430
5431 len = sizeof(*cmd);
5432 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5433 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305434 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5435 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305436 }
5437 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5438
5439 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
5440 WMITLV_SET_HDR(&cmd->tlv_header,
5441 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
5442 WMITLV_GET_STRUCT_TLVLEN
5443 (wmi_extscan_get_cached_results_cmd_fixed_param));
5444
5445 cmd->request_id = pcached_results->request_id;
5446 cmd->vdev_id = pcached_results->session_id;
5447 cmd->control_flags = pcached_results->flush;
5448
5449 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5450 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305451 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305452 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305453 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305454 }
Govind Singhb53420c2016-03-09 14:32:57 +05305455 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305456}
5457
5458/**
5459 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
5460 * @wmi_handle: wmi handle
5461 * @reset_req: Reset change request params
5462 *
5463 * This function sends stop change monitor request to fw.
5464 *
5465 * Return: CDF status
5466 */
Govind Singhb53420c2016-03-09 14:32:57 +05305467QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305468 struct extscan_capabilities_reset_params *reset_req)
5469{
5470 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5471 wmi_buf_t wmi_buf;
5472 uint32_t len;
5473 uint8_t *buf_ptr;
5474 int change_list = 0;
5475
5476 len = sizeof(*cmd);
5477
5478 /* reset significant change tlv is set to 0 */
5479 len += WMI_TLV_HDR_SIZE;
5480 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
5481 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5482 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305483 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5484 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305485 }
5486 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5487
5488 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5489 buf_ptr;
5490 WMITLV_SET_HDR(&cmd->tlv_header,
5491 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5492 WMITLV_GET_STRUCT_TLVLEN
5493 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5494
5495 cmd->request_id = reset_req->request_id;
5496 cmd->vdev_id = reset_req->session_id;
5497 cmd->mode = 0;
5498
5499 buf_ptr += sizeof(*cmd);
5500 WMITLV_SET_HDR(buf_ptr,
5501 WMITLV_TAG_ARRAY_STRUC,
5502 change_list *
5503 sizeof(wmi_extscan_wlan_change_bssid_param));
5504 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
5505 sizeof
5506 (wmi_extscan_wlan_change_bssid_param));
5507
5508 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5509 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305510 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305511 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305512 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305513 }
Govind Singhb53420c2016-03-09 14:32:57 +05305514 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305515}
5516
5517/**
5518 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
5519 * @wmi_handle: wmi handle
5520 * @psigchange: change monitor request params
5521 * @buf: wmi buffer
5522 * @buf_len: buffer length
5523 *
5524 * This function fills elements of change monitor request buffer.
5525 *
5526 * Return: CDF status
5527 */
Govind Singhb53420c2016-03-09 14:32:57 +05305528static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305529 struct extscan_set_sig_changereq_params
5530 *psigchange, wmi_buf_t *buf, int *buf_len)
5531{
5532 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5533 wmi_extscan_wlan_change_bssid_param *dest_chglist;
5534 uint8_t *buf_ptr;
5535 int j;
5536 int len = sizeof(*cmd);
5537 int numap = psigchange->num_ap;
5538 struct ap_threshold_params *src_ap = psigchange->ap;
5539
5540 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +05305541 WMI_LOGE("%s: Invalid number of bssid's", __func__);
5542 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305543 }
5544 len += WMI_TLV_HDR_SIZE;
5545 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
5546
5547 *buf = wmi_buf_alloc(wmi_handle, len);
5548 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305549 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305550 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305551 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305552 }
5553 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5554 cmd =
5555 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5556 buf_ptr;
5557 WMITLV_SET_HDR(&cmd->tlv_header,
5558 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5559 WMITLV_GET_STRUCT_TLVLEN
5560 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5561
5562 cmd->request_id = psigchange->request_id;
5563 cmd->vdev_id = psigchange->session_id;
5564 cmd->total_entries = numap;
5565 cmd->mode = 1;
5566 cmd->num_entries_in_page = numap;
5567 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
5568 cmd->max_rssi_samples = psigchange->rssi_sample_size;
5569 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
5570 cmd->max_out_of_range_count = psigchange->min_breaching;
5571
5572 buf_ptr += sizeof(*cmd);
5573 WMITLV_SET_HDR(buf_ptr,
5574 WMITLV_TAG_ARRAY_STRUC,
5575 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5576 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
5577 (buf_ptr + WMI_TLV_HDR_SIZE);
5578
5579 for (j = 0; j < numap; j++) {
5580 WMITLV_SET_HDR(dest_chglist,
5581 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5582 WMITLV_GET_STRUCT_TLVLEN
5583 (wmi_extscan_wlan_change_bssid_param));
5584
5585 dest_chglist->lower_rssi_limit = src_ap->low;
5586 dest_chglist->upper_rssi_limit = src_ap->high;
5587 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
5588 &dest_chglist->bssid);
5589
Govind Singhb53420c2016-03-09 14:32:57 +05305590 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305591 dest_chglist->lower_rssi_limit);
5592 dest_chglist++;
5593 src_ap++;
5594 }
5595 buf_ptr += WMI_TLV_HDR_SIZE +
5596 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5597 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305598 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305599}
5600
5601/**
5602 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
5603 * @wmi_handle: wmi handle
5604 * @psigchange: change monitor request params
5605 *
5606 * This function sends start change monitor request to fw.
5607 *
5608 * Return: CDF status
5609 */
Govind Singhb53420c2016-03-09 14:32:57 +05305610QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305611 struct extscan_set_sig_changereq_params *
5612 psigchange)
5613{
Govind Singhb53420c2016-03-09 14:32:57 +05305614 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305615 wmi_buf_t buf;
5616 int len;
5617
5618
Govind Singhb53420c2016-03-09 14:32:57 +05305619 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305620 psigchange, &buf,
5621 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305622 if (qdf_status != QDF_STATUS_SUCCESS) {
5623 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305624 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305625 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305626 }
5627 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305628 WMI_LOGE("%s: Failed to get buffer", __func__);
5629 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305630 }
5631 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5632 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305633 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305634 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305635 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305636 }
Govind Singhb53420c2016-03-09 14:32:57 +05305637 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305638}
5639
5640/**
5641 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
5642 * @wmi_handle: wmi handle
5643 * @photlist_reset: hotlist reset params
5644 *
5645 * This function configures hotlist monitor to stop in fw.
5646 *
5647 * Return: CDF status
5648 */
Govind Singhb53420c2016-03-09 14:32:57 +05305649QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305650 struct extscan_bssid_hotlist_reset_params *photlist_reset)
5651{
5652 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
5653 wmi_buf_t wmi_buf;
5654 uint32_t len;
5655 uint8_t *buf_ptr;
5656 int hotlist_entries = 0;
5657
5658 len = sizeof(*cmd);
5659
5660 /* reset bssid hotlist with tlv set to 0 */
5661 len += WMI_TLV_HDR_SIZE;
5662 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
5663
5664 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5665 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305666 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5667 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305668 }
5669
5670 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5671 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
5672 buf_ptr;
5673 WMITLV_SET_HDR(&cmd->tlv_header,
5674 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
5675 WMITLV_GET_STRUCT_TLVLEN
5676 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
5677
5678 cmd->request_id = photlist_reset->request_id;
5679 cmd->vdev_id = photlist_reset->session_id;
5680 cmd->mode = 0;
5681
5682 buf_ptr += sizeof(*cmd);
5683 WMITLV_SET_HDR(buf_ptr,
5684 WMITLV_TAG_ARRAY_STRUC,
5685 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5686 buf_ptr += WMI_TLV_HDR_SIZE +
5687 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5688
5689 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5690 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305691 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305692 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305693 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305694 }
Govind Singhb53420c2016-03-09 14:32:57 +05305695 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305696}
5697
5698/**
5699 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
5700 * @wmi_handle: wmi handle
5701 * @pstopcmd: stop scan command request params
5702 *
5703 * This function sends stop extscan request to fw.
5704 *
5705 * Return: CDF Status.
5706 */
Govind Singhb53420c2016-03-09 14:32:57 +05305707QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305708 struct extscan_stop_req_params *pstopcmd)
5709{
5710 wmi_extscan_stop_cmd_fixed_param *cmd;
5711 wmi_buf_t wmi_buf;
5712 uint32_t len;
5713 uint8_t *buf_ptr;
5714
5715 len = sizeof(*cmd);
5716 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5717 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305718 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5719 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305720 }
5721 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5722 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
5723 WMITLV_SET_HDR(&cmd->tlv_header,
5724 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
5725 WMITLV_GET_STRUCT_TLVLEN
5726 (wmi_extscan_stop_cmd_fixed_param));
5727
5728 cmd->request_id = pstopcmd->request_id;
5729 cmd->vdev_id = pstopcmd->session_id;
5730
5731 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5732 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305733 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305734 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305735 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305736 }
5737
Govind Singhb53420c2016-03-09 14:32:57 +05305738 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305739}
5740
5741/**
5742 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
5743 * @wmi_handle: wmi handle
5744 * @pstart: scan command request params
5745 * @buf: event buffer
5746 * @buf_len: length of buffer
5747 *
5748 * This function fills individual elements of extscan request and
5749 * TLV for buckets, channel list.
5750 *
5751 * Return: CDF Status.
5752 */
Govind Singhb53420c2016-03-09 14:32:57 +05305753QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305754 struct wifi_scan_cmd_req_params *pstart,
5755 wmi_buf_t *buf, int *buf_len)
5756{
5757 wmi_extscan_start_cmd_fixed_param *cmd;
5758 wmi_extscan_bucket *dest_blist;
5759 wmi_extscan_bucket_channel *dest_clist;
5760 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
5761 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
5762 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
5763
5764 uint8_t *buf_ptr;
5765 int i, k, count = 0;
5766 int len = sizeof(*cmd);
5767 int nbuckets = pstart->numBuckets;
5768 int nchannels = 0;
5769
5770 /* These TLV's are are NULL by default */
5771 uint32_t ie_len_with_pad = 0;
5772 int num_ssid = 0;
5773 int num_bssid = 0;
5774 int ie_len = 0;
5775
5776 uint32_t base_period = pstart->basePeriod;
5777
5778 /* TLV placeholder for ssid_list (NULL) */
5779 len += WMI_TLV_HDR_SIZE;
5780 len += num_ssid * sizeof(wmi_ssid);
5781
5782 /* TLV placeholder for bssid_list (NULL) */
5783 len += WMI_TLV_HDR_SIZE;
5784 len += num_bssid * sizeof(wmi_mac_addr);
5785
5786 /* TLV placeholder for ie_data (NULL) */
5787 len += WMI_TLV_HDR_SIZE;
5788 len += ie_len * sizeof(uint32_t);
5789
5790 /* TLV placeholder for bucket */
5791 len += WMI_TLV_HDR_SIZE;
5792 len += nbuckets * sizeof(wmi_extscan_bucket);
5793
5794 /* TLV channel placeholder */
5795 len += WMI_TLV_HDR_SIZE;
5796 for (i = 0; i < nbuckets; i++) {
5797 nchannels += src_bucket->numChannels;
5798 src_bucket++;
5799 }
5800
Govind Singhb53420c2016-03-09 14:32:57 +05305801 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305802 __func__, nbuckets, nchannels);
5803 len += nchannels * sizeof(wmi_extscan_bucket_channel);
5804 /* Allocate the memory */
5805 *buf = wmi_buf_alloc(wmi_handle, len);
5806 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305807 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05305808 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305809 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305810 }
5811 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5812 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
5813 WMITLV_SET_HDR(&cmd->tlv_header,
5814 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
5815 WMITLV_GET_STRUCT_TLVLEN
5816 (wmi_extscan_start_cmd_fixed_param));
5817
5818 cmd->request_id = pstart->requestId;
5819 cmd->vdev_id = pstart->sessionId;
5820 cmd->base_period = pstart->basePeriod;
5821 cmd->num_buckets = nbuckets;
5822 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05305823 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305824 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05305825 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305826 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05305827#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05305828 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
5829 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05305830 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
5831 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
5832#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05305833 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5834
5835 /* The max dwell time is retrieved from the first channel
5836 * of the first bucket and kept common for all channels.
5837 */
5838 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
5839 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
5840 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
5841 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
5842 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5843 cmd->max_table_usage = pstart->report_threshold_percent;
5844 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
5845
5846 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05305847 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305848 cmd->probe_delay = 0;
5849 cmd->probe_spacing_time = 0;
5850 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305851 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
5852 WMI_SCAN_ADD_CCK_RATES |
5853 WMI_SCAN_ADD_OFDM_RATES |
5854 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
5855 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05305856 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
5857 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05305858 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305859 cmd->num_ssids = 0;
5860 cmd->num_bssid = 0;
5861 cmd->ie_len = 0;
5862 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
5863 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
5864
5865 buf_ptr += sizeof(*cmd);
5866 WMITLV_SET_HDR(buf_ptr,
5867 WMITLV_TAG_ARRAY_FIXED_STRUC,
5868 num_ssid * sizeof(wmi_ssid));
5869 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
5870
5871 WMITLV_SET_HDR(buf_ptr,
5872 WMITLV_TAG_ARRAY_FIXED_STRUC,
5873 num_bssid * sizeof(wmi_mac_addr));
5874 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
5875
5876 ie_len_with_pad = 0;
5877 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5878 ie_len_with_pad);
5879 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
5880
5881 WMITLV_SET_HDR(buf_ptr,
5882 WMITLV_TAG_ARRAY_STRUC,
5883 nbuckets * sizeof(wmi_extscan_bucket));
5884 dest_blist = (wmi_extscan_bucket *)
5885 (buf_ptr + WMI_TLV_HDR_SIZE);
5886 src_bucket = pstart->buckets;
5887
5888 /* Retrieve scanning information from each bucket and
5889 * channels and send it to the target
5890 */
5891 for (i = 0; i < nbuckets; i++) {
5892 WMITLV_SET_HDR(dest_blist,
5893 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5894 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
5895
5896 dest_blist->bucket_id = src_bucket->bucket;
5897 dest_blist->base_period_multiplier =
5898 src_bucket->period / base_period;
5899 dest_blist->min_period = src_bucket->period;
5900 dest_blist->max_period = src_bucket->max_period;
5901 dest_blist->exp_backoff = src_bucket->exponent;
5902 dest_blist->exp_max_step_count = src_bucket->step_count;
5903 dest_blist->channel_band = src_bucket->band;
5904 dest_blist->num_channels = src_bucket->numChannels;
5905 dest_blist->notify_extscan_events = 0;
5906
5907 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
5908 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07005909 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
5910 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305911
5912 if (src_bucket->reportEvents &
5913 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
5914 dest_blist->forwarding_flags =
5915 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
5916 dest_blist->notify_extscan_events |=
5917 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
5918 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
5919 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
5920 } else {
5921 dest_blist->forwarding_flags =
5922 WMI_EXTSCAN_NO_FORWARDING;
5923 }
5924
5925 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
5926 dest_blist->configuration_flags = 0;
5927 else
5928 dest_blist->configuration_flags =
5929 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
5930
Govind Singhb53420c2016-03-09 14:32:57 +05305931 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305932 __func__, dest_blist->notify_extscan_events,
5933 dest_blist->configuration_flags,
5934 dest_blist->forwarding_flags);
5935
5936 dest_blist->min_dwell_time_active =
5937 src_bucket->min_dwell_time_active;
5938 dest_blist->max_dwell_time_active =
5939 src_bucket->max_dwell_time_active;
5940 dest_blist->min_dwell_time_passive =
5941 src_bucket->min_dwell_time_passive;
5942 dest_blist->max_dwell_time_passive =
5943 src_bucket->max_dwell_time_passive;
5944 src_channel = src_bucket->channels;
5945
5946 /* save the channel info to later populate
5947 * the channel TLV
5948 */
5949 for (k = 0; k < src_bucket->numChannels; k++) {
5950 save_channel[count++].channel = src_channel->channel;
5951 src_channel++;
5952 }
5953 dest_blist++;
5954 src_bucket++;
5955 }
5956 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
5957 WMITLV_SET_HDR(buf_ptr,
5958 WMITLV_TAG_ARRAY_STRUC,
5959 nchannels * sizeof(wmi_extscan_bucket_channel));
5960 dest_clist = (wmi_extscan_bucket_channel *)
5961 (buf_ptr + WMI_TLV_HDR_SIZE);
5962
5963 /* Active or passive scan is based on the bucket dwell time
5964 * and channel specific active,passive scans are not
5965 * supported yet
5966 */
5967 for (i = 0; i < nchannels; i++) {
5968 WMITLV_SET_HDR(dest_clist,
5969 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
5970 WMITLV_GET_STRUCT_TLVLEN
5971 (wmi_extscan_bucket_channel));
5972 dest_clist->channel = save_channel[i].channel;
5973 dest_clist++;
5974 }
5975 buf_ptr += WMI_TLV_HDR_SIZE +
5976 (nchannels * sizeof(wmi_extscan_bucket_channel));
5977 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305978 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305979}
5980
5981/**
5982 * send_start_extscan_cmd_tlv() - start extscan command to fw.
5983 * @wmi_handle: wmi handle
5984 * @pstart: scan command request params
5985 *
5986 * This function sends start extscan request to fw.
5987 *
5988 * Return: CDF Status.
5989 */
Govind Singhb53420c2016-03-09 14:32:57 +05305990QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305991 struct wifi_scan_cmd_req_params *pstart)
5992{
Govind Singhb53420c2016-03-09 14:32:57 +05305993 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305994 wmi_buf_t buf;
5995 int len;
5996
5997 /* Fill individual elements of extscan request and
5998 * TLV for buckets, channel list.
5999 */
Govind Singhb53420c2016-03-09 14:32:57 +05306000 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306001 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306002 if (qdf_status != QDF_STATUS_SUCCESS) {
6003 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6004 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306005 }
6006 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306007 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306008 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306009 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306010 }
6011 if (wmi_unified_cmd_send(wmi_handle, buf,
6012 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306013 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306014 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306015 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306016 }
6017
Govind Singhb53420c2016-03-09 14:32:57 +05306018 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306019}
6020
6021/**
6022 * send_plm_stop_cmd_tlv() - plm stop request
6023 * @wmi_handle: wmi handle
6024 * @plm: plm request parameters
6025 *
6026 * This function request FW to stop PLM.
6027 *
6028 * Return: CDF status
6029 */
Govind Singhb53420c2016-03-09 14:32:57 +05306030QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306031 const struct plm_req_params *plm)
6032{
6033 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6034 int32_t len;
6035 wmi_buf_t buf;
6036 uint8_t *buf_ptr;
6037 int ret;
6038
6039 len = sizeof(*cmd);
6040 buf = wmi_buf_alloc(wmi_handle, len);
6041 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306042 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6043 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306044 }
6045
6046 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6047
6048 buf_ptr = (uint8_t *) cmd;
6049
6050 WMITLV_SET_HDR(&cmd->tlv_header,
6051 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6052 WMITLV_GET_STRUCT_TLVLEN
6053 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6054
6055 cmd->vdev_id = plm->session_id;
6056
6057 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306058 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306059
6060 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6061 WMI_VDEV_PLMREQ_STOP_CMDID);
6062 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306063 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306064 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306065 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306066 }
6067
Govind Singhb53420c2016-03-09 14:32:57 +05306068 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306069}
6070
6071/**
6072 * send_plm_start_cmd_tlv() - plm start request
6073 * @wmi_handle: wmi handle
6074 * @plm: plm request parameters
6075 *
6076 * This function request FW to start PLM.
6077 *
6078 * Return: CDF status
6079 */
Govind Singhb53420c2016-03-09 14:32:57 +05306080QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306081 const struct plm_req_params *plm,
6082 uint32_t *gchannel_list)
6083{
6084 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6085 uint32_t *channel_list;
6086 int32_t len;
6087 wmi_buf_t buf;
6088 uint8_t *buf_ptr;
6089 uint8_t count;
6090 int ret;
6091
6092 /* TLV place holder for channel_list */
6093 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6094 len += sizeof(uint32_t) * plm->plm_num_ch;
6095
6096 buf = wmi_buf_alloc(wmi_handle, len);
6097 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306098 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6099 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306100 }
6101 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6102
6103 buf_ptr = (uint8_t *) cmd;
6104
6105 WMITLV_SET_HDR(&cmd->tlv_header,
6106 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6107 WMITLV_GET_STRUCT_TLVLEN
6108 (wmi_vdev_plmreq_start_cmd_fixed_param));
6109
6110 cmd->vdev_id = plm->session_id;
6111
6112 cmd->meas_token = plm->meas_token;
6113 cmd->dialog_token = plm->diag_token;
6114 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306115 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306116 cmd->off_duration = plm->meas_duration;
6117 cmd->burst_cycle = plm->burst_len;
6118 cmd->tx_power = plm->desired_tx_pwr;
6119 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6120 cmd->num_chans = plm->plm_num_ch;
6121
6122 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6123
Govind Singhb53420c2016-03-09 14:32:57 +05306124 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6125 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6126 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6127 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6128 WMI_LOGD("off_duration: %d", cmd->off_duration);
6129 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6130 WMI_LOGD("tx_power: %d", cmd->tx_power);
6131 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306132
6133 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6134 (cmd->num_chans * sizeof(uint32_t)));
6135
6136 buf_ptr += WMI_TLV_HDR_SIZE;
6137 if (cmd->num_chans) {
6138 channel_list = (uint32_t *) buf_ptr;
6139 for (count = 0; count < cmd->num_chans; count++) {
6140 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306141 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306142 channel_list[count] =
6143 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306144 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306145 }
6146 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6147 }
6148
6149 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6150 WMI_VDEV_PLMREQ_START_CMDID);
6151 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306152 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306153 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306154 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306155 }
6156
Govind Singhb53420c2016-03-09 14:32:57 +05306157 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306158}
6159
6160/**
6161 * send_pno_stop_cmd_tlv() - PNO stop request
6162 * @wmi_handle: wmi handle
6163 * @vdev_id: vdev id
6164 *
6165 * This function request FW to stop ongoing PNO operation.
6166 *
6167 * Return: CDF status
6168 */
Govind Singhb53420c2016-03-09 14:32:57 +05306169QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306170{
6171 wmi_nlo_config_cmd_fixed_param *cmd;
6172 int32_t len = sizeof(*cmd);
6173 wmi_buf_t buf;
6174 uint8_t *buf_ptr;
6175 int ret;
6176
6177 /*
6178 * TLV place holder for array of structures nlo_configured_parameters
6179 * TLV place holder for array of uint32_t channel_list
6180 * TLV place holder for chnl prediction cfg
6181 */
6182 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6183 buf = wmi_buf_alloc(wmi_handle, len);
6184 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306185 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6186 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306187 }
6188
6189 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6190 buf_ptr = (uint8_t *) cmd;
6191
6192 WMITLV_SET_HDR(&cmd->tlv_header,
6193 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6194 WMITLV_GET_STRUCT_TLVLEN
6195 (wmi_nlo_config_cmd_fixed_param));
6196
6197 cmd->vdev_id = vdev_id;
6198 cmd->flags = WMI_NLO_CONFIG_STOP;
6199 buf_ptr += sizeof(*cmd);
6200
6201 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6202 buf_ptr += WMI_TLV_HDR_SIZE;
6203
6204 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6205 buf_ptr += WMI_TLV_HDR_SIZE;
6206
6207 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6208 buf_ptr += WMI_TLV_HDR_SIZE;
6209
6210
6211 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6212 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6213 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306214 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306215 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306216 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306217 }
6218
Govind Singhb53420c2016-03-09 14:32:57 +05306219 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306220}
6221
6222/**
Govind Singhccb0c272016-04-01 16:30:08 +05306223 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6224 * @buf_ptr: Buffer passed by upper layers
6225 * @pno: Buffer to be sent to the firmware
6226 *
6227 * Copy the PNO Channel prediction configuration parameters
6228 * passed by the upper layers to a WMI format TLV and send it
6229 * down to the firmware.
6230 *
6231 * Return: None
6232 */
6233static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6234 struct pno_scan_req_params *pno)
6235{
6236 nlo_channel_prediction_cfg *channel_prediction_cfg =
6237 (nlo_channel_prediction_cfg *) buf_ptr;
6238 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6239 WMITLV_TAG_ARRAY_BYTE,
6240 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306241#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306242 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6243 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6244 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6245 channel_prediction_cfg->full_scan_period_ms =
6246 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306247#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306248 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6249 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6250 channel_prediction_cfg->enable,
6251 channel_prediction_cfg->top_k_num,
6252 channel_prediction_cfg->stationary_threshold,
6253 channel_prediction_cfg->full_scan_period_ms);
6254}
6255
6256/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306257 * send_pno_start_cmd_tlv() - PNO start request
6258 * @wmi_handle: wmi handle
6259 * @pno: PNO request
6260 *
6261 * This function request FW to start PNO request.
6262 * Request: CDF status
6263 */
Govind Singhb53420c2016-03-09 14:32:57 +05306264QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306265 struct pno_scan_req_params *pno,
6266 uint32_t *gchannel_freq_list)
6267{
6268 wmi_nlo_config_cmd_fixed_param *cmd;
6269 nlo_configured_parameters *nlo_list;
6270 uint32_t *channel_list;
6271 int32_t len;
6272 wmi_buf_t buf;
6273 uint8_t *buf_ptr;
6274 uint8_t i;
6275 int ret;
6276
6277 /*
6278 * TLV place holder for array nlo_configured_parameters(nlo_list)
6279 * TLV place holder for array of uint32_t channel_list
6280 * TLV place holder for chnnl prediction cfg
6281 */
6282 len = sizeof(*cmd) +
6283 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6284
Govind Singhb53420c2016-03-09 14:32:57 +05306285 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306286 WMI_NLO_MAX_CHAN);
6287 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306288 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306289 len += sizeof(nlo_channel_prediction_cfg);
6290
6291 buf = wmi_buf_alloc(wmi_handle, len);
6292 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306293 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6294 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306295 }
6296
6297 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6298
6299 buf_ptr = (uint8_t *) cmd;
6300 WMITLV_SET_HDR(&cmd->tlv_header,
6301 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6302 WMITLV_GET_STRUCT_TLVLEN
6303 (wmi_nlo_config_cmd_fixed_param));
6304 cmd->vdev_id = pno->sessionId;
6305 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6306
Govind Singh87542482016-06-08 19:40:11 +05306307#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306308 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6309 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306310#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306311 /* Current FW does not support min-max range for dwell time */
6312 cmd->active_dwell_time = pno->active_max_time;
6313 cmd->passive_dwell_time = pno->passive_max_time;
6314
6315 /* Copy scan interval */
6316 cmd->fast_scan_period = pno->fast_scan_period;
6317 cmd->slow_scan_period = pno->slow_scan_period;
6318 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306319 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306320 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306321 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306322
6323 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6324
Govind Singhb53420c2016-03-09 14:32:57 +05306325 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6326 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306327 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6328 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6329 buf_ptr += WMI_TLV_HDR_SIZE;
6330
6331 nlo_list = (nlo_configured_parameters *) buf_ptr;
6332 for (i = 0; i < cmd->no_of_ssids; i++) {
6333 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6334 WMITLV_TAG_ARRAY_BYTE,
6335 WMITLV_GET_STRUCT_TLVLEN
6336 (nlo_configured_parameters));
6337 /* Copy ssid and it's length */
6338 nlo_list[i].ssid.valid = true;
6339 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306340 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306341 pno->aNetworks[i].ssid.mac_ssid,
6342 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306343 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306344 nlo_list[i].ssid.ssid.ssid_len,
6345 (char *)nlo_list[i].ssid.ssid.ssid,
6346 nlo_list[i].ssid.ssid.ssid_len);
6347
6348 /* Copy rssi threshold */
6349 if (pno->aNetworks[i].rssiThreshold &&
6350 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6351 nlo_list[i].rssi_cond.valid = true;
6352 nlo_list[i].rssi_cond.rssi =
6353 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306354 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306355 nlo_list[i].rssi_cond.rssi);
6356 }
6357 nlo_list[i].bcast_nw_type.valid = true;
6358 nlo_list[i].bcast_nw_type.bcast_nw_type =
6359 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306360 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306361 nlo_list[i].bcast_nw_type.bcast_nw_type);
6362 }
6363 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6364
6365 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306366 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306367 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306368 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306369 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6370 (cmd->num_of_channels * sizeof(uint32_t)));
6371 buf_ptr += WMI_TLV_HDR_SIZE;
6372
6373 channel_list = (uint32_t *) buf_ptr;
6374 for (i = 0; i < cmd->num_of_channels; i++) {
6375 channel_list[i] = pno->aNetworks[0].aChannels[i];
6376
6377 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6378 channel_list[i] = gchannel_freq_list[i];
6379
Govind Singhb53420c2016-03-09 14:32:57 +05306380 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306381 }
6382 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6383 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6384 sizeof(nlo_channel_prediction_cfg));
6385 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306386 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306387 buf_ptr += WMI_TLV_HDR_SIZE;
6388 /** TODO: Discrete firmware doesn't have command/option to configure
6389 * App IE which comes from wpa_supplicant as of part PNO start request.
6390 */
6391 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6392 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6393 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306394 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306395 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306396 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306397 }
6398
Govind Singhb53420c2016-03-09 14:32:57 +05306399 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306400}
6401
6402/* send_set_ric_req_cmd_tlv() - set ric request element
6403 * @wmi_handle: wmi handle
6404 * @msg: message
6405 * @is_add_ts: is addts required
6406 *
6407 * This function sets ric request element for 11r roaming.
6408 *
6409 * Return: CDF status
6410 */
Govind Singhb53420c2016-03-09 14:32:57 +05306411QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306412 void *msg, uint8_t is_add_ts)
6413{
6414 wmi_ric_request_fixed_param *cmd;
6415 wmi_ric_tspec *tspec_param;
6416 wmi_buf_t buf;
6417 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306418 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306419 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6420 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6421
6422 buf = wmi_buf_alloc(wmi_handle, len);
6423 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306424 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6425 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306426 }
6427
6428 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6429
6430 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6431 WMITLV_SET_HDR(&cmd->tlv_header,
6432 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6433 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6434 if (is_add_ts)
6435 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
6436 else
6437 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
6438 cmd->num_ric_request = 1;
6439 cmd->is_add_ric = is_add_ts;
6440
6441 buf_ptr += sizeof(wmi_ric_request_fixed_param);
6442 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
6443
6444 buf_ptr += WMI_TLV_HDR_SIZE;
6445 tspec_param = (wmi_ric_tspec *) buf_ptr;
6446 WMITLV_SET_HDR(&tspec_param->tlv_header,
6447 WMITLV_TAG_STRUC_wmi_ric_tspec,
6448 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
6449
6450 if (is_add_ts)
6451 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05306452#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05306453 else
6454 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05306455#endif
6456 if (ptspecIE) {
6457 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05306458#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05306459 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
6460 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306461#else
Govind Singh87542482016-06-08 19:40:11 +05306462 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
6463 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306464#endif /* ANI_LITTLE_BIT_ENDIAN */
6465
Govind Singh87542482016-06-08 19:40:11 +05306466 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
6467 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
6468 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
6469 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
6470 tspec_param->inactivity_interval = ptspecIE->inactInterval;
6471 tspec_param->suspension_interval = ptspecIE->suspendInterval;
6472 tspec_param->svc_start_time = ptspecIE->svcStartTime;
6473 tspec_param->min_data_rate = ptspecIE->minDataRate;
6474 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
6475 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
6476 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
6477 tspec_param->delay_bound = ptspecIE->delayBound;
6478 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
6479 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
6480 tspec_param->medium_time = 0;
6481 }
Govind Singhb53420c2016-03-09 14:32:57 +05306482 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306483
6484 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6485 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306486 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306487 __func__);
6488 if (is_add_ts)
6489 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05306490 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05306491 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306492 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306493 }
6494
Govind Singhb53420c2016-03-09 14:32:57 +05306495 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306496}
6497
6498/**
6499 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
6500 * @wmi_handle: wmi handle
6501 * @clear_req: ll stats clear request command params
6502 *
Govind Singhb53420c2016-03-09 14:32:57 +05306503 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306504 */
Govind Singhb53420c2016-03-09 14:32:57 +05306505QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306506 const struct ll_stats_clear_params *clear_req,
6507 uint8_t addr[IEEE80211_ADDR_LEN])
6508{
6509 wmi_clear_link_stats_cmd_fixed_param *cmd;
6510 int32_t len;
6511 wmi_buf_t buf;
6512 uint8_t *buf_ptr;
6513 int ret;
6514
6515 len = sizeof(*cmd);
6516 buf = wmi_buf_alloc(wmi_handle, len);
6517
6518 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306519 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6520 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306521 }
6522
6523 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306524 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306525 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
6526
6527 WMITLV_SET_HDR(&cmd->tlv_header,
6528 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
6529 WMITLV_GET_STRUCT_TLVLEN
6530 (wmi_clear_link_stats_cmd_fixed_param));
6531
6532 cmd->stop_stats_collection_req = clear_req->stop_req;
6533 cmd->vdev_id = clear_req->sta_id;
6534 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
6535
6536 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6537 &cmd->peer_macaddr);
6538
Govind Singhb53420c2016-03-09 14:32:57 +05306539 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
6540 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
6541 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
6542 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
6543 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306544 cmd->peer_macaddr); */
6545
6546 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6547 WMI_CLEAR_LINK_STATS_CMDID);
6548 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306549 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306550 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306551 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306552 }
6553
Govind Singhb53420c2016-03-09 14:32:57 +05306554 WMI_LOGD("Clear Link Layer Stats request sent successfully");
6555 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306556}
6557
6558/**
6559 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
6560 * @wmi_handle: wmi handle
6561 * @setReq: ll stats set request command params
6562 *
Govind Singhb53420c2016-03-09 14:32:57 +05306563 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306564 */
Govind Singhb53420c2016-03-09 14:32:57 +05306565QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306566 const struct ll_stats_set_params *set_req)
6567{
6568 wmi_start_link_stats_cmd_fixed_param *cmd;
6569 int32_t len;
6570 wmi_buf_t buf;
6571 uint8_t *buf_ptr;
6572 int ret;
6573
6574 len = sizeof(*cmd);
6575 buf = wmi_buf_alloc(wmi_handle, len);
6576
6577 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306578 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6579 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306580 }
6581
6582 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306583 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306584 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
6585
6586 WMITLV_SET_HDR(&cmd->tlv_header,
6587 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
6588 WMITLV_GET_STRUCT_TLVLEN
6589 (wmi_start_link_stats_cmd_fixed_param));
6590
6591 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
6592 cmd->aggressive_statistics_gathering =
6593 set_req->aggressive_statistics_gathering;
6594
Govind Singhb53420c2016-03-09 14:32:57 +05306595 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
6596 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
6597 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306598
6599 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6600 WMI_START_LINK_STATS_CMDID);
6601 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306602 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306603 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306604 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306605 }
6606
Govind Singhb53420c2016-03-09 14:32:57 +05306607 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306608}
6609
6610/**
6611 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
6612 * @wmi_handle:wmi handle
6613 * @get_req:ll stats get request command params
6614 * @addr: mac address
6615 *
Govind Singhb53420c2016-03-09 14:32:57 +05306616 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306617 */
Govind Singhb53420c2016-03-09 14:32:57 +05306618QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306619 const struct ll_stats_get_params *get_req,
6620 uint8_t addr[IEEE80211_ADDR_LEN])
6621{
6622 wmi_request_link_stats_cmd_fixed_param *cmd;
6623 int32_t len;
6624 wmi_buf_t buf;
6625 uint8_t *buf_ptr;
6626 int ret;
6627
6628 len = sizeof(*cmd);
6629 buf = wmi_buf_alloc(wmi_handle, len);
6630
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05306631 if (!buf) {
6632 WMI_LOGE("%s: buf allocation failed", __func__);
6633 return QDF_STATUS_E_NOMEM;
6634 }
6635
Govind Singh4eacd2b2016-03-07 14:24:22 +05306636 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306637 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306638 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
6639
6640 WMITLV_SET_HDR(&cmd->tlv_header,
6641 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
6642 WMITLV_GET_STRUCT_TLVLEN
6643 (wmi_request_link_stats_cmd_fixed_param));
6644
6645 cmd->request_id = get_req->req_id;
6646 cmd->stats_type = get_req->param_id_mask;
6647 cmd->vdev_id = get_req->sta_id;
6648
6649 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6650 &cmd->peer_macaddr);
6651
Govind Singhb53420c2016-03-09 14:32:57 +05306652 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
6653 WMI_LOGD("Request ID : %d", cmd->request_id);
6654 WMI_LOGD("Stats Type : %d", cmd->stats_type);
6655 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
6656 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306657
6658 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6659 WMI_REQUEST_LINK_STATS_CMDID);
6660 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306661 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306662 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306663 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306664 }
6665
Govind Singhb53420c2016-03-09 14:32:57 +05306666 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306667}
6668
6669/**
6670 * send_get_stats_cmd_tlv() - get stats request
6671 * @wmi_handle: wmi handle
6672 * @get_stats_param: stats params
6673 * @addr: mac address
6674 *
6675 * Return: CDF status
6676 */
Govind Singhb53420c2016-03-09 14:32:57 +05306677QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306678 struct pe_stats_req *get_stats_param,
6679 uint8_t addr[IEEE80211_ADDR_LEN])
6680{
6681 wmi_buf_t buf;
6682 wmi_request_stats_cmd_fixed_param *cmd;
6683 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6684
6685 buf = wmi_buf_alloc(wmi_handle, len);
6686 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306687 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
6688 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306689 }
6690
6691
6692 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6693 WMITLV_SET_HDR(&cmd->tlv_header,
6694 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6695 WMITLV_GET_STRUCT_TLVLEN
6696 (wmi_request_stats_cmd_fixed_param));
6697 cmd->stats_id =
6698 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05306699 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306700 cmd->vdev_id = get_stats_param->session_id;
6701 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05306702 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306703 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6704 WMI_REQUEST_STATS_CMDID)) {
6705
Govind Singhb53420c2016-03-09 14:32:57 +05306706 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306707 __func__);
6708 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306709 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306710 }
6711
Govind Singhb53420c2016-03-09 14:32:57 +05306712 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306713
6714}
6715
Govind Singh20c5dac2016-03-07 15:33:31 +05306716/**
6717 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
6718 * @wmi_handle: wmi handle
6719 * @rssi_req: get RSSI request
6720 *
6721 * Return: CDF status
6722 */
Govind Singhb53420c2016-03-09 14:32:57 +05306723QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05306724{
6725 wmi_buf_t buf;
6726 wmi_request_stats_cmd_fixed_param *cmd;
6727 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6728
6729 buf = wmi_buf_alloc(wmi_handle, len);
6730 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306731 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6732 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306733 }
6734
6735 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6736 WMITLV_SET_HDR(&cmd->tlv_header,
6737 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6738 WMITLV_GET_STRUCT_TLVLEN
6739 (wmi_request_stats_cmd_fixed_param));
6740 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6741 if (wmi_unified_cmd_send
6742 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306743 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306744 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306745 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306746 }
6747
Govind Singhb53420c2016-03-09 14:32:57 +05306748 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306749}
6750
6751/**
6752 * send_snr_cmd_tlv() - get RSSI from fw
6753 * @wmi_handle: wmi handle
6754 * @vdev_id: vdev id
6755 *
6756 * Return: CDF status
6757 */
Govind Singhb53420c2016-03-09 14:32:57 +05306758QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05306759{
6760 wmi_buf_t buf;
6761 wmi_request_stats_cmd_fixed_param *cmd;
6762 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6763
6764 buf = wmi_buf_alloc(wmi_handle, len);
6765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306766 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6767 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306768 }
6769
6770 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6771 cmd->vdev_id = vdev_id;
6772
6773 WMITLV_SET_HDR(&cmd->tlv_header,
6774 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6775 WMITLV_GET_STRUCT_TLVLEN
6776 (wmi_request_stats_cmd_fixed_param));
6777 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6778 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6779 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306780 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306781 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306782 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306783 }
6784
Govind Singhb53420c2016-03-09 14:32:57 +05306785 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306786}
6787
6788/**
6789 * send_link_status_req_cmd_tlv() - process link status request from UMAC
6790 * @wmi_handle: wmi handle
6791 * @link_status: get link params
6792 *
6793 * Return: CDF status
6794 */
Govind Singhb53420c2016-03-09 14:32:57 +05306795QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306796 struct link_status_params *link_status)
6797{
6798 wmi_buf_t buf;
6799 wmi_request_stats_cmd_fixed_param *cmd;
6800 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6801
6802 buf = wmi_buf_alloc(wmi_handle, len);
6803 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306804 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6805 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306806 }
6807
6808 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6809 WMITLV_SET_HDR(&cmd->tlv_header,
6810 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6811 WMITLV_GET_STRUCT_TLVLEN
6812 (wmi_request_stats_cmd_fixed_param));
6813 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
6814 cmd->vdev_id = link_status->session_id;
6815 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6816 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306817 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306818 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306819 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306820 }
6821
Govind Singhb53420c2016-03-09 14:32:57 +05306822 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306823}
6824
6825#ifdef FEATURE_WLAN_LPHB
6826
6827/**
6828 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
6829 * @wmi_handle: wmi handle
6830 * @lphb_conf_req: configuration info
6831 *
6832 * Return: CDF status
6833 */
Govind Singhb53420c2016-03-09 14:32:57 +05306834QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306835 wmi_hb_set_enable_cmd_fixed_param *params)
6836{
Govind Singh67922e82016-04-01 16:48:57 +05306837 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306838 wmi_buf_t buf = NULL;
6839 uint8_t *buf_ptr;
6840 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
6841 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
6842
6843
6844 buf = wmi_buf_alloc(wmi_handle, len);
6845 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306846 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6847 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306848 }
6849
6850 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6851 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
6852 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
6853 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
6854 WMITLV_GET_STRUCT_TLVLEN
6855 (wmi_hb_set_enable_cmd_fixed_param));
6856
6857 /* fill in values */
6858 hb_enable_fp->vdev_id = params->session;
6859 hb_enable_fp->enable = params->enable;
6860 hb_enable_fp->item = params->item;
6861 hb_enable_fp->session = params->session;
6862
6863 status = wmi_unified_cmd_send(wmi_handle, buf,
6864 len, WMI_HB_SET_ENABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306865 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306866 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_ENABLE returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306867 status);
Govind Singh67922e82016-04-01 16:48:57 +05306868 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306869 }
6870
Govind Singh67922e82016-04-01 16:48:57 +05306871 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306872}
6873
6874/**
6875 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
6876 * @wmi_handle: wmi handle
6877 * @lphb_conf_req: lphb config request
6878 *
6879 * Return: CDF status
6880 */
Govind Singhb53420c2016-03-09 14:32:57 +05306881QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306882 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
6883{
Govind Singh67922e82016-04-01 16:48:57 +05306884 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306885 wmi_buf_t buf = NULL;
6886 uint8_t *buf_ptr;
6887 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
6888 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
6889
6890 buf = wmi_buf_alloc(wmi_handle, len);
6891 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306892 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6893 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306894 }
6895
6896 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6897 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
6898 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
6899 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
6900 WMITLV_GET_STRUCT_TLVLEN
6901 (wmi_hb_set_tcp_params_cmd_fixed_param));
6902
6903 /* fill in values */
6904 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
6905 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
6906 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
6907 hb_tcp_params_fp->seq = lphb_conf_req->seq;
6908 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
6909 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
6910 hb_tcp_params_fp->interval = lphb_conf_req->interval;
6911 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
6912 hb_tcp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05306913 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05306914 &lphb_conf_req->gateway_mac,
6915 sizeof(hb_tcp_params_fp->gateway_mac));
6916
6917 status = wmi_unified_cmd_send(wmi_handle, buf,
6918 len, WMI_HB_SET_TCP_PARAMS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306919 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306920 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306921 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306922 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306923 }
6924
Govind Singh67922e82016-04-01 16:48:57 +05306925 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306926}
6927
6928/**
6929 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
6930 * @wmi_handle: wmi handle
6931 * @lphb_conf_req: lphb config request
6932 *
6933 * Return: CDF status
6934 */
Govind Singhb53420c2016-03-09 14:32:57 +05306935QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306936 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
6937{
Govind Singh67922e82016-04-01 16:48:57 +05306938 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306939 wmi_buf_t buf = NULL;
6940 uint8_t *buf_ptr;
6941 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
6942 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
6943
6944 buf = wmi_buf_alloc(wmi_handle, len);
6945 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306946 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6947 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306948 }
6949
6950 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6951 hb_tcp_filter_fp =
6952 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
6953 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
6954 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
6955 WMITLV_GET_STRUCT_TLVLEN
6956 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
6957
6958 /* fill in values */
6959 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
6960 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
6961 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
6962 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
6963 memcpy((void *)&hb_tcp_filter_fp->filter,
6964 (void *)&g_hb_tcp_filter_fp->filter,
6965 WMI_WLAN_HB_MAX_FILTER_SIZE);
6966
6967 status = wmi_unified_cmd_send(wmi_handle, buf,
6968 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306969 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306970 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306971 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306972 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306973 }
6974
Govind Singh67922e82016-04-01 16:48:57 +05306975 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306976}
6977
6978/**
6979 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
6980 * @wmi_handle: wmi handle
6981 * @lphb_conf_req: lphb config request
6982 *
6983 * Return: CDF status
6984 */
Govind Singhb53420c2016-03-09 14:32:57 +05306985QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306986 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
6987{
Govind Singh67922e82016-04-01 16:48:57 +05306988 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306989 wmi_buf_t buf = NULL;
6990 uint8_t *buf_ptr;
6991 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
6992 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
6993
6994 buf = wmi_buf_alloc(wmi_handle, len);
6995 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306996 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6997 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306998 }
6999
7000 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7001 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
7002 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
7003 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
7004 WMITLV_GET_STRUCT_TLVLEN
7005 (wmi_hb_set_udp_params_cmd_fixed_param));
7006
7007 /* fill in values */
7008 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
7009 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
7010 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
7011 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
7012 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
7013 hb_udp_params_fp->interval = lphb_conf_req->interval;
7014 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
7015 hb_udp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05307016 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05307017 &lphb_conf_req->gateway_mac,
7018 sizeof(lphb_conf_req->gateway_mac));
7019
7020 status = wmi_unified_cmd_send(wmi_handle, buf,
7021 len, WMI_HB_SET_UDP_PARAMS_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307022 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307023 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307024 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307025 wmi_buf_free(buf);
7026 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307027
Govind Singh67922e82016-04-01 16:48:57 +05307028 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307029}
7030
7031/**
7032 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
7033 * @wmi_handle: wmi handle
7034 * @lphb_conf_req: lphb config request
7035 *
7036 * Return: CDF status
7037 */
Govind Singhb53420c2016-03-09 14:32:57 +05307038QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307039 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
7040{
Govind Singh67922e82016-04-01 16:48:57 +05307041 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307042 wmi_buf_t buf = NULL;
7043 uint8_t *buf_ptr;
7044 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
7045 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
7046
7047 buf = wmi_buf_alloc(wmi_handle, len);
7048 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307049 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7050 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307051 }
7052
7053 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7054 hb_udp_filter_fp =
7055 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
7056 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
7057 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
7058 WMITLV_GET_STRUCT_TLVLEN
7059 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
7060
7061 /* fill in values */
7062 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
7063 hb_udp_filter_fp->length = lphb_conf_req->length;
7064 hb_udp_filter_fp->offset = lphb_conf_req->offset;
7065 hb_udp_filter_fp->session = lphb_conf_req->session;
7066 memcpy((void *)&hb_udp_filter_fp->filter,
7067 (void *)&lphb_conf_req->filter,
7068 WMI_WLAN_HB_MAX_FILTER_SIZE);
7069
7070 status = wmi_unified_cmd_send(wmi_handle, buf,
7071 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307072 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307073 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307074 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307075 wmi_buf_free(buf);
7076 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307077
Govind Singh67922e82016-04-01 16:48:57 +05307078 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307079}
7080#endif /* FEATURE_WLAN_LPHB */
7081
7082/**
7083 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7084 * @wmi_handle: wmi handle
7085 * @ta_dhcp_ind: DHCP indication parameter
7086 *
7087 * Return: CDF Status
7088 */
Govind Singhb53420c2016-03-09 14:32:57 +05307089QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307090 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7091{
Govind Singh67922e82016-04-01 16:48:57 +05307092 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307093 wmi_buf_t buf = NULL;
7094 uint8_t *buf_ptr;
7095 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7096 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7097
7098
7099 buf = wmi_buf_alloc(wmi_handle, len);
7100 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307101 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7102 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307103 }
7104
7105 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7106 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7107 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7108 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7109 WMITLV_GET_STRUCT_TLVLEN
7110 (wmi_peer_set_param_cmd_fixed_param));
7111
7112 /* fill in values */
7113 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7114 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7115 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307116 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307117 &ta_dhcp_ind->peer_macaddr,
7118 sizeof(ta_dhcp_ind->peer_macaddr));
7119
7120 status = wmi_unified_cmd_send(wmi_handle, buf,
7121 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307122 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307123 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307124 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307125 wmi_buf_free(buf);
7126 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307127
Govind Singh67922e82016-04-01 16:48:57 +05307128 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307129}
7130
7131/**
7132 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7133 * @wmi_handle: wmi handle
7134 * @pLinkSpeed: link speed info
7135 *
7136 * Return: CDF status
7137 */
Govind Singhb53420c2016-03-09 14:32:57 +05307138QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307139 wmi_mac_addr peer_macaddr)
7140{
7141 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7142 wmi_buf_t wmi_buf;
7143 uint32_t len;
7144 uint8_t *buf_ptr;
7145
7146 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7147 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7148 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307149 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7150 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307151 }
7152 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7153
7154 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7155 WMITLV_SET_HDR(&cmd->tlv_header,
7156 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7157 WMITLV_GET_STRUCT_TLVLEN
7158 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7159
7160 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307161 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307162 &peer_macaddr,
7163 sizeof(peer_macaddr));
7164
7165
7166 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7167 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307168 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307169 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307170 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307171 }
Govind Singhb53420c2016-03-09 14:32:57 +05307172 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307173}
7174
7175/**
7176 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7177 * @wmi_handle: wmi handler
7178 * @egap_params: pointer to egap_params
7179 *
7180 * Return: 0 for success, otherwise appropriate error code
7181 */
Govind Singhb53420c2016-03-09 14:32:57 +05307182QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307183 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7184{
7185 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7186 wmi_buf_t buf;
7187 int32_t err;
7188
7189 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7190 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307191 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7192 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307193 }
7194 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7195 WMITLV_SET_HDR(&cmd->tlv_header,
7196 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7197 WMITLV_GET_STRUCT_TLVLEN(
7198 wmi_ap_ps_egap_param_cmd_fixed_param));
7199
7200 cmd->enable = egap_params->enable;
7201 cmd->inactivity_time = egap_params->inactivity_time;
7202 cmd->wait_time = egap_params->wait_time;
7203 cmd->flags = egap_params->flags;
7204 err = wmi_unified_cmd_send(wmi_handle, buf,
7205 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7206 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307207 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307208 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307209 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307210 }
7211
Govind Singhb53420c2016-03-09 14:32:57 +05307212 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307213}
7214
7215/**
7216 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7217 * @wmi_handl: wmi handle
7218 * @cmd: Profiling command index
7219 * @value1: parameter1 value
7220 * @value2: parameter2 value
7221 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307222 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307223 */
Govind Singhb53420c2016-03-09 14:32:57 +05307224QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307225 uint32_t cmd, uint32_t value1, uint32_t value2)
7226{
7227 wmi_buf_t buf;
7228 int32_t len = 0;
7229 int ret;
7230 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7231 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7232 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7233 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7234
7235 switch (cmd) {
7236 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7237 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7238 buf = wmi_buf_alloc(wmi_handle, len);
7239 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307240 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307241 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307242 }
7243 prof_trig_cmd =
7244 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7245 wmi_buf_data(buf);
7246 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7247 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7248 WMITLV_GET_STRUCT_TLVLEN
7249 (wmi_wlan_profile_trigger_cmd_fixed_param));
7250 prof_trig_cmd->enable = value1;
7251 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7252 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7253 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307254 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307255 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307256 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307257 return ret;
7258 }
7259 break;
7260
7261 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7262 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7263 buf = wmi_buf_alloc(wmi_handle, len);
7264 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307265 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307266 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307267 }
7268 profile_getdata_cmd =
7269 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7270 wmi_buf_data(buf);
7271 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7272 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7273 WMITLV_GET_STRUCT_TLVLEN
7274 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7275 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7276 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7277 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307278 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307279 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307280 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307281 return ret;
7282 }
7283 break;
7284
7285 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7286 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7287 buf = wmi_buf_alloc(wmi_handle, len);
7288 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307289 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307290 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307291 }
7292 hist_intvl_cmd =
7293 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7294 wmi_buf_data(buf);
7295 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7296 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7297 WMITLV_GET_STRUCT_TLVLEN
7298 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7299 hist_intvl_cmd->profile_id = value1;
7300 hist_intvl_cmd->value = value2;
7301 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7302 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7303 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307304 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307305 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307306 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307307 return ret;
7308 }
7309 break;
7310
7311 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7312 len =
7313 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7314 buf = wmi_buf_alloc(wmi_handle, len);
7315 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307316 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307317 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307318 }
7319 profile_enable_cmd =
7320 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7321 wmi_buf_data(buf);
7322 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7323 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7324 WMITLV_GET_STRUCT_TLVLEN
7325 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7326 profile_enable_cmd->profile_id = value1;
7327 profile_enable_cmd->enable = value2;
7328 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7329 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7330 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307331 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307332 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307333 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307334 return ret;
7335 }
7336 break;
7337
7338 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307339 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307340 break;
7341 }
7342
7343 return 0;
7344}
7345
7346#ifdef FEATURE_WLAN_RA_FILTERING
7347/**
7348 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
7349 * @wmi_handle: wmi handle
7350 * @vdev_id: vdev id
7351 *
7352 * Return: CDF status
7353 */
Govind Singhb53420c2016-03-09 14:32:57 +05307354QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307355 uint8_t vdev_id, uint8_t default_pattern,
7356 uint16_t rate_limit_interval)
7357{
7358
7359 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7360 wmi_buf_t buf;
7361 uint8_t *buf_ptr;
7362 int32_t len;
7363 int ret;
7364
7365 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7366 WMI_TLV_HDR_SIZE +
7367 0 * sizeof(WOW_BITMAP_PATTERN_T) +
7368 WMI_TLV_HDR_SIZE +
7369 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7370 WMI_TLV_HDR_SIZE +
7371 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7372 WMI_TLV_HDR_SIZE +
7373 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7374 WMI_TLV_HDR_SIZE +
7375 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7376
7377 buf = wmi_buf_alloc(wmi_handle, len);
7378 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307379 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7380 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307381 }
7382
7383 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7384 buf_ptr = (uint8_t *) cmd;
7385
7386 WMITLV_SET_HDR(&cmd->tlv_header,
7387 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7388 WMITLV_GET_STRUCT_TLVLEN
7389 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7390 cmd->vdev_id = vdev_id;
7391 cmd->pattern_id = default_pattern,
7392 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
7393 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7394
7395 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
7396 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7397 buf_ptr += WMI_TLV_HDR_SIZE;
7398
7399 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7400 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7401 buf_ptr += WMI_TLV_HDR_SIZE;
7402
7403 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7404 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7405 buf_ptr += WMI_TLV_HDR_SIZE;
7406
7407 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7408 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7409 buf_ptr += WMI_TLV_HDR_SIZE;
7410
7411 /* Fill TLV for pattern_info_timeout but no data. */
7412 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7413 buf_ptr += WMI_TLV_HDR_SIZE;
7414
7415 /* Fill TLV for ra_ratelimit_interval. */
7416 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
7417 buf_ptr += WMI_TLV_HDR_SIZE;
7418
7419 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
7420
Govind Singhb53420c2016-03-09 14:32:57 +05307421 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05307422 rate_limit_interval, vdev_id);
7423
7424 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7425 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7426 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307427 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307428 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307429 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307430 }
7431
Govind Singhb53420c2016-03-09 14:32:57 +05307432 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307433
7434}
7435#endif /* FEATURE_WLAN_RA_FILTERING */
7436
7437/**
7438 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7439 * @wmi_handle: wmi handle
7440 * @vdev_id: vdev id
7441 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307442 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307443 */
Govind Singhb53420c2016-03-09 14:32:57 +05307444QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307445{
7446 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7447 wmi_buf_t buf;
7448 int32_t len = sizeof(*cmd);
7449
Govind Singhb53420c2016-03-09 14:32:57 +05307450 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307451 buf = wmi_buf_alloc(wmi_handle, len);
7452 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307453 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307454 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307455 }
7456 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7457 wmi_buf_data(buf);
7458 WMITLV_SET_HDR(&cmd->tlv_header,
7459 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7460 WMITLV_GET_STRUCT_TLVLEN
7461 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7462 cmd->vdev_id = vdev_id;
7463 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7464 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7465 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307466 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307467 __func__);
7468 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307469 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307470 }
7471
7472 return 0;
7473}
7474
7475/**
7476 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7477 * @wmi_handle: wmi handle
7478 * @vdev_id: vdev id
7479 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307480 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307481 */
Govind Singhb53420c2016-03-09 14:32:57 +05307482QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307483 uint8_t vdev_id)
7484{
7485 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7486 wmi_buf_t buf;
7487 int32_t len = sizeof(*cmd);
7488
Govind Singhb53420c2016-03-09 14:32:57 +05307489 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307490 buf = wmi_buf_alloc(wmi_handle, len);
7491 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307492 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307493 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307494 }
7495 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7496 WMITLV_SET_HDR(&cmd->tlv_header,
7497 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7498 WMITLV_GET_STRUCT_TLVLEN
7499 (wmi_csa_offload_enable_cmd_fixed_param));
7500 cmd->vdev_id = vdev_id;
7501 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7502 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7503 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307504 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307505 __func__);
7506 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307507 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307508 }
7509
7510 return 0;
7511}
7512
7513/**
7514 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7515 * @wmi_handle: wmi handle
7516 * @startOemDataReq: start request params
7517 *
7518 * Return: CDF status
7519 */
Govind Singhb53420c2016-03-09 14:32:57 +05307520QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007521 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307522 uint8_t *data)
7523{
7524 wmi_buf_t buf;
7525 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307526 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307527
7528 buf = wmi_buf_alloc(wmi_handle,
7529 (data_len + WMI_TLV_HDR_SIZE));
7530 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307531 WMI_LOGE(FL("wmi_buf_alloc failed"));
7532 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307533 }
7534
7535 cmd = (uint8_t *) wmi_buf_data(buf);
7536
7537 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7538 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307539 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307540 data_len);
7541
Govind Singhb53420c2016-03-09 14:32:57 +05307542 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307543 data_len);
7544
7545 ret = wmi_unified_cmd_send(wmi_handle, buf,
7546 (data_len +
7547 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7548
Govind Singh67922e82016-04-01 16:48:57 +05307549 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307550 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307551 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307552 }
7553
Govind Singh67922e82016-04-01 16:48:57 +05307554 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307555}
7556
7557/**
7558 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7559 * @wmi_handle: wmi handle
7560 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7561 *
7562 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7563 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7564 * to firmware based on phyerr filtering
7565 * offload status.
7566 *
7567 * Return: 1 success, 0 failure
7568 */
Govind Singhb53420c2016-03-09 14:32:57 +05307569QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307570send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7571 bool dfs_phyerr_filter_offload)
7572{
7573 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7574 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7575 wmi_buf_t buf;
7576 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307577 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307578
7579
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007580 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307581 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307582 __func__);
7583 len = sizeof(*disable_phyerr_offload_cmd);
7584 buf = wmi_buf_alloc(wmi_handle, len);
7585 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307586 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307587 return 0;
7588 }
7589 disable_phyerr_offload_cmd =
7590 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7591 wmi_buf_data(buf);
7592
7593 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7594 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7595 WMITLV_GET_STRUCT_TLVLEN
7596 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7597
7598 /*
7599 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7600 * to the firmware to disable the phyerror
7601 * filtering offload.
7602 */
7603 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7604 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307605 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307606 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307607 __func__, ret);
7608 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307609 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307610 }
Govind Singhb53420c2016-03-09 14:32:57 +05307611 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307612 __func__);
7613 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307614 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307615 __func__);
7616
7617 len = sizeof(*enable_phyerr_offload_cmd);
7618 buf = wmi_buf_alloc(wmi_handle, len);
7619 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307620 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7621 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307622 }
7623
7624 enable_phyerr_offload_cmd =
7625 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7626 wmi_buf_data(buf);
7627
7628 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7629 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7630 WMITLV_GET_STRUCT_TLVLEN
7631 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7632
7633 /*
7634 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7635 * to the firmware to enable the phyerror
7636 * filtering offload.
7637 */
7638 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7639 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7640
Govind Singh67922e82016-04-01 16:48:57 +05307641 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307642 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307643 __func__, ret);
7644 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307645 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307646 }
Govind Singhb53420c2016-03-09 14:32:57 +05307647 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307648 __func__);
7649 }
7650
Govind Singhb53420c2016-03-09 14:32:57 +05307651 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307652}
7653
7654#if !defined(REMOVE_PKT_LOG)
7655/**
7656 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7657 * @wmi_handle: wmi handle
7658 * @pktlog_event: pktlog event
7659 * @cmd_id: pktlog cmd id
7660 *
7661 * Return: CDF status
7662 */
Govind Singhb53420c2016-03-09 14:32:57 +05307663QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307664 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307665 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307666{
7667 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7668 WMI_CMD_ID CMD_ID;
7669 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7670 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7671 int len = 0;
7672 wmi_buf_t buf;
7673
7674 PKTLOG_EVENT = pktlog_event;
7675 CMD_ID = cmd_id;
7676
7677 switch (CMD_ID) {
7678 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7679 len = sizeof(*cmd);
7680 buf = wmi_buf_alloc(wmi_handle, len);
7681 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307682 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7683 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307684 }
7685 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7686 wmi_buf_data(buf);
7687 WMITLV_SET_HDR(&cmd->tlv_header,
7688 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7689 WMITLV_GET_STRUCT_TLVLEN
7690 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7691 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307692 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7693 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007694 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307695 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7696 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307697 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307698 goto wmi_send_failed;
7699 }
7700 break;
7701 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7702 len = sizeof(*disable_cmd);
7703 buf = wmi_buf_alloc(wmi_handle, len);
7704 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307705 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7706 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307707 }
7708 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7709 wmi_buf_data(buf);
7710 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7711 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7712 WMITLV_GET_STRUCT_TLVLEN
7713 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007714 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307715 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7716 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307717 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307718 goto wmi_send_failed;
7719 }
7720 break;
7721 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307722 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307723 break;
7724 }
7725
Govind Singhb53420c2016-03-09 14:32:57 +05307726 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307727
7728wmi_send_failed:
7729 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307730 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307731}
7732#endif /* REMOVE_PKT_LOG */
7733
7734/**
7735 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
7736 * @wmi_handle: wmi handle
7737 * @vdev_id: vdev id
7738 * @bitmap: Event bitmap
7739 * @enable: enable/disable
7740 *
7741 * Return: CDF status
7742 */
Govind Singhb53420c2016-03-09 14:32:57 +05307743QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307744 uint32_t vdev_id,
7745 uint32_t bitmap,
7746 bool enable)
7747{
7748 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
7749 uint16_t len;
7750 wmi_buf_t buf;
7751 int ret;
7752
7753 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
7754 buf = wmi_buf_alloc(wmi_handle, len);
7755 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307756 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7757 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307758 }
7759 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
7760 WMITLV_SET_HDR(&cmd->tlv_header,
7761 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
7762 WMITLV_GET_STRUCT_TLVLEN
7763 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
7764 cmd->vdev_id = vdev_id;
7765 cmd->is_add = enable;
7766 cmd->event_bitmap = bitmap;
7767
7768 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7769 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
7770 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307771 WMI_LOGE("Failed to config wow wakeup event");
Govind Singh20c5dac2016-03-07 15:33:31 +05307772 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307773 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307774 }
7775
Govind Singhb53420c2016-03-09 14:32:57 +05307776 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
Govind Singh20c5dac2016-03-07 15:33:31 +05307777 enable ? "enabled" : "disabled");
7778
Govind Singhb53420c2016-03-09 14:32:57 +05307779 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307780}
7781
7782/**
7783 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
7784 * @wmi_handle: wmi handle
7785 * @vdev_id: vdev id
7786 * @ptrn_id: pattern id
7787 * @ptrn: pattern
7788 * @ptrn_len: pattern length
7789 * @ptrn_offset: pattern offset
7790 * @mask: mask
7791 * @mask_len: mask length
7792 * @user: true for user configured pattern and false for default pattern
7793 * @default_patterns: default patterns
7794 *
7795 * Return: CDF status
7796 */
Govind Singhb53420c2016-03-09 14:32:57 +05307797QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307798 uint8_t vdev_id, uint8_t ptrn_id,
7799 const uint8_t *ptrn, uint8_t ptrn_len,
7800 uint8_t ptrn_offset, const uint8_t *mask,
7801 uint8_t mask_len, bool user,
7802 uint8_t default_patterns)
7803{
7804 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7805 WOW_BITMAP_PATTERN_T *bitmap_pattern;
7806 wmi_buf_t buf;
7807 uint8_t *buf_ptr;
7808 int32_t len;
7809 int ret;
7810
7811
7812 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7813 WMI_TLV_HDR_SIZE +
7814 1 * sizeof(WOW_BITMAP_PATTERN_T) +
7815 WMI_TLV_HDR_SIZE +
7816 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7817 WMI_TLV_HDR_SIZE +
7818 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7819 WMI_TLV_HDR_SIZE +
7820 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7821 WMI_TLV_HDR_SIZE +
7822 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7823
7824 buf = wmi_buf_alloc(wmi_handle, len);
7825 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307826 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7827 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307828 }
7829
7830 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7831 buf_ptr = (uint8_t *) cmd;
7832
7833 WMITLV_SET_HDR(&cmd->tlv_header,
7834 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7835 WMITLV_GET_STRUCT_TLVLEN
7836 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7837 cmd->vdev_id = vdev_id;
7838 cmd->pattern_id = ptrn_id;
7839
7840 cmd->pattern_type = WOW_BITMAP_PATTERN;
7841 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7842
7843 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7844 sizeof(WOW_BITMAP_PATTERN_T));
7845 buf_ptr += WMI_TLV_HDR_SIZE;
7846 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
7847
7848 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
7849 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
7850 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
7851
Govind Singhb53420c2016-03-09 14:32:57 +05307852 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
7853 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05307854
7855 bitmap_pattern->pattern_offset = ptrn_offset;
7856 bitmap_pattern->pattern_len = ptrn_len;
7857
7858 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
7859 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
7860
7861 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
7862 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
7863
7864 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
7865 bitmap_pattern->pattern_id = ptrn_id;
7866
Govind Singhb53420c2016-03-09 14:32:57 +05307867 WMI_LOGI("vdev id : %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307868 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
7869 bitmap_pattern->pattern_offset, user);
Govind Singh87542482016-06-08 19:40:11 +05307870#ifdef CONFIG_MCL
Govind Singhb53420c2016-03-09 14:32:57 +05307871 WMI_LOGI("Pattern : ");
7872 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307873 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
7874
Govind Singhb53420c2016-03-09 14:32:57 +05307875 WMI_LOGI("Mask : ");
7876 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307877 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
Govind Singh87542482016-06-08 19:40:11 +05307878#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05307879
7880 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
7881
7882 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7883 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7884 buf_ptr += WMI_TLV_HDR_SIZE;
7885
7886 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7887 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7888 buf_ptr += WMI_TLV_HDR_SIZE;
7889
7890 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7891 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7892 buf_ptr += WMI_TLV_HDR_SIZE;
7893
7894 /* Fill TLV for pattern_info_timeout but no data. */
7895 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7896 buf_ptr += WMI_TLV_HDR_SIZE;
7897
7898 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
7899 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
7900 buf_ptr += WMI_TLV_HDR_SIZE;
7901 *(A_UINT32 *) buf_ptr = 0;
7902
7903 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7904 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7905 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307906 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307907 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307908 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307909 }
7910
Govind Singhb53420c2016-03-09 14:32:57 +05307911 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307912}
7913
7914/**
7915 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
7916 * @wmi_handle: wmi handle
7917 * @ptrn_id: pattern id
7918 * @vdev_id: vdev id
7919 *
7920 * Return: CDF status
7921 */
Govind Singhb53420c2016-03-09 14:32:57 +05307922QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle, uint8_t ptrn_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307923 uint8_t vdev_id)
7924{
7925 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
7926 wmi_buf_t buf;
7927 int32_t len;
7928 int ret;
7929
7930 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
7931
7932
7933 buf = wmi_buf_alloc(wmi_handle, len);
7934 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307935 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7936 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307937 }
7938
7939 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7940
7941 WMITLV_SET_HDR(&cmd->tlv_header,
7942 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
7943 WMITLV_GET_STRUCT_TLVLEN(
7944 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
7945 cmd->vdev_id = vdev_id;
7946 cmd->pattern_id = ptrn_id;
7947 cmd->pattern_type = WOW_BITMAP_PATTERN;
7948
Govind Singhb53420c2016-03-09 14:32:57 +05307949 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05307950 cmd->pattern_id, vdev_id);
7951
7952 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7953 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
7954 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307955 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307956 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307957 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307958 }
7959
Govind Singhb53420c2016-03-09 14:32:57 +05307960 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307961}
7962
7963/**
7964 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
7965 * @wmi_handle: wmi handle
7966 *
7967 * Sends host wakeup indication to FW. On receiving this indication,
7968 * FW will come out of WOW.
7969 *
7970 * Return: CDF status
7971 */
Govind Singhb53420c2016-03-09 14:32:57 +05307972QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307973{
7974 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
7975 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05307976 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307977 int32_t len;
7978 int ret;
7979
7980 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
7981
7982 buf = wmi_buf_alloc(wmi_handle, len);
7983 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307984 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7985 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307986 }
7987
7988 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
7989 wmi_buf_data(buf);
7990 WMITLV_SET_HDR(&cmd->tlv_header,
7991 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
7992 WMITLV_GET_STRUCT_TLVLEN
7993 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
7994
7995
7996 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7997 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
7998 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307999 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308000 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308001 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308002 }
8003
Govind Singhb53420c2016-03-09 14:32:57 +05308004 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308005}
8006
8007/**
8008 * send_del_ts_cmd_tlv() - send DELTS request to fw
8009 * @wmi_handle: wmi handle
8010 * @msg: delts params
8011 *
8012 * Return: CDF status
8013 */
Govind Singhb53420c2016-03-09 14:32:57 +05308014QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308015 uint8_t ac)
8016{
8017 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8018 wmi_buf_t buf;
8019 int32_t len = sizeof(*cmd);
8020
8021 buf = wmi_buf_alloc(wmi_handle, len);
8022 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308023 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8024 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308025 }
8026 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8027 WMITLV_SET_HDR(&cmd->tlv_header,
8028 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8029 WMITLV_GET_STRUCT_TLVLEN
8030 (wmi_vdev_wmm_delts_cmd_fixed_param));
8031 cmd->vdev_id = vdev_id;
8032 cmd->ac = ac;
8033
Govind Singhb53420c2016-03-09 14:32:57 +05308034 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308035 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8036 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8037 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308038 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308039 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308040 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308041 }
8042
Govind Singhb53420c2016-03-09 14:32:57 +05308043 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308044}
8045
8046/**
8047 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8048 * @wmi_handle: handle to wmi
8049 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8050 *
Govind Singhb53420c2016-03-09 14:32:57 +05308051 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308052 * ADD_TS requestes to firmware in loop for all the ACs with
8053 * active flow.
8054 *
8055 * Return: CDF status
8056 */
Govind Singhb53420c2016-03-09 14:32:57 +05308057QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308058 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8059{
8060 int i = 0;
8061 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8062 wmi_buf_t buf;
8063 int32_t len = sizeof(*cmd);
8064
8065 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8066 /* if flow in this AC is active */
8067 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8068 /*
8069 * as per implementation of wma_add_ts_req() we
8070 * are not waiting any response from firmware so
8071 * apart from sending ADDTS to firmware just send
8072 * success to upper layers
8073 */
Govind Singhb53420c2016-03-09 14:32:57 +05308074 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308075
8076 buf = wmi_buf_alloc(wmi_handle, len);
8077 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308078 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8079 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308080 }
8081 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8082 wmi_buf_data(buf);
8083 WMITLV_SET_HDR(&cmd->tlv_header,
8084 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8085 WMITLV_GET_STRUCT_TLVLEN
8086 (wmi_vdev_wmm_addts_cmd_fixed_param));
8087 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8088 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308089 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308090 traffic.userPrio);
8091 cmd->medium_time_us =
8092 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8093 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308094 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308095 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8096 cmd->medium_time_us, cmd->downgrade_type);
8097 if (wmi_unified_cmd_send
8098 (wmi_handle, buf, len,
8099 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308100 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308101 __func__);
8102 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308103 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308104 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308105 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308106 }
8107 }
8108 }
8109
Govind Singhb53420c2016-03-09 14:32:57 +05308110 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308111}
8112
8113/**
8114 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8115 * @wmi_handle: wmi handle
8116 * @msg: ADDTS params
8117 *
8118 * Return: CDF status
8119 */
Govind Singhb53420c2016-03-09 14:32:57 +05308120QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308121 struct add_ts_param *msg)
8122{
8123 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8124 wmi_buf_t buf;
8125 int32_t len = sizeof(*cmd);
8126
Govind Singhb53420c2016-03-09 14:32:57 +05308127 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308128
8129 buf = wmi_buf_alloc(wmi_handle, len);
8130 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308131 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8132 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308133 }
8134 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8135 WMITLV_SET_HDR(&cmd->tlv_header,
8136 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8137 WMITLV_GET_STRUCT_TLVLEN
8138 (wmi_vdev_wmm_addts_cmd_fixed_param));
8139 cmd->vdev_id = msg->sme_session_id;
8140 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8141 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8142 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308143 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308144 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8145 cmd->downgrade_type, __func__, __LINE__);
8146 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8147 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308148 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8149 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308150 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308151 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308152 }
8153
Govind Singhb53420c2016-03-09 14:32:57 +05308154 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308155}
8156
8157/**
8158 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
8159 * @wmi_handle: wmi handle
8160 * @vdev_id: vdev id
8161 * @enable: Flag to enable/disable packet filter
8162 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308163 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308164 */
Govind Singhb53420c2016-03-09 14:32:57 +05308165QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308166 uint8_t vdev_id, bool enable)
8167{
8168 int32_t len;
8169 int ret = 0;
8170 wmi_buf_t buf;
8171 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
8172
8173 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
8174
8175 buf = wmi_buf_alloc(wmi_handle, len);
8176 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308177 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308178 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308179 }
8180
8181 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
8182 WMITLV_SET_HDR(&cmd->tlv_header,
8183 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
8184 WMITLV_GET_STRUCT_TLVLEN(
8185 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
8186
8187 cmd->vdev_id = vdev_id;
8188 if (enable)
8189 cmd->enable = PACKET_FILTER_SET_ENABLE;
8190 else
8191 cmd->enable = PACKET_FILTER_SET_DISABLE;
8192
Govind Singhb53420c2016-03-09 14:32:57 +05308193 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308194 __func__, cmd->enable, vdev_id);
8195
8196 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8197 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308198 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308199 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308200 wmi_buf_free(buf);
8201 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308202
8203 return ret;
8204}
8205
8206/**
8207 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
8208 * @wmi_handle: wmi handle
8209 * @vdev_id: vdev id
8210 * @rcv_filter_param: Packet filter parameters
8211 * @filter_id: Filter id
8212 * @enable: Flag to add/delete packet filter configuration
8213 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308214 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308215 */
Govind Singhb53420c2016-03-09 14:32:57 +05308216QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308217 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8218 uint8_t filter_id, bool enable)
8219{
8220 int len, i;
8221 int err = 0;
8222 wmi_buf_t buf;
8223 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8224
8225
8226 /* allocate the memory */
8227 len = sizeof(*cmd);
8228 buf = wmi_buf_alloc(wmi_handle, len);
8229 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308230 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308231 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308232 }
8233
8234 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8235 WMITLV_SET_HDR(&cmd->tlv_header,
8236 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8237 WMITLV_GET_STRUCT_TLVLEN
8238 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8239
8240 cmd->vdev_id = vdev_id;
8241 cmd->filter_id = filter_id;
8242 if (enable)
8243 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8244 else
8245 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8246
8247 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308248 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308249 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8250 rcv_filter_param->numFieldParams);
8251 cmd->filter_type = rcv_filter_param->filterType;
8252 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8253
8254 for (i = 0; i < cmd->num_params; i++) {
8255 cmd->paramsData[i].proto_type =
8256 rcv_filter_param->paramsData[i].protocolLayer;
8257 cmd->paramsData[i].cmp_type =
8258 rcv_filter_param->paramsData[i].cmpFlag;
8259 cmd->paramsData[i].data_length =
8260 rcv_filter_param->paramsData[i].dataLength;
8261 cmd->paramsData[i].data_offset =
8262 rcv_filter_param->paramsData[i].dataOffset;
8263 memcpy(&cmd->paramsData[i].compareData,
8264 rcv_filter_param->paramsData[i].compareData,
8265 sizeof(cmd->paramsData[i].compareData));
8266 memcpy(&cmd->paramsData[i].dataMask,
8267 rcv_filter_param->paramsData[i].dataMask,
8268 sizeof(cmd->paramsData[i].dataMask));
8269 }
8270 }
8271
Govind Singhb53420c2016-03-09 14:32:57 +05308272 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308273 cmd->filter_action, cmd->filter_id, cmd->num_params);
8274 /* send the command along with data */
8275 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8276 WMI_PACKET_FILTER_CONFIG_CMDID);
8277 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308278 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308279 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308280 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308281 }
8282
8283
8284 return 0;
8285}
8286
8287/**
8288 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
8289 * @wmi_handle: wmi handle
8290 * @vdev_id: vdev id
8291 * @multicastAddr: mcast address
8292 * @clearList: clear list flag
8293 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308294 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308295 */
Govind Singhb53420c2016-03-09 14:32:57 +05308296QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308297 uint8_t vdev_id,
Govind Singhb53420c2016-03-09 14:32:57 +05308298 struct qdf_mac_addr multicast_addr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308299 bool clearList)
8300{
8301 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
8302 wmi_buf_t buf;
8303 int err;
8304
8305 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8306 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308307 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308308 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308309 }
8310
8311 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308312 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308313
8314 WMITLV_SET_HDR(&cmd->tlv_header,
8315 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
8316 WMITLV_GET_STRUCT_TLVLEN
8317 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
8318 cmd->action =
8319 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
8320 cmd->vdev_id = vdev_id;
8321 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
Dustin Brown4103e4a2016-11-14 16:11:26 -08008322
8323 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
8324 cmd->action, vdev_id, clearList, multicast_addr.bytes);
8325
Govind Singh20c5dac2016-03-07 15:33:31 +05308326 err = wmi_unified_cmd_send(wmi_handle, buf,
8327 sizeof(*cmd),
8328 WMI_SET_MCASTBCAST_FILTER_CMDID);
8329 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308330 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308331 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308332 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308333 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308334
Dustin Brown4103e4a2016-11-14 16:11:26 -08008335 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308336}
8337
8338/**
8339 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
8340 * @wmi_handle: wmi handle
8341 * @vdev_id: vdev id
8342 * @params: GTK offload parameters
8343 *
8344 * Return: CDF status
8345 */
Govind Singhb53420c2016-03-09 14:32:57 +05308346QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308347 struct gtk_offload_params *params,
8348 bool enable_offload,
8349 uint32_t gtk_offload_opcode)
8350{
8351 int len;
8352 wmi_buf_t buf;
8353 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308354 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308355
Govind Singhb53420c2016-03-09 14:32:57 +05308356 WMI_LOGD("%s Enter", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308357
8358 len = sizeof(*cmd);
8359
8360 /* alloc wmi buffer */
8361 buf = wmi_buf_alloc(wmi_handle, len);
8362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308363 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8364 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308365 goto out;
8366 }
8367
8368 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8369 WMITLV_SET_HDR(&cmd->tlv_header,
8370 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8371 WMITLV_GET_STRUCT_TLVLEN
8372 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8373
8374 cmd->vdev_id = vdev_id;
8375
8376 /* Request target to enable GTK offload */
Siddarth Poddar9500f2e2016-04-01 17:45:06 +05308377 if (enable_offload == WMI_GTK_OFFLOAD_ENABLE) {
Govind Singh20c5dac2016-03-07 15:33:31 +05308378 cmd->flags = gtk_offload_opcode;
8379
8380 /* Copy the keys and replay counter */
Govind Singhb53420c2016-03-09 14:32:57 +05308381 qdf_mem_copy(cmd->KCK, params->aKCK, WMI_GTK_OFFLOAD_KCK_BYTES);
8382 qdf_mem_copy(cmd->KEK, params->aKEK, WMI_GTK_OFFLOAD_KEK_BYTES);
8383 qdf_mem_copy(cmd->replay_counter, &params->ullKeyReplayCounter,
Govind Singh20c5dac2016-03-07 15:33:31 +05308384 GTK_REPLAY_COUNTER_BYTES);
8385 } else {
8386 cmd->flags = gtk_offload_opcode;
8387 }
8388
Dustin Brown4103e4a2016-11-14 16:11:26 -08008389 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
8390
Govind Singh20c5dac2016-03-07 15:33:31 +05308391 /* send the wmi command */
8392 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8393 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308394 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
Govind Singh20c5dac2016-03-07 15:33:31 +05308395 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308396 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308397 }
8398
Govind Singh20c5dac2016-03-07 15:33:31 +05308399out:
Govind Singhb53420c2016-03-09 14:32:57 +05308400 WMI_LOGD("%s Exit", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308401 return status;
8402}
8403
8404/**
8405 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
8406 * @wmi_handle: wmi handle
8407 * @params: GTK offload params
8408 *
8409 * Return: CDF status
8410 */
Govind Singhb53420c2016-03-09 14:32:57 +05308411QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308412 uint8_t vdev_id,
8413 uint64_t offload_req_opcode)
8414{
8415 int len;
8416 wmi_buf_t buf;
8417 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308418 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308419
8420 len = sizeof(*cmd);
8421
8422 /* alloc wmi buffer */
8423 buf = wmi_buf_alloc(wmi_handle, len);
8424 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308425 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8426 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308427 goto out;
8428 }
8429
8430 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8431 WMITLV_SET_HDR(&cmd->tlv_header,
8432 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8433 WMITLV_GET_STRUCT_TLVLEN
8434 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8435
8436 /* Request for GTK offload status */
8437 cmd->flags = offload_req_opcode;
8438 cmd->vdev_id = vdev_id;
8439
8440 /* send the wmi command */
8441 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8442 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308443 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
Govind Singh20c5dac2016-03-07 15:33:31 +05308444 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308445 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308446 }
8447
8448out:
8449 return status;
8450}
8451
8452/**
8453 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8454 * @wmi_handle: wmi handle
8455 * @pAddPeriodicTxPtrnParams: tx ptrn params
8456 *
8457 * Retrun: CDF status
8458 */
Govind Singhb53420c2016-03-09 14:32:57 +05308459QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308460 struct periodic_tx_pattern *
8461 pAddPeriodicTxPtrnParams,
8462 uint8_t vdev_id)
8463{
8464 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8465 wmi_buf_t wmi_buf;
8466 uint32_t len;
8467 uint8_t *buf_ptr;
8468 uint32_t ptrn_len, ptrn_len_aligned;
8469 int j;
8470
8471 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8472 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8473 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8474 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8475
8476 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8477 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308478 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8479 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308480 }
8481
8482 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8483
8484 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8485 WMITLV_SET_HDR(&cmd->tlv_header,
8486 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8487 WMITLV_GET_STRUCT_TLVLEN
8488 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8489
8490 /* Pass the pattern id to delete for the corresponding vdev id */
8491 cmd->vdev_id = vdev_id;
8492 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8493 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8494 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8495
8496 /* Pattern info */
8497 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8498 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8499 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308500 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308501 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308502 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308503
Govind Singhb53420c2016-03-09 14:32:57 +05308504 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308505 __func__, cmd->pattern_id, cmd->vdev_id);
8506
8507 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8508 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308509 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308510 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308511 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308512 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308513 }
Govind Singhb53420c2016-03-09 14:32:57 +05308514 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308515}
8516
8517/**
8518 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8519 * @wmi_handle: wmi handle
8520 * @vdev_id: vdev id
8521 * @pattern_id: pattern id
8522 *
8523 * Retrun: CDF status
8524 */
Govind Singhb53420c2016-03-09 14:32:57 +05308525QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308526 uint8_t vdev_id,
8527 uint8_t pattern_id)
8528{
8529 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8530 wmi_buf_t wmi_buf;
8531 uint32_t len =
8532 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8533
8534 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8535 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308536 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8537 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308538 }
8539
8540 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8541 wmi_buf_data(wmi_buf);
8542 WMITLV_SET_HDR(&cmd->tlv_header,
8543 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8544 WMITLV_GET_STRUCT_TLVLEN
8545 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8546
8547 /* Pass the pattern id to delete for the corresponding vdev id */
8548 cmd->vdev_id = vdev_id;
8549 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308550 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308551 __func__, cmd->pattern_id, cmd->vdev_id);
8552
8553 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8554 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308555 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308556 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308557 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308558 }
Govind Singhb53420c2016-03-09 14:32:57 +05308559 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308560}
8561
8562/**
8563 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8564 * @wmi_handle: wmi handle
8565 * @preq: stats ext params
8566 *
8567 * Return: CDF status
8568 */
Govind Singhb53420c2016-03-09 14:32:57 +05308569QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308570 struct stats_ext_params *preq)
8571{
Govind Singh67922e82016-04-01 16:48:57 +05308572 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308573 wmi_req_stats_ext_cmd_fixed_param *cmd;
8574 wmi_buf_t buf;
8575 uint16_t len;
8576 uint8_t *buf_ptr;
8577
8578 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8579
8580 buf = wmi_buf_alloc(wmi_handle, len);
8581 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308582 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308583 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308584 }
8585
8586 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8587 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8588
8589 WMITLV_SET_HDR(&cmd->tlv_header,
8590 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8591 WMITLV_GET_STRUCT_TLVLEN
8592 (wmi_req_stats_ext_cmd_fixed_param));
8593 cmd->vdev_id = preq->vdev_id;
8594 cmd->data_len = preq->request_data_len;
8595
Govind Singhb53420c2016-03-09 14:32:57 +05308596 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308597 __func__, preq->request_data_len, preq->vdev_id);
8598
8599 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8600 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8601
8602 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308603 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308604
8605 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8606 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308607 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308608 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308609 ret);
8610 wmi_buf_free(buf);
8611 }
8612
8613 return ret;
8614}
8615
8616/**
8617 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8618 * @wmi_handle: wmi handle
8619 * @params: ext wow params
8620 *
8621 * Return:0 for success or error code
8622 */
Govind Singhb53420c2016-03-09 14:32:57 +05308623QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308624 struct ext_wow_params *params)
8625{
8626 wmi_extwow_enable_cmd_fixed_param *cmd;
8627 wmi_buf_t buf;
8628 int32_t len;
8629 int ret;
8630
8631 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8632 buf = wmi_buf_alloc(wmi_handle, len);
8633 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308634 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8635 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308636 }
8637
8638 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8639
8640 WMITLV_SET_HDR(&cmd->tlv_header,
8641 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8642 WMITLV_GET_STRUCT_TLVLEN
8643 (wmi_extwow_enable_cmd_fixed_param));
8644
8645 cmd->vdev_id = params->vdev_id;
8646 cmd->type = params->type;
8647 cmd->wakeup_pin_num = params->wakeup_pin_num;
8648
Govind Singhb53420c2016-03-09 14:32:57 +05308649 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308650 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8651
8652 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8653 WMI_EXTWOW_ENABLE_CMDID);
8654 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308655 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308656 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308657 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308658 }
8659
Govind Singhb53420c2016-03-09 14:32:57 +05308660 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308661
8662}
8663
8664/**
8665 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8666 * @wmi_handle: wmi handle
8667 * @app_type1_params: app type1 params
8668 *
8669 * Return: CDF status
8670 */
Govind Singhb53420c2016-03-09 14:32:57 +05308671QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308672 struct app_type1_params *app_type1_params)
8673{
8674 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8675 wmi_buf_t buf;
8676 int32_t len;
8677 int ret;
8678
8679 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8680 buf = wmi_buf_alloc(wmi_handle, len);
8681 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308682 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8683 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308684 }
8685
8686 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8687 wmi_buf_data(buf);
8688
8689 WMITLV_SET_HDR(&cmd->tlv_header,
8690 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8691 WMITLV_GET_STRUCT_TLVLEN
8692 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8693
8694 cmd->vdev_id = app_type1_params->vdev_id;
8695 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8696 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308697 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308698 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308699 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308700 cmd->passwd_len = app_type1_params->pass_length;
8701
Govind Singhb53420c2016-03-09 14:32:57 +05308702 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308703 "identification_id %.8s id_length %u "
8704 "password %.16s pass_length %u",
8705 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8706 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8707
8708 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8709 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8710 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308711 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308712 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308713 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308714 }
8715
Govind Singhb53420c2016-03-09 14:32:57 +05308716 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308717}
8718
8719/**
8720 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8721 * @wmi_handle: wmi handle
8722 * @appType2Params: app type2 params
8723 *
8724 * Return: CDF status
8725 */
Govind Singhb53420c2016-03-09 14:32:57 +05308726QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308727 struct app_type2_params *appType2Params)
8728{
8729 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8730 wmi_buf_t buf;
8731 int32_t len;
8732 int ret;
8733
8734 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8735 buf = wmi_buf_alloc(wmi_handle, len);
8736 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308737 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8738 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308739 }
8740
8741 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8742 wmi_buf_data(buf);
8743
8744 WMITLV_SET_HDR(&cmd->tlv_header,
8745 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8746 WMITLV_GET_STRUCT_TLVLEN
8747 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8748
8749 cmd->vdev_id = appType2Params->vdev_id;
8750
Govind Singhb53420c2016-03-09 14:32:57 +05308751 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308752 cmd->rc4_key_len = appType2Params->rc4_key_len;
8753
8754 cmd->ip_id = appType2Params->ip_id;
8755 cmd->ip_device_ip = appType2Params->ip_device_ip;
8756 cmd->ip_server_ip = appType2Params->ip_server_ip;
8757
8758 cmd->tcp_src_port = appType2Params->tcp_src_port;
8759 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8760 cmd->tcp_seq = appType2Params->tcp_seq;
8761 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8762
8763 cmd->keepalive_init = appType2Params->keepalive_init;
8764 cmd->keepalive_min = appType2Params->keepalive_min;
8765 cmd->keepalive_max = appType2Params->keepalive_max;
8766 cmd->keepalive_inc = appType2Params->keepalive_inc;
8767
8768 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8769 &cmd->gateway_mac);
8770 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8771 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8772
Govind Singhb53420c2016-03-09 14:32:57 +05308773 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308774 "rc4_key %.16s rc4_key_len %u "
8775 "ip_id %x ip_device_ip %x ip_server_ip %x "
8776 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8777 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8778 "keepalive_max %u keepalive_inc %u "
8779 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8780 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8781 cmd->rc4_key, cmd->rc4_key_len,
8782 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8783 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8784 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8785 cmd->keepalive_max, cmd->keepalive_inc,
8786 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8787
8788 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8789 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8790 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308791 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308792 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308793 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308794 }
8795
Govind Singhb53420c2016-03-09 14:32:57 +05308796 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308797
8798}
8799
8800/**
8801 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8802 * @wmi_handle: wmi handle
8803 * @timer_val: auto shutdown timer value
8804 *
8805 * Return: CDF status
8806 */
Govind Singhb53420c2016-03-09 14:32:57 +05308807QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308808 uint32_t timer_val)
8809{
Govind Singh67922e82016-04-01 16:48:57 +05308810 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308811 wmi_buf_t buf = NULL;
8812 uint8_t *buf_ptr;
8813 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8814 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8815
Govind Singhb53420c2016-03-09 14:32:57 +05308816 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308817 __func__, timer_val);
8818
8819 buf = wmi_buf_alloc(wmi_handle, len);
8820 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308821 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8822 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308823 }
8824
8825 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8826 wmi_auto_sh_cmd =
8827 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8828 wmi_auto_sh_cmd->timer_value = timer_val;
8829
8830 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8831 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8832 WMITLV_GET_STRUCT_TLVLEN
8833 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8834
8835 status = wmi_unified_cmd_send(wmi_handle, buf,
8836 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308837 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308838 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308839 __func__, status);
8840 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308841 }
8842
Govind Singh67922e82016-04-01 16:48:57 +05308843 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308844}
8845
8846/**
8847 * send_nan_req_cmd_tlv() - to send nan request to target
8848 * @wmi_handle: wmi handle
8849 * @nan_req: request data which will be non-null
8850 *
8851 * Return: CDF status
8852 */
Govind Singhb53420c2016-03-09 14:32:57 +05308853QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308854 struct nan_req_params *nan_req)
8855{
Govind Singh67922e82016-04-01 16:48:57 +05308856 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308857 wmi_nan_cmd_param *cmd;
8858 wmi_buf_t buf;
8859 uint16_t len = sizeof(*cmd);
8860 uint16_t nan_data_len, nan_data_len_aligned;
8861 uint8_t *buf_ptr;
8862
8863 /*
8864 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8865 * +------------+----------+-----------------------+--------------+
8866 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8867 * +------------+----------+-----------------------+--------------+
8868 */
8869 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308870 WMI_LOGE("%s:nan req is not valid", __func__);
8871 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308872 }
8873 nan_data_len = nan_req->request_data_len;
8874 nan_data_len_aligned = roundup(nan_req->request_data_len,
8875 sizeof(uint32_t));
8876 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8877 buf = wmi_buf_alloc(wmi_handle, len);
8878 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308879 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8880 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308881 }
8882 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8883 cmd = (wmi_nan_cmd_param *) buf_ptr;
8884 WMITLV_SET_HDR(&cmd->tlv_header,
8885 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8886 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8887 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308888 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308889 __func__, nan_req->request_data_len);
8890 buf_ptr += sizeof(wmi_nan_cmd_param);
8891 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8892 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308893 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308894
8895 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8896 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308897 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308898 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308899 __func__, ret);
8900 wmi_buf_free(buf);
8901 }
8902
8903 return ret;
8904}
8905
8906/**
8907 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8908 * @wmi_handle: wmi handle
8909 * @pDhcpSrvOffloadInfo: DHCP server offload info
8910 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308911 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308912 */
Govind Singhb53420c2016-03-09 14:32:57 +05308913QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308914 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8915{
8916 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8917 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308918 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308919
8920 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8921 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308922 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308923 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308924 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308925 }
8926
8927 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308928 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308929
8930 WMITLV_SET_HDR(&cmd->tlv_header,
8931 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8932 WMITLV_GET_STRUCT_TLVLEN
8933 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8934 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8935 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8936 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8937 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8938 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308939 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308940 sizeof(*cmd),
8941 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308942 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308943 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308944 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308945 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308946 }
Govind Singhb53420c2016-03-09 14:32:57 +05308947 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308948 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308949
8950 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308951}
8952
8953/**
8954 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8955 * @wmi_handle: wmi handle
8956 * @flashing: flashing request
8957 *
8958 * Return: CDF status
8959 */
Govind Singhb53420c2016-03-09 14:32:57 +05308960QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308961 struct flashing_req_params *flashing)
8962{
8963 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308964 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308965 wmi_buf_t buf;
8966 uint8_t *buf_ptr;
8967 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8968
8969 buf = wmi_buf_alloc(wmi_handle, len);
8970 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308971 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308972 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308973 }
8974 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8975 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8976 WMITLV_SET_HDR(&cmd->tlv_header,
8977 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8978 WMITLV_GET_STRUCT_TLVLEN
8979 (wmi_set_led_flashing_cmd_fixed_param));
8980 cmd->pattern_id = flashing->pattern_id;
8981 cmd->led_x0 = flashing->led_x0;
8982 cmd->led_x1 = flashing->led_x1;
8983
8984 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8985 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308986 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308987 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308988 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308989 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308990 }
Govind Singh67922e82016-04-01 16:48:57 +05308991
8992 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308993}
8994
8995/**
8996 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8997 * @wmi_handle: wmi handle
8998 * @ch_avoid_update_req: channel avoid update params
8999 *
9000 * Return: CDF status
9001 */
Govind Singhb53420c2016-03-09 14:32:57 +05309002QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309003{
Govind Singh67922e82016-04-01 16:48:57 +05309004 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309005 wmi_buf_t buf = NULL;
9006 uint8_t *buf_ptr;
9007 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9008 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9009
9010
9011 buf = wmi_buf_alloc(wmi_handle, len);
9012 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309013 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9014 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309015 }
9016
9017 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9018 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9019 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9020 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9021 WMITLV_GET_STRUCT_TLVLEN
9022 (wmi_chan_avoid_update_cmd_param));
9023
9024 status = wmi_unified_cmd_send(wmi_handle, buf,
9025 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309026 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309027 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309028 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9029 " returned Error %d", status);
9030 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309031 }
9032
Govind Singh67922e82016-04-01 16:48:57 +05309033 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309034}
9035
9036/**
9037 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9038 * @wmi_handle: wmi handle
9039 * @reg_dmn: reg domain
9040 * @regdmn2G: 2G reg domain
9041 * @regdmn5G: 5G reg domain
9042 * @ctl2G: 2G test limit
9043 * @ctl5G: 5G test limit
9044 *
9045 * Return: none
9046 */
Govind Singhb53420c2016-03-09 14:32:57 +05309047QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309048 uint32_t reg_dmn, uint16_t regdmn2G,
9049 uint16_t regdmn5G, int8_t ctl2G,
9050 int8_t ctl5G)
9051{
9052 wmi_buf_t buf;
9053 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9054 int32_t len = sizeof(*cmd);
9055
9056
9057 buf = wmi_buf_alloc(wmi_handle, len);
9058 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309059 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9060 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309061 }
9062 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9063 WMITLV_SET_HDR(&cmd->tlv_header,
9064 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9065 WMITLV_GET_STRUCT_TLVLEN
9066 (wmi_pdev_set_regdomain_cmd_fixed_param));
9067 cmd->reg_domain = reg_dmn;
9068 cmd->reg_domain_2G = regdmn2G;
9069 cmd->reg_domain_5G = regdmn5G;
9070 cmd->conformance_test_limit_2G = ctl2G;
9071 cmd->conformance_test_limit_5G = ctl5G;
9072
9073 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9074 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309075 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309076 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309077 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309078 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309079 }
9080
Govind Singhb53420c2016-03-09 14:32:57 +05309081 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309082}
9083
9084
9085/**
9086 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9087 * @wmi_handle: wmi handle
9088 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9089 *
9090 * This function sets tdls off channel mode
9091 *
9092 * Return: 0 on success; Negative errno otherwise
9093 */
Govind Singhb53420c2016-03-09 14:32:57 +05309094QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309095 struct tdls_channel_switch_params *chan_switch_params)
9096{
9097 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9098 wmi_buf_t wmi_buf;
9099 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9100
9101 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9102 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309103 WMI_LOGE(FL("wmi_buf_alloc failed"));
9104 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309105 }
9106 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9107 wmi_buf_data(wmi_buf);
9108 WMITLV_SET_HDR(&cmd->tlv_header,
9109 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9110 WMITLV_GET_STRUCT_TLVLEN(
9111 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9112
9113 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9114 &cmd->peer_macaddr);
9115 cmd->vdev_id = chan_switch_params->vdev_id;
9116 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9117 cmd->is_peer_responder = chan_switch_params->is_responder;
9118 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9119 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9120 cmd->offchan_oper_class = chan_switch_params->oper_class;
9121
Govind Singhb53420c2016-03-09 14:32:57 +05309122 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309123 cmd->peer_macaddr.mac_addr31to0,
9124 cmd->peer_macaddr.mac_addr47to32);
9125
Govind Singhb53420c2016-03-09 14:32:57 +05309126 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309127 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9128 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9129 ),
9130 cmd->vdev_id,
9131 cmd->offchan_mode,
9132 cmd->offchan_num,
9133 cmd->offchan_bw_bitmap,
9134 cmd->is_peer_responder,
9135 cmd->offchan_oper_class);
9136
9137 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9138 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309139 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309140 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309141 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309142 }
9143
9144
Govind Singhb53420c2016-03-09 14:32:57 +05309145 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309146}
9147
9148/**
9149 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9150 * @wmi_handle: wmi handle
9151 * @pwmaTdlsparams: TDLS params
9152 *
9153 * Return: 0 for sucess or error code
9154 */
Govind Singhb53420c2016-03-09 14:32:57 +05309155QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309156 void *tdls_param, uint8_t tdls_state)
9157{
9158 wmi_tdls_set_state_cmd_fixed_param *cmd;
9159 wmi_buf_t wmi_buf;
9160
9161 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9162 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9163
9164 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9165 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309166 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9167 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309168 }
9169 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9170 WMITLV_SET_HDR(&cmd->tlv_header,
9171 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9172 WMITLV_GET_STRUCT_TLVLEN
9173 (wmi_tdls_set_state_cmd_fixed_param));
9174 cmd->vdev_id = wmi_tdls->vdev_id;
9175 cmd->state = tdls_state;
9176 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9177 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9178 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9179 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9180 cmd->rssi_delta = wmi_tdls->rssi_delta;
9181 cmd->tdls_options = wmi_tdls->tdls_options;
9182 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9183 cmd->tdls_peer_traffic_response_timeout_ms =
9184 wmi_tdls->peer_traffic_response_timeout;
9185 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9186 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9187 cmd->tdls_puapsd_rx_frame_threshold =
9188 wmi_tdls->puapsd_rx_frame_threshold;
9189 cmd->teardown_notification_ms =
9190 wmi_tdls->teardown_notification_ms;
9191 cmd->tdls_peer_kickout_threshold =
9192 wmi_tdls->tdls_peer_kickout_threshold;
9193
Govind Singhb53420c2016-03-09 14:32:57 +05309194 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309195 "notification_interval_ms: %d, "
9196 "tx_discovery_threshold: %d, "
9197 "tx_teardown_threshold: %d, "
9198 "rssi_teardown_threshold: %d, "
9199 "rssi_delta: %d, "
9200 "tdls_options: 0x%x, "
9201 "tdls_peer_traffic_ind_window: %d, "
9202 "tdls_peer_traffic_response_timeout: %d, "
9203 "tdls_puapsd_mask: 0x%x, "
9204 "tdls_puapsd_inactivity_time: %d, "
9205 "tdls_puapsd_rx_frame_threshold: %d, "
9206 "teardown_notification_ms: %d, "
9207 "tdls_peer_kickout_threshold: %d",
9208 __func__, tdls_state, cmd->state,
9209 cmd->notification_interval_ms,
9210 cmd->tx_discovery_threshold,
9211 cmd->tx_teardown_threshold,
9212 cmd->rssi_teardown_threshold,
9213 cmd->rssi_delta,
9214 cmd->tdls_options,
9215 cmd->tdls_peer_traffic_ind_window,
9216 cmd->tdls_peer_traffic_response_timeout_ms,
9217 cmd->tdls_puapsd_mask,
9218 cmd->tdls_puapsd_inactivity_time_ms,
9219 cmd->tdls_puapsd_rx_frame_threshold,
9220 cmd->teardown_notification_ms,
9221 cmd->tdls_peer_kickout_threshold);
9222
9223 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9224 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309225 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309226 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309227 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309228 }
Govind Singhb53420c2016-03-09 14:32:57 +05309229 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309230
Govind Singhb53420c2016-03-09 14:32:57 +05309231 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309232}
9233
9234/**
9235 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9236 * @wmi_handle: wmi handle
9237 * @peerStateParams: TDLS peer state params
9238 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309239 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309240 */
Govind Singhb53420c2016-03-09 14:32:57 +05309241QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309242 struct tdls_peer_state_params *peerStateParams,
9243 uint32_t *ch_mhz)
9244{
9245 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9246 wmi_tdls_peer_capabilities *peer_cap;
9247 wmi_channel *chan_info;
9248 wmi_buf_t wmi_buf;
9249 uint8_t *buf_ptr;
9250 uint32_t i;
9251 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9252 sizeof(wmi_tdls_peer_capabilities);
9253
9254
9255 len += WMI_TLV_HDR_SIZE +
9256 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9257
9258 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9259 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309260 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9261 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309262 }
9263
9264 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9265 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9266 WMITLV_SET_HDR(&cmd->tlv_header,
9267 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9268 WMITLV_GET_STRUCT_TLVLEN
9269 (wmi_tdls_peer_update_cmd_fixed_param));
9270
9271 cmd->vdev_id = peerStateParams->vdevId;
9272 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9273 &cmd->peer_macaddr);
9274
9275
9276 cmd->peer_state = peerStateParams->peerState;
9277
Govind Singhb53420c2016-03-09 14:32:57 +05309278 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309279 "peer_macaddr.mac_addr31to0: 0x%x, "
9280 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9281 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9282 cmd->peer_macaddr.mac_addr31to0,
9283 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9284
9285 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9286 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9287 WMITLV_SET_HDR(&peer_cap->tlv_header,
9288 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9289 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9290
9291 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9292 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9293 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9294 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9295 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9296 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9297 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9298 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9299
9300 /* Ack and More Data Ack are sent as 0, so no need to set
9301 * but fill SP
9302 */
9303 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9304 peerStateParams->peerCap.peerMaxSp);
9305
9306 peer_cap->buff_sta_support =
9307 peerStateParams->peerCap.peerBuffStaSupport;
9308 peer_cap->off_chan_support =
9309 peerStateParams->peerCap.peerOffChanSupport;
9310 peer_cap->peer_curr_operclass =
9311 peerStateParams->peerCap.peerCurrOperClass;
9312 /* self curr operclass is not being used and so pass op class for
9313 * preferred off chan in it.
9314 */
9315 peer_cap->self_curr_operclass =
9316 peerStateParams->peerCap.opClassForPrefOffChan;
9317 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9318 peer_cap->peer_operclass_len =
9319 peerStateParams->peerCap.peerOperClassLen;
9320
Govind Singhb53420c2016-03-09 14:32:57 +05309321 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309322 __func__, peer_cap->peer_operclass_len);
9323 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9324 peer_cap->peer_operclass[i] =
9325 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309326 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309327 __func__, i, peer_cap->peer_operclass[i]);
9328 }
9329
9330 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9331 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9332 peer_cap->pref_offchan_bw =
9333 peerStateParams->peerCap.prefOffChanBandwidth;
9334
Govind Singhb53420c2016-03-09 14:32:57 +05309335 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309336 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9337 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9338 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9339 " %d, pref_offchan_bw: %d",
9340 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9341 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9342 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9343 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9344 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9345
9346 /* next fill variable size array of peer chan info */
9347 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9348 WMITLV_SET_HDR(buf_ptr,
9349 WMITLV_TAG_ARRAY_STRUC,
9350 sizeof(wmi_channel) *
9351 peerStateParams->peerCap.peerChanLen);
9352 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9353
9354 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9355 WMITLV_SET_HDR(&chan_info->tlv_header,
9356 WMITLV_TAG_STRUC_wmi_channel,
9357 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9358 chan_info->mhz = ch_mhz[i];
9359 chan_info->band_center_freq1 = chan_info->mhz;
9360 chan_info->band_center_freq2 = 0;
9361
Govind Singhb53420c2016-03-09 14:32:57 +05309362 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309363
9364 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9365 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309366 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309367 peerStateParams->peerCap.peerChan[i].chanId,
9368 peerStateParams->peerCap.peerChan[i].dfsSet);
9369 }
9370
9371 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9372 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9373 else
9374 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9375
9376 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9377 peerStateParams->peerCap.
9378 peerChan[i].pwr);
9379
9380 WMI_SET_CHANNEL_REG_POWER(chan_info,
9381 peerStateParams->peerCap.peerChan[i].
9382 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309383 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309384 peerStateParams->peerCap.peerChan[i].pwr);
9385
9386 chan_info++;
9387 }
9388
9389 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9390 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309391 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309392 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309393 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309394 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309395 }
9396
9397
Govind Singhb53420c2016-03-09 14:32:57 +05309398 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309399}
9400
9401/*
9402 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9403 * firmware
9404 * @wmi_handle: Pointer to wmi handle
9405 * @mem_dump_req: Pointer for mem_dump_req
9406 *
9407 * This function sends memory dump request to firmware
9408 *
Govind Singhb53420c2016-03-09 14:32:57 +05309409 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309410 *
9411 */
Govind Singhb53420c2016-03-09 14:32:57 +05309412QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309413 struct fw_dump_req_param *mem_dump_req)
9414{
9415 wmi_get_fw_mem_dump_fixed_param *cmd;
9416 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309417 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309418 int32_t len;
9419 wmi_buf_t buf;
9420 u_int8_t *buf_ptr;
9421 int ret, loop;
9422
9423 /*
9424 * len = sizeof(fixed param) that includes tlv header +
9425 * tlv header for array of struc +
9426 * sizeof (each struct)
9427 */
9428 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9429 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9430 buf = wmi_buf_alloc(wmi_handle, len);
9431
9432 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309433 WMI_LOGE(FL("Failed allocate wmi buffer"));
9434 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309435 }
9436
9437 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309438 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309439 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9440
9441 WMITLV_SET_HDR(&cmd->tlv_header,
9442 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9443 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9444
9445 cmd->request_id = mem_dump_req->request_id;
9446 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9447
9448 /* TLV indicating array of structures to follow */
9449 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9450 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9451 sizeof(wmi_fw_mem_dump) *
9452 cmd->num_fw_mem_dump_segs);
9453
9454 buf_ptr += WMI_TLV_HDR_SIZE;
9455 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9456
Govind Singhb53420c2016-03-09 14:32:57 +05309457 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309458 mem_dump_req->request_id, mem_dump_req->num_seg);
9459 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309460 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309461 ((uint8_t *)(mem_dump_req->segment) +
9462 loop * sizeof(*seg_req));
9463 WMITLV_SET_HDR(&dump_params->tlv_header,
9464 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9465 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9466 dump_params->seg_id = seg_req->seg_id;
9467 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9468 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9469 dump_params->seg_length = seg_req->seg_length;
9470 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9471 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309472 WMI_LOGI(FL("seg_number:%d"), loop);
9473 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309474 dump_params->seg_id, dump_params->seg_start_addr_lo,
9475 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309476 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309477 dump_params->seg_length, dump_params->dest_addr_lo,
9478 dump_params->dest_addr_hi);
9479 dump_params++;
9480 }
9481
9482 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9483 WMI_GET_FW_MEM_DUMP_CMDID);
9484 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309485 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309486 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309487 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309488 }
9489
Govind Singhb53420c2016-03-09 14:32:57 +05309490 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9491 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309492}
9493
9494/*
9495 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9496 * @wmi_handle: Pointer to WMi handle
9497 * @ie_data: Pointer for ie data
9498 *
9499 * This function sends IE information to firmware
9500 *
Govind Singhb53420c2016-03-09 14:32:57 +05309501 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309502 *
9503 */
Govind Singhb53420c2016-03-09 14:32:57 +05309504QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309505 struct vdev_ie_info_param *ie_info)
9506{
9507 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9508 wmi_buf_t buf;
9509 uint8_t *buf_ptr;
9510 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309511 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309512
9513
9514 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9515 /* Allocate memory for the WMI command */
9516 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9517
9518 buf = wmi_buf_alloc(wmi_handle, len);
9519 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309520 WMI_LOGE(FL("wmi_buf_alloc failed"));
9521 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309522 }
9523
9524 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309525 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309526
9527 /* Populate the WMI command */
9528 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9529
9530 WMITLV_SET_HDR(&cmd->tlv_header,
9531 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9532 WMITLV_GET_STRUCT_TLVLEN(
9533 wmi_vdev_set_ie_cmd_fixed_param));
9534 cmd->vdev_id = ie_info->vdev_id;
9535 cmd->ie_id = ie_info->ie_id;
9536 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009537 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309538
Govind Singhb53420c2016-03-09 14:32:57 +05309539 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309540 ie_info->length, ie_info->vdev_id);
9541
9542 buf_ptr += sizeof(*cmd);
9543 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9544 buf_ptr += WMI_TLV_HDR_SIZE;
9545
Govind Singhb53420c2016-03-09 14:32:57 +05309546 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309547
9548 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9549 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309550 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309551 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309552 wmi_buf_free(buf);
9553 }
9554
9555 return ret;
9556}
9557
Govind Singh9ddd5162016-03-07 16:30:32 +05309558
9559void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05309560 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05309561{
Govind Singhe7f2f342016-05-23 12:12:52 +05309562 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05309563 resource_cfg->num_peers = tgt_res_cfg->num_peers;
9564 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
9565 resource_cfg->num_offload_reorder_buffs =
9566 tgt_res_cfg->num_offload_reorder_buffs;
9567 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
9568 resource_cfg->num_tids = tgt_res_cfg->num_tids;
9569 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
9570 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
9571 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
9572 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
9573 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
9574 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
9575 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
9576 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
9577 resource_cfg->scan_max_pending_req =
9578 tgt_res_cfg->scan_max_pending_req;
9579 resource_cfg->bmiss_offload_max_vdev =
9580 tgt_res_cfg->bmiss_offload_max_vdev;
9581 resource_cfg->roam_offload_max_vdev =
9582 tgt_res_cfg->roam_offload_max_vdev;
9583 resource_cfg->roam_offload_max_ap_profiles =
9584 tgt_res_cfg->roam_offload_max_ap_profiles;
9585 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
9586 resource_cfg->num_mcast_table_elems =
9587 tgt_res_cfg->num_mcast_table_elems;
9588 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
9589 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
9590 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
9591 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
9592 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
9593 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
9594 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
9595 resource_cfg->vow_config = tgt_res_cfg->vow_config;
9596 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
9597 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
9598 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
9599 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
9600 resource_cfg->num_tdls_conn_table_entries =
9601 tgt_res_cfg->num_tdls_conn_table_entries;
9602 resource_cfg->beacon_tx_offload_max_vdev =
9603 tgt_res_cfg->beacon_tx_offload_max_vdev;
9604 resource_cfg->num_multicast_filter_entries =
9605 tgt_res_cfg->num_multicast_filter_entries;
9606 resource_cfg->num_wow_filters =
9607 tgt_res_cfg->num_wow_filters;
9608 resource_cfg->num_keep_alive_pattern =
9609 tgt_res_cfg->num_keep_alive_pattern;
9610 resource_cfg->keep_alive_pattern_size =
9611 tgt_res_cfg->keep_alive_pattern_size;
9612 resource_cfg->max_tdls_concurrent_sleep_sta =
9613 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
9614 resource_cfg->max_tdls_concurrent_buffer_sta =
9615 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
9616 resource_cfg->wmi_send_separate =
9617 tgt_res_cfg->wmi_send_separate;
9618 resource_cfg->num_ocb_vdevs =
9619 tgt_res_cfg->num_ocb_vdevs;
9620 resource_cfg->num_ocb_channels =
9621 tgt_res_cfg->num_ocb_channels;
9622 resource_cfg->num_ocb_schedules =
9623 tgt_res_cfg->num_ocb_schedules;
9624
9625}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309626#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309627/**
9628 * send_init_cmd_tlv() - wmi init command
9629 * @wmi_handle: pointer to wmi handle
9630 * @res_cfg: resource config
9631 * @num_mem_chunks: no of mem chunck
9632 * @mem_chunk: pointer to mem chunck structure
9633 *
9634 * This function sends IE information to firmware
9635 *
Govind Singhb53420c2016-03-09 14:32:57 +05309636 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309637 *
9638 */
Govind Singhb53420c2016-03-09 14:32:57 +05309639QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309640 wmi_resource_config *tgt_res_cfg,
9641 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
9642 bool action)
9643{
9644 wmi_buf_t buf;
9645 wmi_init_cmd_fixed_param *cmd;
9646 wmi_abi_version my_vers;
9647 int num_whitelist;
9648 uint8_t *buf_ptr;
9649 wmi_resource_config *resource_cfg;
9650 wlan_host_memory_chunk *host_mem_chunks;
9651 uint32_t mem_chunk_len = 0;
9652 uint16_t idx;
9653 int len;
9654 int ret;
9655
9656 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
9657 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
9658 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
9659 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309660 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
9661 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309662 }
9663
9664 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9665 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
9666 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
9667
9668 host_mem_chunks = (wlan_host_memory_chunk *)
9669 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
9670 + WMI_TLV_HDR_SIZE);
9671
9672 WMITLV_SET_HDR(&cmd->tlv_header,
9673 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
9674 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
9675
Govind Singhb53420c2016-03-09 14:32:57 +05309676 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +05309677 WMITLV_SET_HDR(&resource_cfg->tlv_header,
9678 WMITLV_TAG_STRUC_wmi_resource_config,
9679 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
9680
9681 for (idx = 0; idx < num_mem_chunks; ++idx) {
9682 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
9683 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
9684 WMITLV_GET_STRUCT_TLVLEN
9685 (wlan_host_memory_chunk));
9686 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
9687 host_mem_chunks[idx].size = mem_chunks[idx].len;
9688 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309689 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +05309690 idx, host_mem_chunks[idx].size,
9691 host_mem_chunks[idx].ptr);
9692 }
9693 cmd->num_host_mem_chunks = num_mem_chunks;
9694 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
9695 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
9696 WMITLV_TAG_ARRAY_STRUC,
9697 (sizeof(wlan_host_memory_chunk) *
9698 num_mem_chunks));
9699
9700 num_whitelist = sizeof(version_whitelist) /
9701 sizeof(wmi_whitelist_version_info);
9702 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
9703 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
9704 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
9705 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
9706 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
9707 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +05309708#ifdef CONFIG_MCL
9709 /* This needs to be enabled for WIN Lithium after removing dependency
9710 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +05309711 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
9712 &my_vers,
9713 &wmi_handle->fw_abi_version,
9714 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +05309715#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309716 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05309717 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
9718 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
9719 cmd->host_abi_vers.abi_version_ns_0,
9720 cmd->host_abi_vers.abi_version_ns_1,
9721 cmd->host_abi_vers.abi_version_ns_2,
9722 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +05309723#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309724 /* Save version sent from host -
9725 * Will be used to check ready event
9726 */
Govind Singhb53420c2016-03-09 14:32:57 +05309727 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309728 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309729#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309730 if (action) {
9731 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9732 WMI_INIT_CMDID);
9733 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309734 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +05309735 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309736 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309737 }
9738 } else {
9739 wmi_handle->saved_wmi_init_cmd.buf = buf;
9740 wmi_handle->saved_wmi_init_cmd.buf_len = len;
9741 }
9742
Govind Singhb53420c2016-03-09 14:32:57 +05309743 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309744
9745}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309746#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309747/**
9748 * send_saved_init_cmd_tlv() - wmi init command
9749 * @wmi_handle: pointer to wmi handle
9750 *
9751 * This function sends IE information to firmware
9752 *
Govind Singhb53420c2016-03-09 14:32:57 +05309753 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309754 *
9755 */
Govind Singhb53420c2016-03-09 14:32:57 +05309756QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +05309757{
9758 int status;
9759
9760 if (!wmi_handle->saved_wmi_init_cmd.buf ||
9761 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05309762 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
9763 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309764 }
9765 status = wmi_unified_cmd_send(wmi_handle,
9766 wmi_handle->saved_wmi_init_cmd.buf,
9767 wmi_handle->saved_wmi_init_cmd.buf_len,
9768 WMI_INIT_CMDID);
9769 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +05309770 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +05309771 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309772 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309773 }
9774 wmi_handle->saved_wmi_init_cmd.buf = NULL;
9775 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
9776
Govind Singhb53420c2016-03-09 14:32:57 +05309777 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309778}
9779
Govind Singhb53420c2016-03-09 14:32:57 +05309780QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05309781{
9782 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
9783 wmi_service_ready_event_fixed_param *ev;
9784
9785
9786 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
9787
9788 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
9789 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05309790 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309791
Govind Singh87542482016-06-08 19:40:11 +05309792#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309793 /*Save fw version from service ready message */
9794 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05309795 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309796 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309797#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309798 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309799}
9800
9801/**
9802 * wmi_unified_save_fw_version_cmd() - save fw version
9803 * @wmi_handle: pointer to wmi handle
9804 * @res_cfg: resource config
9805 * @num_mem_chunks: no of mem chunck
9806 * @mem_chunk: pointer to mem chunck structure
9807 *
9808 * This function sends IE information to firmware
9809 *
Govind Singhb53420c2016-03-09 14:32:57 +05309810 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309811 *
9812 */
Govind Singhb53420c2016-03-09 14:32:57 +05309813QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309814 void *evt_buf)
9815{
9816 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
9817 wmi_ready_event_fixed_param *ev = NULL;
9818
9819 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
9820 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +05309821#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309822 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
9823 &ev->fw_abi_vers)) {
9824 /*
9825 * Error: Our host version and the given firmware version
9826 * are incompatible.
9827 **/
Govind Singhb53420c2016-03-09 14:32:57 +05309828 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +05309829 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
9830 __func__,
9831 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
9832 abi_version_0),
9833 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
9834 abi_version_0),
9835 wmi_handle->final_abi_vers.abi_version_ns_0,
9836 wmi_handle->final_abi_vers.abi_version_ns_1,
9837 wmi_handle->final_abi_vers.abi_version_ns_2,
9838 wmi_handle->final_abi_vers.abi_version_ns_3,
9839 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
9840 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
9841 ev->fw_abi_vers.abi_version_ns_0,
9842 ev->fw_abi_vers.abi_version_ns_1,
9843 ev->fw_abi_vers.abi_version_ns_2,
9844 ev->fw_abi_vers.abi_version_ns_3);
9845
Govind Singhb53420c2016-03-09 14:32:57 +05309846 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309847 }
Govind Singhb53420c2016-03-09 14:32:57 +05309848 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309849 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +05309850 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309851 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309852#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309853
Govind Singhb53420c2016-03-09 14:32:57 +05309854 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309855}
Govind Singha4836fd2016-03-07 16:45:38 +05309856
9857/**
9858 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
9859 * @wmi_handle: wmi handle
9860 * @custom_addr: base mac address
9861 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309862 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +05309863 */
Govind Singhb53420c2016-03-09 14:32:57 +05309864QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309865 uint8_t *custom_addr)
9866{
9867 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
9868 wmi_buf_t buf;
9869 int err;
9870
9871 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9872 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309873 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309874 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309875 }
9876
9877 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309878 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +05309879
9880 WMITLV_SET_HDR(&cmd->tlv_header,
9881 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
9882 WMITLV_GET_STRUCT_TLVLEN
9883 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
9884 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -07009885 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +05309886 err = wmi_unified_cmd_send(wmi_handle, buf,
9887 sizeof(*cmd),
9888 WMI_PDEV_SET_BASE_MACADDR_CMDID);
9889 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05309890 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05309891 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309892 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309893 }
9894
9895 return 0;
9896}
9897
9898/**
9899 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
9900 * @handle: wmi handle
9901 * @event: Event received from FW
9902 * @len: Length of the event
9903 *
9904 * Enables the low frequency events and disables the high frequency
9905 * events. Bit 17 indicates if the event if low/high frequency.
9906 * 1 - high frequency, 0 - low frequency
9907 *
9908 * Return: 0 on successfully enabling/disabling the events
9909 */
Govind Singhb53420c2016-03-09 14:32:57 +05309910QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309911 uint8_t *event,
9912 uint32_t len)
9913{
9914 uint32_t num_of_diag_events_logs;
9915 wmi_diag_event_log_config_fixed_param *cmd;
9916 wmi_buf_t buf;
9917 uint8_t *buf_ptr;
9918 uint32_t *cmd_args, *evt_args;
9919 uint32_t buf_len, i;
9920
9921 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
9922 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
9923
Govind Singhb53420c2016-03-09 14:32:57 +05309924 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +05309925
9926 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
9927 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309928 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +05309929 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309930 }
9931 wmi_event = param_buf->fixed_param;
9932 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
9933 evt_args = param_buf->diag_events_logs_list;
9934 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +05309935 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309936 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +05309937 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309938 }
9939
Govind Singhb53420c2016-03-09 14:32:57 +05309940 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309941 __func__, num_of_diag_events_logs);
9942
9943 /* Free any previous allocation */
9944 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +05309945 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309946
9947 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +05309948 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +05309949 sizeof(uint32_t));
9950 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +05309951 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +05309952 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309953 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309954 }
9955 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
9956
9957 /* Prepare the send buffer */
9958 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
9959 (num_of_diag_events_logs * sizeof(uint32_t));
9960
9961 buf = wmi_buf_alloc(wmi_handle, buf_len);
9962 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309963 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9964 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309965 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05309966 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309967 }
9968
9969 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
9970 buf_ptr = (uint8_t *) cmd;
9971
9972 WMITLV_SET_HDR(&cmd->tlv_header,
9973 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
9974 WMITLV_GET_STRUCT_TLVLEN(
9975 wmi_diag_event_log_config_fixed_param));
9976
9977 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
9978
9979 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
9980
9981 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9982 (num_of_diag_events_logs * sizeof(uint32_t)));
9983
9984 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
9985
9986 /* Populate the events */
9987 for (i = 0; i < num_of_diag_events_logs; i++) {
9988 /* Low freq (0) - Enable (1) the event
9989 * High freq (1) - Disable (0) the event
9990 */
9991 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
9992 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
9993 /* Set the event ID */
9994 WMI_DIAG_ID_SET(cmd_args[i],
9995 WMI_DIAG_ID_GET(evt_args[i]));
9996 /* Set the type */
9997 WMI_DIAG_TYPE_SET(cmd_args[i],
9998 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +05309999 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053010000 wmi_handle->events_logs_list[i] = evt_args[i];
10001 }
10002
10003 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
10004 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010005 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010006 __func__);
10007 wmi_buf_free(buf);
10008 /* Not clearing events_logs_list, though wmi cmd failed.
10009 * Host can still have this list
10010 */
Govind Singh67922e82016-04-01 16:48:57 +053010011 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010012 }
10013
10014 return 0;
10015}
10016
10017/**
10018 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
10019 * @wmi_handle: wmi handle
10020 * @start_log: Start logging related parameters
10021 *
10022 * Send the command to the FW based on which specific logging of diag
10023 * event/log id can be started/stopped
10024 *
10025 * Return: None
10026 */
Govind Singhb53420c2016-03-09 14:32:57 +053010027QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010028 struct wmi_wifi_start_log *start_log)
10029{
10030 wmi_diag_event_log_config_fixed_param *cmd;
10031 wmi_buf_t buf;
10032 uint8_t *buf_ptr;
10033 uint32_t len, count, log_level, i;
10034 uint32_t *cmd_args;
10035 uint32_t total_len;
10036 count = 0;
10037
10038 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010039 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053010040 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010041 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010042 }
10043 /* total_len stores the number of events where BITS 17 and 18 are set.
10044 * i.e., events of high frequency (17) and for extended debugging (18)
10045 */
10046 total_len = 0;
10047 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10048 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
10049 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
10050 total_len++;
10051 }
10052
10053 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10054 (total_len * sizeof(uint32_t));
10055
10056 buf = wmi_buf_alloc(wmi_handle, len);
10057 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010058 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010059 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010060 }
10061 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10062 buf_ptr = (uint8_t *) cmd;
10063
10064 WMITLV_SET_HDR(&cmd->tlv_header,
10065 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10066 WMITLV_GET_STRUCT_TLVLEN(
10067 wmi_diag_event_log_config_fixed_param));
10068
10069 cmd->num_of_diag_events_logs = total_len;
10070
10071 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10072
10073 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10074 (total_len * sizeof(uint32_t)));
10075
10076 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10077
Govind Singh224a7312016-06-21 14:33:26 +053010078 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053010079 log_level = 1;
10080 else
10081 log_level = 0;
10082
Govind Singhb53420c2016-03-09 14:32:57 +053010083 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053010084 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10085 uint32_t val = wmi_handle->events_logs_list[i];
10086 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
10087 (WMI_DIAG_EXT_FEATURE_GET(val))) {
10088
10089 WMI_DIAG_ID_SET(cmd_args[count],
10090 WMI_DIAG_ID_GET(val));
10091 WMI_DIAG_TYPE_SET(cmd_args[count],
10092 WMI_DIAG_TYPE_GET(val));
10093 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
10094 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053010095 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053010096 count++;
10097 }
10098 }
10099
10100 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10101 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010102 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010103 __func__);
10104 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010105 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010106 }
10107
Govind Singhb53420c2016-03-09 14:32:57 +053010108 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010109}
10110
10111/**
10112 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
10113 * @wmi_handle: WMI handle
10114 *
10115 * This function is used to send the flush command to the FW,
10116 * that will flush the fw logs that are residue in the FW
10117 *
10118 * Return: None
10119 */
Govind Singhb53420c2016-03-09 14:32:57 +053010120QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053010121{
10122 wmi_debug_mesg_flush_fixed_param *cmd;
10123 wmi_buf_t buf;
10124 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053010125 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010126
10127 buf = wmi_buf_alloc(wmi_handle, len);
10128 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010129 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010130 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010131 }
10132
10133 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
10134 WMITLV_SET_HDR(&cmd->tlv_header,
10135 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
10136 WMITLV_GET_STRUCT_TLVLEN(
10137 wmi_debug_mesg_flush_fixed_param));
10138 cmd->reserved0 = 0;
10139
10140 ret = wmi_unified_cmd_send(wmi_handle,
10141 buf,
10142 len,
10143 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010144 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010145 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053010146 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010147 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010148 }
Govind Singhb53420c2016-03-09 14:32:57 +053010149 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053010150
Govind Singh67922e82016-04-01 16:48:57 +053010151 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010152}
10153
10154/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010155 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010156 * @wmi_handle: wmi handle
10157 * @msg: PCL structure containing the PCL and the number of channels
10158 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010159 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053010160 * firmware. The DBS Manager is the consumer of this information in the WLAN
10161 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
10162 * to migrate to a new channel without host driver involvement. An example of
10163 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
10164 * manage the channel selection without firmware involvement.
10165 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010166 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
10167 * channel list. The weights corresponds to the channels sent in
10168 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
10169 * weightage compared to the non PCL channels.
10170 *
Govind Singha4836fd2016-03-07 16:45:38 +053010171 * Return: Success if the cmd is sent successfully to the firmware
10172 */
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010173QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
10174 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053010175{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010176 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010177 wmi_buf_t buf;
10178 uint8_t *buf_ptr;
10179 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010180 uint32_t chan_len;
10181
10182 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053010183
10184 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010185 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053010186
10187 buf = wmi_buf_alloc(wmi_handle, len);
10188 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010189 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10190 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010191 }
10192
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010193 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010194 buf_ptr = (uint8_t *) cmd;
10195 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010196 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
10197 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053010198
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010199 cmd->pdev_id = WMI_PDEV_ID_SOC;
10200 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053010201 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010202
10203 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053010204 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010205 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053010206 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010207 for (i = 0; i < chan_len ; i++) {
10208 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053010209 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010210 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010211 }
10212 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010213 WMI_PDEV_SET_PCL_CMDID)) {
10214 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010215 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010216 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010217 }
Govind Singhb53420c2016-03-09 14:32:57 +053010218 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010219}
10220
10221/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010222 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010223 * @wmi_handle: wmi handle
10224 * @msg: Structure containing the following parameters
10225 *
10226 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
10227 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
10228 *
10229 * Provides notification to the WLAN firmware that host driver is requesting a
10230 * HardWare (HW) Mode change. This command is needed to support iHelium in the
10231 * configurations that include the Dual Band Simultaneous (DBS) feature.
10232 *
10233 * Return: Success if the cmd is sent successfully to the firmware
10234 */
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010235QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010236 uint32_t hw_mode_index)
10237{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010238 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010239 wmi_buf_t buf;
10240 uint32_t len;
10241
10242 len = sizeof(*cmd);
10243
10244 buf = wmi_buf_alloc(wmi_handle, len);
10245 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010246 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10247 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010248 }
10249
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010250 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010251 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010252 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
10253 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
10254
10255 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010256 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053010257 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053010258
10259 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010260 WMI_PDEV_SET_HW_MODE_CMDID)) {
10261 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010262 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010263 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010264 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010265 }
10266
Govind Singhb53420c2016-03-09 14:32:57 +053010267 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010268}
10269
10270/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010271 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010272 * @wmi_handle: wmi handle
10273 * @msg: Dual MAC config parameters
10274 *
10275 * Configures WLAN firmware with the dual MAC features
10276 *
Govind Singhb53420c2016-03-09 14:32:57 +053010277 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053010278 */
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010279QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010280 struct wmi_dual_mac_config *msg)
10281{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010282 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010283 wmi_buf_t buf;
10284 uint32_t len;
10285
10286 len = sizeof(*cmd);
10287
10288 buf = wmi_buf_alloc(wmi_handle, len);
10289 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010290 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10291 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010292 }
10293
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010294 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010295 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010296 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053010297 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010298 wmi_pdev_set_mac_config_cmd_fixed_param));
10299
10300 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010301 cmd->concurrent_scan_config_bits = msg->scan_config;
10302 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053010303 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053010304 __func__, msg->scan_config, msg->fw_mode_config);
10305
10306 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010307 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
10308 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010309 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010310 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010311 }
Govind Singhb53420c2016-03-09 14:32:57 +053010312 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010313}
10314
10315/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010316 * fill_arp_offload_params_tlv() - Fill ARP offload data
10317 * @wmi_handle: wmi handle
10318 * @offload_req: offload request
10319 * @buf_ptr: buffer pointer
10320 *
10321 * To fill ARP offload data to firmware
10322 * when target goes to wow mode.
10323 *
10324 * Return: None
10325 */
10326static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
10327 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10328{
10329
10330 int i;
10331 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
10332 bool enable_or_disable = offload_req->enableOrDisable;
10333
10334 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10335 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
10336 *buf_ptr += WMI_TLV_HDR_SIZE;
10337 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
10338 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
10339 WMITLV_SET_HDR(&arp_tuple->tlv_header,
10340 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
10341 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
10342
10343 /* Fill data for ARP and NS in the first tupple for LA */
10344 if ((enable_or_disable & WMI_OFFLOAD_ENABLE) && (i == 0)) {
10345 /* Copy the target ip addr and flags */
10346 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
10347 qdf_mem_copy(&arp_tuple->target_ipaddr,
10348 offload_req->params.hostIpv4Addr,
10349 WMI_IPV4_ADDR_LEN);
10350 WMI_LOGD("ARPOffload IP4 address: %pI4",
10351 offload_req->params.hostIpv4Addr);
10352 }
10353 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
10354 }
10355}
10356
10357#ifdef WLAN_NS_OFFLOAD
10358/**
10359 * fill_ns_offload_params_tlv() - Fill NS offload data
10360 * @wmi|_handle: wmi handle
10361 * @offload_req: offload request
10362 * @buf_ptr: buffer pointer
10363 *
10364 * To fill NS offload data to firmware
10365 * when target goes to wow mode.
10366 *
10367 * Return: None
10368 */
10369static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10370 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10371{
10372
10373 int i;
10374 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10375 struct ns_offload_req_params ns_req;
10376
10377 ns_req = offload_req->nsOffloadInfo;
10378 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10379 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10380 *buf_ptr += WMI_TLV_HDR_SIZE;
10381 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
10382 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10383 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10384 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10385 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
10386
10387 /*
10388 * Fill data only for NS offload in the first ARP tuple for LA
10389 */
10390 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10391 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10392 /* Copy the target/solicitation/remote ip addr */
10393 if (ns_req.targetIPv6AddrValid[i])
10394 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10395 &ns_req.targetIPv6Addr[i],
10396 sizeof(WMI_IPV6_ADDR));
10397 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10398 &ns_req.selfIPv6Addr[i],
10399 sizeof(WMI_IPV6_ADDR));
10400 if (ns_req.target_ipv6_addr_ac_type[i]) {
10401 ns_tuple->flags |=
10402 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10403 }
10404 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10405 i, &ns_req.selfIPv6Addr[i],
10406 &ns_req.targetIPv6Addr[i]);
10407
10408 /* target MAC is optional, check if it is valid,
10409 * if this is not valid, the target will use the known
10410 * local MAC address rather than the tuple
10411 */
10412 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10413 ns_req.self_macaddr.bytes,
10414 &ns_tuple->target_mac);
10415 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10416 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10417 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10418 }
10419 }
10420 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10421 }
10422}
10423
10424
10425/**
10426 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
10427 * @wmi: wmi handle
10428 * @offload_req: offload request
10429 * @buf_ptr: buffer pointer
10430 *
10431 * To fill extended NS offload extended data to firmware
10432 * when target goes to wow mode.
10433 *
10434 * Return: None
10435 */
10436static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10437 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10438{
10439 int i;
10440 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10441 uint32_t count, num_ns_ext_tuples;
10442 struct ns_offload_req_params ns_req;
10443
10444 ns_req = offload_req->nsOffloadInfo;
10445 count = offload_req->num_ns_offload_count;
10446 num_ns_ext_tuples = offload_req->num_ns_offload_count -
10447 WMI_MAX_NS_OFFLOADS;
10448
10449 /* Populate extended NS offload tuples */
10450 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10451 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10452 *buf_ptr += WMI_TLV_HDR_SIZE;
10453 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
10454 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10455 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10456 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10457 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
10458
10459 /*
10460 * Fill data only for NS offload in the first ARP tuple for LA
10461 */
10462 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10463 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10464 /* Copy the target/solicitation/remote ip addr */
10465 if (ns_req.targetIPv6AddrValid[i])
10466 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10467 &ns_req.targetIPv6Addr[i],
10468 sizeof(WMI_IPV6_ADDR));
10469 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10470 &ns_req.selfIPv6Addr[i],
10471 sizeof(WMI_IPV6_ADDR));
10472 if (ns_req.target_ipv6_addr_ac_type[i]) {
10473 ns_tuple->flags |=
10474 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10475 }
10476 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10477 i, &ns_req.selfIPv6Addr[i],
10478 &ns_req.targetIPv6Addr[i]);
10479
10480 /* target MAC is optional, check if it is valid,
10481 * if this is not valid, the target will use the
10482 * known local MAC address rather than the tuple
10483 */
10484 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10485 ns_req.self_macaddr.bytes,
10486 &ns_tuple->target_mac);
10487 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10488 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10489 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10490 }
10491 }
10492 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10493 }
10494}
10495#else
10496static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10497 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10498{
10499 return;
10500}
10501
10502static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10503 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10504{
10505 return;
10506}
10507#endif
10508
10509/**
Govind Singha4836fd2016-03-07 16:45:38 +053010510 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
10511 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010512 * @arp_offload_req: arp offload request
10513 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053010514 * @arp_only: flag
10515 *
10516 * To configure ARP NS off load data to firmware
10517 * when target goes to wow mode.
10518 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010519 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053010520 */
Govind Singhb53420c2016-03-09 14:32:57 +053010521QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010522 struct host_offload_req_param *arp_offload_req,
10523 struct host_offload_req_param *ns_offload_req,
10524 bool arp_only,
Govind Singha4836fd2016-03-07 16:45:38 +053010525 uint8_t vdev_id)
10526{
Govind Singha4836fd2016-03-07 16:45:38 +053010527 int32_t res;
10528 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010529 A_UINT8 *buf_ptr;
10530 wmi_buf_t buf;
10531 int32_t len;
10532 uint32_t count = 0, num_ns_ext_tuples = 0;
10533
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010534 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053010535
Govind Singha4836fd2016-03-07 16:45:38 +053010536 /*
10537 * TLV place holder size for array of NS tuples
10538 * TLV place holder size for array of ARP tuples
10539 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010540 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
10541 WMI_TLV_HDR_SIZE +
10542 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
10543 WMI_TLV_HDR_SIZE +
10544 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010545
10546 /*
10547 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
10548 * extra length for extended NS offload tuples which follows ARP offload
10549 * tuples. Host needs to fill this structure in following format:
10550 * 2 NS ofload tuples
10551 * 2 ARP offload tuples
10552 * N numbers of extended NS offload tuples if HDD has given more than
10553 * 2 NS offload addresses
10554 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010555 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053010556 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010557 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
10558 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010559 }
10560
10561 buf = wmi_buf_alloc(wmi_handle, len);
10562 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010563 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053010564 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010565 }
10566
10567 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
10568 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
10569 WMITLV_SET_HDR(&cmd->tlv_header,
10570 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
10571 WMITLV_GET_STRUCT_TLVLEN
10572 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
10573 cmd->flags = 0;
10574 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010575 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053010576
Govind Singhb53420c2016-03-09 14:32:57 +053010577 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053010578
Govind Singha4836fd2016-03-07 16:45:38 +053010579 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010580 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
10581 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
10582 if (num_ns_ext_tuples)
10583 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053010584
10585 res = wmi_unified_cmd_send(wmi_handle, buf, len,
10586 WMI_SET_ARP_NS_OFFLOAD_CMDID);
10587 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053010588 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053010589 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010590 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010591 }
10592
Govind Singhb53420c2016-03-09 14:32:57 +053010593 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010594}
10595
10596/**
10597 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
10598 * @wmi_handle: wmi handle
10599 * @request: SSID hotlist set request
10600 *
Govind Singhb53420c2016-03-09 14:32:57 +053010601 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053010602 */
Govind Singhb53420c2016-03-09 14:32:57 +053010603QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053010604send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
10605 struct ssid_hotlist_request_params *request)
10606{
10607 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
10608 wmi_buf_t wmi_buf;
10609 uint32_t len;
10610 uint32_t array_size;
10611 uint8_t *buf_ptr;
10612
10613 /* length of fixed portion */
10614 len = sizeof(*cmd);
10615
10616 /* length of variable portion */
10617 array_size =
10618 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
10619 len += WMI_TLV_HDR_SIZE + array_size;
10620
10621 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10622 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010623 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10624 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010625 }
10626
10627 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10628 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
10629 buf_ptr;
10630 WMITLV_SET_HDR
10631 (&cmd->tlv_header,
10632 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
10633 WMITLV_GET_STRUCT_TLVLEN
10634 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
10635
10636 cmd->request_id = request->request_id;
10637 cmd->requestor_id = 0;
10638 cmd->vdev_id = request->session_id;
10639 cmd->table_id = 0;
10640 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
10641 cmd->total_entries = request->ssid_count;
10642 cmd->num_entries_in_page = request->ssid_count;
10643 cmd->first_entry_index = 0;
10644
10645 buf_ptr += sizeof(*cmd);
10646 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
10647
10648 if (request->ssid_count) {
10649 wmi_extscan_hotlist_ssid_entry *entry;
10650 int i;
10651
10652 buf_ptr += WMI_TLV_HDR_SIZE;
10653 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
10654 for (i = 0; i < request->ssid_count; i++) {
10655 WMITLV_SET_HDR
10656 (entry,
10657 WMITLV_TAG_ARRAY_STRUC,
10658 WMITLV_GET_STRUCT_TLVLEN
10659 (wmi_extscan_hotlist_ssid_entry));
10660 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053010661 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053010662 request->ssids[i].ssid.mac_ssid,
10663 request->ssids[i].ssid.length);
10664 entry->band = request->ssids[i].band;
10665 entry->min_rssi = request->ssids[i].rssi_low;
10666 entry->max_rssi = request->ssids[i].rssi_high;
10667 entry++;
10668 }
10669 cmd->mode = WMI_EXTSCAN_MODE_START;
10670 } else {
10671 cmd->mode = WMI_EXTSCAN_MODE_STOP;
10672 }
10673
10674 if (wmi_unified_cmd_send
10675 (wmi_handle, wmi_buf, len,
10676 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010677 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053010678 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010679 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010680 }
10681
Govind Singhb53420c2016-03-09 14:32:57 +053010682 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010683}
10684
10685/**
10686 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
10687 * @wmi_handle: wmi handle
10688 * @vdev_id: vdev id
10689 *
10690 * This function sends roam synch complete event to fw.
10691 *
10692 * Return: CDF STATUS
10693 */
Govind Singhb53420c2016-03-09 14:32:57 +053010694QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010695 uint8_t vdev_id)
10696{
10697 wmi_roam_synch_complete_fixed_param *cmd;
10698 wmi_buf_t wmi_buf;
10699 uint8_t *buf_ptr;
10700 uint16_t len;
10701 len = sizeof(wmi_roam_synch_complete_fixed_param);
10702
10703 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10704 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010705 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10706 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010707 }
10708 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
10709 buf_ptr = (uint8_t *) cmd;
10710 WMITLV_SET_HDR(&cmd->tlv_header,
10711 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
10712 WMITLV_GET_STRUCT_TLVLEN
10713 (wmi_roam_synch_complete_fixed_param));
10714 cmd->vdev_id = vdev_id;
10715 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10716 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010717 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053010718 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010719 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010720 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010721 }
10722
Govind Singhb53420c2016-03-09 14:32:57 +053010723 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010724}
10725
10726/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053010727 * send_fw_test_cmd_tlv() - send fw test command to fw.
10728 * @wmi_handle: wmi handle
10729 * @wmi_fwtest: fw test command
10730 *
10731 * This function sends fw test command to fw.
10732 *
10733 * Return: CDF STATUS
10734 */
10735QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
10736 struct set_fwtest_params *wmi_fwtest)
10737{
10738 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10739 wmi_buf_t wmi_buf;
10740 uint16_t len;
10741
10742 len = sizeof(*cmd);
10743
10744 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10745 if (!wmi_buf) {
10746 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10747 return QDF_STATUS_E_NOMEM;
10748 }
10749
10750 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10751 WMITLV_SET_HDR(&cmd->tlv_header,
10752 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10753 WMITLV_GET_STRUCT_TLVLEN(
10754 wmi_fwtest_set_param_cmd_fixed_param));
10755 cmd->param_id = wmi_fwtest->arg;
10756 cmd->param_value = wmi_fwtest->value;
10757
10758 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10759 WMI_FWTEST_CMDID)) {
10760 WMI_LOGP("%s: failed to send fw test command", __func__);
10761 qdf_nbuf_free(wmi_buf);
10762 return QDF_STATUS_E_FAILURE;
10763 }
10764
10765 return QDF_STATUS_SUCCESS;
10766}
10767
10768/**
Govind Singha4836fd2016-03-07 16:45:38 +053010769 * send_unit_test_cmd_tlv() - send unit test command to fw.
10770 * @wmi_handle: wmi handle
10771 * @wmi_utest: unit test command
10772 *
10773 * This function send unit test command to fw.
10774 *
10775 * Return: CDF STATUS
10776 */
Govind Singhb53420c2016-03-09 14:32:57 +053010777QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010778 struct wmi_unit_test_cmd *wmi_utest)
10779{
10780 wmi_unit_test_cmd_fixed_param *cmd;
10781 wmi_buf_t wmi_buf;
10782 uint8_t *buf_ptr;
10783 int i;
10784 uint16_t len, args_tlv_len;
10785 A_UINT32 *unit_test_cmd_args;
10786
10787 args_tlv_len =
10788 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
10789 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
10790
10791 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10792 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010793 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10794 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010795 }
10796
10797 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10798 buf_ptr = (uint8_t *) cmd;
10799 WMITLV_SET_HDR(&cmd->tlv_header,
10800 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
10801 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
10802 cmd->vdev_id = wmi_utest->vdev_id;
10803 cmd->module_id = wmi_utest->module_id;
10804 cmd->num_args = wmi_utest->num_args;
10805 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
10806 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10807 (wmi_utest->num_args * sizeof(uint32_t)));
10808 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053010809 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053010810 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
10811 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010812 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010813 }
10814 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10815 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010816 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010817 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010818 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010819 }
10820
Govind Singhb53420c2016-03-09 14:32:57 +053010821 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010822}
10823
10824/**
10825 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
10826 * @wmi_handle: wma handle
10827 * @roaminvoke: roam invoke command
10828 *
10829 * Send roam invoke command to fw for fastreassoc.
10830 *
10831 * Return: CDF STATUS
10832 */
Govind Singhb53420c2016-03-09 14:32:57 +053010833QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010834 struct wmi_roam_invoke_cmd *roaminvoke,
10835 uint32_t ch_hz)
10836{
10837 wmi_roam_invoke_cmd_fixed_param *cmd;
10838 wmi_buf_t wmi_buf;
10839 u_int8_t *buf_ptr;
10840 u_int16_t len, args_tlv_len;
10841 A_UINT32 *channel_list;
10842 wmi_mac_addr *bssid_list;
10843
10844 /* Host sends only one channel and one bssid */
10845 args_tlv_len = 2 * WMI_TLV_HDR_SIZE + sizeof(A_UINT32) +
10846 sizeof(wmi_mac_addr);
10847 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
10848 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10849 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010850 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10851 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010852 }
10853
10854 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
10855 buf_ptr = (u_int8_t *) cmd;
10856 WMITLV_SET_HDR(&cmd->tlv_header,
10857 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
10858 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
10859 cmd->vdev_id = roaminvoke->vdev_id;
10860 cmd->flags = 0;
10861 cmd->roam_scan_mode = 0;
10862 cmd->roam_ap_sel_mode = 0;
10863 cmd->roam_delay = 0;
10864 cmd->num_chan = 1;
10865 cmd->num_bssid = 1;
10866 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
10867 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10868 (sizeof(u_int32_t)));
10869 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
10870 *channel_list = ch_hz;
10871 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
10872 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
10873 (sizeof(wmi_mac_addr)));
10874 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
10875 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
10876 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10877 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010878 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053010879 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010880 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010881 }
10882
Govind Singhb53420c2016-03-09 14:32:57 +053010883 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010884}
10885
10886/**
10887 * send_roam_scan_offload_cmd_tlv() - set roam offload command
10888 * @wmi_handle: wmi handle
10889 * @command: command
10890 * @vdev_id: vdev id
10891 *
10892 * This function set roam offload command to fw.
10893 *
10894 * Return: CDF status
10895 */
Govind Singhb53420c2016-03-09 14:32:57 +053010896QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010897 uint32_t command, uint32_t vdev_id)
10898{
Govind Singh67922e82016-04-01 16:48:57 +053010899 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010900 wmi_roam_scan_cmd_fixed_param *cmd_fp;
10901 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053010902 int len;
10903 uint8_t *buf_ptr;
10904
10905 len = sizeof(wmi_roam_scan_cmd_fixed_param);
10906 buf = wmi_buf_alloc(wmi_handle, len);
10907 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010908 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10909 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010910 }
10911
10912 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10913
10914 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
10915 WMITLV_SET_HDR(&cmd_fp->tlv_header,
10916 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
10917 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
10918 cmd_fp->vdev_id = vdev_id;
10919 cmd_fp->command_arg = command;
10920
10921 status = wmi_unified_cmd_send(wmi_handle, buf,
10922 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053010923 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010924 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010925 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010926 goto error;
10927 }
10928
Govind Singhb53420c2016-03-09 14:32:57 +053010929 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
10930 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010931
10932error:
10933 wmi_buf_free(buf);
10934
Govind Singh67922e82016-04-01 16:48:57 +053010935 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010936}
10937
10938/**
10939 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
10940 * @wmi_handle: wmi handle
10941 * @ap_profile_p: ap profile
10942 * @vdev_id: vdev id
10943 *
10944 * Send WMI_ROAM_AP_PROFILE to firmware
10945 *
10946 * Return: CDF status
10947 */
Govind Singhb53420c2016-03-09 14:32:57 +053010948QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010949 wmi_ap_profile *ap_profile_p,
10950 uint32_t vdev_id)
10951{
Govind Singha4836fd2016-03-07 16:45:38 +053010952 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010953 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010954 int len;
10955 uint8_t *buf_ptr;
10956 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
10957
10958 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
10959
10960 buf = wmi_buf_alloc(wmi_handle, len);
10961 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010962 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10963 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010964 }
10965
10966 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10967 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
10968 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
10969 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
10970 WMITLV_GET_STRUCT_TLVLEN
10971 (wmi_roam_ap_profile_fixed_param));
10972 /* fill in threshold values */
10973 roam_ap_profile_fp->vdev_id = vdev_id;
10974 roam_ap_profile_fp->id = 0;
10975 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
10976
Govind Singhb53420c2016-03-09 14:32:57 +053010977 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053010978 WMITLV_SET_HDR(buf_ptr,
10979 WMITLV_TAG_STRUC_wmi_ap_profile,
10980 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
10981 status = wmi_unified_cmd_send(wmi_handle, buf,
10982 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053010983 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010984 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010985 status);
Govind Singh67922e82016-04-01 16:48:57 +053010986 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010987 }
10988
Govind Singhb53420c2016-03-09 14:32:57 +053010989 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053010990
Govind Singh67922e82016-04-01 16:48:57 +053010991 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010992}
10993
10994/**
10995 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
10996 * @wmi_handle: wmi handle
10997 * @scan_period: scan period
10998 * @scan_age: scan age
10999 * @vdev_id: vdev id
11000 *
11001 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
11002 *
11003 * Return: CDF status
11004 */
Govind Singhb53420c2016-03-09 14:32:57 +053011005QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011006 uint32_t scan_period,
11007 uint32_t scan_age,
11008 uint32_t vdev_id)
11009{
Govind Singh67922e82016-04-01 16:48:57 +053011010 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011011 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053011012 int len;
11013 uint8_t *buf_ptr;
11014 wmi_roam_scan_period_fixed_param *scan_period_fp;
11015
11016 /* Send scan period values */
11017 len = sizeof(wmi_roam_scan_period_fixed_param);
11018 buf = wmi_buf_alloc(wmi_handle, len);
11019 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011020 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11021 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011022 }
11023
11024 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11025 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
11026 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
11027 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
11028 WMITLV_GET_STRUCT_TLVLEN
11029 (wmi_roam_scan_period_fixed_param));
11030 /* fill in scan period values */
11031 scan_period_fp->vdev_id = vdev_id;
11032 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
11033 scan_period_fp->roam_scan_age = scan_age;
11034
11035 status = wmi_unified_cmd_send(wmi_handle, buf,
11036 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053011037 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011038 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011039 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011040 goto error;
11041 }
11042
Govind Singhb53420c2016-03-09 14:32:57 +053011043 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011044 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053011045 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011046error:
11047 wmi_buf_free(buf);
11048
Govind Singh67922e82016-04-01 16:48:57 +053011049 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011050}
11051
11052/**
11053 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
11054 * @wmi_handle: wmi handle
11055 * @chan_count: channel count
11056 * @chan_list: channel list
11057 * @list_type: list type
11058 * @vdev_id: vdev id
11059 *
11060 * Set roam offload channel list.
11061 *
11062 * Return: CDF status
11063 */
Govind Singhb53420c2016-03-09 14:32:57 +053011064QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011065 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070011066 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053011067 uint8_t list_type, uint32_t vdev_id)
11068{
Govind Singha4836fd2016-03-07 16:45:38 +053011069 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011070 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011071 int len, list_tlv_len;
11072 int i;
11073 uint8_t *buf_ptr;
11074 wmi_roam_chan_list_fixed_param *chan_list_fp;
11075 A_UINT32 *roam_chan_list_array;
11076
11077 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053011078 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053011079 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053011080 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053011081 }
11082 /* Channel list is a table of 2 TLV's */
11083 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
11084 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
11085 buf = wmi_buf_alloc(wmi_handle, len);
11086 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011087 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11088 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011089 }
11090
11091 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11092 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
11093 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
11094 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
11095 WMITLV_GET_STRUCT_TLVLEN
11096 (wmi_roam_chan_list_fixed_param));
11097 chan_list_fp->vdev_id = vdev_id;
11098 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053011099 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053011100 /* external app is controlling channel list */
11101 chan_list_fp->chan_list_type =
11102 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
11103 } else {
11104 /* umac supplied occupied channel list in LFR */
11105 chan_list_fp->chan_list_type =
11106 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
11107 }
11108
11109 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
11110 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11111 (chan_list_fp->num_chan * sizeof(uint32_t)));
11112 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053011113 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053011114 for (i = 0; ((i < chan_list_fp->num_chan) &&
11115 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
11116 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053011117 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011118 }
11119
11120 status = wmi_unified_cmd_send(wmi_handle, buf,
11121 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053011122 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011123 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011124 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011125 goto error;
11126 }
11127
Govind Singhb53420c2016-03-09 14:32:57 +053011128 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
11129 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011130error:
11131 wmi_buf_free(buf);
11132
Govind Singh67922e82016-04-01 16:48:57 +053011133 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011134}
11135
11136/**
11137 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
11138 * @wmi_handle: wmi handle
11139 * @rssi_change_thresh: RSSI Change threshold
11140 * @bcn_rssi_weight: beacon RSSI weight
11141 * @vdev_id: vdev id
11142 *
11143 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
11144 *
11145 * Return: CDF status
11146 */
Govind Singhb53420c2016-03-09 14:32:57 +053011147QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011148 uint32_t vdev_id,
11149 int32_t rssi_change_thresh,
11150 uint32_t bcn_rssi_weight,
11151 uint32_t hirssi_delay_btw_scans)
11152{
Govind Singha4836fd2016-03-07 16:45:38 +053011153 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011154 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011155 int len;
11156 uint8_t *buf_ptr;
11157 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
11158
11159 /* Send rssi change parameters */
11160 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
11161 buf = wmi_buf_alloc(wmi_handle, len);
11162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011163 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11164 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011165 }
11166
11167 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11168 rssi_change_fp =
11169 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
11170 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
11171 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
11172 WMITLV_GET_STRUCT_TLVLEN
11173 (wmi_roam_scan_rssi_change_threshold_fixed_param));
11174 /* fill in rssi change threshold (hysteresis) values */
11175 rssi_change_fp->vdev_id = vdev_id;
11176 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
11177 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
11178 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
11179
11180 status = wmi_unified_cmd_send(wmi_handle, buf,
11181 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053011182 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011183 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011184 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011185 goto error;
11186 }
11187
Govind Singhb53420c2016-03-09 14:32:57 +053011188 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053011189 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053011190 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
11191 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011192error:
11193 wmi_buf_free(buf);
11194
Govind Singh67922e82016-04-01 16:48:57 +053011195 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011196}
11197
11198/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
11199 * @wmi_handle: wmi handle.
11200 * @cmd: size of command structure.
11201 * @per_entry_size: per entry size.
11202 *
11203 * This utility function calculates how many hotlist entries can
11204 * fit in one page.
11205 *
11206 * Return: number of entries
11207 */
11208static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
11209 size_t cmd_size,
11210 size_t per_entry_size)
11211{
11212 uint32_t avail_space = 0;
11213 int num_entries = 0;
11214 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
11215
11216 /* Calculate number of hotlist entries that can
11217 * be passed in wma message request.
11218 */
11219 avail_space = max_msg_len - cmd_size;
11220 num_entries = avail_space / per_entry_size;
11221 return num_entries;
11222}
11223
11224/**
11225 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
11226 * @wmi_handle: wmi handle
11227 * @photlist: hotlist command params
11228 * @buf_len: buffer length
11229 *
11230 * This function fills individual elements for hotlist request and
11231 * TLV for bssid entries
11232 *
11233 * Return: CDF Status.
11234 */
Govind Singhb53420c2016-03-09 14:32:57 +053011235QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011236 struct ext_scan_setbssi_hotlist_params *
11237 photlist, int *buf_len)
11238{
11239 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
11240 wmi_extscan_hotlist_entry *dest_hotlist;
11241 struct ap_threshold_params *src_ap = photlist->ap;
11242 wmi_buf_t buf;
11243 uint8_t *buf_ptr;
11244
11245 int j, index = 0;
11246 int cmd_len = 0;
11247 int num_entries;
11248 int min_entries = 0;
11249 int numap = photlist->numAp;
11250 int len = sizeof(*cmd);
11251
11252 len += WMI_TLV_HDR_SIZE;
11253 cmd_len = len;
11254
11255 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
11256 cmd_len,
11257 sizeof(*dest_hotlist));
11258 /* setbssid hotlist expects the bssid list
11259 * to be non zero value
11260 */
11261 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011262 WMI_LOGE("%s: Invalid number of bssid's", __func__);
11263 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011264 }
11265
11266 /* Split the hot list entry pages and send multiple command
11267 * requests if the buffer reaches the maximum request size
11268 */
11269 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011270 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053011271 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
11272 buf = wmi_buf_alloc(wmi_handle, len);
11273 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011274 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
11275 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011276 }
11277 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11278 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
11279 buf_ptr;
11280 WMITLV_SET_HDR(&cmd->tlv_header,
11281 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
11282 WMITLV_GET_STRUCT_TLVLEN
11283 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
11284
11285 /* Multiple requests are sent until the num_entries_in_page
11286 * matches the total_entries
11287 */
11288 cmd->request_id = photlist->requestId;
11289 cmd->vdev_id = photlist->sessionId;
11290 cmd->total_entries = numap;
11291 cmd->mode = 1;
11292 cmd->num_entries_in_page = min_entries;
11293 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
11294 cmd->first_entry_index = index;
11295
Govind Singhb53420c2016-03-09 14:32:57 +053011296 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011297 __func__, cmd->vdev_id, cmd->total_entries,
11298 cmd->num_entries_in_page,
11299 cmd->lost_ap_scan_count);
11300
11301 buf_ptr += sizeof(*cmd);
11302 WMITLV_SET_HDR(buf_ptr,
11303 WMITLV_TAG_ARRAY_STRUC,
11304 min_entries * sizeof(wmi_extscan_hotlist_entry));
11305 dest_hotlist = (wmi_extscan_hotlist_entry *)
11306 (buf_ptr + WMI_TLV_HDR_SIZE);
11307
11308 /* Populate bssid, channel info and rssi
11309 * for the bssid's that are sent as hotlists.
11310 */
11311 for (j = 0; j < min_entries; j++) {
11312 WMITLV_SET_HDR(dest_hotlist,
11313 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
11314 WMITLV_GET_STRUCT_TLVLEN
11315 (wmi_extscan_hotlist_entry));
11316
11317 dest_hotlist->min_rssi = src_ap->low;
11318 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
11319 &dest_hotlist->bssid);
11320
Govind Singhb53420c2016-03-09 14:32:57 +053011321 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011322 __func__, dest_hotlist->channel,
11323 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053011324 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053011325 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
11326 __func__, dest_hotlist->bssid.mac_addr31to0,
11327 dest_hotlist->bssid.mac_addr47to32);
11328 dest_hotlist++;
11329 src_ap++;
11330 }
11331 buf_ptr += WMI_TLV_HDR_SIZE +
11332 (min_entries * sizeof(wmi_extscan_hotlist_entry));
11333
11334 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11335 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011336 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011337 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011338 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011339 }
11340 index = index + min_entries;
11341 num_entries = numap - min_entries;
11342 len = cmd_len;
11343 }
Govind Singhb53420c2016-03-09 14:32:57 +053011344 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011345}
11346
Govind Singhbca3b1b2016-05-02 17:59:24 +053011347/**
11348 * send_power_dbg_cmd_tlv() - send power debug commands
11349 * @wmi_handle: wmi handle
11350 * @param: wmi power debug parameter
11351 *
11352 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
11353 *
11354 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
11355 */
11356QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
11357 struct wmi_power_dbg_params *param)
11358{
11359 wmi_buf_t buf = NULL;
11360 QDF_STATUS status;
11361 int len, args_tlv_len;
11362 uint8_t *buf_ptr;
11363 uint8_t i;
11364 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
11365 uint32_t *cmd_args;
11366
11367 /* Prepare and send power debug cmd parameters */
11368 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
11369 len = sizeof(*cmd) + args_tlv_len;
11370 buf = wmi_buf_alloc(wmi_handle, len);
11371 if (!buf) {
11372 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11373 return QDF_STATUS_E_NOMEM;
11374 }
11375
11376 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11377 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
11378 WMITLV_SET_HDR(&cmd->tlv_header,
11379 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
11380 WMITLV_GET_STRUCT_TLVLEN
11381 (wmi_pdev_wal_power_debug_cmd_fixed_param));
11382
11383 cmd->pdev_id = param->pdev_id;
11384 cmd->module_id = param->module_id;
11385 cmd->num_args = param->num_args;
11386 buf_ptr += sizeof(*cmd);
11387 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11388 (param->num_args * sizeof(uint32_t)));
11389 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11390 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
11391 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
11392 cmd_args[i] = param->args[i];
11393 WMI_LOGI("%d,", param->args[i]);
11394 }
11395
11396 status = wmi_unified_cmd_send(wmi_handle, buf,
11397 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
11398 if (QDF_IS_STATUS_ERROR(status)) {
11399 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
11400 status);
11401 goto error;
11402 }
11403
11404 return QDF_STATUS_SUCCESS;
11405error:
11406 wmi_buf_free(buf);
11407
11408 return status;
11409}
11410
Govind Singhe7f2f342016-05-23 12:12:52 +053011411/**
11412 * init_cmd_send_tlv() - send initialization cmd to fw
11413 * @wmi_handle: wmi handle
11414 * @param tgt_res_cfg: pointer to target resource configuration
11415 * @param num_mem_chunks: Number of memory chunks
11416 * @param mem_chunks: pointer to target memory chunks
11417 *
11418 * Return: QDF_STATUS_SUCCESS for success or error code
11419 */
11420static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
11421 target_resource_config *tgt_res_cfg, uint8_t num_mem_chunks,
11422 struct wmi_host_mem_chunk *mem_chunks)
11423{
11424 wmi_buf_t buf;
11425 wmi_init_cmd_fixed_param *cmd;
11426 wmi_abi_version my_vers;
11427 int num_whitelist;
11428 uint8_t *buf_ptr;
11429 wmi_resource_config *resource_cfg;
11430 wlan_host_memory_chunk *host_mem_chunks;
11431 uint32_t mem_chunk_len = 0;
11432 uint16_t idx;
11433 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053011434 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053011435
11436 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11437 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11438 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11439 if (!buf) {
11440 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11441 return QDF_STATUS_E_FAILURE;
11442 }
11443
11444 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11445 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11446 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11447
11448 host_mem_chunks = (wlan_host_memory_chunk *)
11449 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11450 + WMI_TLV_HDR_SIZE);
11451
11452 WMITLV_SET_HDR(&cmd->tlv_header,
11453 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11454 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11455
11456 wmi_copy_resource_config(resource_cfg, tgt_res_cfg);
11457 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11458 WMITLV_TAG_STRUC_wmi_resource_config,
11459 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11460
11461 for (idx = 0; idx < num_mem_chunks; ++idx) {
11462 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11463 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11464 WMITLV_GET_STRUCT_TLVLEN
11465 (wlan_host_memory_chunk));
11466 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11467 host_mem_chunks[idx].size = mem_chunks[idx].len;
11468 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
11469 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
11470 idx, host_mem_chunks[idx].size,
11471 host_mem_chunks[idx].ptr);
11472 }
11473 cmd->num_host_mem_chunks = num_mem_chunks;
11474 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11475 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11476 WMITLV_TAG_ARRAY_STRUC,
11477 (sizeof(wlan_host_memory_chunk) *
11478 num_mem_chunks));
11479
11480 num_whitelist = sizeof(version_whitelist) /
11481 sizeof(wmi_whitelist_version_info);
11482 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11483 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11484 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11485 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11486 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11487 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
11488
Govind Singh87542482016-06-08 19:40:11 +053011489#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011490 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11491 &my_vers,
11492 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
11493 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011494#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011495 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
11496 __func__,
11497 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11498 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11499 cmd->host_abi_vers.abi_version_ns_0,
11500 cmd->host_abi_vers.abi_version_ns_1,
11501 cmd->host_abi_vers.abi_version_ns_2,
11502 cmd->host_abi_vers.abi_version_ns_3);
11503
11504 /* Save version sent from host -
11505 * Will be used to check ready event
11506 */
Govind Singh87542482016-06-08 19:40:11 +053011507#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011508 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
11509 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011510#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053011511 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
11512 if (QDF_IS_STATUS_ERROR(ret)) {
11513 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
11514 ret);
11515 wmi_buf_free(buf);
11516 }
11517 return ret;
11518
Govind Singhe7f2f342016-05-23 12:12:52 +053011519}
11520
11521/**
11522 * save_service_bitmap_tlv() - save service bitmap
11523 * @wmi_handle: wmi handle
11524 * @param evt_buf: pointer to event buffer
11525 *
11526 * Return: None
11527 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011528#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011529void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11530{
11531 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11532 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11533
11534 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
11535 param_buf->wmi_service_bitmap,
11536 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
11537}
11538#else
11539void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11540{
11541 return;
11542}
11543
11544#endif
11545
11546/**
11547 * is_service_enabled_tlv() - Check if service enabled
11548 * @param wmi_handle: wmi handle
11549 * @param service_id: service identifier
11550 *
11551 * Return: 1 enabled, 0 disabled
11552 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011553#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011554static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11555 uint32_t service_id)
11556{
11557 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
11558 service_id);
11559}
11560#else
11561static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11562 uint32_t service_id)
11563{
11564 return false;
11565}
11566#endif
11567
11568/**
11569 * extract_service_ready_tlv() - extract service ready event
11570 * @wmi_handle: wmi handle
11571 * @param evt_buf: pointer to received event buffer
11572 * @param cap: pointer to hold target capability information extracted from even
11573 *
11574 * Return: QDF_STATUS_SUCCESS for success or error code
11575 */
11576static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
11577 void *evt_buf, target_capability_info *cap)
11578{
11579 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11580 wmi_service_ready_event_fixed_param *ev;
11581
11582
11583 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11584
11585 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11586 if (!ev) {
11587 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11588 return QDF_STATUS_E_FAILURE;
11589 }
11590
11591 cap->phy_capability = ev->phy_capability;
11592 cap->max_frag_entry = ev->max_frag_entry;
11593 cap->num_rf_chains = ev->num_rf_chains;
11594 cap->ht_cap_info = ev->ht_cap_info;
11595 cap->vht_cap_info = ev->vht_cap_info;
11596 cap->vht_supp_mcs = ev->vht_supp_mcs;
11597 cap->hw_min_tx_power = ev->hw_min_tx_power;
11598 cap->hw_max_tx_power = ev->hw_max_tx_power;
11599 cap->sys_cap_info = ev->sys_cap_info;
11600 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
11601 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
11602 cap->max_num_scan_channels = ev->max_num_scan_channels;
11603 cap->max_supported_macs = ev->max_supported_macs;
11604 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
11605 cap->txrx_chainmask = ev->txrx_chainmask;
11606 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
11607 cap->num_msdu_desc = ev->num_msdu_desc;
11608
11609 return QDF_STATUS_SUCCESS;
11610}
11611
11612/**
11613 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
11614 * @wmi_handle: wmi handle
11615 * @param evt_buf: Pointer to event buffer
11616 * @param cap: pointer to hold HAL reg capabilities
11617 *
11618 * Return: QDF_STATUS_SUCCESS for success or error code
11619 */
11620static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
11621 void *evt_buf, TARGET_HAL_REG_CAPABILITIES *cap)
11622{
11623 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11624
11625 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11626
11627 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
11628 sizeof(uint32_t)),
11629 sizeof(TARGET_HAL_REG_CAPABILITIES));
11630
11631 return QDF_STATUS_SUCCESS;
11632}
11633
11634/**
11635 * extract_host_mem_req_tlv() - Extract host memory request event
11636 * @wmi_handle: wmi handle
11637 * @param evt_buf: pointer to event buffer
11638 * @param num_entries: pointer to hold number of entries requested
11639 *
11640 * Return: Number of entries requested
11641 */
11642static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
11643 void *evt_buf, uint8_t *num_entries)
11644{
11645 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11646 wmi_service_ready_event_fixed_param *ev;
11647
11648 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11649
11650 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11651 if (!ev) {
11652 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11653 return NULL;
11654 }
11655
11656 *num_entries = ev->num_mem_reqs;
11657
11658 return (host_mem_req *)param_buf->mem_reqs;
11659}
11660
11661/**
11662 * save_fw_version_in_service_ready_tlv() - Save fw version in service
11663 * ready function
11664 * @wmi_handle: wmi handle
11665 * @param evt_buf: pointer to event buffer
11666 *
11667 * Return: QDF_STATUS_SUCCESS for success or error code
11668 */
11669static QDF_STATUS
11670save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11671{
11672 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11673 wmi_service_ready_event_fixed_param *ev;
11674
11675
11676 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11677
11678 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11679 if (!ev) {
11680 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11681 return QDF_STATUS_E_FAILURE;
11682 }
11683
Govind Singh87542482016-06-08 19:40:11 +053011684#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011685 /*Save fw version from service ready message */
11686 /*This will be used while sending INIT message */
11687 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
11688 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011689#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011690 return QDF_STATUS_SUCCESS;
11691}
11692
11693/**
11694 * ready_extract_init_status_tlv() - Extract init status from ready event
11695 * @wmi_handle: wmi handle
11696 * @param evt_buf: Pointer to event buffer
11697 *
11698 * Return: ready status
11699 */
11700static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
11701 void *evt_buf)
11702{
11703 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11704 wmi_ready_event_fixed_param *ev = NULL;
11705
11706
11707 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11708 ev = param_buf->fixed_param;
11709
11710 qdf_print("%s:%d\n", __func__, ev->status);
11711
11712 return ev->status;
11713}
11714
11715/**
11716 * ready_extract_mac_addr_tlv() - extract mac address from ready event
11717 * @wmi_handle: wmi handle
11718 * @param evt_buf: pointer to event buffer
11719 * @param macaddr: Pointer to hold MAC address
11720 *
11721 * Return: QDF_STATUS_SUCCESS for success or error code
11722 */
11723static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
11724 void *evt_buf, uint8_t *macaddr)
11725{
11726 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11727 wmi_ready_event_fixed_param *ev = NULL;
11728
11729
11730 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11731 ev = param_buf->fixed_param;
11732
11733 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
11734
11735 return QDF_STATUS_SUCCESS;
11736}
11737
11738/**
11739 * extract_dbglog_data_len_tlv() - extract debuglog data length
11740 * @wmi_handle: wmi handle
11741 * @param evt_buf: pointer to event buffer
11742 *
11743 * Return: length
11744 */
11745static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
11746 void *evt_buf, uint16_t *len)
11747{
11748 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
11749
11750 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
11751
11752 *len = param_buf->num_bufp;
11753
11754 return param_buf->bufp;
11755}
11756
11757/**
11758 * extract_vdev_start_resp_tlv() - extract vdev start response
11759 * @wmi_handle: wmi handle
11760 * @param evt_buf: pointer to event buffer
11761 * @param vdev_rsp: Pointer to hold vdev response
11762 *
11763 * Return: QDF_STATUS_SUCCESS for success or error code
11764 */
11765static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
11766 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
11767{
11768 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
11769 wmi_vdev_start_response_event_fixed_param *ev;
11770
11771 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
11772 if (!param_buf) {
11773 qdf_print("Invalid start response event buffer\n");
11774 return QDF_STATUS_E_INVAL;
11775 }
11776
11777 ev = param_buf->fixed_param;
11778 if (!ev) {
11779 qdf_print("Invalid start response event buffer\n");
11780 return QDF_STATUS_E_INVAL;
11781 }
11782
11783 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
11784
11785 vdev_rsp->vdev_id = ev->vdev_id;
11786 vdev_rsp->requestor_id = ev->requestor_id;
11787 vdev_rsp->resp_type = ev->resp_type;
11788 vdev_rsp->status = ev->status;
11789 vdev_rsp->chain_mask = ev->chain_mask;
11790 vdev_rsp->smps_mode = ev->smps_mode;
11791 vdev_rsp->mac_id = ev->mac_id;
11792 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
11793 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
11794
11795 return QDF_STATUS_SUCCESS;
11796}
11797
11798/**
11799 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
11800 * @wmi_handle: wmi handle
11801 * @param evt_buf: pointer to event buffer
11802 * @param vdev_map: Pointer to hold vdev map
11803 * @param tbttoffset_list: Pointer to tbtt offset list
11804 *
11805 * Return: QDF_STATUS_SUCCESS for success or error code
11806 */
11807static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
11808 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
11809{
11810 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
11811 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
11812
11813 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
11814 if (!param_buf) {
11815 qdf_print("Invalid tbtt update event buffer\n");
11816 return QDF_STATUS_E_INVAL;
11817 }
11818 tbtt_offset_event = param_buf->fixed_param;
11819
11820 *vdev_map = tbtt_offset_event->vdev_map;
11821 *tbttoffset_list = param_buf->tbttoffset_list;
11822
11823 return QDF_STATUS_SUCCESS;
11824}
11825
11826/**
11827 * extract_mgmt_rx_params_tlv() - extract management rx params from event
11828 * @wmi_handle: wmi handle
11829 * @param evt_buf: pointer to event buffer
11830 * @param hdr: Pointer to hold header
11831 * @param bufp: Pointer to hold pointer to rx param buffer
11832 *
11833 * Return: QDF_STATUS_SUCCESS for success or error code
11834 */
11835static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
11836 void *evt_buf, wmi_host_mgmt_rx_hdr *hdr, uint8_t **bufp)
11837{
11838 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
11839 wmi_mgmt_rx_hdr *ev_hdr = NULL;
11840
11841 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
11842 if (!param_tlvs) {
11843 WMI_LOGE("Get NULL point message from FW");
11844 return QDF_STATUS_E_INVAL;
11845 }
11846
11847 ev_hdr = param_tlvs->hdr;
11848 if (!hdr) {
11849 WMI_LOGE("Rx event is NULL");
11850 return QDF_STATUS_E_INVAL;
11851 }
11852
11853
11854 hdr->channel = ev_hdr->channel;
11855 hdr->snr = ev_hdr->snr;
11856 hdr->rate = ev_hdr->rate;
11857 hdr->phy_mode = ev_hdr->phy_mode;
11858 hdr->buf_len = ev_hdr->buf_len;
11859 hdr->status = ev_hdr->status;
11860 hdr->flags = ev_hdr->flags;
11861 hdr->rssi = ev_hdr->rssi;
11862 hdr->tsf_delta = ev_hdr->tsf_delta;
11863 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
11864
11865 *bufp = param_tlvs->bufp;
11866
11867 return QDF_STATUS_SUCCESS;
11868}
11869
11870/**
11871 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
11872 * @wmi_handle: wmi handle
11873 * @param evt_buf: pointer to event buffer
11874 * @param vdev_id: Pointer to hold vdev identifier
11875 *
11876 * Return: QDF_STATUS_SUCCESS for success or error code
11877 */
11878static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
11879 void *evt_buf, uint32_t *vdev_id)
11880{
11881 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
11882 wmi_vdev_stopped_event_fixed_param *resp_event;
11883
11884 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
11885 if (!param_buf) {
11886 WMI_LOGE("Invalid event buffer");
11887 return QDF_STATUS_E_INVAL;
11888 }
11889 resp_event = param_buf->fixed_param;
11890 *vdev_id = resp_event->vdev_id;
11891
11892 return QDF_STATUS_SUCCESS;
11893}
11894
11895/**
11896 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
11897 * @wmi_handle: wmi handle
11898 * @param evt_buf: pointer to event buffer
11899 * @param param: Pointer to hold roam param
11900 *
11901 * Return: QDF_STATUS_SUCCESS for success or error code
11902 */
11903static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
11904 void *evt_buf, wmi_host_roam_event *param)
11905{
11906 WMI_ROAM_EVENTID_param_tlvs *param_buf;
11907 wmi_roam_event_fixed_param *evt;
11908
11909 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
11910 if (!param_buf) {
11911 WMI_LOGE("Invalid roam event buffer");
11912 return QDF_STATUS_E_INVAL;
11913 }
11914
11915 evt = param_buf->fixed_param;
11916 qdf_mem_zero(param, sizeof(*param));
11917
11918 param->vdev_id = evt->vdev_id;
11919 param->reason = evt->reason;
11920 param->rssi = evt->rssi;
11921
11922 return QDF_STATUS_SUCCESS;
11923}
11924
11925/**
11926 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
11927 * @wmi_handle: wmi handle
11928 * @param evt_buf: pointer to event buffer
11929 * @param param: Pointer to hold vdev scan param
11930 *
11931 * Return: QDF_STATUS_SUCCESS for success or error code
11932 */
11933static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
11934 void *evt_buf, wmi_host_scan_event *param)
11935{
11936 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
11937 wmi_scan_event_fixed_param *evt = NULL;
11938
11939 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
11940 evt = param_buf->fixed_param;
11941
11942 qdf_mem_zero(param, sizeof(*param));
11943 switch (evt->event) {
11944 case WMI_SCAN_EVENT_STARTED:
11945 param->event = WMI_HOST_SCAN_EVENT_STARTED;
11946 break;
11947 case WMI_SCAN_EVENT_COMPLETED:
11948 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
11949 break;
11950 case WMI_SCAN_EVENT_BSS_CHANNEL:
11951 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
11952 break;
11953 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
11954 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
11955 break;
11956 case WMI_SCAN_EVENT_DEQUEUED:
11957 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
11958 break;
11959 case WMI_SCAN_EVENT_PREEMPTED:
11960 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
11961 break;
11962 case WMI_SCAN_EVENT_START_FAILED:
11963 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
11964 break;
11965 case WMI_SCAN_EVENT_RESTARTED:
11966 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
11967 break;
11968 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
11969 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
11970 break;
11971 case WMI_SCAN_EVENT_MAX:
11972 default:
11973 param->event = WMI_HOST_SCAN_EVENT_MAX;
11974 break;
11975 };
11976
11977 switch (evt->reason) {
11978 case WMI_SCAN_REASON_NONE:
11979 param->reason = WMI_HOST_SCAN_REASON_NONE;
11980 break;
11981 case WMI_SCAN_REASON_COMPLETED:
11982 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
11983 break;
11984 case WMI_SCAN_REASON_CANCELLED:
11985 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
11986 break;
11987 case WMI_SCAN_REASON_PREEMPTED:
11988 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
11989 break;
11990 case WMI_SCAN_REASON_TIMEDOUT:
11991 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
11992 break;
11993 case WMI_SCAN_REASON_INTERNAL_FAILURE:
11994 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
11995 break;
11996 case WMI_SCAN_REASON_MAX:
11997 default:
11998 param->reason = WMI_HOST_SCAN_REASON_MAX;
11999 break;
12000 };
12001
12002 param->channel_freq = evt->channel_freq;
12003 param->requestor = evt->requestor;
12004 param->scan_id = evt->scan_id;
12005 param->vdev_id = evt->vdev_id;
12006
12007 return QDF_STATUS_SUCCESS;
12008}
12009
12010/**
12011 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
12012 * @wmi_handle: wmi handle
12013 * @param evt_buf: pointer to event buffer
12014 * @param param: Pointer to hold MGMT TX completion params
12015 *
12016 * Return: QDF_STATUS_SUCCESS for success or error code
12017 */
12018static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
12019 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
12020{
12021 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
12022 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
12023
12024 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
12025 evt_buf;
12026 if (!param_buf) {
12027 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
12028 return QDF_STATUS_E_INVAL;
12029 }
12030 cmpl_params = param_buf->fixed_param;
12031
12032 param->desc_id = cmpl_params->desc_id;
12033 param->status = cmpl_params->status;
12034
12035 return QDF_STATUS_SUCCESS;
12036}
12037
12038/**
12039 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
12040 * @wmi_handle: wmi handle
12041 * @param evt_buf: pointer to event buffer
12042 * @param vdev_map: Pointer to hold vdev map
12043 *
12044 * Return: QDF_STATUS_SUCCESS for success or error code
12045 */
12046static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
12047 void *evt_buf, uint32_t *vdev_map)
12048{
12049 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12050 wmi_host_swba_event_fixed_param *swba_event;
12051
12052 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12053 if (!param_buf) {
12054 WMI_LOGE("Invalid swba event buffer");
12055 return QDF_STATUS_E_INVAL;
12056 }
12057 swba_event = param_buf->fixed_param;
12058 *vdev_map = swba_event->vdev_map;
12059
12060 return QDF_STATUS_SUCCESS;
12061}
12062
12063/**
12064 * extract_swba_tim_info_tlv() - extract swba tim info from event
12065 * @wmi_handle: wmi handle
12066 * @param evt_buf: pointer to event buffer
12067 * @param idx: Index to bcn info
12068 * @param tim_info: Pointer to hold tim info
12069 *
12070 * Return: QDF_STATUS_SUCCESS for success or error code
12071 */
12072static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
12073 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
12074{
12075 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12076 wmi_tim_info *tim_info_ev;
12077
12078 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12079 if (!param_buf) {
12080 WMI_LOGE("Invalid swba event buffer");
12081 return QDF_STATUS_E_INVAL;
12082 }
12083
12084 tim_info_ev = &param_buf->tim_info[idx];
12085
12086 tim_info->tim_len = tim_info_ev->tim_len;
12087 tim_info->tim_mcast = tim_info_ev->tim_mcast;
12088 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
12089 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
12090 tim_info->tim_changed = tim_info_ev->tim_changed;
12091 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
12092
12093 return QDF_STATUS_SUCCESS;
12094}
12095
12096/**
12097 * extract_swba_noa_info_tlv() - extract swba NoA information from event
12098 * @wmi_handle: wmi handle
12099 * @param evt_buf: pointer to event buffer
12100 * @param idx: Index to bcn info
12101 * @param p2p_desc: Pointer to hold p2p NoA info
12102 *
12103 * Return: QDF_STATUS_SUCCESS for success or error code
12104 */
12105static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
12106 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
12107{
12108 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12109 wmi_p2p_noa_info *p2p_noa_info;
12110 uint8_t i = 0;
12111
12112 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12113 if (!param_buf) {
12114 WMI_LOGE("Invalid swba event buffer");
12115 return QDF_STATUS_E_INVAL;
12116 }
12117
12118 p2p_noa_info = &param_buf->p2p_noa_info[idx];
12119
12120 p2p_desc->modified = false;
12121 p2p_desc->num_descriptors = 0;
12122 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
12123 p2p_desc->modified = true;
12124 p2p_desc->index =
12125 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
12126 p2p_desc->oppPS =
12127 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
12128 p2p_desc->ctwindow =
12129 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
12130 p2p_desc->num_descriptors =
12131 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
12132 (p2p_noa_info);
12133 for (i = 0; i < p2p_desc->num_descriptors; i++) {
12134 p2p_desc->noa_descriptors[i].type_count =
12135 (uint8_t) p2p_noa_info->noa_descriptors[i].
12136 type_count;
12137 p2p_desc->noa_descriptors[i].duration =
12138 p2p_noa_info->noa_descriptors[i].duration;
12139 p2p_desc->noa_descriptors[i].interval =
12140 p2p_noa_info->noa_descriptors[i].interval;
12141 p2p_desc->noa_descriptors[i].start_time =
12142 p2p_noa_info->noa_descriptors[i].start_time;
12143 }
12144 }
12145
12146 return QDF_STATUS_SUCCESS;
12147}
12148
12149/**
12150 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
12151 * @wmi_handle: wmi handle
12152 * @param evt_buf: pointer to event buffer
12153 * @param ev: Pointer to hold peer param
12154 *
12155 * Return: QDF_STATUS_SUCCESS for success or error code
12156 */
12157static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
12158 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
12159{
12160 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
12161 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
12162
12163 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
12164 kickout_event = param_buf->fixed_param;
12165
12166 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
12167 ev->peer_macaddr);
12168
12169 ev->reason = kickout_event->reason;
12170 ev->rssi = kickout_event->rssi;
12171
12172 return QDF_STATUS_SUCCESS;
12173}
12174
12175/**
12176 * extract_all_stats_counts_tlv() - extract all stats count from event
12177 * @wmi_handle: wmi handle
12178 * @param evt_buf: pointer to event buffer
12179 * @param stats_param: Pointer to hold stats count
12180 *
12181 * Return: QDF_STATUS_SUCCESS for success or error code
12182 */
12183static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
12184 void *evt_buf, wmi_host_stats_event *stats_param)
12185{
12186 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12187 wmi_stats_event_fixed_param *ev;
12188
12189 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12190
12191 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12192 if (!ev) {
12193 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
12194 return QDF_STATUS_E_FAILURE;
12195 }
12196
12197 switch (ev->stats_id) {
12198 case WMI_REQUEST_PEER_STAT:
12199 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
12200 break;
12201
12202 case WMI_REQUEST_AP_STAT:
12203 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
12204 break;
12205
12206 case WMI_REQUEST_PDEV_STAT:
12207 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
12208 break;
12209
12210 case WMI_REQUEST_VDEV_STAT:
12211 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
12212 break;
12213
12214 case WMI_REQUEST_BCNFLT_STAT:
12215 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
12216 break;
12217
12218 case WMI_REQUEST_VDEV_RATE_STAT:
12219 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
12220 break;
12221
12222 default:
12223 stats_param->stats_id = 0;
12224 break;
12225
12226 }
12227
12228 stats_param->num_pdev_stats = ev->num_pdev_stats;
12229 stats_param->num_pdev_ext_stats = 0;
12230 stats_param->num_vdev_stats = ev->num_vdev_stats;
12231 stats_param->num_peer_stats = ev->num_peer_stats;
12232 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
12233 stats_param->num_chan_stats = ev->num_chan_stats;
12234
12235 return QDF_STATUS_SUCCESS;
12236}
12237
12238/**
12239 * extract_pdev_stats_tlv() - extract pdev stats from event
12240 * @wmi_handle: wmi handle
12241 * @param evt_buf: pointer to event buffer
12242 * @param index: Index into pdev stats
12243 * @param pdev_stats: Pointer to hold pdev stats
12244 *
12245 * Return: QDF_STATUS_SUCCESS for success or error code
12246 */
12247static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
12248 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
12249{
12250 return QDF_STATUS_SUCCESS;
12251}
12252
12253/**
12254 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
12255 * @wmi_handle: wmi handle
12256 * @param evt_buf: pointer to event buffer
12257 * @param index: Index into extended pdev stats
12258 * @param pdev_ext_stats: Pointer to hold extended pdev stats
12259 *
12260 * Return: QDF_STATUS_SUCCESS for success or error code
12261 */
12262static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
12263 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
12264{
12265 return QDF_STATUS_SUCCESS;
12266}
12267
12268/**
12269 * extract_vdev_stats_tlv() - extract vdev stats from event
12270 * @wmi_handle: wmi handle
12271 * @param evt_buf: pointer to event buffer
12272 * @param index: Index into vdev stats
12273 * @param vdev_stats: Pointer to hold vdev stats
12274 *
12275 * Return: QDF_STATUS_SUCCESS for success or error code
12276 */
12277static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
12278 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
12279{
12280 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12281 wmi_stats_event_fixed_param *ev_param;
12282 uint8_t *data;
12283
12284 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12285 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12286 data = (uint8_t *) param_buf->data;
12287
12288 if (index < ev_param->num_vdev_stats) {
12289 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
12290 ((ev_param->num_pdev_stats) *
12291 sizeof(wmi_pdev_stats)) +
12292 (index * sizeof(wmi_vdev_stats)));
12293
12294 vdev_stats->vdev_id = ev->vdev_id;
12295 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
12296 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
12297
12298 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
12299 sizeof(ev->tx_frm_cnt));
12300 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
12301 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
12302 ev->multiple_retry_cnt,
12303 sizeof(ev->multiple_retry_cnt));
12304 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
12305 sizeof(ev->fail_cnt));
12306 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
12307 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
12308 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
12309 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
12310 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
12311 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
12312 sizeof(ev->tx_rate_history));
12313 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
12314 sizeof(ev->bcn_rssi_history));
12315
12316 }
12317
12318 return QDF_STATUS_SUCCESS;
12319}
12320
12321/**
12322 * extract_peer_stats_tlv() - extract peer stats from event
12323 * @wmi_handle: wmi handle
12324 * @param evt_buf: pointer to event buffer
12325 * @param index: Index into peer stats
12326 * @param peer_stats: Pointer to hold peer stats
12327 *
12328 * Return: QDF_STATUS_SUCCESS for success or error code
12329 */
12330static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
12331 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
12332{
12333 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12334 wmi_stats_event_fixed_param *ev_param;
12335 uint8_t *data;
12336
12337 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12338 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12339 data = (uint8_t *) param_buf->data;
12340
12341 if (index < ev_param->num_peer_stats) {
12342 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
12343 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12344 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12345 (index * sizeof(wmi_peer_stats)));
12346
12347 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
12348
12349 OS_MEMCPY(&(peer_stats->peer_macaddr),
12350 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
12351
12352 peer_stats->peer_rssi = ev->peer_rssi;
12353 peer_stats->peer_tx_rate = ev->peer_tx_rate;
12354 peer_stats->peer_rx_rate = ev->peer_rx_rate;
12355 }
12356
12357 return QDF_STATUS_SUCCESS;
12358}
12359
12360/**
12361 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
12362 * @wmi_handle: wmi handle
12363 * @param evt_buf: pointer to event buffer
12364 * @param index: Index into bcn fault stats
12365 * @param bcnflt_stats: Pointer to hold bcn fault stats
12366 *
12367 * Return: QDF_STATUS_SUCCESS for success or error code
12368 */
12369static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
12370 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
12371{
12372 return QDF_STATUS_SUCCESS;
12373}
12374
12375/**
12376 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
12377 * @wmi_handle: wmi handle
12378 * @param evt_buf: pointer to event buffer
12379 * @param index: Index into extended peer stats
12380 * @param peer_extd_stats: Pointer to hold extended peer stats
12381 *
12382 * Return: QDF_STATUS_SUCCESS for success or error code
12383 */
12384static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
12385 void *evt_buf, uint32_t index,
12386 wmi_host_peer_extd_stats *peer_extd_stats)
12387{
12388 return QDF_STATUS_SUCCESS;
12389}
12390
12391/**
12392 * extract_chan_stats_tlv() - extract chan stats from event
12393 * @wmi_handle: wmi handle
12394 * @param evt_buf: pointer to event buffer
12395 * @param index: Index into chan stats
12396 * @param vdev_extd_stats: Pointer to hold chan stats
12397 *
12398 * Return: QDF_STATUS_SUCCESS for success or error code
12399 */
12400static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
12401 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
12402{
12403 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12404 wmi_stats_event_fixed_param *ev_param;
12405 uint8_t *data;
12406
12407 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12408 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12409 data = (uint8_t *) param_buf->data;
12410
12411 if (index < ev_param->num_chan_stats) {
12412 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
12413 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12414 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12415 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
12416 (index * sizeof(wmi_chan_stats)));
12417
12418
12419 /* Non-TLV doesnt have num_chan_stats */
12420 chan_stats->chan_mhz = ev->chan_mhz;
12421 chan_stats->sampling_period_us = ev->sampling_period_us;
12422 chan_stats->rx_clear_count = ev->rx_clear_count;
12423 chan_stats->tx_duration_us = ev->tx_duration_us;
12424 chan_stats->rx_duration_us = ev->rx_duration_us;
12425 }
12426
12427 return QDF_STATUS_SUCCESS;
12428}
12429
12430/**
12431 * extract_profile_ctx_tlv() - extract profile context from event
12432 * @wmi_handle: wmi handle
12433 * @param evt_buf: pointer to event buffer
12434 * @idx: profile stats index to extract
12435 * @param profile_ctx: Pointer to hold profile context
12436 *
12437 * Return: QDF_STATUS_SUCCESS for success or error code
12438 */
12439static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
12440 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
12441{
12442 return QDF_STATUS_SUCCESS;
12443}
12444
12445/**
12446 * extract_profile_data_tlv() - extract profile data from event
12447 * @wmi_handle: wmi handle
12448 * @param evt_buf: pointer to event buffer
12449 * @param profile_data: Pointer to hold profile data
12450 *
12451 * Return: QDF_STATUS_SUCCESS for success or error code
12452 */
12453static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
12454 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
12455{
12456
12457 return QDF_STATUS_SUCCESS;
12458}
12459
12460/**
12461 * extract_chan_info_event_tlv() - extract chan information from event
12462 * @wmi_handle: wmi handle
12463 * @param evt_buf: pointer to event buffer
12464 * @param chan_info: Pointer to hold chan information
12465 *
12466 * Return: QDF_STATUS_SUCCESS for success or error code
12467 */
12468static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
12469 void *evt_buf, wmi_host_chan_info_event *chan_info)
12470{
12471 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
12472 wmi_chan_info_event_fixed_param *ev;
12473
12474 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
12475
12476 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
12477 if (!ev) {
12478 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
12479 return QDF_STATUS_E_FAILURE;
12480 }
12481
12482 chan_info->err_code = ev->err_code;
12483 chan_info->freq = ev->freq;
12484 chan_info->cmd_flags = ev->cmd_flags;
12485 chan_info->noise_floor = ev->noise_floor;
12486 chan_info->rx_clear_count = ev->rx_clear_count;
12487 chan_info->cycle_count = ev->cycle_count;
12488
12489 return QDF_STATUS_SUCCESS;
12490}
12491
12492/**
12493 * extract_channel_hopping_event_tlv() - extract channel hopping param
12494 * from event
12495 * @wmi_handle: wmi handle
12496 * @param evt_buf: pointer to event buffer
12497 * @param ch_hopping: Pointer to hold channel hopping param
12498 *
12499 * Return: QDF_STATUS_SUCCESS for success or error code
12500 */
12501static QDF_STATUS extract_channel_hopping_event_tlv(wmi_unified_t wmi_handle,
12502 void *evt_buf, wmi_host_pdev_channel_hopping_event *chan_info)
12503{
12504 return QDF_STATUS_SUCCESS;
12505}
12506
Kiran Venkatappa06520822016-08-10 23:55:40 +053012507/**
12508 * extract_service_ready_ext_tlv() - extract basic extended service ready params
12509 * from event
12510 * @wmi_handle: wmi handle
12511 * @param evt_buf: pointer to event buffer
12512 * @param param: Pointer to hold evt buf
12513 *
12514 * Return: QDF_STATUS_SUCCESS for success or error code
12515 */
12516static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
12517 uint8_t *event, struct wmi_host_service_ext_param *param)
12518{
12519 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12520 wmi_service_ready_ext_event_fixed_param *ev;
12521 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
12522 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
12523
12524 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12525 if (!param_buf)
12526 return -EINVAL;
12527
12528 ev = param_buf->fixed_param;
12529 if (!ev)
12530 return -EINVAL;
12531
12532 /* Move this to host based bitmap */
12533 param->default_conc_scan_config_bits =
12534 ev->default_conc_scan_config_bits;
12535 param->default_fw_config_bits = ev->default_fw_config_bits;
12536 param->he_cap_info = ev->he_cap_info;
12537 param->mpdu_density = ev->mpdu_density;
12538 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
12539 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
12540
12541 hw_caps = param_buf->soc_hw_mode_caps;
12542 param->num_hw_modes = hw_caps->num_hw_modes;
12543
12544 reg_caps = param_buf->soc_hal_reg_caps;
12545 param->num_phy = reg_caps->num_phy;
12546
12547 return QDF_STATUS_SUCCESS;
12548}
12549
12550/**
12551 * extract_hw_mode_cap_service_ready_ext_tlv() -
12552 * extract HW mode cap from service ready event
12553 * @wmi_handle: wmi handle
12554 * @param evt_buf: pointer to event buffer
12555 * @param param: Pointer to hold evt buf
12556 * @param hw_mode_idx: hw mode idx should be less than num_mode
12557 *
12558 * Return: QDF_STATUS_SUCCESS for success or error code
12559 */
12560static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
12561 wmi_unified_t wmi_handle,
12562 uint8_t *event, uint8_t hw_mode_idx,
12563 struct wmi_host_hw_mode_caps *param)
12564{
12565 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12566 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
12567
12568 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12569 if (!param_buf)
12570 return -EINVAL;
12571
12572 hw_caps = param_buf->soc_hw_mode_caps;
12573 if (hw_mode_idx >= hw_caps->num_hw_modes)
12574 return -EINVAL;
12575
12576 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
12577 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
12578
12579 return QDF_STATUS_SUCCESS;
12580}
12581
12582/**
12583 * extract_mac_phy_cap_service_ready_ext_tlv() -
12584 * extract MAC phy cap from service ready event
12585 * @wmi_handle: wmi handle
12586 * @param evt_buf: pointer to event buffer
12587 * @param param: Pointer to hold evt buf
12588 * @param hw_mode_idx: hw mode idx should be less than num_mode
12589 *
12590 * Return: QDF_STATUS_SUCCESS for success or error code
12591 */
12592static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
12593 wmi_unified_t wmi_handle,
12594 uint8_t *event, uint8_t hw_mode_idx,
12595 struct wmi_host_mac_phy_caps *param)
12596{
12597 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12598 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
12599 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
12600
12601 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12602 if (!param_buf)
12603 return -EINVAL;
12604
12605 hw_caps = param_buf->soc_hw_mode_caps;
12606 if (hw_mode_idx >= hw_caps->num_hw_modes)
12607 return -EINVAL;
12608
12609 mac_phy_caps = &param_buf->mac_phy_caps[hw_mode_idx];
12610
12611 param->hw_mode_id = mac_phy_caps->hw_mode_id;
12612 param->pdev_id = mac_phy_caps->pdev_id;
12613 param->phy_id = mac_phy_caps->phy_id;
12614 param->supports_11b = mac_phy_caps->supports_11b;
12615 param->supports_11g = mac_phy_caps->supports_11g;
12616 param->supports_11a = mac_phy_caps->supports_11a;
12617 param->supports_11n = mac_phy_caps->supports_11n;
12618 param->supports_11ac = mac_phy_caps->supports_11ac;
12619 param->supports_11ax = mac_phy_caps->supports_11ax;
12620
12621 param->supported_bands = mac_phy_caps->supported_bands;
12622 param->ampdu_density = mac_phy_caps->ampdu_density;
12623 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
12624 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
12625 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
12626 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
12627 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
12628 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
12629 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
12630 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
12631 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
12632 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
12633 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
12634 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
12635 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
12636 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
12637 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
12638 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
12639
12640 return QDF_STATUS_SUCCESS;
12641}
12642
12643/**
12644 * extract_reg_cap_service_ready_ext_tlv() -
12645 * extract REG cap from service ready event
12646 * @wmi_handle: wmi handle
12647 * @param evt_buf: pointer to event buffer
12648 * @param param: Pointer to hold evt buf
12649 * @param phy_idx: phy idx should be less than num_mode
12650 *
12651 * Return: QDF_STATUS_SUCCESS for success or error code
12652 */
12653static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
12654 wmi_unified_t wmi_handle,
12655 uint8_t *event, uint8_t phy_idx,
12656 struct WMI_HOST_HAL_REG_CAPABILITIES_EXT *param)
12657{
12658 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12659 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
12660 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
12661
12662 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12663 if (!param_buf)
12664 return -EINVAL;
12665
12666 reg_caps = param_buf->soc_hal_reg_caps;
12667 if (phy_idx >= reg_caps->num_phy)
12668 return -EINVAL;
12669
12670 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
12671
12672 param->phy_id = ext_reg_cap->phy_id;
12673 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
12674 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
12675 param->regcap1 = ext_reg_cap->regcap1;
12676 param->regcap2 = ext_reg_cap->regcap2;
12677 param->wireless_modes = ext_reg_cap->wireless_modes;
12678 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
12679 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
12680 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
12681 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
12682
12683 return QDF_STATUS_SUCCESS;
12684}
12685
Govind Singh06c18392016-06-10 10:33:19 +053012686#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhecf03cd2016-05-12 12:45:51 +053012687static bool is_management_record_tlv(uint32_t cmd_id)
12688{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053012689 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053012690 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053012691
Govind Singhecf03cd2016-05-12 12:45:51 +053012692 return false;
12693}
Govind Singh06c18392016-06-10 10:33:19 +053012694#endif
Govind Singhecf03cd2016-05-12 12:45:51 +053012695
Govind Singh5eb51532016-03-09 11:34:12 +053012696struct wmi_ops tlv_ops = {
12697 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
12698 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
12699 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053012700 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
12701 .send_hidden_ssid_vdev_restart_cmd =
12702 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012703 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
12704 .send_peer_param_cmd = send_peer_param_cmd_tlv,
12705 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012706 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012707 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012708 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070012709 .send_peer_rx_reorder_queue_setup_cmd =
12710 send_peer_rx_reorder_queue_setup_cmd_tlv,
12711 .send_peer_rx_reorder_queue_remove_cmd =
12712 send_peer_rx_reorder_queue_remove_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012713 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
12714 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
12715 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
12716 .send_suspend_cmd = send_suspend_cmd_tlv,
12717 .send_resume_cmd = send_resume_cmd_tlv,
12718 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
12719 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
12720 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
12721 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
12722 .send_dbglog_cmd = send_dbglog_cmd_tlv,
12723 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
12724 .send_stats_request_cmd = send_stats_request_cmd_tlv,
12725 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
12726 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012727#ifndef CONFIG_MCL
12728 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
12729#endif
Govind Singh5eb51532016-03-09 11:34:12 +053012730 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
12731 .send_scan_start_cmd = send_scan_start_cmd_tlv,
12732 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
12733 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012734 .send_mgmt_cmd = send_mgmt_cmd_tlv,
12735 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
12736 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012737 .send_set_sta_uapsd_auto_trig_cmd =
12738 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012739 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
12740 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
12741 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
12742 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
12743 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053012744 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
12745 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
12746 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
12747 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
12748 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
12749 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
12750 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012751 .send_ocb_start_timing_advert_cmd =
12752 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053012753 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
12754 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
12755 .send_set_mcc_channel_time_latency_cmd =
12756 send_set_mcc_channel_time_latency_cmd_tlv,
12757 .send_set_mcc_channel_time_quota_cmd =
12758 send_set_mcc_channel_time_quota_cmd_tlv,
12759 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
12760 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053012761 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012762 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
12763 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
12764 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012765 .send_probe_rsp_tmpl_send_cmd =
12766 send_probe_rsp_tmpl_send_cmd_tlv,
12767 .send_p2p_go_set_beacon_ie_cmd =
12768 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053012769 .send_setup_install_key_cmd =
12770 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012771 .send_set_gateway_params_cmd =
12772 send_set_gateway_params_cmd_tlv,
12773 .send_set_rssi_monitoring_cmd =
12774 send_set_rssi_monitoring_cmd_tlv,
12775 .send_scan_probe_setoui_cmd =
12776 send_scan_probe_setoui_cmd_tlv,
12777 .send_reset_passpoint_network_list_cmd =
12778 send_reset_passpoint_network_list_cmd_tlv,
12779 .send_set_passpoint_network_list_cmd =
12780 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053012781 .send_roam_scan_offload_rssi_thresh_cmd =
12782 send_roam_scan_offload_rssi_thresh_cmd_tlv,
12783 .send_roam_scan_filter_cmd =
12784 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012785 .send_set_epno_network_list_cmd =
12786 send_set_epno_network_list_cmd_tlv,
12787 .send_ipa_offload_control_cmd =
12788 send_ipa_offload_control_cmd_tlv,
12789 .send_extscan_get_capabilities_cmd =
12790 send_extscan_get_capabilities_cmd_tlv,
12791 .send_extscan_get_cached_results_cmd =
12792 send_extscan_get_cached_results_cmd_tlv,
12793 .send_extscan_stop_change_monitor_cmd =
12794 send_extscan_stop_change_monitor_cmd_tlv,
12795 .send_extscan_start_change_monitor_cmd =
12796 send_extscan_start_change_monitor_cmd_tlv,
12797 .send_extscan_stop_hotlist_monitor_cmd =
12798 send_extscan_stop_hotlist_monitor_cmd_tlv,
12799 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
12800 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
12801 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
12802 .send_plm_start_cmd = send_plm_start_cmd_tlv,
12803 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012804#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053012805 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012806#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053012807 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
12808 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
12809 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
12810 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
12811 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053012812 .send_snr_request_cmd = send_snr_request_cmd_tlv,
12813 .send_snr_cmd = send_snr_cmd_tlv,
12814 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012815#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053012816 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
12817 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
12818 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
12819 .send_lphb_config_udp_pkt_filter_cmd =
12820 send_lphb_config_udp_pkt_filter_cmd_tlv,
12821 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
12822 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
12823 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012824 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
12825 .send_process_update_edca_param_cmd =
12826 send_process_update_edca_param_cmd_tlv,
12827 .send_roam_scan_offload_mode_cmd =
12828 send_roam_scan_offload_mode_cmd_tlv,
12829 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
12830 .send_roam_scan_offload_ap_profile_cmd =
12831 send_roam_scan_offload_ap_profile_cmd_tlv,
12832#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053012833 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
12834 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012835#ifdef FEATURE_WLAN_RA_FILTERING
Govind Singh20c5dac2016-03-07 15:33:31 +053012836 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012837#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053012838 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
12839 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
12840 .send_dfs_phyerr_filter_offload_en_cmd =
12841 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053012842 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
12843 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
12844 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
12845 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
12846 .send_del_ts_cmd = send_del_ts_cmd_tlv,
12847 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
12848 .send_add_ts_cmd = send_add_ts_cmd_tlv,
12849 .send_enable_disable_packet_filter_cmd =
12850 send_enable_disable_packet_filter_cmd_tlv,
12851 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
12852 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
12853 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
12854 .send_process_gtk_offload_getinfo_cmd =
12855 send_process_gtk_offload_getinfo_cmd_tlv,
12856 .send_process_add_periodic_tx_ptrn_cmd =
12857 send_process_add_periodic_tx_ptrn_cmd_tlv,
12858 .send_process_del_periodic_tx_ptrn_cmd =
12859 send_process_del_periodic_tx_ptrn_cmd_tlv,
12860 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
12861 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
12862 .send_set_app_type2_params_in_fw_cmd =
12863 send_set_app_type2_params_in_fw_cmd_tlv,
12864 .send_set_auto_shutdown_timer_cmd =
12865 send_set_auto_shutdown_timer_cmd_tlv,
12866 .send_nan_req_cmd = send_nan_req_cmd_tlv,
12867 .send_process_dhcpserver_offload_cmd =
12868 send_process_dhcpserver_offload_cmd_tlv,
12869 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
12870 .send_process_ch_avoid_update_cmd =
12871 send_process_ch_avoid_update_cmd_tlv,
12872 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
12873 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
12874 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
12875 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
12876 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
12877 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012878#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012879 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012880#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012881 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053012882 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053012883 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053012884 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012885 .send_set_base_macaddr_indicate_cmd =
12886 send_set_base_macaddr_indicate_cmd_tlv,
12887 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
12888 .send_enable_specific_fw_logs_cmd =
12889 send_enable_specific_fw_logs_cmd_tlv,
12890 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012891 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012892 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012893 .send_pdev_set_dual_mac_config_cmd =
12894 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012895 .send_enable_arp_ns_offload_cmd =
12896 send_enable_arp_ns_offload_cmd_tlv,
12897 .send_app_type1_params_in_fw_cmd =
12898 send_app_type1_params_in_fw_cmd_tlv,
12899 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
12900 .send_process_roam_synch_complete_cmd =
12901 send_process_roam_synch_complete_cmd_tlv,
12902 .send_unit_test_cmd = send_unit_test_cmd_tlv,
12903 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
12904 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012905 .send_roam_scan_offload_scan_period_cmd =
12906 send_roam_scan_offload_scan_period_cmd_tlv,
12907 .send_roam_scan_offload_chan_list_cmd =
12908 send_roam_scan_offload_chan_list_cmd_tlv,
12909 .send_roam_scan_offload_rssi_change_cmd =
12910 send_roam_scan_offload_rssi_change_cmd_tlv,
12911 .send_get_buf_extscan_hotlist_cmd =
12912 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053012913 .send_adapt_dwelltime_params_cmd =
12914 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053012915 .init_cmd_send = init_cmd_send_tlv,
12916 .get_target_cap_from_service_ready = extract_service_ready_tlv,
12917 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
12918 .extract_host_mem_req = extract_host_mem_req_tlv,
12919 .save_service_bitmap = save_service_bitmap_tlv,
12920 .is_service_enabled = is_service_enabled_tlv,
12921 .save_fw_version = save_fw_version_in_service_ready_tlv,
12922 .ready_extract_init_status = ready_extract_init_status_tlv,
12923 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
12924 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
12925 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
12926 .extract_tbttoffset_update_params =
12927 extract_tbttoffset_update_params_tlv,
12928 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
12929 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
12930 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
12931 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
12932 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
12933 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
12934 .extract_swba_tim_info = extract_swba_tim_info_tlv,
12935 .extract_swba_noa_info = extract_swba_noa_info_tlv,
12936 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
12937 .extract_all_stats_count = extract_all_stats_counts_tlv,
12938 .extract_pdev_stats = extract_pdev_stats_tlv,
12939 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
12940 .extract_vdev_stats = extract_vdev_stats_tlv,
12941 .extract_peer_stats = extract_peer_stats_tlv,
12942 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
12943 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
12944 .extract_chan_stats = extract_chan_stats_tlv,
12945 .extract_profile_ctx = extract_profile_ctx_tlv,
12946 .extract_profile_data = extract_profile_data_tlv,
12947 .extract_chan_info_event = extract_chan_info_event_tlv,
12948 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053012949 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053012950 .send_encrypt_decrypt_send_cmd =
12951 send_encrypt_decrypt_send_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053012952 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053012953 .extract_service_ready_ext = extract_service_ready_ext_tlv,
12954 .extract_hw_mode_cap_service_ready_ext =
12955 extract_hw_mode_cap_service_ready_ext_tlv,
12956 .extract_mac_phy_cap_service_ready_ext =
12957 extract_mac_phy_cap_service_ready_ext_tlv,
12958 .extract_reg_cap_service_ready_ext =
12959 extract_reg_cap_service_ready_ext_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012960};
12961
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053012962#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053012963/**
12964 * populate_tlv_service() - populates wmi services
12965 *
12966 * @param wmi_service: Pointer to hold wmi_service
12967 * Return: None
12968 */
12969static void populate_tlv_service(uint32_t *wmi_service)
12970{
12971 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
12972 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
12973 wmi_service[wmi_service_roam_scan_offload] =
12974 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
12975 wmi_service[wmi_service_bcn_miss_offload] =
12976 WMI_SERVICE_BCN_MISS_OFFLOAD;
12977 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
12978 wmi_service[wmi_service_sta_advanced_pwrsave] =
12979 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
12980 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
12981 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
12982 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
12983 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
12984 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
12985 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
12986 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
12987 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
12988 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
12989 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
12990 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
12991 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
12992 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
12993 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
12994 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
12995 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
12996 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
12997 wmi_service[wmi_service_packet_power_save] =
12998 WMI_SERVICE_PACKET_POWER_SAVE;
12999 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
13000 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
13001 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
13002 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
13003 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
13004 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
13005 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
13006 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
13007 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
13008 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
13009 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
13010 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
13011 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
13012 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
13013 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
13014 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
13015 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
13016 wmi_service[wmi_service_mcc_bcn_interval_change] =
13017 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
13018 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
13019 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
13020 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
13021 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
13022 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
13023 wmi_service[wmi_service_lte_ant_share_support] =
13024 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
13025 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
13026 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
13027 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
13028 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
13029 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
13030 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
13031 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
13032 wmi_service[wmi_service_bcn_txrate_override] =
13033 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
13034 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
13035 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
13036 wmi_service[wmi_service_estimate_linkspeed] =
13037 WMI_SERVICE_ESTIMATE_LINKSPEED;
13038 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
13039 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
13040 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
13041 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
13042 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
13043 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
13044 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
13045 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
13046 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
13047 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
13048 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
13049 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
13050 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
13051 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
13052 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
13053 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
13054 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
13055 wmi_service[wmi_service_sap_auth_offload] =
13056 WMI_SERVICE_SAP_AUTH_OFFLOAD;
13057 wmi_service[wmi_service_dual_band_simultaneous_support] =
13058 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
13059 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
13060 wmi_service[wmi_service_ap_arpns_offload] =
13061 WMI_SERVICE_AP_ARPNS_OFFLOAD;
13062 wmi_service[wmi_service_per_band_chainmask_support] =
13063 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
13064 wmi_service[wmi_service_packet_filter_offload] =
13065 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
13066 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
13067 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
13068 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
13069 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
13070
13071 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
13072 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
13073 wmi_service[wmi_service_smart_antenna_sw_support] =
13074 WMI_SERVICE_UNAVAILABLE;
13075 wmi_service[wmi_service_smart_antenna_hw_support] =
13076 WMI_SERVICE_UNAVAILABLE;
13077 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
13078 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
13079 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
13080 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
13081 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
13082 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
13083 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
13084 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
13085 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
13086 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
13087 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
13088
13089 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
13090 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
13091 wmi_service[wmi_service_periodic_chan_stat_support] =
13092 WMI_SERVICE_UNAVAILABLE;
13093 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
13094 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
13095 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
13096}
13097
13098/**
13099 * populate_tlv_event_id() - populates wmi event ids
13100 *
13101 * @param event_ids: Pointer to hold event ids
13102 * Return: None
13103 */
13104static void populate_tlv_events_id(uint32_t *event_ids)
13105{
13106 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
13107 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
13108 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
13109 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
13110 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
13111 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
13112 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
13113 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
13114 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
13115 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
13116 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
13117 event_ids[wmi_service_ready_ext_event_id] =
13118 WMI_SERVICE_READY_EXT_EVENTID;
13119 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
13120 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
13121 event_ids[wmi_vdev_install_key_complete_event_id] =
13122 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
13123 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
13124 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
13125
13126 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
13127 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
13128 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
13129 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
13130 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
13131 event_ids[wmi_peer_estimated_linkspeed_event_id] =
13132 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
13133 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
13134 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
13135 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
13136 event_ids[wmi_tbttoffset_update_event_id] =
13137 WMI_TBTTOFFSET_UPDATE_EVENTID;
13138 event_ids[wmi_offload_bcn_tx_status_event_id] =
13139 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
13140 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
13141 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
13142 event_ids[wmi_mgmt_tx_completion_event_id] =
13143 WMI_MGMT_TX_COMPLETION_EVENTID;
13144
13145 event_ids[wmi_tx_delba_complete_event_id] =
13146 WMI_TX_DELBA_COMPLETE_EVENTID;
13147 event_ids[wmi_tx_addba_complete_event_id] =
13148 WMI_TX_ADDBA_COMPLETE_EVENTID;
13149 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
13150
13151 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
13152
13153 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
13154 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
13155
13156 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
13157
13158 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
13159
13160 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
13161
13162 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
13163 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
13164 event_ids[wmi_do_wow_disable_ack_event_id] =
13165 WMI_D0_WOW_DISABLE_ACK_EVENTID;
13166 event_ids[wmi_wow_initial_wakeup_event_id] =
13167 WMI_WOW_INITIAL_WAKEUP_EVENTID;
13168
13169 event_ids[wmi_rtt_meas_report_event_id] =
13170 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
13171 event_ids[wmi_tsf_meas_report_event_id] =
13172 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
13173 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
13174 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
13175 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
13176 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
13177 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
13178 event_ids[wmi_update_fw_mem_dump_event_id] =
13179 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
13180 event_ids[wmi_diag_event_id_log_supported_event_id] =
13181 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
13182 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
13183 event_ids[wmi_nlo_scan_complete_event_id] =
13184 WMI_NLO_SCAN_COMPLETE_EVENTID;
13185 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
13186 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
13187
13188 event_ids[wmi_gtk_offload_status_event_id] =
13189 WMI_GTK_OFFLOAD_STATUS_EVENTID;
13190 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
13191 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
13192 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
13193
13194 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
13195
13196 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
13197
13198 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
13199 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
13200 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
13201 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
13202 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
13203 event_ids[wmi_wlan_profile_data_event_id] =
13204 WMI_WLAN_PROFILE_DATA_EVENTID;
13205 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
13206 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
13207 event_ids[wmi_vdev_get_keepalive_event_id] =
13208 WMI_VDEV_GET_KEEPALIVE_EVENTID;
13209 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
13210
13211 event_ids[wmi_diag_container_event_id] =
13212 WMI_DIAG_DATA_CONTAINER_EVENTID;
13213
13214 event_ids[wmi_host_auto_shutdown_event_id] =
13215 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
13216
13217 event_ids[wmi_update_whal_mib_stats_event_id] =
13218 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
13219
13220 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
13221 event_ids[wmi_update_vdev_rate_stats_event_id] =
13222 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
13223
13224 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
13225
13226 /** Set OCB Sched Response, deprecated */
13227 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
13228
13229 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
13230 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
13231 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
13232
13233 /* GPIO Event */
13234 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
13235 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
13236
13237 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
13238 event_ids[wmi_rfkill_state_change_event_id] =
13239 WMI_RFKILL_STATE_CHANGE_EVENTID;
13240
13241 /* TDLS Event */
13242 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
13243
13244 event_ids[wmi_batch_scan_enabled_event_id] =
13245 WMI_BATCH_SCAN_ENABLED_EVENTID;
13246 event_ids[wmi_batch_scan_result_event_id] =
13247 WMI_BATCH_SCAN_RESULT_EVENTID;
13248 /* OEM Event */
13249 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
13250 event_ids[wmi_oem_meas_report_event_id] =
13251 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
13252 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
13253
13254 /* NAN Event */
13255 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
13256
13257 /* LPI Event */
13258 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
13259 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
13260 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
13261
13262 /* ExtScan events */
13263 event_ids[wmi_extscan_start_stop_event_id] =
13264 WMI_EXTSCAN_START_STOP_EVENTID;
13265 event_ids[wmi_extscan_operation_event_id] =
13266 WMI_EXTSCAN_OPERATION_EVENTID;
13267 event_ids[wmi_extscan_table_usage_event_id] =
13268 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
13269 event_ids[wmi_extscan_cached_results_event_id] =
13270 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
13271 event_ids[wmi_extscan_wlan_change_results_event_id] =
13272 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
13273 event_ids[wmi_extscan_hotlist_match_event_id] =
13274 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
13275 event_ids[wmi_extscan_capabilities_event_id] =
13276 WMI_EXTSCAN_CAPABILITIES_EVENTID;
13277 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
13278 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
13279
13280 /* mDNS offload events */
13281 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
13282
13283 /* SAP Authentication offload events */
13284 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
13285 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
13286
13287 /** Out-of-context-of-bss (OCB) events */
13288 event_ids[wmi_ocb_set_config_resp_event_id] =
13289 WMI_OCB_SET_CONFIG_RESP_EVENTID;
13290 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
13291 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
13292 event_ids[wmi_dcc_get_stats_resp_event_id] =
13293 WMI_DCC_GET_STATS_RESP_EVENTID;
13294 event_ids[wmi_dcc_update_ndl_resp_event_id] =
13295 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
13296 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
13297 /* System-On-Chip events */
13298 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
13299 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
13300 event_ids[wmi_soc_hw_mode_transition_event_id] =
13301 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
13302 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
13303 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
13304}
13305
13306/**
13307 * populate_pdev_param_tlv() - populates pdev params
13308 *
13309 * @param pdev_param: Pointer to hold pdev params
13310 * Return: None
13311 */
13312static void populate_pdev_param_tlv(uint32_t *pdev_param)
13313{
13314 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
13315 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
13316 pdev_param[wmi_pdev_param_txpower_limit2g] =
13317 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
13318 pdev_param[wmi_pdev_param_txpower_limit5g] =
13319 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
13320 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
13321 pdev_param[wmi_pdev_param_beacon_gen_mode] =
13322 WMI_PDEV_PARAM_BEACON_GEN_MODE;
13323 pdev_param[wmi_pdev_param_beacon_tx_mode] =
13324 WMI_PDEV_PARAM_BEACON_TX_MODE;
13325 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
13326 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
13327 pdev_param[wmi_pdev_param_protection_mode] =
13328 WMI_PDEV_PARAM_PROTECTION_MODE;
13329 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
13330 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
13331 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
13332 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
13333 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
13334 pdev_param[wmi_pdev_param_sta_kickout_th] =
13335 WMI_PDEV_PARAM_STA_KICKOUT_TH;
13336 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
13337 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
13338 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
13339 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
13340 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
13341 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
13342 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
13343 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
13344 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
13345 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
13346 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
13347 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
13348 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
13349 pdev_param[wmi_pdev_param_ltr_sleep_override] =
13350 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
13351 pdev_param[wmi_pdev_param_ltr_rx_override] =
13352 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
13353 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
13354 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
13355 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
13356 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
13357 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
13358 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
13359 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
13360 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
13361 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
13362 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
13363 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
13364 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
13365 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
13366 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
13367 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
13368 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
13369 pdev_param[wmi_pdev_param_peer_stats_update_period] =
13370 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
13371 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
13372 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
13373 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
13374 pdev_param[wmi_pdev_param_arp_ac_override] =
13375 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
13376 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
13377 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
13378 pdev_param[wmi_pdev_param_ani_poll_period] =
13379 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
13380 pdev_param[wmi_pdev_param_ani_listen_period] =
13381 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
13382 pdev_param[wmi_pdev_param_ani_ofdm_level] =
13383 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
13384 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
13385 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
13386 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
13387 pdev_param[wmi_pdev_param_idle_ps_config] =
13388 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
13389 pdev_param[wmi_pdev_param_power_gating_sleep] =
13390 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
13391 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
13392 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
13393 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
13394 pdev_param[wmi_pdev_param_hw_rfkill_config] =
13395 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
13396 pdev_param[wmi_pdev_param_low_power_rf_enable] =
13397 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
13398 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
13399 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
13400 pdev_param[wmi_pdev_param_power_collapse_enable] =
13401 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
13402 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
13403 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
13404 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
13405 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
13406 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
13407 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
13408 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
13409 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
13410 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
13411 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
13412 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
13413 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
13414 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
13415 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
13416 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
13417 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
13418 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
13419 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
13420 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
13421 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
13422 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
13423 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
13424 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
13425 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
13426 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
13427 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
13428 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
13429 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
13430 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
13431 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
13432 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
13433 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
13434 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
13435 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
13436 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
13437 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
13438 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
13439 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
13440 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
13441 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
13442 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
13443 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
13444 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
13445 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
13446 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
13447 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
13448 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
13449 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
13450 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
13451 WMI_UNAVAILABLE_PARAM;
13452 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
13453 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
13454 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
13455 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
13456 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
13457 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
13458 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
13459 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
13460 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
13461 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
13462 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
13463 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
13464 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
13465 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
13466 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
13467 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
13468 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
13469 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
13470 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
13471 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
13472 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
13473 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
13474 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
13475 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
13476 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
13477 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
13478 WMI_UNAVAILABLE_PARAM;
13479 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
13480 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
13481 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
13482 WMI_UNAVAILABLE_PARAM;
13483 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
13484 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
13485 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
13486 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
13487 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
13488 WMI_UNAVAILABLE_PARAM;
13489 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
13490 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
13491 WMI_UNAVAILABLE_PARAM;
13492 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] = WMI_UNAVAILABLE_PARAM;
13493 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
13494}
13495
13496/**
13497 * populate_vdev_param_tlv() - populates vdev params
13498 *
13499 * @param vdev_param: Pointer to hold vdev params
13500 * Return: None
13501 */
13502static void populate_vdev_param_tlv(uint32_t *vdev_param)
13503{
13504 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
13505 vdev_param[wmi_vdev_param_fragmentation_threshold] =
13506 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
13507 vdev_param[wmi_vdev_param_beacon_interval] =
13508 WMI_VDEV_PARAM_BEACON_INTERVAL;
13509 vdev_param[wmi_vdev_param_listen_interval] =
13510 WMI_VDEV_PARAM_LISTEN_INTERVAL;
13511 vdev_param[wmi_vdev_param_multicast_rate] =
13512 WMI_VDEV_PARAM_MULTICAST_RATE;
13513 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
13514 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
13515 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
13516 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
13517 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
13518 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
13519 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
13520 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
13521 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
13522 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
13523 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
13524 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
13525 vdev_param[wmi_vdev_param_bmiss_count_max] =
13526 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
13527 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
13528 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
13529 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
13530 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
13531 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
13532 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
13533 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
13534 vdev_param[wmi_vdev_param_disable_htprotection] =
13535 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
13536 vdev_param[wmi_vdev_param_sta_quickkickout] =
13537 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
13538 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
13539 vdev_param[wmi_vdev_param_protection_mode] =
13540 WMI_VDEV_PARAM_PROTECTION_MODE;
13541 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
13542 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
13543 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
13544 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
13545 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
13546 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
13547 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
13548 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
13549 vdev_param[wmi_vdev_param_bcast_data_rate] =
13550 WMI_VDEV_PARAM_BCAST_DATA_RATE;
13551 vdev_param[wmi_vdev_param_mcast_data_rate] =
13552 WMI_VDEV_PARAM_MCAST_DATA_RATE;
13553 vdev_param[wmi_vdev_param_mcast_indicate] =
13554 WMI_VDEV_PARAM_MCAST_INDICATE;
13555 vdev_param[wmi_vdev_param_dhcp_indicate] =
13556 WMI_VDEV_PARAM_DHCP_INDICATE;
13557 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
13558 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
13559 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
13560 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
13561 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
13562 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
13563 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
13564 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
13565 vdev_param[wmi_vdev_param_ap_enable_nawds] =
13566 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
13567 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
13568 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
13569 vdev_param[wmi_vdev_param_packet_powersave] =
13570 WMI_VDEV_PARAM_PACKET_POWERSAVE;
13571 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
13572 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
13573 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
13574 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
13575 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
13576 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
13577 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
13578 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
13579 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
13580 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
13581 vdev_param[wmi_vdev_param_early_rx_slop_step] =
13582 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
13583 vdev_param[wmi_vdev_param_early_rx_init_slop] =
13584 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
13585 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
13586 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
13587 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
13588 vdev_param[wmi_vdev_param_snr_num_for_cal] =
13589 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
13590 vdev_param[wmi_vdev_param_roam_fw_offload] =
13591 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
13592 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
13593 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
13594 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
13595 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
13596 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
13597 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
13598 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
13599 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
13600 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
13601 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
13602 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
13603 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
13604 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
13605 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
13606 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
13607 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
13608 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
13609 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
13610 vdev_param[wmi_vdev_param_inactivity_cnt] =
13611 WMI_VDEV_PARAM_INACTIVITY_CNT;
13612 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
13613 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
13614 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
13615 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
13616 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
13617 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
13618 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
13619 vdev_param[wmi_vdev_param_rx_leak_window] =
13620 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
13621 vdev_param[wmi_vdev_param_stats_avg_factor] =
13622 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
13623 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
13624 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
13625 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
13626 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
13627 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
13628 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
13629}
13630#endif
13631
Govind Singh5eb51532016-03-09 11:34:12 +053013632/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013633 * wmi_tlv_attach() - Attach TLV APIs
Govind Singh5eb51532016-03-09 11:34:12 +053013634 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013635 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053013636 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013637#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013638void wmi_tlv_attach(wmi_unified_t wmi_handle)
13639{
13640 wmi_handle->ops = &tlv_ops;
13641#ifdef WMI_INTERFACE_EVENT_LOGGING
13642 wmi_handle->log_info.buf_offset_command = 2;
13643 wmi_handle->log_info.buf_offset_event = 4;
13644 wmi_handle->log_info.is_management_record =
13645 is_management_record_tlv;
13646#endif
13647 populate_tlv_service(wmi_handle->services);
13648 populate_tlv_events_id(wmi_handle->wmi_events);
13649 populate_pdev_param_tlv(wmi_handle->pdev_param);
13650 populate_vdev_param_tlv(wmi_handle->vdev_param);
13651}
13652#else
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013653void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053013654{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013655 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053013656#ifdef WMI_INTERFACE_EVENT_LOGGING
13657 wmi_handle->log_info.buf_offset_command = 2;
13658 wmi_handle->log_info.buf_offset_event = 4;
13659 wmi_handle->log_info.is_management_record =
13660 is_management_record_tlv;
13661#endif
Govind Singh5eb51532016-03-09 11:34:12 +053013662}
Govind Singhe7f2f342016-05-23 12:12:52 +053013663#endif