blob: 7f4537046e7f9324dab089baead54da74f0eed7e [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 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700732static
Leo Changeee40872016-09-28 13:43:36 -0700733QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
734 struct rx_reorder_queue_setup_params *param)
735{
736 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
737 wmi_buf_t buf;
738 int32_t len = sizeof(*cmd);
739
740 buf = wmi_buf_alloc(wmi, len);
741 if (!buf) {
742 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
743 return QDF_STATUS_E_NOMEM;
744 }
745 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
746 WMITLV_SET_HDR(&cmd->tlv_header,
747 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
748 WMITLV_GET_STRUCT_TLVLEN
749 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
750 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
751 cmd->vdev_id = param->vdev_id;
752 cmd->tid = param->tid;
753 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
754 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
755 cmd->queue_no = param->queue_no;
756
757 if (wmi_unified_cmd_send(wmi, buf, len,
758 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
759 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
760 __func__);
761 qdf_nbuf_free(buf);
762 return QDF_STATUS_E_FAILURE;
763 }
764 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
765 param->peer_macaddr, param->vdev_id, param->tid);
766
767 return QDF_STATUS_SUCCESS;
768}
769
770/**
771 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
772 * command to fw
773 * @wmi: wmi handle
774 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
775 *
776 * Return: 0 for success or error code
777 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700778static
Leo Changeee40872016-09-28 13:43:36 -0700779QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
780 struct rx_reorder_queue_remove_params *param)
781{
782 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
783 wmi_buf_t buf;
784 int32_t len = sizeof(*cmd);
785
786 buf = wmi_buf_alloc(wmi, len);
787 if (!buf) {
788 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
789 return QDF_STATUS_E_NOMEM;
790 }
791 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
792 wmi_buf_data(buf);
793 WMITLV_SET_HDR(&cmd->tlv_header,
794 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
795 WMITLV_GET_STRUCT_TLVLEN
796 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
797 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
798 cmd->vdev_id = param->vdev_id;
799 cmd->tid_mask = param->peer_tid_bitmap;
800
801 if (wmi_unified_cmd_send(wmi, buf, len,
802 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
803 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
804 __func__);
805 qdf_nbuf_free(buf);
806 return QDF_STATUS_E_FAILURE;
807 }
808 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
809 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
810
811 return QDF_STATUS_SUCCESS;
812}
813
814/**
Govind Singh5eb51532016-03-09 11:34:12 +0530815 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
816 * @wmi_handle: wmi handle
817 * @value: value
818 * @mac_id: mac id to have radio context
819 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530820 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530821 */
Govind Singhb53420c2016-03-09 14:32:57 +0530822QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530823 uint32_t value, uint8_t mac_id)
824{
825 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
826 wmi_buf_t buf;
827 int32_t len = sizeof(*cmd);
828
Govind Singhb53420c2016-03-09 14:32:57 +0530829 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530830
831 buf = wmi_buf_alloc(wmi_handle, len);
832 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530833 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530834 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530835 }
836
837 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
838 WMITLV_SET_HDR(&cmd->tlv_header,
839 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
840 WMITLV_GET_STRUCT_TLVLEN
841 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530842 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530843 cmd->enable = value;
844
845 if (wmi_unified_cmd_send(wmi_handle, buf, len,
846 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530847 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530848 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530849 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530850 }
851
852 return 0;
853}
854
855/**
856 * send_pdev_utf_cmd_tlv() - send utf command to fw
857 * @wmi_handle: wmi handle
858 * @param: pointer to pdev_utf_params
859 * @mac_id: mac id to have radio context
860 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530861 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530862 */
Govind Singhb53420c2016-03-09 14:32:57 +0530863QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530864send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
865 struct pdev_utf_params *param,
866 uint8_t mac_id)
867{
868 wmi_buf_t buf;
869 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -0700870 /* if param->len is 0 no data is sent, return error */
871 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +0530872 static uint8_t msgref = 1;
873 uint8_t segNumber = 0, segInfo, numSegments;
874 uint16_t chunk_len, total_bytes;
875 uint8_t *bufpos;
876 struct seg_hdr_info segHdrInfo;
877
878 bufpos = param->utf_payload;
879 total_bytes = param->len;
880 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
881 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
882 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
883
884 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
885 numSegments++;
886
887 while (param->len) {
888 if (param->len > MAX_WMI_UTF_LEN)
889 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
890 else
891 chunk_len = param->len;
892
893 buf = wmi_buf_alloc(wmi_handle,
894 (chunk_len + sizeof(segHdrInfo) +
895 WMI_TLV_HDR_SIZE));
896 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530897 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530898 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530899 }
900
901 cmd = (uint8_t *) wmi_buf_data(buf);
902
903 segHdrInfo.len = total_bytes;
904 segHdrInfo.msgref = msgref;
905 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
906 segHdrInfo.segmentInfo = segInfo;
907 segHdrInfo.pad = 0;
908
Govind Singhb53420c2016-03-09 14:32:57 +0530909 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +0530910 " segHdrInfo.segmentInfo = %d",
911 __func__, segHdrInfo.len, segHdrInfo.msgref,
912 segHdrInfo.segmentInfo);
913
Govind Singhb53420c2016-03-09 14:32:57 +0530914 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +0530915 "chunk len %d", __func__, total_bytes, segNumber,
916 numSegments, chunk_len);
917
918 segNumber++;
919
920 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
921 (chunk_len + sizeof(segHdrInfo)));
922 cmd += WMI_TLV_HDR_SIZE;
923 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
924 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
925
926 ret = wmi_unified_cmd_send(wmi_handle, buf,
927 (chunk_len + sizeof(segHdrInfo) +
928 WMI_TLV_HDR_SIZE),
929 WMI_PDEV_UTF_CMDID);
930
Govind Singh67922e82016-04-01 16:48:57 +0530931 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530932 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530933 wmi_buf_free(buf);
934 break;
935 }
936
937 param->len -= chunk_len;
938 bufpos += chunk_len;
939 }
940
941 msgref++;
942
943 return ret;
944}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530945#ifdef CONFIG_MCL
946static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
947 uint32_t host_param)
948{
949 return host_param;
950}
951#else
952static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
953 uint32_t host_param)
954{
955 if (host_param < wmi_pdev_param_max)
956 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +0530957
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530958 return WMI_UNAVAILABLE_PARAM;
959}
960#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530961/**
962 * send_pdev_param_cmd_tlv() - set pdev parameters
963 * @wmi_handle: wmi handle
964 * @param: pointer to pdev parameter
965 * @mac_id: radio context
966 *
967 * Return: 0 on success, errno on failure
968 */
Govind Singhb53420c2016-03-09 14:32:57 +0530969QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530970send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
971 struct pdev_params *param,
972 uint8_t mac_id)
973{
Govind Singh67922e82016-04-01 16:48:57 +0530974 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530975 wmi_pdev_set_param_cmd_fixed_param *cmd;
976 wmi_buf_t buf;
977 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530978 uint32_t pdev_param;
979
980 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
981 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
982 WMI_LOGW("%s: Unavailable param %d\n",
983 __func__, param->param_id);
984 return QDF_STATUS_E_INVAL;
985 }
Govind Singh5eb51532016-03-09 11:34:12 +0530986
987 buf = wmi_buf_alloc(wmi_handle, len);
988 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530989 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530990 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530991 }
992 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
993 WMITLV_SET_HDR(&cmd->tlv_header,
994 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
995 WMITLV_GET_STRUCT_TLVLEN
996 (wmi_pdev_set_param_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530997 cmd->pdev_id = 0;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530998 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +0530999 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301000 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301001 param->param_value);
1002 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1003 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301004 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301005 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301006 wmi_buf_free(buf);
1007 }
1008 return ret;
1009}
1010
1011/**
1012 * send_suspend_cmd_tlv() - WMI suspend function
1013 * @param wmi_handle : handle to WMI.
1014 * @param param : pointer to hold suspend parameter
1015 * @mac_id: radio context
1016 *
1017 * Return 0 on success and -ve on failure.
1018 */
Govind Singhb53420c2016-03-09 14:32:57 +05301019QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301020 struct suspend_params *param,
1021 uint8_t mac_id)
1022{
1023 wmi_pdev_suspend_cmd_fixed_param *cmd;
1024 wmi_buf_t wmibuf;
1025 uint32_t len = sizeof(*cmd);
1026 int32_t ret;
1027
1028 /*
1029 * send the comand to Target to ignore the
1030 * PCIE reset so as to ensure that Host and target
1031 * states are in sync
1032 */
1033 wmibuf = wmi_buf_alloc(wmi_handle, len);
1034 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301035 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301036
1037 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1038 WMITLV_SET_HDR(&cmd->tlv_header,
1039 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1040 WMITLV_GET_STRUCT_TLVLEN
1041 (wmi_pdev_suspend_cmd_fixed_param));
1042 if (param->disable_target_intr)
1043 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1044 else
1045 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1046 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1047 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301048 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301049 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301050 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301051 }
1052
1053 return ret;
1054}
1055
1056/**
1057 * send_resume_cmd_tlv() - WMI resume function
1058 * @param wmi_handle : handle to WMI.
1059 * @mac_id: radio context
1060 *
1061 * Return: 0 on success and -ve on failure.
1062 */
Govind Singhb53420c2016-03-09 14:32:57 +05301063QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301064 uint8_t mac_id)
1065{
1066 wmi_buf_t wmibuf;
1067 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301068 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301069
1070 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1071 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301072 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301073 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1074 WMITLV_SET_HDR(&cmd->tlv_header,
1075 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1076 WMITLV_GET_STRUCT_TLVLEN
1077 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07001078 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +05301079 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1080 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301081 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301082 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301083 wmi_buf_free(wmibuf);
1084 }
1085
1086 return ret;
1087}
1088
1089/**
1090 * send_wow_enable_cmd_tlv() - WMI wow enable function
1091 * @param wmi_handle : handle to WMI.
1092 * @param param : pointer to hold wow enable parameter
1093 * @mac_id: radio context
1094 *
1095 * Return: 0 on success and -ve on failure.
1096 */
Govind Singhb53420c2016-03-09 14:32:57 +05301097QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301098 struct wow_cmd_params *param,
1099 uint8_t mac_id)
1100{
1101 wmi_wow_enable_cmd_fixed_param *cmd;
1102 wmi_buf_t buf;
1103 int32_t len;
1104 int32_t ret;
1105
1106 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1107
1108 buf = wmi_buf_alloc(wmi_handle, len);
1109 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301110 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1111 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301112 }
1113 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1114 WMITLV_SET_HDR(&cmd->tlv_header,
1115 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1116 WMITLV_GET_STRUCT_TLVLEN
1117 (wmi_wow_enable_cmd_fixed_param));
1118 cmd->enable = param->enable;
1119 if (param->can_suspend_link)
1120 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1121 else
1122 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
1123
Govind Singhb53420c2016-03-09 14:32:57 +05301124 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301125 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1126 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1127
1128 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1129 WMI_WOW_ENABLE_CMDID);
1130 if (ret)
1131 wmi_buf_free(buf);
1132
1133 return ret;
1134}
1135
1136/**
1137 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301138 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301139 * @peer_addr: peer mac address
1140 * @param: pointer to ap_ps parameter structure
1141 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301142 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301143 */
Govind Singhb53420c2016-03-09 14:32:57 +05301144QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301145 uint8_t *peer_addr,
1146 struct ap_ps_params *param)
1147{
1148 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1149 wmi_buf_t buf;
1150 int32_t err;
1151
1152 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1153 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301154 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301155 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301156 }
1157 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1158 WMITLV_SET_HDR(&cmd->tlv_header,
1159 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1160 WMITLV_GET_STRUCT_TLVLEN
1161 (wmi_ap_ps_peer_cmd_fixed_param));
1162 cmd->vdev_id = param->vdev_id;
1163 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1164 cmd->param = param->param;
1165 cmd->value = param->value;
1166 err = wmi_unified_cmd_send(wmi_handle, buf,
1167 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1168 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301169 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301170 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301171 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301172 }
1173
1174 return 0;
1175}
1176
1177/**
1178 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301179 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301180 * @peer_addr: peer mac address
1181 * @param: pointer to sta_ps parameter structure
1182 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301183 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301184 */
Govind Singhb53420c2016-03-09 14:32:57 +05301185QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301186 struct sta_ps_params *param)
1187{
1188 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1189 wmi_buf_t buf;
1190 int32_t len = sizeof(*cmd);
1191
1192 buf = wmi_buf_alloc(wmi_handle, len);
1193 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301194 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301195 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301196 }
1197
1198 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1199 WMITLV_SET_HDR(&cmd->tlv_header,
1200 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1201 WMITLV_GET_STRUCT_TLVLEN
1202 (wmi_sta_powersave_param_cmd_fixed_param));
1203 cmd->vdev_id = param->vdev_id;
1204 cmd->param = param->param;
1205 cmd->value = param->value;
1206
1207 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1208 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301209 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301210 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301211 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301212 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301213 }
1214
1215 return 0;
1216}
1217
1218/**
1219 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301220 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301221 * @param: ponirt to crash inject paramter structure
1222 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301223 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301224 */
Govind Singhb53420c2016-03-09 14:32:57 +05301225QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301226 struct crash_inject *param)
1227{
1228 int32_t ret = 0;
1229 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1230 uint16_t len = sizeof(*cmd);
1231 wmi_buf_t buf;
1232
1233 buf = wmi_buf_alloc(wmi_handle, len);
1234 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301235 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301236 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301237 }
1238
1239 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1240 WMITLV_SET_HDR(&cmd->tlv_header,
1241 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1242 WMITLV_GET_STRUCT_TLVLEN
1243 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1244 cmd->type = param->type;
1245 cmd->delay_time_ms = param->delay_time_ms;
1246
1247 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1248 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301249 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301250 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301251 __func__, ret);
1252 wmi_buf_free(buf);
1253 }
1254
1255 return ret;
1256}
1257
1258/**
1259 * send_dbglog_cmd_tlv() - set debug log level
1260 * @param wmi_handle : handle to WMI.
1261 * @param param : pointer to hold dbglog level parameter
1262 *
1263 * Return: 0 on success and -ve on failure.
1264 */
Govind Singhb53420c2016-03-09 14:32:57 +05301265QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301266send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1267 struct dbglog_params *dbglog_param)
1268{
1269 wmi_buf_t buf;
1270 wmi_debug_log_config_cmd_fixed_param *configmsg;
1271 A_STATUS status = A_OK;
1272 int32_t i;
1273 int32_t len;
1274 int8_t *buf_ptr;
1275 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1276
1277 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1278
1279 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1280 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1281 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1282 buf = wmi_buf_alloc(wmi_handle, len);
1283 if (buf == NULL)
1284 return A_NO_MEMORY;
1285
1286 configmsg =
1287 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1288 buf_ptr = (int8_t *) configmsg;
1289 WMITLV_SET_HDR(&configmsg->tlv_header,
1290 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1291 WMITLV_GET_STRUCT_TLVLEN
1292 (wmi_debug_log_config_cmd_fixed_param));
1293 configmsg->dbg_log_param = dbglog_param->param;
1294 configmsg->value = dbglog_param->val;
1295 /* Filling in the data part of second tlv -- should
1296 * follow first tlv _ WMI_TLV_HDR_SIZE */
1297 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1298 sizeof
1299 (wmi_debug_log_config_cmd_fixed_param)
1300 + WMI_TLV_HDR_SIZE);
1301 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1302 WMITLV_TAG_ARRAY_UINT32,
1303 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1304 if (dbglog_param->module_id_bitmap) {
1305 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1306 module_id_bitmap_array[i] =
1307 dbglog_param->module_id_bitmap[i];
1308 }
1309 }
1310
1311 status = wmi_unified_cmd_send(wmi_handle, buf,
1312 len, WMI_DBGLOG_CFG_CMDID);
1313
1314 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301315 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301316
1317 return status;
1318}
1319
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301320#ifdef CONFIG_MCL
1321static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1322 uint32_t host_param)
1323{
1324 return host_param;
1325}
1326#else
1327static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1328 uint32_t host_param)
1329{
1330 if (host_param < wmi_vdev_param_max)
1331 return wmi_handle->vdev_param[host_param];
1332
1333 return WMI_UNAVAILABLE_PARAM;
1334}
1335#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301336/**
1337 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1338 * @param wmi_handle : handle to WMI.
1339 * @param macaddr : MAC address
1340 * @param param : pointer to hold vdev set parameter
1341 *
1342 * Return: 0 on success and -ve on failure.
1343 */
Govind Singhb53420c2016-03-09 14:32:57 +05301344QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301345 struct vdev_set_params *param)
1346{
Govind Singh67922e82016-04-01 16:48:57 +05301347 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301348 wmi_vdev_set_param_cmd_fixed_param *cmd;
1349 wmi_buf_t buf;
1350 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301351 uint32_t vdev_param;
1352
1353 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1354 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1355 WMI_LOGW("%s:Vdev param %d not available", __func__,
1356 param->param_id);
1357 return QDF_STATUS_E_INVAL;
1358
1359 }
Govind Singh5eb51532016-03-09 11:34:12 +05301360
1361 buf = wmi_buf_alloc(wmi_handle, len);
1362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301363 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301364 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301365 }
1366 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1367 WMITLV_SET_HDR(&cmd->tlv_header,
1368 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1369 WMITLV_GET_STRUCT_TLVLEN
1370 (wmi_vdev_set_param_cmd_fixed_param));
1371 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301372 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301373 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301374 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301375 param->if_id, param->param_id, param->param_value);
1376 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1377 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301378 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301379 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301380 wmi_buf_free(buf);
1381 }
1382
1383 return ret;
1384}
1385
1386/**
1387 * send_stats_request_cmd_tlv() - WMI request stats function
1388 * @param wmi_handle : handle to WMI.
1389 * @param macaddr : MAC address
1390 * @param param : pointer to hold stats request parameter
1391 *
1392 * Return: 0 on success and -ve on failure.
1393 */
Govind Singhb53420c2016-03-09 14:32:57 +05301394QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301395 uint8_t macaddr[IEEE80211_ADDR_LEN],
1396 struct stats_request_params *param)
1397{
Govind Singhd3156eb2016-02-26 17:50:39 +05301398 int32_t ret;
1399 wmi_request_stats_cmd_fixed_param *cmd;
1400 wmi_buf_t buf;
1401 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1402
1403 buf = wmi_buf_alloc(wmi_handle, len);
1404 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301405 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1406 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301407 }
1408
1409 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1410 WMITLV_SET_HDR(&cmd->tlv_header,
1411 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1412 WMITLV_GET_STRUCT_TLVLEN
1413 (wmi_request_stats_cmd_fixed_param));
1414 cmd->stats_id = param->stats_id;
1415 cmd->vdev_id = param->vdev_id;
1416 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1417 WMI_REQUEST_STATS_CMDID);
1418 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301419 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301420 wmi_buf_free(buf);
1421 }
1422
1423 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301424}
1425
Govind Singh87542482016-06-08 19:40:11 +05301426#ifdef CONFIG_WIN
1427/**
1428 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1429 * @param wmi_handle : handle to WMI.
1430 * @param macaddr : MAC address
1431 * @param param : pointer to hold stats request parameter
1432 *
1433 * Return: 0 on success and -ve on failure.
1434 */
1435QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
1436 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1437{
1438 return 0;
1439}
1440#else
Govind Singh5eb51532016-03-09 11:34:12 +05301441/**
1442 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1443 * @param wmi_handle : handle to WMI.
1444 * @param macaddr : MAC address
1445 * @param param : pointer to hold stats request parameter
1446 *
1447 * Return: 0 on success and -ve on failure.
1448 */
Govind Singhb53420c2016-03-09 14:32:57 +05301449QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301450 uint8_t macaddr[IEEE80211_ADDR_LEN],
1451 struct packet_enable_params *param)
1452{
1453 return 0;
1454}
Govind Singh87542482016-06-08 19:40:11 +05301455#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301456
Govind Singh87542482016-06-08 19:40:11 +05301457#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301458/**
1459 * send_beacon_send_cmd_tlv() - WMI beacon send function
1460 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301461 * @param param : pointer to hold beacon send cmd parameter
1462 *
1463 * Return: 0 on success and -ve on failure.
1464 */
Govind Singhb53420c2016-03-09 14:32:57 +05301465QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301466 struct beacon_params *param)
1467{
Govind Singhd3156eb2016-02-26 17:50:39 +05301468 int32_t ret;
1469 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1470 wmi_bcn_prb_info *bcn_prb_info;
1471 wmi_buf_t wmi_buf;
1472 uint8_t *buf_ptr;
1473 uint32_t wmi_buf_len;
1474
1475 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1476 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1477 param->tmpl_len_aligned;
1478 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1479 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301480 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301481 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301482 }
1483 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1484 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1485 WMITLV_SET_HDR(&cmd->tlv_header,
1486 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1487 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1488 cmd->vdev_id = param->vdev_id;
1489 cmd->tim_ie_offset = param->tim_ie_offset;
1490 cmd->buf_len = param->tmpl_len;
1491 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1492
1493 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1494 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1495 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1496 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1497 bcn_prb_info->caps = 0;
1498 bcn_prb_info->erp = 0;
1499 buf_ptr += sizeof(wmi_bcn_prb_info);
1500
1501 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1502 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301503 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301504
1505 ret = wmi_unified_cmd_send(wmi_handle,
1506 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1507 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301508 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301509 wmi_buf_free(wmi_buf);
1510 }
Govind Singh5eb51532016-03-09 11:34:12 +05301511 return 0;
1512}
Govind Singh87542482016-06-08 19:40:11 +05301513#else
1514QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
1515 struct beacon_params *param)
1516{
1517 return 0;
1518}
1519
1520/**
1521 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1522 * @param wmi_handle : handle to WMI.
1523 * @param param : pointer to hold beacon send cmd parameter
1524 *
1525 * Return: 0 on success and -ve on failure.
1526 */
1527QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
1528 struct beacon_tmpl_params *param)
1529{
1530 int32_t ret;
1531 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1532 wmi_bcn_prb_info *bcn_prb_info;
1533 wmi_buf_t wmi_buf;
1534 uint8_t *buf_ptr;
1535 uint32_t wmi_buf_len;
1536
1537 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1538 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1539 param->tmpl_len_aligned;
1540 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1541 if (!wmi_buf) {
1542 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1543 return QDF_STATUS_E_NOMEM;
1544 }
1545 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1546 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1547 WMITLV_SET_HDR(&cmd->tlv_header,
1548 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1549 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1550 cmd->vdev_id = param->vdev_id;
1551 cmd->tim_ie_offset = param->tim_ie_offset;
1552 cmd->buf_len = param->tmpl_len;
1553 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1554
1555 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1556 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1557 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1558 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1559 bcn_prb_info->caps = 0;
1560 bcn_prb_info->erp = 0;
1561 buf_ptr += sizeof(wmi_bcn_prb_info);
1562
1563 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1564 buf_ptr += WMI_TLV_HDR_SIZE;
1565 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1566
1567 ret = wmi_unified_cmd_send(wmi_handle,
1568 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1569 if (ret) {
1570 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1571 wmi_buf_free(wmi_buf);
1572 }
1573 return 0;
1574}
1575#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301576
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301577#ifdef CONFIG_MCL
1578static inline void copy_peer_flags_tlv(
1579 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1580 struct peer_assoc_params *param)
1581{
1582 cmd->peer_flags = param->peer_flags;
1583}
1584#else
1585static inline void copy_peer_flags_tlv(
1586 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1587 struct peer_assoc_params *param)
1588{
1589 /*
1590 * The target only needs a subset of the flags maintained in the host.
1591 * Just populate those flags and send it down
1592 */
1593 cmd->peer_flags = 0;
1594
1595 /*
1596 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1597 */
1598 if (param->is_wme_set) {
1599
1600 if (param->qos_flag)
1601 cmd->peer_flags |= WMI_PEER_QOS;
1602 if (param->apsd_flag)
1603 cmd->peer_flags |= WMI_PEER_APSD;
1604 if (param->ht_flag)
1605 cmd->peer_flags |= WMI_PEER_HT;
1606 if (param->bw_40)
1607 cmd->peer_flags |= WMI_PEER_40MHZ;
1608 if (param->bw_80)
1609 cmd->peer_flags |= WMI_PEER_80MHZ;
1610 if (param->bw_160)
1611 cmd->peer_flags |= WMI_PEER_160MHZ;
1612
1613 /* Typically if STBC is enabled for VHT it should be enabled
1614 * for HT as well
1615 **/
1616 if (param->stbc_flag)
1617 cmd->peer_flags |= WMI_PEER_STBC;
1618
1619 /* Typically if LDPC is enabled for VHT it should be enabled
1620 * for HT as well
1621 **/
1622 if (param->ldpc_flag)
1623 cmd->peer_flags |= WMI_PEER_LDPC;
1624
1625 if (param->static_mimops_flag)
1626 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1627 if (param->dynamic_mimops_flag)
1628 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1629 if (param->spatial_mux_flag)
1630 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1631 if (param->vht_flag)
1632 cmd->peer_flags |= WMI_PEER_VHT;
1633 }
1634 /*
1635 * Suppress authorization for all AUTH modes that need 4-way handshake
1636 * (during re-association).
1637 * Authorization will be done for these modes on key installation.
1638 */
1639 if (param->auth_flag)
1640 cmd->peer_flags |= WMI_PEER_AUTH;
1641 if (param->need_ptk_4_way)
1642 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1643 else
1644 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1645 if (param->need_gtk_2_way)
1646 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1647 /* safe mode bypass the 4-way handshake */
1648 if (param->safe_mode_enabled)
1649 cmd->peer_flags &=
1650 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1651 /* Disable AMSDU for station transmit, if user configures it */
1652 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1653 * it
1654 * if (param->amsdu_disable) Add after FW support
1655 **/
1656
1657 /* Target asserts if node is marked HT and all MCS is set to 0.
1658 * Mark the node as non-HT if all the mcs rates are disabled through
1659 * iwpriv
1660 **/
1661 if (param->peer_ht_rates.num_rates == 0)
1662 cmd->peer_flags &= ~WMI_PEER_HT;
1663}
1664#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301665/**
1666 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1667 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301668 * @param param : pointer to peer assoc parameter
1669 *
1670 * Return: 0 on success and -ve on failure.
1671 */
Govind Singhb53420c2016-03-09 14:32:57 +05301672QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301673 struct peer_assoc_params *param)
1674{
Govind Singhd3156eb2016-02-26 17:50:39 +05301675 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1676 wmi_vht_rate_set *mcs;
1677 wmi_buf_t buf;
1678 int32_t len;
1679 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301680 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301681 uint32_t peer_legacy_rates_align;
1682 uint32_t peer_ht_rates_align;
1683
1684
1685 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1686 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301687
1688 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301689 (peer_legacy_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301690 WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301691 (peer_ht_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301692 sizeof(wmi_vht_rate_set);
1693
1694 buf = wmi_buf_alloc(wmi_handle, len);
1695 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301696 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301697 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301698 }
1699
1700 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1701 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1702 WMITLV_SET_HDR(&cmd->tlv_header,
1703 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1704 WMITLV_GET_STRUCT_TLVLEN
1705 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301706
Govind Singhd3156eb2016-02-26 17:50:39 +05301707 cmd->vdev_id = param->vdev_id;
Govind Singh3419aea2016-03-28 22:02:42 +05301708 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1709 sizeof(param->peer_macaddr));
Govind Singhd3156eb2016-02-26 17:50:39 +05301710 cmd->peer_new_assoc = param->peer_new_assoc;
1711 cmd->peer_associd = param->peer_associd;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301712 copy_peer_flags_tlv(cmd, param);
Govind Singhd3156eb2016-02-26 17:50:39 +05301713 cmd->peer_rate_caps = param->peer_rate_caps;
1714 cmd->peer_caps = param->peer_caps;
1715 cmd->peer_listen_intval = param->peer_listen_intval;
1716 cmd->peer_ht_caps = param->peer_ht_caps;
1717 cmd->peer_max_mpdu = param->peer_max_mpdu;
1718 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301719 cmd->peer_vht_caps = param->peer_vht_caps;
1720 cmd->peer_phymode = param->peer_phymode;
1721
1722 /* Update peer legacy rate information */
1723 buf_ptr += sizeof(*cmd);
1724 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301725 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301726 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301727 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301728 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301729 param->peer_legacy_rates.num_rates);
1730
1731 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001732 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301733 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301734 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301735 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301736 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301737 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301738 param->peer_ht_rates.num_rates);
1739
1740 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001741 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301742 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1743 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1744
1745 cmd->peer_nss = param->peer_nss;
1746 mcs = (wmi_vht_rate_set *) buf_ptr;
1747 if (param->vht_capable) {
1748 mcs->rx_max_rate = param->rx_max_rate;
1749 mcs->rx_mcs_set = param->rx_mcs_set;
1750 mcs->tx_max_rate = param->tx_max_rate;
1751 mcs->tx_mcs_set = param->tx_mcs_set;
1752 }
1753
Govind Singhb53420c2016-03-09 14:32:57 +05301754 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301755 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1756 "nss %d phymode %d peer_mpdu_density %d "
1757 "cmd->peer_vht_caps %x", __func__,
1758 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1759 cmd->peer_rate_caps, cmd->peer_caps,
1760 cmd->peer_listen_intval, cmd->peer_ht_caps,
1761 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1762 cmd->peer_mpdu_density,
1763 cmd->peer_vht_caps);
1764
1765 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1766 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301767 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301768 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301769 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301770 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301771 }
1772
1773 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301774}
1775
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301776/* copy_scan_notify_events() - Helper routine to copy scan notify events
1777 */
1778#ifdef CONFIG_MCL
1779static inline void copy_scan_notify_ev_flags(
1780 wmi_start_scan_cmd_fixed_param * cmd,
1781 struct scan_start_params *params)
1782{
1783 cmd->notify_scan_events = params->notify_scan_events;
1784 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1785}
1786#else
1787static inline void copy_scan_notify_ev_flags(
1788 wmi_start_scan_cmd_fixed_param * cmd,
1789 struct scan_start_params *params)
1790{
1791 cmd->notify_scan_events = WMI_SCAN_EVENT_STARTED |
1792 WMI_SCAN_EVENT_COMPLETED |
1793 WMI_SCAN_EVENT_BSS_CHANNEL |
1794 WMI_SCAN_EVENT_FOREIGN_CHANNEL |
1795 WMI_SCAN_EVENT_DEQUEUED
1796 ;
1797 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1798 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
1799
1800 if (params->is_phy_error)
1801 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
1802}
1803#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301804/**
1805 * send_scan_start_cmd_tlv() - WMI scan start function
1806 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301807 * @param param : pointer to hold scan start cmd parameter
1808 *
1809 * Return: 0 on success and -ve on failure.
1810 */
Govind Singhb53420c2016-03-09 14:32:57 +05301811QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301812 struct scan_start_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05301813{
Govind Singhd3156eb2016-02-26 17:50:39 +05301814 int32_t ret = 0;
1815 int32_t i;
1816 wmi_buf_t wmi_buf;
1817 wmi_start_scan_cmd_fixed_param *cmd;
1818 uint8_t *buf_ptr;
1819 uint32_t *tmp_ptr;
1820 wmi_ssid *ssid = NULL;
1821 wmi_mac_addr *bssid;
1822 int len = sizeof(*cmd);
1823
1824 /* Length TLV placeholder for array of uint32_t */
1825 len += WMI_TLV_HDR_SIZE;
1826 /* calculate the length of buffer required */
1827 if (params->num_chan)
1828 len += params->num_chan * sizeof(uint32_t);
1829
1830 /* Length TLV placeholder for array of wmi_ssid structures */
1831 len += WMI_TLV_HDR_SIZE;
1832 if (params->num_ssids)
1833 len += params->num_ssids * sizeof(wmi_ssid);
1834
1835 /* Length TLV placeholder for array of wmi_mac_addr structures */
1836 len += WMI_TLV_HDR_SIZE;
1837 len += sizeof(wmi_mac_addr);
1838
1839 /* Length TLV placeholder for array of bytes */
1840 len += WMI_TLV_HDR_SIZE;
1841 if (params->ie_len)
1842 len += roundup(params->ie_len, sizeof(uint32_t));
1843
1844 /* Allocate the memory */
1845 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1846 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301847 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301848 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05301849 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05301850 }
1851 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1852 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
1853 WMITLV_SET_HDR(&cmd->tlv_header,
1854 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
1855 WMITLV_GET_STRUCT_TLVLEN
1856 (wmi_start_scan_cmd_fixed_param));
1857
1858 cmd->scan_id = params->scan_id;
1859 cmd->scan_req_id = params->scan_req_id;
1860 cmd->vdev_id = params->vdev_id;
1861 cmd->scan_priority = params->scan_priority;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301862 copy_scan_notify_ev_flags(cmd, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05301863 cmd->dwell_time_active = params->dwell_time_active;
1864 cmd->dwell_time_passive = params->dwell_time_passive;
1865 cmd->min_rest_time = params->min_rest_time;
1866 cmd->max_rest_time = params->max_rest_time;
1867 cmd->repeat_probe_time = params->repeat_probe_time;
1868 cmd->probe_spacing_time = params->probe_spacing_time;
1869 cmd->idle_time = params->idle_time;
1870 cmd->max_scan_time = params->max_scan_time;
1871 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05301872 cmd->burst_duration = params->burst_duration;
1873 cmd->num_chan = params->num_chan;
1874 cmd->num_bssid = params->num_bssid;
1875 cmd->num_ssids = params->num_ssids;
1876 cmd->ie_len = params->ie_len;
1877 cmd->n_probes = params->n_probes;
1878 buf_ptr += sizeof(*cmd);
1879 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
1880 for (i = 0; i < params->num_chan; ++i)
1881 tmp_ptr[i] = params->chan_list[i];
1882
1883 WMITLV_SET_HDR(buf_ptr,
1884 WMITLV_TAG_ARRAY_UINT32,
1885 (params->num_chan * sizeof(uint32_t)));
1886 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05301887 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05301888 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05301889 goto error;
1890 }
1891
1892 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1893 (params->num_ssids * sizeof(wmi_ssid)));
1894
1895 if (params->num_ssids) {
1896 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
1897 for (i = 0; i < params->num_ssids; ++i) {
1898 ssid->ssid_len = params->ssid[i].length;
Govind Singhb53420c2016-03-09 14:32:57 +05301899 qdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05301900 params->ssid[i].length);
1901 ssid++;
1902 }
1903 }
1904 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
1905
1906 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1907 (params->num_bssid * sizeof(wmi_mac_addr)));
1908 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
1909 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
1910 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
1911
1912 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, params->ie_len_with_pad);
1913 if (params->ie_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05301914 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singhd3156eb2016-02-26 17:50:39 +05301915 (uint8_t *) params->ie_base +
1916 (params->uie_fieldOffset), params->ie_len);
1917 }
1918 buf_ptr += WMI_TLV_HDR_SIZE + params->ie_len_with_pad;
1919
1920 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1921 len, WMI_START_SCAN_CMDID);
1922 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301923 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301924 wmi_buf_free(wmi_buf);
1925 }
1926 return ret;
1927error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05301928 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05301929 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301930}
1931
1932/**
1933 * send_scan_stop_cmd_tlv() - WMI scan start function
1934 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301935 * @param param : pointer to hold scan start cmd parameter
1936 *
1937 * Return: 0 on success and -ve on failure.
1938 */
Govind Singhb53420c2016-03-09 14:32:57 +05301939QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301940 struct scan_stop_params *param)
1941{
Govind Singhd3156eb2016-02-26 17:50:39 +05301942 wmi_stop_scan_cmd_fixed_param *cmd;
1943 int ret;
1944 int len = sizeof(*cmd);
1945 wmi_buf_t wmi_buf;
1946
1947 /* Allocate the memory */
1948 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1949 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301950 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301951 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301952 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301953 goto error;
1954 }
1955
1956 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1957 WMITLV_SET_HDR(&cmd->tlv_header,
1958 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
1959 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
1960 cmd->vdev_id = param->vdev_id;
1961 cmd->requestor = param->requestor;
1962 cmd->scan_id = param->scan_id;
1963 /* stop the scan with the corresponding scan_id */
1964 cmd->req_type = param->req_type;
1965 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1966 len, WMI_STOP_SCAN_CMDID);
1967 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301968 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301969 wmi_buf_free(wmi_buf);
1970 }
1971
1972error:
1973 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301974}
1975
Govind Singh87542482016-06-08 19:40:11 +05301976#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301977/**
1978 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
1979 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301980 * @param param : pointer to hold scan channel list parameter
1981 *
1982 * Return: 0 on success and -ve on failure.
1983 */
Govind Singhb53420c2016-03-09 14:32:57 +05301984QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301985 struct scan_chan_list_params *chan_list)
1986{
1987 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05301988 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05301989 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301990 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05301991 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05301992 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05301993 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
1994
1995 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
1996 buf = wmi_buf_alloc(wmi_handle, len);
1997 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301998 WMI_LOGE("Failed to allocate memory");
1999 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302000 goto end;
2001 }
2002
2003 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2004 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2005 WMITLV_SET_HDR(&cmd->tlv_header,
2006 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2007 WMITLV_GET_STRUCT_TLVLEN
2008 (wmi_scan_chan_list_cmd_fixed_param));
2009
Govind Singhb53420c2016-03-09 14:32:57 +05302010 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302011
2012 cmd->num_scan_chans = chan_list->num_scan_chans;
2013 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2014 WMITLV_TAG_ARRAY_STRUC,
2015 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302016 chan_info = (wmi_channel_param *)
2017 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302018 tchan_info = chan_list->chan_info;
2019
2020 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2021 WMITLV_SET_HDR(&chan_info->tlv_header,
2022 WMITLV_TAG_STRUC_wmi_channel,
2023 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2024 chan_info->mhz = tchan_info->mhz;
2025 chan_info->band_center_freq1 =
2026 tchan_info->band_center_freq1;
2027 chan_info->band_center_freq2 =
2028 tchan_info->band_center_freq2;
2029 chan_info->info = tchan_info->info;
2030 chan_info->reg_info_1 = tchan_info->reg_info_1;
2031 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302032 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302033
2034 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2035 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2036 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2037 tchan_info++;
2038 chan_info++;
2039 }
2040
Govind Singh67922e82016-04-01 16:48:57 +05302041 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singhd3156eb2016-02-26 17:50:39 +05302042 WMI_SCAN_CHAN_LIST_CMDID);
2043
Govind Singh67922e82016-04-01 16:48:57 +05302044 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302045 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302046 wmi_buf_free(buf);
2047 }
Govind Singh67922e82016-04-01 16:48:57 +05302048
Govind Singhd3156eb2016-02-26 17:50:39 +05302049end:
Govind Singhb53420c2016-03-09 14:32:57 +05302050 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302051}
Govind Singh87542482016-06-08 19:40:11 +05302052#else
2053QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
2054 struct scan_chan_list_params *chan_list)
2055{
2056 wmi_buf_t buf;
2057 QDF_STATUS qdf_status;
2058 wmi_scan_chan_list_cmd_fixed_param *cmd;
2059 int i;
2060 uint8_t *buf_ptr;
2061 wmi_channel *chan_info;
2062 struct channel_param *tchan_info;
2063 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302064
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302065 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302066 buf = wmi_buf_alloc(wmi_handle, len);
2067 if (!buf) {
2068 WMI_LOGE("Failed to allocate memory");
2069 qdf_status = QDF_STATUS_E_NOMEM;
2070 goto end;
2071 }
2072
2073 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2074 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2075 WMITLV_SET_HDR(&cmd->tlv_header,
2076 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2077 WMITLV_GET_STRUCT_TLVLEN
2078 (wmi_scan_chan_list_cmd_fixed_param));
2079
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302080 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302081
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302082 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302083 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2084 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302085 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302086 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2087 tchan_info = &(chan_list->ch_param[0]);
2088
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302089 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302090 WMITLV_SET_HDR(&chan_info->tlv_header,
2091 WMITLV_TAG_STRUC_wmi_channel,
2092 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2093 chan_info->mhz = tchan_info->mhz;
2094 chan_info->band_center_freq1 =
2095 tchan_info->cfreq1;
2096 chan_info->band_center_freq2 =
2097 tchan_info->cfreq2;
2098
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302099 if (tchan_info->is_chan_passive)
2100 WMI_SET_CHANNEL_FLAG(chan_info,
2101 WMI_CHAN_FLAG_PASSIVE);
2102
2103 if (tchan_info->allow_vht)
2104 WMI_SET_CHANNEL_FLAG(chan_info,
2105 WMI_CHAN_FLAG_ALLOW_VHT);
2106 else if (tchan_info->allow_ht)
2107 WMI_SET_CHANNEL_FLAG(chan_info,
2108 WMI_CHAN_FLAG_ALLOW_HT);
2109 WMI_SET_CHANNEL_MODE(chan_info,
2110 tchan_info->phy_mode);
2111
2112 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2113 * after FW support
2114 */
2115
2116 /* also fill in power information */
2117 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2118 tchan_info->minpower);
2119 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2120 tchan_info->maxpower);
2121 WMI_SET_CHANNEL_REG_POWER(chan_info,
2122 tchan_info->maxregpower);
2123 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2124 tchan_info->antennamax);
2125 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2126 tchan_info->reg_class_id);
2127
Govind Singh87542482016-06-08 19:40:11 +05302128 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2129
Govind Singh87542482016-06-08 19:40:11 +05302130 tchan_info++;
2131 chan_info++;
2132 }
2133
2134 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
2135 WMI_SCAN_CHAN_LIST_CMDID);
2136
2137 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2138 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2139 wmi_buf_free(buf);
2140 }
2141
2142end:
2143 return qdf_status;
2144}
2145#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302146/**
2147 * send_mgmt_cmd_tlv() - WMI scan start function
2148 * @wmi_handle : handle to WMI.
2149 * @param : pointer to hold mgmt cmd parameter
2150 *
2151 * Return: 0 on success and -ve on failure.
2152 */
Govind Singhb53420c2016-03-09 14:32:57 +05302153QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302154 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302155{
Govind Singh427ee5a2016-02-26 18:09:36 +05302156 wmi_buf_t buf;
2157 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2158 int32_t cmd_len;
2159 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302160 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302161 uint8_t *bufp;
2162 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2163 mgmt_tx_dl_frm_len;
2164
2165 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2166 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2167
2168 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2169 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302170 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2171 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302172 }
2173
2174 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2175 bufp = (uint8_t *) cmd;
2176 WMITLV_SET_HDR(&cmd->tlv_header,
2177 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2178 WMITLV_GET_STRUCT_TLVLEN
2179 (wmi_mgmt_tx_send_cmd_fixed_param));
2180
2181 cmd->vdev_id = param->vdev_id;
2182
Govind Singh224a7312016-06-21 14:33:26 +05302183 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302184 cmd->chanfreq = param->chanfreq;
2185 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2186 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2187 sizeof(uint32_t)));
2188 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302189 qdf_mem_copy(bufp, param->pdata, bufp_len);
2190 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2191 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302192 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2193#if defined(HELIUMPLUS_PADDR64)
2194 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2195#endif
2196 cmd->frame_len = param->frm_len;
2197 cmd->buf_len = bufp_len;
2198
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002199 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002200 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002201
Govind Singh427ee5a2016-02-26 18:09:36 +05302202 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2203 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302204 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302205 goto err1;
2206 }
Govind Singhb53420c2016-03-09 14:32:57 +05302207 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302208
2209err1:
2210 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302211 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302212}
2213
2214/**
2215 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2216 * @wmi_handle: wmi handle
2217 * @param_value: parameter value
2218 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302219 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302220 */
Govind Singhb53420c2016-03-09 14:32:57 +05302221QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302222 uint32_t param_value)
2223{
Govind Singh67922e82016-04-01 16:48:57 +05302224 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302225 wmi_modem_power_state_cmd_param *cmd;
2226 wmi_buf_t buf;
2227 uint16_t len = sizeof(*cmd);
2228
2229 buf = wmi_buf_alloc(wmi_handle, len);
2230 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302231 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302232 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302233 }
2234 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2235 WMITLV_SET_HDR(&cmd->tlv_header,
2236 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2237 WMITLV_GET_STRUCT_TLVLEN
2238 (wmi_modem_power_state_cmd_param));
2239 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302240 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302241 param_value);
2242 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2243 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302244 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302245 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302246 wmi_buf_free(buf);
2247 }
Govind Singh67922e82016-04-01 16:48:57 +05302248
Govind Singh427ee5a2016-02-26 18:09:36 +05302249 return ret;
2250}
2251
2252/**
2253 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2254 * @wmi_handle: wmi handle
2255 * @vdev_id: vdev id
2256 * @val: value
2257 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302258 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302259 */
Govind Singhb53420c2016-03-09 14:32:57 +05302260QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302261 uint32_t vdev_id, uint8_t val)
2262{
2263 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2264 wmi_buf_t buf;
2265 int32_t len = sizeof(*cmd);
2266
Govind Singhb53420c2016-03-09 14:32:57 +05302267 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302268
2269 buf = wmi_buf_alloc(wmi_handle, len);
2270 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302271 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302272 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302273 }
2274 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2275 WMITLV_SET_HDR(&cmd->tlv_header,
2276 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2277 WMITLV_GET_STRUCT_TLVLEN
2278 (wmi_sta_powersave_mode_cmd_fixed_param));
2279 cmd->vdev_id = vdev_id;
2280 if (val)
2281 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2282 else
2283 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2284
2285 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2286 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302287 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302288 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302289 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302290 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302291 }
Govind Singh5eb51532016-03-09 11:34:12 +05302292 return 0;
2293}
2294
Govind Singh427ee5a2016-02-26 18:09:36 +05302295/**
2296 * send_set_mimops_cmd_tlv() - set MIMO powersave
2297 * @wmi_handle: wmi handle
2298 * @vdev_id: vdev id
2299 * @value: value
2300 *
Govind Singhb53420c2016-03-09 14:32:57 +05302301 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302302 */
Govind Singhb53420c2016-03-09 14:32:57 +05302303QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302304 uint8_t vdev_id, int value)
2305{
Govind Singh67922e82016-04-01 16:48:57 +05302306 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302307 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2308 wmi_buf_t buf;
2309 uint16_t len = sizeof(*cmd);
2310
2311 buf = wmi_buf_alloc(wmi_handle, len);
2312 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302313 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302314 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302315 }
2316 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2317 WMITLV_SET_HDR(&cmd->tlv_header,
2318 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2319 WMITLV_GET_STRUCT_TLVLEN
2320 (wmi_sta_smps_force_mode_cmd_fixed_param));
2321
2322 cmd->vdev_id = vdev_id;
2323
Houston Hoffmanb5168052016-04-14 02:18:01 -07002324 /* WMI_SMPS_FORCED_MODE values do not directly map
2325 * to SM power save values defined in the specification.
2326 * Make sure to send the right mapping.
2327 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302328 switch (value) {
2329 case 0:
2330 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2331 break;
2332 case 1:
2333 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2334 break;
2335 case 2:
2336 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2337 break;
2338 case 3:
2339 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2340 break;
2341 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302342 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2343 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302344 }
2345
Govind Singhb53420c2016-03-09 14:32:57 +05302346 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302347
2348 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2349 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302350 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302351 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302352 wmi_buf_free(buf);
2353 }
2354
2355 return ret;
2356}
2357
2358/**
2359 * send_set_smps_params_cmd_tlv() - set smps params
2360 * @wmi_handle: wmi handle
2361 * @vdev_id: vdev id
2362 * @value: value
2363 *
Govind Singhb53420c2016-03-09 14:32:57 +05302364 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302365 */
Govind Singhb53420c2016-03-09 14:32:57 +05302366QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302367 int value)
2368{
Govind Singh67922e82016-04-01 16:48:57 +05302369 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302370 wmi_sta_smps_param_cmd_fixed_param *cmd;
2371 wmi_buf_t buf;
2372 uint16_t len = sizeof(*cmd);
2373
2374 buf = wmi_buf_alloc(wmi_handle, len);
2375 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302376 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302377 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302378 }
2379 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2380 WMITLV_SET_HDR(&cmd->tlv_header,
2381 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2382 WMITLV_GET_STRUCT_TLVLEN
2383 (wmi_sta_smps_param_cmd_fixed_param));
2384
2385 cmd->vdev_id = vdev_id;
2386 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2387 cmd->param =
2388 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2389
Govind Singhb53420c2016-03-09 14:32:57 +05302390 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302391 cmd->param);
2392
2393 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2394 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302395 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302396 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302397 wmi_buf_free(buf);
2398 }
2399
2400 return ret;
2401}
2402
2403/**
2404 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2405 * @wmi_handle: wmi handle
2406 * @noa: p2p power save parameters
2407 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302408 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302409 */
Govind Singhb53420c2016-03-09 14:32:57 +05302410QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302411 struct p2p_ps_params *noa)
2412{
2413 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2414 wmi_p2p_noa_descriptor *noa_discriptor;
2415 wmi_buf_t buf;
2416 uint8_t *buf_ptr;
2417 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302418 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302419 uint32_t duration;
2420
Govind Singhb53420c2016-03-09 14:32:57 +05302421 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302422 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2423 buf = wmi_buf_alloc(wmi_handle, len);
2424 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302425 WMI_LOGE("Failed to allocate memory");
2426 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302427 goto end;
2428 }
2429
2430 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2431 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2432 WMITLV_SET_HDR(&cmd->tlv_header,
2433 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2434 WMITLV_GET_STRUCT_TLVLEN
2435 (wmi_p2p_set_noa_cmd_fixed_param));
2436 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2437 cmd->vdev_id = noa->session_id;
2438 cmd->enable = (duration) ? true : false;
2439 cmd->num_noa = 1;
2440
2441 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2442 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2443 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2444 sizeof
2445 (wmi_p2p_set_noa_cmd_fixed_param)
2446 + WMI_TLV_HDR_SIZE);
2447 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2448 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2449 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2450 noa_discriptor->type_count = noa->count;
2451 noa_discriptor->duration = duration;
2452 noa_discriptor->interval = noa->interval;
2453 noa_discriptor->start_time = 0;
2454
Govind Singhb53420c2016-03-09 14:32:57 +05302455 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302456 cmd->vdev_id, noa->count, noa_discriptor->duration,
2457 noa->interval);
2458 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2459 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302460 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302461 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302462 wmi_buf_free(buf);
2463 }
2464
2465end:
Govind Singhb53420c2016-03-09 14:32:57 +05302466 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302467 return status;
2468}
2469
2470
2471/**
2472 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2473 * @wmi_handle: wmi handle
2474 * @noa: p2p opp power save parameters
2475 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302476 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302477 */
Govind Singhb53420c2016-03-09 14:32:57 +05302478QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302479 struct p2p_ps_params *oppps)
2480{
2481 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2482 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302483 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302484
Govind Singhb53420c2016-03-09 14:32:57 +05302485 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302486 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2487 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302488 WMI_LOGE("Failed to allocate memory");
2489 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302490 goto end;
2491 }
2492
2493 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2494 WMITLV_SET_HDR(&cmd->tlv_header,
2495 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2496 WMITLV_GET_STRUCT_TLVLEN
2497 (wmi_p2p_set_oppps_cmd_fixed_param));
2498 cmd->vdev_id = oppps->session_id;
2499 if (oppps->ctwindow)
2500 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2501
2502 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302503 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302504 cmd->vdev_id, oppps->ctwindow);
2505 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2506 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302507 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302508 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302509 wmi_buf_free(buf);
2510 }
2511
2512end:
Govind Singhb53420c2016-03-09 14:32:57 +05302513 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302514 return status;
2515}
2516
2517/**
2518 * send_get_temperature_cmd_tlv() - get pdev temperature req
2519 * @wmi_handle: wmi handle
2520 *
Govind Singhb53420c2016-03-09 14:32:57 +05302521 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302522 */
Govind Singhb53420c2016-03-09 14:32:57 +05302523QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05302524{
2525 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
2526 wmi_buf_t wmi_buf;
2527 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
2528 uint8_t *buf_ptr;
2529
2530 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05302531 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
2532 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05302533 }
2534
2535 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2536 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302537 WMI_LOGE(FL("wmi_buf_alloc failed"));
2538 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302539 }
2540
2541 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2542
2543 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
2544 WMITLV_SET_HDR(&cmd->tlv_header,
2545 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
2546 WMITLV_GET_STRUCT_TLVLEN
2547 (wmi_pdev_get_temperature_cmd_fixed_param));
2548
2549 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
2550 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302551 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05302552 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302553 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302554 }
Govind Singh2edc80f2016-03-01 15:30:53 +05302555
Govind Singhb53420c2016-03-09 14:32:57 +05302556 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302557}
2558
2559/**
2560 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
2561 * @wmi_handle: wmi handle
2562 * @vdevid: vdev id
2563 * @peer_addr: peer mac address
2564 * @auto_triggerparam: auto trigger parameters
2565 * @num_ac: number of access category
2566 *
2567 * This function sets the trigger
2568 * uapsd params such as service interval, delay interval
2569 * and suspend interval which will be used by the firmware
2570 * to send trigger frames periodically when there is no
2571 * traffic on the transmit side.
2572 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302573 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302574 */
Govind Singhb53420c2016-03-09 14:32:57 +05302575QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302576 struct sta_uapsd_trig_params *param)
2577{
2578 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302579 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302580 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
2581 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
2582 uint32_t i;
2583 wmi_buf_t buf;
2584 uint8_t *buf_ptr;
2585
2586 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2587 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302588 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302589 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302590 }
2591
2592 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2593 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
2594 WMITLV_SET_HDR(&cmd->tlv_header,
2595 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
2596 WMITLV_GET_STRUCT_TLVLEN
2597 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
2598 cmd->vdev_id = param->vdevid;
2599 cmd->num_ac = param->num_ac;
2600 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
2601
2602 /* TLV indicating array of structures to follow */
2603 buf_ptr += sizeof(*cmd);
2604 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
2605
2606 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302607 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302608
2609 /*
2610 * Update tag and length for uapsd auto trigger params (this will take
2611 * care of updating tag and length if it is not pre-filled by caller).
2612 */
2613 for (i = 0; i < param->num_ac; i++) {
2614 WMITLV_SET_HDR((buf_ptr +
2615 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
2616 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
2617 WMITLV_GET_STRUCT_TLVLEN
2618 (wmi_sta_uapsd_auto_trig_param));
2619 }
2620
2621 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2622 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302623 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302624 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302625 wmi_buf_free(buf);
2626 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05302627
Govind Singh427ee5a2016-02-26 18:09:36 +05302628 return ret;
2629}
2630
Govind Singh2edc80f2016-03-01 15:30:53 +05302631/**
2632 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
2633 * @wmi_handle: pointer to the wmi handle
2634 * @utc: pointer to the UTC time struct
2635 *
2636 * Return: 0 on succes
2637 */
Govind Singhb53420c2016-03-09 14:32:57 +05302638QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302639 struct ocb_utc_param *utc)
2640{
Govind Singh67922e82016-04-01 16:48:57 +05302641 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302642 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
2643 uint8_t *buf_ptr;
2644 uint32_t len, i;
2645 wmi_buf_t buf;
2646
2647 len = sizeof(*cmd);
2648 buf = wmi_buf_alloc(wmi_handle, len);
2649 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302650 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302651 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302652 }
2653
2654 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2655 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
2656 WMITLV_SET_HDR(&cmd->tlv_header,
2657 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
2658 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
2659 cmd->vdev_id = utc->vdev_id;
2660
2661 for (i = 0; i < SIZE_UTC_TIME; i++)
2662 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
2663
2664 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
2665 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
2666
2667 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2668 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302669 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302670 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302671 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302672 }
2673
Govind Singh67922e82016-04-01 16:48:57 +05302674 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302675}
2676
2677/**
2678 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
2679 * frames on a channel
2680 * @wmi_handle: pointer to the wmi handle
2681 * @timing_advert: pointer to the timing advertisement struct
2682 *
2683 * Return: 0 on succes
2684 */
Govind Singhb53420c2016-03-09 14:32:57 +05302685QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302686 struct ocb_timing_advert_param *timing_advert)
2687{
Govind Singh67922e82016-04-01 16:48:57 +05302688 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302689 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
2690 uint8_t *buf_ptr;
2691 uint32_t len, len_template;
2692 wmi_buf_t buf;
2693
2694 len = sizeof(*cmd) +
2695 WMI_TLV_HDR_SIZE;
2696
2697 len_template = timing_advert->template_length;
2698 /* Add padding to the template if needed */
2699 if (len_template % 4 != 0)
2700 len_template += 4 - (len_template % 4);
2701 len += len_template;
2702
2703 buf = wmi_buf_alloc(wmi_handle, len);
2704 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302705 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302706 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302707 }
2708
2709 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2710 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
2711 WMITLV_SET_HDR(&cmd->tlv_header,
2712 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
2713 WMITLV_GET_STRUCT_TLVLEN(
2714 wmi_ocb_start_timing_advert_cmd_fixed_param));
2715 cmd->vdev_id = timing_advert->vdev_id;
2716 cmd->repeat_rate = timing_advert->repeat_rate;
2717 cmd->channel_freq = timing_advert->chan_freq;
2718 cmd->timestamp_offset = timing_advert->timestamp_offset;
2719 cmd->time_value_offset = timing_advert->time_value_offset;
2720 cmd->timing_advert_template_length = timing_advert->template_length;
2721 buf_ptr += sizeof(*cmd);
2722
2723 /* Add the timing advert template */
2724 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2725 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05302726 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05302727 (uint8_t *)timing_advert->template_value,
2728 timing_advert->template_length);
2729
2730 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2731 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302732 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302733 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302734 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302735 }
2736
Govind Singh67922e82016-04-01 16:48:57 +05302737 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302738}
2739
2740/**
2741 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
2742 * on a channel
2743 * @wmi_handle: pointer to the wmi handle
2744 * @timing_advert: pointer to the timing advertisement struct
2745 *
2746 * Return: 0 on succes
2747 */
Govind Singhb53420c2016-03-09 14:32:57 +05302748QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302749 struct ocb_timing_advert_param *timing_advert)
2750{
Govind Singh67922e82016-04-01 16:48:57 +05302751 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302752 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
2753 uint8_t *buf_ptr;
2754 uint32_t len;
2755 wmi_buf_t buf;
2756
2757 len = sizeof(*cmd);
2758 buf = wmi_buf_alloc(wmi_handle, len);
2759 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302760 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302761 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302762 }
2763
2764 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2765 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
2766 WMITLV_SET_HDR(&cmd->tlv_header,
2767 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
2768 WMITLV_GET_STRUCT_TLVLEN(
2769 wmi_ocb_stop_timing_advert_cmd_fixed_param));
2770 cmd->vdev_id = timing_advert->vdev_id;
2771 cmd->channel_freq = timing_advert->chan_freq;
2772
2773 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2774 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302775 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302776 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302777 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302778 }
2779
Govind Singh67922e82016-04-01 16:48:57 +05302780 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302781}
2782
2783/**
2784 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
2785 * @wmi_handle: pointer to the wmi handle
2786 * @request: pointer to the request
2787 *
2788 * Return: 0 on succes
2789 */
Govind Singhb53420c2016-03-09 14:32:57 +05302790QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302791 uint8_t vdev_id)
2792{
Govind Singhb53420c2016-03-09 14:32:57 +05302793 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302794 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
2795 uint8_t *buf_ptr;
2796 wmi_buf_t buf;
2797 int32_t len;
2798
2799 len = sizeof(*cmd);
2800 buf = wmi_buf_alloc(wmi_handle, len);
2801 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302802 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302803 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302804 }
2805 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2806
2807 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302808 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302809 WMITLV_SET_HDR(&cmd->tlv_header,
2810 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
2811 WMITLV_GET_STRUCT_TLVLEN(
2812 wmi_ocb_get_tsf_timer_cmd_fixed_param));
2813 cmd->vdev_id = vdev_id;
2814
2815 /* Send the WMI command */
2816 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2817 WMI_OCB_GET_TSF_TIMER_CMDID);
2818 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05302819 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302820 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302821 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302822 }
2823
Govind Singh67922e82016-04-01 16:48:57 +05302824 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302825}
2826
2827/**
2828 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
2829 * @wmi_handle: pointer to the wmi handle
2830 * @get_stats_param: pointer to the dcc stats
2831 *
2832 * Return: 0 on succes
2833 */
Govind Singhb53420c2016-03-09 14:32:57 +05302834QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302835 struct dcc_get_stats_param *get_stats_param)
2836{
Govind Singh67922e82016-04-01 16:48:57 +05302837 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302838 wmi_dcc_get_stats_cmd_fixed_param *cmd;
2839 wmi_dcc_channel_stats_request *channel_stats_array;
2840 wmi_buf_t buf;
2841 uint8_t *buf_ptr;
2842 uint32_t len;
2843 uint32_t i;
2844
2845 /* Validate the input */
2846 if (get_stats_param->request_array_len !=
2847 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302848 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05302849 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302850 }
2851
2852 /* Allocate memory for the WMI command */
2853 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
2854 get_stats_param->request_array_len;
2855
2856 buf = wmi_buf_alloc(wmi_handle, len);
2857 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302858 WMI_LOGE(FL("wmi_buf_alloc failed"));
2859 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302860 }
2861
2862 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302863 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302864
2865 /* Populate the WMI command */
2866 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
2867 buf_ptr += sizeof(*cmd);
2868
2869 WMITLV_SET_HDR(&cmd->tlv_header,
2870 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
2871 WMITLV_GET_STRUCT_TLVLEN(
2872 wmi_dcc_get_stats_cmd_fixed_param));
2873 cmd->vdev_id = get_stats_param->vdev_id;
2874 cmd->num_channels = get_stats_param->channel_count;
2875
2876 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2877 get_stats_param->request_array_len);
2878 buf_ptr += WMI_TLV_HDR_SIZE;
2879
2880 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302881 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05302882 get_stats_param->request_array_len);
2883 for (i = 0; i < cmd->num_channels; i++)
2884 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
2885 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
2886 WMITLV_GET_STRUCT_TLVLEN(
2887 wmi_dcc_channel_stats_request));
2888
2889 /* Send the WMI command */
2890 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2891 WMI_DCC_GET_STATS_CMDID);
2892
Govind Singh67922e82016-04-01 16:48:57 +05302893 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302894 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302895 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302896 }
2897
Govind Singh67922e82016-04-01 16:48:57 +05302898 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302899}
2900
2901/**
2902 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
2903 * @wmi_handle: pointer to the wmi handle
2904 * @vdev_id: vdev id
2905 * @dcc_stats_bitmap: dcc status bitmap
2906 *
2907 * Return: 0 on succes
2908 */
Govind Singhb53420c2016-03-09 14:32:57 +05302909QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302910 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
2911{
Govind Singh67922e82016-04-01 16:48:57 +05302912 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302913 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
2914 wmi_buf_t buf;
2915 uint8_t *buf_ptr;
2916 uint32_t len;
2917
2918 /* Allocate memory for the WMI command */
2919 len = sizeof(*cmd);
2920
2921 buf = wmi_buf_alloc(wmi_handle, len);
2922 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302923 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302924 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302925 }
2926
2927 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302928 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302929
2930 /* Populate the WMI command */
2931 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
2932
2933 WMITLV_SET_HDR(&cmd->tlv_header,
2934 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
2935 WMITLV_GET_STRUCT_TLVLEN(
2936 wmi_dcc_clear_stats_cmd_fixed_param));
2937 cmd->vdev_id = vdev_id;
2938 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
2939
2940 /* Send the WMI command */
2941 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2942 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302943 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302944 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302945 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302946 }
2947
Govind Singh67922e82016-04-01 16:48:57 +05302948 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302949}
2950
2951/**
2952 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
2953 * @wmi_handle: pointer to the wmi handle
2954 * @update_ndl_param: pointer to the request parameters
2955 *
2956 * Return: 0 on success
2957 */
Govind Singhb53420c2016-03-09 14:32:57 +05302958QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302959 struct dcc_update_ndl_param *update_ndl_param)
2960{
Govind Singhb53420c2016-03-09 14:32:57 +05302961 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05302962 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
2963 wmi_dcc_ndl_chan *ndl_chan_array;
2964 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
2965 uint32_t active_state_count;
2966 wmi_buf_t buf;
2967 uint8_t *buf_ptr;
2968 uint32_t len;
2969 uint32_t i;
2970
2971 /* validate the input */
2972 if (update_ndl_param->dcc_ndl_chan_list_len !=
2973 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302974 WMI_LOGE(FL("Invalid parameter"));
2975 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302976 }
2977 active_state_count = 0;
2978 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
2979 for (i = 0; i < update_ndl_param->channel_count; i++)
2980 active_state_count +=
2981 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
2982 if (update_ndl_param->dcc_ndl_active_state_list_len !=
2983 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302984 WMI_LOGE(FL("Invalid parameter"));
2985 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302986 }
2987
2988 /* Allocate memory for the WMI command */
2989 len = sizeof(*cmd) +
2990 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
2991 WMI_TLV_HDR_SIZE +
2992 update_ndl_param->dcc_ndl_active_state_list_len;
2993
2994 buf = wmi_buf_alloc(wmi_handle, len);
2995 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302996 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302997 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302998 }
2999
3000 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303001 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303002
3003 /* Populate the WMI command */
3004 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3005 buf_ptr += sizeof(*cmd);
3006
3007 WMITLV_SET_HDR(&cmd->tlv_header,
3008 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3009 WMITLV_GET_STRUCT_TLVLEN(
3010 wmi_dcc_update_ndl_cmd_fixed_param));
3011 cmd->vdev_id = update_ndl_param->vdev_id;
3012 cmd->num_channel = update_ndl_param->channel_count;
3013
3014 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3015 update_ndl_param->dcc_ndl_chan_list_len);
3016 buf_ptr += WMI_TLV_HDR_SIZE;
3017
3018 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303019 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303020 update_ndl_param->dcc_ndl_chan_list_len);
3021 for (i = 0; i < cmd->num_channel; i++)
3022 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3023 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3024 WMITLV_GET_STRUCT_TLVLEN(
3025 wmi_dcc_ndl_chan));
3026 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3027
3028 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3029 update_ndl_param->dcc_ndl_active_state_list_len);
3030 buf_ptr += WMI_TLV_HDR_SIZE;
3031
3032 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303033 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303034 update_ndl_param->dcc_ndl_active_state_list,
3035 update_ndl_param->dcc_ndl_active_state_list_len);
3036 for (i = 0; i < active_state_count; i++) {
3037 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3038 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3039 WMITLV_GET_STRUCT_TLVLEN(
3040 wmi_dcc_ndl_active_state_config));
3041 }
3042 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3043
3044 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303045 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303046 WMI_DCC_UPDATE_NDL_CMDID);
3047 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303048 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303049 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303050 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303051 }
3052
Govind Singh67922e82016-04-01 16:48:57 +05303053 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303054}
3055
3056/**
3057 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3058 * @wmi_handle: pointer to the wmi handle
3059 * @config: the OCB configuration
3060 *
3061 * Return: 0 on success
3062 */
Govind Singhb53420c2016-03-09 14:32:57 +05303063QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303064 struct ocb_config_param *config, uint32_t *ch_mhz)
3065{
Govind Singh67922e82016-04-01 16:48:57 +05303066 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303067 wmi_ocb_set_config_cmd_fixed_param *cmd;
3068 wmi_channel *chan;
3069 wmi_ocb_channel *ocb_chan;
3070 wmi_qos_parameter *qos_param;
3071 wmi_dcc_ndl_chan *ndl_chan;
3072 wmi_dcc_ndl_active_state_config *ndl_active_config;
3073 wmi_ocb_schedule_element *sched_elem;
3074 uint8_t *buf_ptr;
3075 wmi_buf_t buf;
3076 int32_t len;
3077 int32_t i, j, active_state_count;
3078
3079 /*
3080 * Validate the dcc_ndl_chan_list_len and count the number of active
3081 * states. Validate dcc_ndl_active_state_list_len.
3082 */
3083 active_state_count = 0;
3084 if (config->dcc_ndl_chan_list_len) {
3085 if (!config->dcc_ndl_chan_list ||
3086 config->dcc_ndl_chan_list_len !=
3087 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303088 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303089 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303090 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303091 }
3092
3093 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3094 i < config->channel_count; ++i, ++ndl_chan)
3095 active_state_count +=
3096 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3097
3098 if (active_state_count) {
3099 if (!config->dcc_ndl_active_state_list ||
3100 config->dcc_ndl_active_state_list_len !=
3101 active_state_count *
3102 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303103 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303104 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303105 }
3106 }
3107 }
3108
3109 len = sizeof(*cmd) +
3110 WMI_TLV_HDR_SIZE + config->channel_count *
3111 sizeof(wmi_channel) +
3112 WMI_TLV_HDR_SIZE + config->channel_count *
3113 sizeof(wmi_ocb_channel) +
3114 WMI_TLV_HDR_SIZE + config->channel_count *
3115 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3116 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3117 WMI_TLV_HDR_SIZE + active_state_count *
3118 sizeof(wmi_dcc_ndl_active_state_config) +
3119 WMI_TLV_HDR_SIZE + config->schedule_size *
3120 sizeof(wmi_ocb_schedule_element);
3121 buf = wmi_buf_alloc(wmi_handle, len);
3122 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303123 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303124 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303125 }
3126
3127 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3128 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3129 WMITLV_SET_HDR(&cmd->tlv_header,
3130 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3131 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3132 cmd->vdev_id = config->session_id;
3133 cmd->channel_count = config->channel_count;
3134 cmd->schedule_size = config->schedule_size;
3135 cmd->flags = config->flags;
3136 buf_ptr += sizeof(*cmd);
3137
3138 /* Add the wmi_channel info */
3139 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3140 config->channel_count*sizeof(wmi_channel));
3141 buf_ptr += WMI_TLV_HDR_SIZE;
3142 for (i = 0; i < config->channel_count; i++) {
3143 chan = (wmi_channel *)buf_ptr;
3144 WMITLV_SET_HDR(&chan->tlv_header,
3145 WMITLV_TAG_STRUC_wmi_channel,
3146 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3147 chan->mhz = config->channels[i].chan_freq;
3148 chan->band_center_freq1 = config->channels[i].chan_freq;
3149 chan->band_center_freq2 = 0;
3150 chan->info = 0;
3151
3152 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3153 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3154 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3155 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3156 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3157 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3158 config->channels[i].antenna_max);
3159
3160 if (config->channels[i].bandwidth < 10)
3161 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3162 else if (config->channels[i].bandwidth < 20)
3163 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3164 buf_ptr += sizeof(*chan);
3165 }
3166
3167 /* Add the wmi_ocb_channel info */
3168 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3169 config->channel_count*sizeof(wmi_ocb_channel));
3170 buf_ptr += WMI_TLV_HDR_SIZE;
3171 for (i = 0; i < config->channel_count; i++) {
3172 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3173 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3174 WMITLV_TAG_STRUC_wmi_ocb_channel,
3175 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3176 ocb_chan->bandwidth = config->channels[i].bandwidth;
3177 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3178 config->channels[i].mac_address.bytes,
3179 &ocb_chan->mac_address);
3180 buf_ptr += sizeof(*ocb_chan);
3181 }
3182
3183 /* Add the wmi_qos_parameter info */
3184 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3185 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3186 buf_ptr += WMI_TLV_HDR_SIZE;
3187 /* WMI_MAX_NUM_AC parameters for each channel */
3188 for (i = 0; i < config->channel_count; i++) {
3189 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3190 qos_param = (wmi_qos_parameter *)buf_ptr;
3191 WMITLV_SET_HDR(&qos_param->tlv_header,
3192 WMITLV_TAG_STRUC_wmi_qos_parameter,
3193 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3194 qos_param->aifsn =
3195 config->channels[i].qos_params[j].aifsn;
3196 qos_param->cwmin =
3197 config->channels[i].qos_params[j].cwmin;
3198 qos_param->cwmax =
3199 config->channels[i].qos_params[j].cwmax;
3200 buf_ptr += sizeof(*qos_param);
3201 }
3202 }
3203
3204 /* Add the wmi_dcc_ndl_chan (per channel) */
3205 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3206 config->dcc_ndl_chan_list_len);
3207 buf_ptr += WMI_TLV_HDR_SIZE;
3208 if (config->dcc_ndl_chan_list_len) {
3209 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303210 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303211 config->dcc_ndl_chan_list_len);
3212 for (i = 0; i < config->channel_count; i++)
3213 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3214 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3215 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3216 buf_ptr += config->dcc_ndl_chan_list_len;
3217 }
3218
3219 /* Add the wmi_dcc_ndl_active_state_config */
3220 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3221 sizeof(wmi_dcc_ndl_active_state_config));
3222 buf_ptr += WMI_TLV_HDR_SIZE;
3223 if (active_state_count) {
3224 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303225 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303226 config->dcc_ndl_active_state_list,
3227 active_state_count * sizeof(*ndl_active_config));
3228 for (i = 0; i < active_state_count; ++i)
3229 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3230 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3231 WMITLV_GET_STRUCT_TLVLEN(
3232 wmi_dcc_ndl_active_state_config));
3233 buf_ptr += active_state_count *
3234 sizeof(*ndl_active_config);
3235 }
3236
3237 /* Add the wmi_ocb_schedule_element info */
3238 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3239 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3240 buf_ptr += WMI_TLV_HDR_SIZE;
3241 for (i = 0; i < config->schedule_size; i++) {
3242 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3243 WMITLV_SET_HDR(&sched_elem->tlv_header,
3244 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3245 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3246 sched_elem->channel_freq = config->schedule[i].chan_freq;
3247 sched_elem->total_duration = config->schedule[i].total_duration;
3248 sched_elem->guard_interval = config->schedule[i].guard_interval;
3249 buf_ptr += sizeof(*sched_elem);
3250 }
3251
3252
3253 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3254 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303255 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303256 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303257 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303258 }
3259
Govind Singh67922e82016-04-01 16:48:57 +05303260 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303261}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303262
3263/**
3264 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3265 * @wmi_handle: wmi handle
3266 * @mcc_adaptive_scheduler: enable/disable
3267 *
3268 * This function enable/disable mcc adaptive scheduler in fw.
3269 *
Govind Singhb53420c2016-03-09 14:32:57 +05303270 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303271 */
Govind Singhb53420c2016-03-09 14:32:57 +05303272QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003273 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3274 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303275{
Govind Singh67922e82016-04-01 16:48:57 +05303276 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303277 wmi_buf_t buf = 0;
3278 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3279 uint16_t len =
3280 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3281
3282 buf = wmi_buf_alloc(wmi_handle, len);
3283 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303284 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3285 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303286 }
3287 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3288 wmi_buf_data(buf);
3289
3290 WMITLV_SET_HDR(&cmd->tlv_header,
3291 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3292 WMITLV_GET_STRUCT_TLVLEN
3293 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3294 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003295 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303296
3297 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3298 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303299 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303300 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303301 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303302 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303303 }
Govind Singh67922e82016-04-01 16:48:57 +05303304
3305 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303306}
3307
3308/**
3309 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3310 * @wmi: wmi handle
3311 * @mcc_channel: mcc channel
3312 * @mcc_channel_time_latency: MCC channel time latency.
3313 *
3314 * Currently used to set time latency for an MCC vdev/adapter using operating
3315 * channel of it and channel number. The info is provided run time using
3316 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3317 *
3318 * Return: CDF status
3319 */
Govind Singhb53420c2016-03-09 14:32:57 +05303320QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303321 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3322{
Govind Singh67922e82016-04-01 16:48:57 +05303323 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303324 wmi_buf_t buf = 0;
3325 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3326 uint16_t len = 0;
3327 uint8_t *buf_ptr = NULL;
3328 wmi_resmgr_chan_latency chan_latency;
3329 /* Note: we only support MCC time latency for a single channel */
3330 uint32_t num_channels = 1;
3331 uint32_t chan1_freq = mcc_channel_freq;
3332 uint32_t latency_chan1 = mcc_channel_time_latency;
3333
3334
3335 /* If 0ms latency is provided, then FW will set to a default.
3336 * Otherwise, latency must be at least 30ms.
3337 */
3338 if ((latency_chan1 > 0) &&
3339 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303340 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303341 "Minimum is 30ms (or 0 to use default value by "
3342 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303343 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303344 }
3345
3346 /* Set WMI CMD for channel time latency here */
3347 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3348 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3349 num_channels * sizeof(wmi_resmgr_chan_latency);
3350 buf = wmi_buf_alloc(wmi_handle, len);
3351 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303352 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3353 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303354 }
3355 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3356 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3357 wmi_buf_data(buf);
3358 WMITLV_SET_HDR(&cmdTL->tlv_header,
3359 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3360 WMITLV_GET_STRUCT_TLVLEN
3361 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3362 cmdTL->num_chans = num_channels;
3363 /* Update channel time latency information for home channel(s) */
3364 buf_ptr += sizeof(*cmdTL);
3365 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3366 num_channels * sizeof(wmi_resmgr_chan_latency));
3367 buf_ptr += WMI_TLV_HDR_SIZE;
3368 chan_latency.chan_mhz = chan1_freq;
3369 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303370 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303371 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3372 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303373 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303374 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303375 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303376 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303377 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303378 }
Govind Singh67922e82016-04-01 16:48:57 +05303379
3380 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303381}
3382
3383/**
3384 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3385 * @wmi: wmi handle
3386 * @adapter_1_chan_number: adapter 1 channel number
3387 * @adapter_1_quota: adapter 1 quota
3388 * @adapter_2_chan_number: adapter 2 channel number
3389 *
3390 * Return: CDF status
3391 */
Govind Singhb53420c2016-03-09 14:32:57 +05303392QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303393 uint32_t adapter_1_chan_freq,
3394 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3395{
Govind Singh67922e82016-04-01 16:48:57 +05303396 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303397 wmi_buf_t buf = 0;
3398 uint16_t len = 0;
3399 uint8_t *buf_ptr = NULL;
3400 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3401 wmi_resmgr_chan_time_quota chan_quota;
3402 uint32_t quota_chan1 = adapter_1_quota;
3403 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3404 uint32_t quota_chan2 = 100 - quota_chan1;
3405 /* Note: setting time quota for MCC requires info for 2 channels */
3406 uint32_t num_channels = 2;
3407 uint32_t chan1_freq = adapter_1_chan_freq;
3408 uint32_t chan2_freq = adapter_2_chan_freq;
3409
Govind Singhb53420c2016-03-09 14:32:57 +05303410 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303411 "freq2:%dMHz, Quota2:%dms", __func__,
3412 chan1_freq, quota_chan1, chan2_freq,
3413 quota_chan2);
3414
3415 /*
3416 * Perform sanity check on time quota values provided.
3417 */
3418 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3419 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303420 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303421 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303422 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303423 }
3424 /* Set WMI CMD for channel time quota here */
3425 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3426 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3427 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3428 buf = wmi_buf_alloc(wmi_handle, len);
3429 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303430 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3431 QDF_ASSERT(0);
3432 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303433 }
3434 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3435 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3436 wmi_buf_data(buf);
3437 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3438 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3439 WMITLV_GET_STRUCT_TLVLEN
3440 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3441 cmdTQ->num_chans = num_channels;
3442
3443 /* Update channel time quota information for home channel(s) */
3444 buf_ptr += sizeof(*cmdTQ);
3445 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3446 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3447 buf_ptr += WMI_TLV_HDR_SIZE;
3448 chan_quota.chan_mhz = chan1_freq;
3449 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303450 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303451 /* Construct channel and quota record for the 2nd MCC mode. */
3452 buf_ptr += sizeof(chan_quota);
3453 chan_quota.chan_mhz = chan2_freq;
3454 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05303455 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303456
3457 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3458 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303459 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303460 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303461 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303462 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303463 }
Govind Singh67922e82016-04-01 16:48:57 +05303464
3465 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303466}
3467
3468/**
3469 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3470 * @wmi_handle: Pointer to wmi handle
3471 * @thermal_info: Thermal command information
3472 *
3473 * This function sends the thermal management command
3474 * to the firmware
3475 *
Govind Singhb53420c2016-03-09 14:32:57 +05303476 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303477 */
Govind Singhb53420c2016-03-09 14:32:57 +05303478QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303479 struct thermal_cmd_params *thermal_info)
3480{
3481 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3482 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303483 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303484 uint32_t len = 0;
3485
3486 len = sizeof(*cmd);
3487
3488 buf = wmi_buf_alloc(wmi_handle, len);
3489 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303490 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3491 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303492 }
3493
3494 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3495
3496 WMITLV_SET_HDR(&cmd->tlv_header,
3497 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3498 WMITLV_GET_STRUCT_TLVLEN
3499 (wmi_thermal_mgmt_cmd_fixed_param));
3500
3501 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3502 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3503 cmd->enable = thermal_info->thermal_enable;
3504
Govind Singhb53420c2016-03-09 14:32:57 +05303505 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303506 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3507
3508 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3509 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303510 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303511 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303512 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303513 }
3514
Govind Singh67922e82016-04-01 16:48:57 +05303515 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303516}
3517
3518
3519/**
3520 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303521 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303522 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3523 *
3524 * This function sends down the LRO configuration parameters to
3525 * the firmware to enable LRO, sets the TCP flags and sets the
3526 * seed values for the toeplitz hash generation
3527 *
Govind Singhb53420c2016-03-09 14:32:57 +05303528 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303529 */
Govind Singhb53420c2016-03-09 14:32:57 +05303530QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303531 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3532{
3533 wmi_lro_info_cmd_fixed_param *cmd;
3534 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303535 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303536
3537
3538 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3539 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303540 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3541 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303542 }
3543
3544 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3545
3546 WMITLV_SET_HDR(&cmd->tlv_header,
3547 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3548 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3549
3550 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3551 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3552 wmi_lro_cmd->tcp_flag);
3553 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3554 wmi_lro_cmd->tcp_flag_mask);
3555 cmd->toeplitz_hash_ipv4_0_3 =
3556 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3557 cmd->toeplitz_hash_ipv4_4_7 =
3558 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3559 cmd->toeplitz_hash_ipv4_8_11 =
3560 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3561 cmd->toeplitz_hash_ipv4_12_15 =
3562 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3563 cmd->toeplitz_hash_ipv4_16 =
3564 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3565
3566 cmd->toeplitz_hash_ipv6_0_3 =
3567 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3568 cmd->toeplitz_hash_ipv6_4_7 =
3569 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3570 cmd->toeplitz_hash_ipv6_8_11 =
3571 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3572 cmd->toeplitz_hash_ipv6_12_15 =
3573 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3574 cmd->toeplitz_hash_ipv6_16_19 =
3575 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3576 cmd->toeplitz_hash_ipv6_20_23 =
3577 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3578 cmd->toeplitz_hash_ipv6_24_27 =
3579 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3580 cmd->toeplitz_hash_ipv6_28_31 =
3581 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3582 cmd->toeplitz_hash_ipv6_32_35 =
3583 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3584 cmd->toeplitz_hash_ipv6_36_39 =
3585 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3586 cmd->toeplitz_hash_ipv6_40 =
3587 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3588
Govind Singhb53420c2016-03-09 14:32:57 +05303589 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303590 cmd->lro_enable, cmd->tcp_flag_u32);
3591
3592 status = wmi_unified_cmd_send(wmi_handle, buf,
3593 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303594 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303595 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303596 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303597 }
3598
Govind Singh67922e82016-04-01 16:48:57 +05303599 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303600}
3601
Govind Singh4eacd2b2016-03-07 14:24:22 +05303602/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303603 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3604 * @wmi_handle: Pointer to wmi handle
3605 * @rate_report_params: Pointer to peer rate report parameters
3606 *
3607 *
3608 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3609 */
3610QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
3611 struct wmi_peer_rate_report_params *rate_report_params)
3612{
3613 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3614 wmi_buf_t buf = NULL;
3615 QDF_STATUS status = 0;
3616 uint32_t len = 0;
3617 uint32_t i, j;
3618
3619 len = sizeof(*cmd);
3620
3621 buf = wmi_buf_alloc(wmi_handle, len);
3622 if (!buf) {
3623 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
3624 return QDF_STATUS_E_FAILURE;
3625 }
3626
3627 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3628 wmi_buf_data(buf);
3629
3630 WMITLV_SET_HDR(
3631 &cmd->tlv_header,
3632 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3633 WMITLV_GET_STRUCT_TLVLEN(
3634 wmi_peer_set_rate_report_condition_fixed_param));
3635
3636 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3637 cmd->report_backoff_time = rate_report_params->backoff_time;
3638 cmd->report_timer_period = rate_report_params->timer_period;
3639 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
3640 cmd->cond_per_phy[i].val_cond_flags =
3641 rate_report_params->report_per_phy[i].cond_flags;
3642 cmd->cond_per_phy[i].rate_delta.min_delta =
3643 rate_report_params->report_per_phy[i].delta.delta_min;
3644 cmd->cond_per_phy[i].rate_delta.percentage =
3645 rate_report_params->report_per_phy[i].delta.percent;
3646 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3647 cmd->cond_per_phy[i].rate_threshold[j] =
3648 rate_report_params->report_per_phy[i].
3649 report_rate_threshold[j];
3650 }
3651 }
3652
3653 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
3654 cmd->enable_rate_report,
3655 cmd->report_backoff_time, cmd->report_timer_period);
3656
3657 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3658 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3659 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303660 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303661 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3662 __func__);
3663 }
3664 return status;
3665}
3666
3667/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303668 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3669 * @wmi_handle: wmi handle
3670 * @param: bcn ll cmd parameter
3671 *
Govind Singhb53420c2016-03-09 14:32:57 +05303672 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303673 */
Govind Singhb53420c2016-03-09 14:32:57 +05303674QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303675 wmi_bcn_send_from_host_cmd_fixed_param *param)
3676{
3677 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3678 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303679 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303680
3681 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3682 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303683 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3684 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303685 }
3686
3687 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3688 WMITLV_SET_HDR(&cmd->tlv_header,
3689 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3690 WMITLV_GET_STRUCT_TLVLEN
3691 (wmi_bcn_send_from_host_cmd_fixed_param));
3692 cmd->vdev_id = param->vdev_id;
3693 cmd->data_len = param->data_len;
3694 cmd->frame_ctrl = param->frame_ctrl;
3695 cmd->frag_ptr = param->frag_ptr;
3696 cmd->dtim_flag = param->dtim_flag;
3697
3698 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3699 WMI_PDEV_SEND_BCN_CMDID);
3700
Govind Singh67922e82016-04-01 16:48:57 +05303701 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303702 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303703 wmi_buf_free(wmi_buf);
3704 }
3705
3706 return ret;
3707}
3708
3709/**
3710 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
3711 * @wmi_handle: wmi handle
3712 * @vdev_id: vdev id
3713 * @max_retries: max retries
3714 * @retry_interval: retry interval
3715 * This function sets sta query related parameters in fw.
3716 *
Govind Singhb53420c2016-03-09 14:32:57 +05303717 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303718 */
3719
Govind Singhb53420c2016-03-09 14:32:57 +05303720QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303721 uint8_t vdev_id, uint32_t max_retries,
3722 uint32_t retry_interval)
3723{
3724 wmi_buf_t buf;
3725 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
3726 int len;
3727
3728 len = sizeof(*cmd);
3729 buf = wmi_buf_alloc(wmi_handle, len);
3730 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303731 WMI_LOGE(FL("wmi_buf_alloc failed"));
3732 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303733 }
3734
3735 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
3736 WMITLV_SET_HDR(&cmd->tlv_header,
3737 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
3738 WMITLV_GET_STRUCT_TLVLEN
3739 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
3740
3741
3742 cmd->vdev_id = vdev_id;
3743 cmd->sa_query_max_retry_count = max_retries;
3744 cmd->sa_query_retry_interval = retry_interval;
3745
Govind Singhb53420c2016-03-09 14:32:57 +05303746 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303747 vdev_id, retry_interval, max_retries);
3748
3749 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3750 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303751 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05303752 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303753 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303754 }
3755
Govind Singhb53420c2016-03-09 14:32:57 +05303756 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303757 return 0;
3758}
3759
3760/**
3761 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
3762 * @wmi_handle: wmi handle
3763 * @params: sta keep alive parameter
3764 *
3765 * This function sets keep alive related parameters in fw.
3766 *
3767 * Return: CDF status
3768 */
Govind Singhb53420c2016-03-09 14:32:57 +05303769QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303770 struct sta_params *params)
3771{
3772 wmi_buf_t buf;
3773 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
3774 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
3775 uint8_t *buf_ptr;
3776 int len;
Govind Singh67922e82016-04-01 16:48:57 +05303777 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303778
Govind Singhb53420c2016-03-09 14:32:57 +05303779 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303780
Govind Singh4eacd2b2016-03-07 14:24:22 +05303781 len = sizeof(*cmd) + sizeof(*arp_rsp);
3782 buf = wmi_buf_alloc(wmi_handle, len);
3783 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303784 WMI_LOGE("wmi_buf_alloc failed");
3785 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303786 }
3787
3788 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
3789 buf_ptr = (uint8_t *) cmd;
3790 WMITLV_SET_HDR(&cmd->tlv_header,
3791 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
3792 WMITLV_GET_STRUCT_TLVLEN
3793 (WMI_STA_KEEPALIVE_CMD_fixed_param));
3794 cmd->interval = params->timeperiod;
3795 cmd->enable = (params->timeperiod) ? 1 : 0;
3796 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05303797 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303798 params->timeperiod, params->method);
3799 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
3800 WMITLV_SET_HDR(&arp_rsp->tlv_header,
3801 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
3802 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
3803
3804 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
3805 if ((NULL == params->hostv4addr) ||
3806 (NULL == params->destv4addr) ||
3807 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303808 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05303809 "destv4addr:%p destmac:%p ", __func__,
3810 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303811 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303812 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303813 }
3814 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05303815 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303816 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05303817 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303818 WMI_IPV4_ADDR_LEN);
3819 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
3820 } else {
3821 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
3822 }
3823
Govind Singh67922e82016-04-01 16:48:57 +05303824 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3825 WMI_STA_KEEPALIVE_CMDID);
3826 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303827 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303828 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303829 }
3830
Govind Singhb53420c2016-03-09 14:32:57 +05303831 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303832 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303833}
3834
3835/**
3836 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
3837 * @wmi_handle: wmi handle
3838 * @if_id: vdev id
3839 * @gtx_info: GTX config params
3840 *
3841 * This function set GTX related params in firmware.
3842 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303843 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303844 */
Govind Singhb53420c2016-03-09 14:32:57 +05303845QDF_STATUS send_vdev_set_gtx_cfg_cmd_tlv(wmi_unified_t wmi_handle, uint32_t if_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303846 struct wmi_gtx_config *gtx_info)
3847{
3848 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
3849 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05303850 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303851 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303852
Govind Singh4eacd2b2016-03-07 14:24:22 +05303853 buf = wmi_buf_alloc(wmi_handle, len);
3854 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303855 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303856 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303857 }
3858 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
3859 WMITLV_SET_HDR(&cmd->tlv_header,
3860 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
3861 WMITLV_GET_STRUCT_TLVLEN
3862 (wmi_vdev_set_gtx_params_cmd_fixed_param));
3863 cmd->vdev_id = if_id;
3864
3865 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
3866 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
3867 cmd->userGtxMask = gtx_info->gtx_usrcfg;
3868 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
3869 cmd->gtxPERMargin = gtx_info->gtx_margin;
3870 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
3871 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
3872 cmd->gtxBWMask = gtx_info->gtx_bwmask;
3873
Govind Singhb53420c2016-03-09 14:32:57 +05303874 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05303875 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
3876 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
3877 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
3878 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
3879
Abhishek Singh716c46c2016-05-04 16:24:07 +05303880 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303881 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303882 if (QDF_IS_STATUS_ERROR(ret)) {
3883 WMI_LOGE("Failed to set GTX PARAMS");
3884 wmi_buf_free(buf);
3885 }
3886 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303887}
3888
3889/**
3890 * send_process_update_edca_param_cmd_tlv() - update EDCA params
3891 * @wmi_handle: wmi handle
3892 * @edca_params: edca parameters
3893 *
3894 * This function updates EDCA parameters to the target
3895 *
3896 * Return: CDF Status
3897 */
Govind Singhb53420c2016-03-09 14:32:57 +05303898QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303899 uint8_t vdev_id,
3900 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
3901{
3902 uint8_t *buf_ptr;
3903 wmi_buf_t buf;
3904 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
3905 wmi_wmm_vparams *wmm_param, *twmm_param;
3906 int len = sizeof(*cmd);
3907 int ac;
3908
3909 buf = wmi_buf_alloc(wmi_handle, len);
3910
3911 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303912 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3913 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303914 }
3915
3916 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3917 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
3918 WMITLV_SET_HDR(&cmd->tlv_header,
3919 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3920 WMITLV_GET_STRUCT_TLVLEN
3921 (wmi_vdev_set_wmm_params_cmd_fixed_param));
3922 cmd->vdev_id = vdev_id;
3923
3924 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
3925 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
3926 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
3927 WMITLV_SET_HDR(&wmm_param->tlv_header,
3928 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3929 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
3930 wmm_param->cwmin = twmm_param->cwmin;
3931 wmm_param->cwmax = twmm_param->cwmax;
3932 wmm_param->aifs = twmm_param->aifs;
3933 wmm_param->txoplimit = twmm_param->txoplimit;
3934 wmm_param->acm = twmm_param->acm;
3935 wmm_param->no_ack = twmm_param->no_ack;
3936 }
3937
3938 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3939 WMI_VDEV_SET_WMM_PARAMS_CMDID))
3940 goto fail;
3941
Govind Singhb53420c2016-03-09 14:32:57 +05303942 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303943
3944fail:
3945 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303946 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
3947 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303948}
3949
3950/**
3951 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
3952 * @wmi_handle: wmi handle
3953 * @vdev_id: vdev id
3954 * @probe_rsp_info: probe response info
3955 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303956 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303957 */
Govind Singhb53420c2016-03-09 14:32:57 +05303958QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303959 uint8_t vdev_id,
3960 struct wmi_probe_resp_params *probe_rsp_info,
3961 uint8_t *frm)
3962{
3963 wmi_prb_tmpl_cmd_fixed_param *cmd;
3964 wmi_bcn_prb_info *bcn_prb_info;
3965 wmi_buf_t wmi_buf;
3966 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
3967 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05303968 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303969
Govind Singhb53420c2016-03-09 14:32:57 +05303970 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303971
3972 tmpl_len = probe_rsp_info->probeRespTemplateLen;
3973 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
3974
3975 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
3976 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
3977 tmpl_len_aligned;
3978
3979 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05303980 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303981 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05303982 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303983 }
3984
3985 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3986 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303987 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303988 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303989 }
3990
3991 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3992
3993 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
3994 WMITLV_SET_HDR(&cmd->tlv_header,
3995 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
3996 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
3997 cmd->vdev_id = vdev_id;
3998 cmd->buf_len = tmpl_len;
3999 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4000
4001 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4002 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4003 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4004 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4005 bcn_prb_info->caps = 0;
4006 bcn_prb_info->erp = 0;
4007 buf_ptr += sizeof(wmi_bcn_prb_info);
4008
4009 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4010 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304011 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304012
4013 ret = wmi_unified_cmd_send(wmi_handle,
4014 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304015 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304016 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304017 wmi_buf_free(wmi_buf);
4018 }
4019
4020 return ret;
4021}
4022
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304023#ifdef FEATURE_WLAN_WAPI
4024#define WPI_IV_LEN 16
4025
4026/**
4027 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4028 *
4029 * @dest_tx: destination address of tsc key counter
4030 * @src_tx: source address of tsc key counter
4031 * @dest_rx: destination address of rsc key counter
4032 * @src_rx: source address of rsc key counter
4033 *
4034 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4035 *
4036 * Return: None
4037 *
4038 */
4039static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4040 uint8_t *dest_rx, uint8_t *src_rx)
4041{
4042 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4043 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4044}
4045#else
4046static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4047 uint8_t *dest_rx, uint8_t *src_rx)
4048{
4049 return;
4050}
4051#endif
4052
4053/**
4054 * send_setup_install_key_cmd_tlv() - set key parameters
4055 * @wmi_handle: wmi handle
4056 * @key_params: key parameters
4057 *
4058 * This function fills structure from information
4059 * passed in key_params.
4060 *
4061 * Return: QDF_STATUS_SUCCESS - success
4062 * QDF_STATUS_E_FAILURE - failure
4063 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4064 */
4065QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
4066 struct set_key_params *key_params)
4067{
4068 wmi_vdev_install_key_cmd_fixed_param *cmd;
4069 wmi_buf_t buf;
4070 uint8_t *buf_ptr;
4071 uint32_t len;
4072 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304073 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304074
4075 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4076 WMI_TLV_HDR_SIZE;
4077
4078 buf = wmi_buf_alloc(wmi_handle, len);
4079 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304080 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304081 return QDF_STATUS_E_NOMEM;
4082 }
4083
4084 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4085 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4086 WMITLV_SET_HDR(&cmd->tlv_header,
4087 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4088 WMITLV_GET_STRUCT_TLVLEN
4089 (wmi_vdev_install_key_cmd_fixed_param));
4090 cmd->vdev_id = key_params->vdev_id;
4091 cmd->key_ix = key_params->key_idx;
4092 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4093 cmd->key_flags |= key_params->key_flags;
4094 cmd->key_cipher = key_params->key_cipher;
4095 if ((key_params->key_txmic_len) &&
4096 (key_params->key_rxmic_len)) {
4097 cmd->key_txmic_len = key_params->key_txmic_len;
4098 cmd->key_rxmic_len = key_params->key_rxmic_len;
4099 }
Govind Singh87542482016-06-08 19:40:11 +05304100#ifdef FEATURE_WLAN_WAPI
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304101 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4102 key_params->tx_iv,
4103 cmd->wpi_key_rsc_counter,
4104 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304105#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304106 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4107 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4108 roundup(key_params->key_len, sizeof(uint32_t)));
4109 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4110 qdf_mem_copy((void *)key_data,
4111 (const void *)key_params->key_data, key_params->key_len);
4112 cmd->key_len = key_params->key_len;
4113
4114 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4115 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304116 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304117 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304118
Govind Singh67922e82016-04-01 16:48:57 +05304119 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304120}
4121
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304122/**
4123 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4124 * @wmi_handle: wmi handle
4125 * @params: encrypt/decrypt params
4126 *
4127 * Return: QDF_STATUS_SUCCESS for success or error code
4128 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004129static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304130QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4131 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4132{
4133 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4134 wmi_buf_t wmi_buf;
4135 uint8_t *buf_ptr;
4136 QDF_STATUS ret;
4137 uint32_t len;
4138
4139 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4140
4141 len = sizeof(*cmd) +
4142 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4143 WMI_TLV_HDR_SIZE;
4144 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4145 if (!wmi_buf) {
4146 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4147 __func__);
4148 return QDF_STATUS_E_NOMEM;
4149 }
4150
4151 buf_ptr = wmi_buf_data(wmi_buf);
4152 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4153
4154 WMITLV_SET_HDR(&cmd->tlv_header,
4155 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4156 WMITLV_GET_STRUCT_TLVLEN(
4157 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4158
4159 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4160 cmd->key_flag = encrypt_decrypt_params->key_flag;
4161 cmd->key_idx = encrypt_decrypt_params->key_idx;
4162 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4163 cmd->key_len = encrypt_decrypt_params->key_len;
4164 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4165 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4166
4167 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4168 encrypt_decrypt_params->key_len);
4169
4170 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4171 MAX_MAC_HEADER_LEN);
4172
4173 cmd->data_len = encrypt_decrypt_params->data_len;
4174
4175 if (cmd->data_len) {
4176 buf_ptr += sizeof(*cmd);
4177 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4178 roundup(encrypt_decrypt_params->data_len,
4179 sizeof(A_UINT32)));
4180 buf_ptr += WMI_TLV_HDR_SIZE;
4181 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4182 encrypt_decrypt_params->data_len);
4183 }
4184
4185 /* This conversion is to facilitate data to FW in little endian */
4186 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4187 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4188 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4189 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4190 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4191 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4192
4193 ret = wmi_unified_cmd_send(wmi_handle,
4194 wmi_buf, len,
4195 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4196 if (QDF_IS_STATUS_ERROR(ret)) {
4197 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4198 wmi_buf_free(wmi_buf);
4199 }
4200
4201 return ret;
4202}
4203
4204
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304205
Govind Singh4eacd2b2016-03-07 14:24:22 +05304206/**
4207 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4208 * @wmi_handle: wmi handle
4209 * @vdev_id: vdev id
4210 * @p2p_ie: p2p IE
4211 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304212 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304213 */
Govind Singhb53420c2016-03-09 14:32:57 +05304214QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304215 A_UINT32 vdev_id, uint8_t *p2p_ie)
4216{
Govind Singh67922e82016-04-01 16:48:57 +05304217 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304218 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4219 wmi_buf_t wmi_buf;
4220 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4221 uint8_t *buf_ptr;
4222
4223 ie_len = (uint32_t) (p2p_ie[1] + 2);
4224
4225 /* More than one P2P IE may be included in a single frame.
4226 If multiple P2P IEs are present, the complete P2P attribute
4227 data consists of the concatenation of the P2P Attribute
4228 fields of the P2P IEs. The P2P Attributes field of each
4229 P2P IE may be any length up to the maximum (251 octets).
4230 In this case host sends one P2P IE to firmware so the length
4231 should not exceed more than 251 bytes
4232 */
4233 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304234 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304235 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304236 }
4237
4238 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4239
4240 wmi_buf_len =
4241 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4242 WMI_TLV_HDR_SIZE;
4243
4244 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4245 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304246 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304247 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304248 }
4249
4250 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4251
4252 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4253 WMITLV_SET_HDR(&cmd->tlv_header,
4254 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4255 WMITLV_GET_STRUCT_TLVLEN
4256 (wmi_p2p_go_set_beacon_ie_fixed_param));
4257 cmd->vdev_id = vdev_id;
4258 cmd->ie_buf_len = ie_len;
4259
4260 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4261 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4262 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304263 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304264
Govind Singhb53420c2016-03-09 14:32:57 +05304265 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304266
4267 ret = wmi_unified_cmd_send(wmi_handle,
4268 wmi_buf, wmi_buf_len,
4269 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304270 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304271 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304272 wmi_buf_free(wmi_buf);
4273 }
4274
Govind Singhb53420c2016-03-09 14:32:57 +05304275 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304276 return ret;
4277}
4278
4279/**
4280 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4281 * @wmi_handle: wmi handle
4282 * @req: gateway parameter update request structure
4283 *
4284 * This function reads the incoming @req and fill in the destination
4285 * WMI structure and sends down the gateway configs down to the firmware
4286 *
Govind Singhb53420c2016-03-09 14:32:57 +05304287 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304288 */
Govind Singhb53420c2016-03-09 14:32:57 +05304289QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304290 struct gateway_update_req_param *req)
4291{
4292 wmi_roam_subnet_change_config_fixed_param *cmd;
4293 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304294 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304295 int len = sizeof(*cmd);
4296
4297 buf = wmi_buf_alloc(wmi_handle, len);
4298 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304299 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4300 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304301 }
4302
4303 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4304 WMITLV_SET_HDR(&cmd->tlv_header,
4305 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4306 WMITLV_GET_STRUCT_TLVLEN(
4307 wmi_roam_subnet_change_config_fixed_param));
4308
4309 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304310 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4311 QDF_IPV4_ADDR_SIZE);
4312 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4313 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304314 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4315 &cmd->inet_gw_mac_addr);
4316 cmd->max_retries = req->max_retries;
4317 cmd->timeout = req->timeout;
4318 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4319 cmd->flag = 0;
4320 if (req->ipv4_addr_type)
4321 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4322
4323 if (req->ipv6_addr_type)
4324 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4325
4326 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4327 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304328 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304329 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304330 ret);
4331 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304332 }
4333
Govind Singh67922e82016-04-01 16:48:57 +05304334 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304335}
4336
4337/**
4338 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4339 * @wmi_handle: wmi handle
4340 * @req: rssi monitoring request structure
4341 *
4342 * This function reads the incoming @req and fill in the destination
4343 * WMI structure and send down the rssi monitoring configs down to the firmware
4344 *
4345 * Return: 0 on success; error number otherwise
4346 */
Govind Singhb53420c2016-03-09 14:32:57 +05304347QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304348 struct rssi_monitor_param *req)
4349{
4350 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4351 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304352 QDF_STATUS ret;
4353 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304354
4355 buf = wmi_buf_alloc(wmi_handle, len);
4356 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304357 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4358 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304359 }
4360
4361 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4362 WMITLV_SET_HDR(&cmd->tlv_header,
4363 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4364 WMITLV_GET_STRUCT_TLVLEN(
4365 wmi_rssi_breach_monitor_config_fixed_param));
4366
4367 cmd->vdev_id = req->session_id;
4368 cmd->request_id = req->request_id;
4369 cmd->lo_rssi_reenable_hysteresis = 0;
4370 cmd->hi_rssi_reenable_histeresis = 0;
4371 cmd->min_report_interval = 0;
4372 cmd->max_num_report = 1;
4373 if (req->control) {
4374 /* enable one threshold for each min/max */
4375 cmd->enabled_bitmap = 0x09;
4376 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4377 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4378 } else {
4379 cmd->enabled_bitmap = 0;
4380 cmd->low_rssi_breach_threshold[0] = 0;
4381 cmd->hi_rssi_breach_threshold[0] = 0;
4382 }
4383
4384 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4385 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304386 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304387 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304388 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304389 }
4390
Govind Singhb53420c2016-03-09 14:32:57 +05304391 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304392 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304393}
4394
4395/**
4396 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4397 * @wmi_handle: wmi handle
4398 * @psetoui: OUI parameters
4399 *
4400 * set scan probe OUI parameters in firmware
4401 *
4402 * Return: CDF status
4403 */
Govind Singhb53420c2016-03-09 14:32:57 +05304404QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304405 struct scan_mac_oui *psetoui)
4406{
4407 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4408 wmi_buf_t wmi_buf;
4409 uint32_t len;
4410 uint8_t *buf_ptr;
4411 uint32_t *oui_buf;
4412
4413 len = sizeof(*cmd);
4414 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4415 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304416 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4417 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304418 }
4419 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4420 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4421 WMITLV_SET_HDR(&cmd->tlv_header,
4422 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4423 WMITLV_GET_STRUCT_TLVLEN
4424 (wmi_scan_prob_req_oui_cmd_fixed_param));
4425
4426 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304427 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304428 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4429 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304430 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304431 cmd->prob_req_oui);
4432
4433 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4434 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304435 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304436 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304437 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304438 }
Govind Singhb53420c2016-03-09 14:32:57 +05304439 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304440}
4441
4442/**
4443 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
4444 * @wmi_handle: wmi handle
4445 * @req: passpoint network request structure
4446 *
4447 * This function sends down WMI command with network id set to wildcard id.
4448 * firmware shall clear all the config entries
4449 *
Govind Singhb53420c2016-03-09 14:32:57 +05304450 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304451 */
Govind Singhb53420c2016-03-09 14:32:57 +05304452QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304453 struct wifi_passpoint_req_param *req)
4454{
4455 wmi_passpoint_config_cmd_fixed_param *cmd;
4456 wmi_buf_t buf;
4457 uint32_t len;
4458 int ret;
4459
4460 len = sizeof(*cmd);
4461 buf = wmi_buf_alloc(wmi_handle, len);
4462 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304463 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4464 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304465 }
4466
4467 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
4468
4469 WMITLV_SET_HDR(&cmd->tlv_header,
4470 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4471 WMITLV_GET_STRUCT_TLVLEN(
4472 wmi_passpoint_config_cmd_fixed_param));
4473 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
4474
4475 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4476 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4477 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304478 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304479 __func__);
4480 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304481 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304482 }
4483
Govind Singhb53420c2016-03-09 14:32:57 +05304484 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304485}
4486
4487/**
4488 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
4489 * @wmi_handle: wmi handle
4490 * @req: passpoint network request structure
4491 *
4492 * This function reads the incoming @req and fill in the destination
4493 * WMI structure and send down the passpoint configs down to the firmware
4494 *
Govind Singhb53420c2016-03-09 14:32:57 +05304495 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304496 */
Govind Singhb53420c2016-03-09 14:32:57 +05304497QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304498 struct wifi_passpoint_req_param *req)
4499{
4500 wmi_passpoint_config_cmd_fixed_param *cmd;
4501 u_int8_t i, j, *bytes;
4502 wmi_buf_t buf;
4503 uint32_t len;
4504 int ret;
4505
4506 len = sizeof(*cmd);
4507 for (i = 0; i < req->num_networks; i++) {
4508 buf = wmi_buf_alloc(wmi_handle, len);
4509 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304510 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4511 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304512 }
4513
4514 cmd = (wmi_passpoint_config_cmd_fixed_param *)
4515 wmi_buf_data(buf);
4516
4517 WMITLV_SET_HDR(&cmd->tlv_header,
4518 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4519 WMITLV_GET_STRUCT_TLVLEN(
4520 wmi_passpoint_config_cmd_fixed_param));
4521 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05304522 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
4523 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304524 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05304525 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304526 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
4527 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05304528 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304529 j, bytes[0], bytes[1], bytes[2], bytes[3],
4530 bytes[4], bytes[5], bytes[6], bytes[7]);
4531
Govind Singhb53420c2016-03-09 14:32:57 +05304532 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05304533 &req->networks[i].roaming_consortium_ids[j],
4534 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
4535 }
Govind Singhb53420c2016-03-09 14:32:57 +05304536 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304537 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304538 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304539 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
4540
4541 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4542 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4543 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304544 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304545 __func__);
4546 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304547 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304548 }
4549 }
4550
Govind Singhb53420c2016-03-09 14:32:57 +05304551 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304552}
4553
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304554/**
4555 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
4556 * @wmi_handle: wmi handle
4557 * @scan_cmd_fp: start scan command ptr
4558 * @roam_req: roam request param
4559 *
4560 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
4561 * of WMI_ROAM_SCAN_MODE.
4562 *
4563 * Return: QDF status
4564 */
4565QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
4566 wmi_start_scan_cmd_fixed_param *
4567 scan_cmd_fp,
4568 struct roam_offload_scan_params *roam_req)
4569{
4570 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304571 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304572 int len;
4573 uint8_t *buf_ptr;
4574 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05304575
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304576#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4577 int auth_mode = roam_req->auth_mode;
4578 wmi_roam_offload_tlv_param *roam_offload_params;
4579 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
4580 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
4581 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304582 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304583#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4584 /* Need to create a buf with roam_scan command at
4585 * front and piggyback with scan command */
4586 len = sizeof(wmi_roam_scan_mode_fixed_param) +
4587#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4588 (2 * WMI_TLV_HDR_SIZE) +
4589#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4590 sizeof(wmi_start_scan_cmd_fixed_param);
4591#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4592 if (roam_req->is_roam_req_valid &&
4593 roam_req->roam_offload_enabled) {
4594 len += sizeof(wmi_roam_offload_tlv_param);
4595 len += WMI_TLV_HDR_SIZE;
4596 if ((auth_mode != WMI_AUTH_NONE) &&
4597 ((auth_mode != WMI_AUTH_OPEN) ||
4598 (auth_mode == WMI_AUTH_OPEN &&
4599 roam_req->mdid.mdie_present) ||
4600 roam_req->is_ese_assoc)) {
4601 len += WMI_TLV_HDR_SIZE;
4602 if (roam_req->is_ese_assoc)
4603 len +=
4604 sizeof(wmi_roam_ese_offload_tlv_param);
4605 else if (auth_mode == WMI_AUTH_FT_RSNA ||
4606 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
4607 (auth_mode == WMI_AUTH_OPEN &&
4608 roam_req->mdid.mdie_present))
4609 len +=
4610 sizeof(wmi_roam_11r_offload_tlv_param);
4611 else
4612 len +=
4613 sizeof(wmi_roam_11i_offload_tlv_param);
4614 } else {
4615 len += WMI_TLV_HDR_SIZE;
4616 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304617
4618 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
4619 + roundup(roam_req->assoc_ie_length,
4620 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304621 } else {
4622 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05304623 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304624 __func__, roam_req->roam_offload_enabled);
4625 else
Govind Singhe7f2f342016-05-23 12:12:52 +05304626 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304627 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304628 }
4629 if (roam_req->is_roam_req_valid &&
4630 roam_req->roam_offload_enabled) {
4631 roam_req->mode = roam_req->mode |
4632 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
4633 }
4634#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4635
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304636 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4637 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4638 len = sizeof(wmi_roam_scan_mode_fixed_param);
4639
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304640 buf = wmi_buf_alloc(wmi_handle, len);
4641 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304642 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304643 return QDF_STATUS_E_NOMEM;
4644 }
4645
4646 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304647
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304648 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
4649 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
4650 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
4651 WMITLV_GET_STRUCT_TLVLEN
4652 (wmi_roam_scan_mode_fixed_param));
4653
4654 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
4655 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304656 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4657 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4658 goto send_roam_scan_mode_cmd;
4659
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304660 /* Fill in scan parameters suitable for roaming scan */
4661 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304662
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304663 qdf_mem_copy(buf_ptr, scan_cmd_fp,
4664 sizeof(wmi_start_scan_cmd_fixed_param));
4665 /* Ensure there is no additional IEs */
4666 scan_cmd_fp->ie_len = 0;
4667 WMITLV_SET_HDR(buf_ptr,
4668 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
4669 WMITLV_GET_STRUCT_TLVLEN
4670 (wmi_start_scan_cmd_fixed_param));
4671#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4672 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
4673 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
4674 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4675 sizeof(wmi_roam_offload_tlv_param));
4676 buf_ptr += WMI_TLV_HDR_SIZE;
4677 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
4678 WMITLV_SET_HDR(buf_ptr,
4679 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
4680 WMITLV_GET_STRUCT_TLVLEN
4681 (wmi_roam_offload_tlv_param));
4682 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
4683 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
4684 roam_offload_params->select_5g_margin =
4685 roam_req->select_5ghz_margin;
4686 roam_offload_params->reassoc_failure_timeout =
4687 roam_req->reassoc_failure_timeout;
4688
4689 /* Fill the capabilities */
4690 roam_offload_params->capability =
4691 roam_req->roam_offload_params.capability;
4692 roam_offload_params->ht_caps_info =
4693 roam_req->roam_offload_params.ht_caps_info;
4694 roam_offload_params->ampdu_param =
4695 roam_req->roam_offload_params.ampdu_param;
4696 roam_offload_params->ht_ext_cap =
4697 roam_req->roam_offload_params.ht_ext_cap;
4698 roam_offload_params->ht_txbf =
4699 roam_req->roam_offload_params.ht_txbf;
4700 roam_offload_params->asel_cap =
4701 roam_req->roam_offload_params.asel_cap;
4702 roam_offload_params->qos_caps =
4703 roam_req->roam_offload_params.qos_caps;
4704 roam_offload_params->wmm_caps =
4705 roam_req->roam_offload_params.wmm_caps;
4706 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
4707 (uint8_t *)roam_req->roam_offload_params.mcsset,
4708 ROAM_OFFLOAD_NUM_MCS_SET);
4709
4710 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
4711 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
4712 * they are filled in the same order.Depending on the
4713 * authentication type, the other mode TLV's are nullified
4714 * and only headers are filled.*/
4715 if ((auth_mode != WMI_AUTH_NONE) &&
4716 ((auth_mode != WMI_AUTH_OPEN) ||
4717 (auth_mode == WMI_AUTH_OPEN
4718 && roam_req->mdid.mdie_present) ||
4719 roam_req->is_ese_assoc)) {
4720 if (roam_req->is_ese_assoc) {
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 WMITLV_GET_STRUCT_TLVLEN(0));
4726 buf_ptr += WMI_TLV_HDR_SIZE;
4727 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4728 sizeof(wmi_roam_ese_offload_tlv_param));
4729 buf_ptr += WMI_TLV_HDR_SIZE;
4730 roam_offload_ese =
4731 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
4732 qdf_mem_copy(roam_offload_ese->krk,
4733 roam_req->krk,
4734 sizeof(roam_req->krk));
4735 qdf_mem_copy(roam_offload_ese->btk,
4736 roam_req->btk,
4737 sizeof(roam_req->btk));
4738 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
4739 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
4740 WMITLV_GET_STRUCT_TLVLEN
4741 (wmi_roam_ese_offload_tlv_param));
4742 buf_ptr +=
4743 sizeof(wmi_roam_ese_offload_tlv_param);
4744 } else if (auth_mode == WMI_AUTH_FT_RSNA
4745 || auth_mode == WMI_AUTH_FT_RSNA_PSK
4746 || (auth_mode == WMI_AUTH_OPEN
4747 && roam_req->mdid.mdie_present)) {
4748 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4749 0);
4750 buf_ptr += WMI_TLV_HDR_SIZE;
4751 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4752 sizeof(wmi_roam_11r_offload_tlv_param));
4753 buf_ptr += WMI_TLV_HDR_SIZE;
4754 roam_offload_11r =
4755 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
4756 roam_offload_11r->r0kh_id_len =
4757 roam_req->rokh_id_length;
4758 qdf_mem_copy(roam_offload_11r->r0kh_id,
4759 roam_req->rokh_id,
4760 roam_offload_11r->r0kh_id_len);
4761 qdf_mem_copy(roam_offload_11r->psk_msk,
4762 roam_req->psk_pmk,
4763 sizeof(roam_req->psk_pmk));
4764 roam_offload_11r->psk_msk_len =
4765 roam_req->pmk_len;
4766 roam_offload_11r->mdie_present =
4767 roam_req->mdid.mdie_present;
4768 roam_offload_11r->mdid =
4769 roam_req->mdid.mobility_domain;
4770 if (auth_mode == WMI_AUTH_OPEN) {
4771 /* If FT-Open ensure pmk length
4772 and r0khid len are zero */
4773 roam_offload_11r->r0kh_id_len = 0;
4774 roam_offload_11r->psk_msk_len = 0;
4775 }
4776 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
4777 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
4778 WMITLV_GET_STRUCT_TLVLEN
4779 (wmi_roam_11r_offload_tlv_param));
4780 buf_ptr +=
4781 sizeof(wmi_roam_11r_offload_tlv_param);
4782 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4783 WMITLV_GET_STRUCT_TLVLEN(0));
4784 buf_ptr += WMI_TLV_HDR_SIZE;
4785 } else {
4786 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4787 sizeof(wmi_roam_11i_offload_tlv_param));
4788 buf_ptr += WMI_TLV_HDR_SIZE;
4789 roam_offload_11i =
4790 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07004791 if (roam_req->roam_key_mgmt_offload_enabled &&
4792 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304793 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
4794 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304795 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304796 } else {
4797 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
4798 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304799 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304800 }
4801
4802 qdf_mem_copy(roam_offload_11i->pmk,
4803 roam_req->psk_pmk,
4804 sizeof(roam_req->psk_pmk));
4805 roam_offload_11i->pmk_len = roam_req->pmk_len;
4806 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
4807 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
4808 WMITLV_GET_STRUCT_TLVLEN
4809 (wmi_roam_11i_offload_tlv_param));
4810 buf_ptr +=
4811 sizeof(wmi_roam_11i_offload_tlv_param);
4812 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4813 0);
4814 buf_ptr += WMI_TLV_HDR_SIZE;
4815 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4816 0);
4817 buf_ptr += WMI_TLV_HDR_SIZE;
4818 }
4819 } else {
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));
4825 buf_ptr += WMI_TLV_HDR_SIZE;
4826 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4827 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304828 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304829 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304830
4831 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4832 sizeof(*assoc_ies));
4833 buf_ptr += WMI_TLV_HDR_SIZE;
4834
4835 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
4836 WMITLV_SET_HDR(&assoc_ies->tlv_header,
4837 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
4838 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
4839 assoc_ies->buf_len = roam_req->assoc_ie_length;
4840
4841 buf_ptr += sizeof(*assoc_ies);
4842
4843 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4844 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
4845 buf_ptr += WMI_TLV_HDR_SIZE;
4846
4847 if (assoc_ies->buf_len != 0) {
4848 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
4849 assoc_ies->buf_len);
4850 }
4851
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304852 } else {
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));
4861 buf_ptr += WMI_TLV_HDR_SIZE;
4862 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4863 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304864 buf_ptr += WMI_TLV_HDR_SIZE;
4865 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4866 WMITLV_GET_STRUCT_TLVLEN(0));
4867 buf_ptr += WMI_TLV_HDR_SIZE;
4868 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4869 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304870 }
4871#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304872
4873send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304874 status = wmi_unified_cmd_send(wmi_handle, buf,
4875 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05304876 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304877 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304878 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
4879 status);
4880 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304881 }
4882
Govind Singh67922e82016-04-01 16:48:57 +05304883 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304884}
4885
4886
4887/**
4888 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
4889 * rssi threashold
4890 * @wmi_handle: wmi handle
4891 * @roam_req: Roaming request buffer
4892 *
4893 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
4894 *
4895 * Return: QDF status
4896 */
4897QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
4898 struct roam_offload_scan_rssi_params *roam_req)
4899{
4900 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304901 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304902 int len;
4903 uint8_t *buf_ptr;
4904 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
4905 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
4906 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05304907 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304908
4909 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4910 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
4911 len += sizeof(wmi_roam_scan_extended_threshold_param);
4912 len += WMI_TLV_HDR_SIZE;
4913 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05304914 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
4915 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304916 buf = wmi_buf_alloc(wmi_handle, len);
4917 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304918 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304919 return QDF_STATUS_E_NOMEM;
4920 }
4921
4922 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4923 rssi_threshold_fp =
4924 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
4925 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
4926 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
4927 WMITLV_GET_STRUCT_TLVLEN
4928 (wmi_roam_scan_rssi_threshold_fixed_param));
4929 /* fill in threshold values */
4930 rssi_threshold_fp->vdev_id = roam_req->session_id;
4931 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
4932 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
4933 rssi_threshold_fp->hirssi_scan_max_count =
4934 roam_req->hi_rssi_scan_max_count;
4935 rssi_threshold_fp->hirssi_scan_delta =
4936 roam_req->hi_rssi_scan_rssi_delta;
4937 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
4938
4939 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4940 WMITLV_SET_HDR(buf_ptr,
4941 WMITLV_TAG_ARRAY_STRUC,
4942 sizeof(wmi_roam_scan_extended_threshold_param));
4943 buf_ptr += WMI_TLV_HDR_SIZE;
4944 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
4945
4946 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
4947 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
4948 ext_thresholds->boost_threshold_5g =
4949 roam_req->boost_threshold_5g;
4950
4951 ext_thresholds->boost_algorithm_5g =
4952 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4953 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
4954 ext_thresholds->penalty_algorithm_5g =
4955 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4956 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
4957 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
4958 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
4959 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
4960
4961 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
4962 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
4963 WMITLV_GET_STRUCT_TLVLEN
4964 (wmi_roam_scan_extended_threshold_param));
4965 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
4966 WMITLV_SET_HDR(buf_ptr,
4967 WMITLV_TAG_ARRAY_STRUC,
4968 sizeof(wmi_roam_earlystop_rssi_thres_param));
4969 buf_ptr += WMI_TLV_HDR_SIZE;
4970 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
4971 early_stop_thresholds->roam_earlystop_thres_min =
4972 roam_req->roam_earlystop_thres_min;
4973 early_stop_thresholds->roam_earlystop_thres_max =
4974 roam_req->roam_earlystop_thres_max;
4975 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
4976 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
4977 WMITLV_GET_STRUCT_TLVLEN
4978 (wmi_roam_earlystop_rssi_thres_param));
4979
Gupta, Kapil7e652922016-04-12 15:02:00 +05304980 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
4981 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4982 sizeof(wmi_roam_dense_thres_param));
4983 buf_ptr += WMI_TLV_HDR_SIZE;
4984 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
4985 dense_thresholds->roam_dense_rssi_thres_offset =
4986 roam_req->dense_rssi_thresh_offset;
4987 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
4988 dense_thresholds->roam_dense_traffic_thres =
4989 roam_req->traffic_threshold;
4990 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
4991 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
4992 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
4993 WMITLV_GET_STRUCT_TLVLEN
4994 (wmi_roam_dense_thres_param));
4995
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304996 status = wmi_unified_cmd_send(wmi_handle, buf,
4997 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05304998 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304999 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305000 status);
5001 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305002 }
5003
Govind Singh67922e82016-04-01 16:48:57 +05305004 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305005}
5006
5007/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305008 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5009 * configuration params
5010 * @wma_handle: wma handler
5011 * @dwelltime_params: pointer to dwelltime_params
5012 *
5013 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5014 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005015static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305016QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5017 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5018{
5019 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5020 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5021 wmi_buf_t buf;
5022 uint8_t *buf_ptr;
5023 int32_t err;
5024 int len;
5025
5026 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5027 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5028 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5029 buf = wmi_buf_alloc(wmi_handle, len);
5030 if (!buf) {
5031 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5032 __func__);
5033 return QDF_STATUS_E_NOMEM;
5034 }
5035 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5036 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5037 WMITLV_SET_HDR(&dwell_param->tlv_header,
5038 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5039 WMITLV_GET_STRUCT_TLVLEN
5040 (wmi_scan_adaptive_dwell_config_fixed_param));
5041
5042 dwell_param->enable = dwelltime_params->is_enabled;
5043 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5044 WMITLV_SET_HDR(buf_ptr,
5045 WMITLV_TAG_ARRAY_STRUC,
5046 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5047 buf_ptr += WMI_TLV_HDR_SIZE;
5048
5049 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5050 WMITLV_SET_HDR(&cmd->tlv_header,
5051 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5052 WMITLV_GET_STRUCT_TLVLEN(
5053 wmi_scan_adaptive_dwell_parameters_tlv));
5054
5055 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5056 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5057 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5058 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5059 err = wmi_unified_cmd_send(wmi_handle, buf,
5060 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5061 if (err) {
5062 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5063 wmi_buf_free(buf);
5064 return QDF_STATUS_E_FAILURE;
5065 }
5066
5067 return QDF_STATUS_SUCCESS;
5068}
5069
5070
5071/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305072 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5073 * @wmi_handle: wmi handle
5074 * @roam_req: Request which contains the filters
5075 *
5076 * There are filters such as whitelist, blacklist and preferred
5077 * list that need to be applied to the scan results to form the
5078 * probable candidates for roaming.
5079 *
5080 * Return: Return success upon succesfully passing the
5081 * parameters to the firmware, otherwise failure.
5082 */
5083QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
5084 struct roam_scan_filter_params *roam_req)
5085{
5086 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305087 QDF_STATUS status;
5088 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305089 uint32_t len;
5090 uint8_t *buf_ptr;
5091 wmi_roam_filter_fixed_param *roam_filter;
5092 uint8_t *bssid_src_ptr = NULL;
5093 wmi_mac_addr *bssid_dst_ptr = NULL;
5094 wmi_ssid *ssid_ptr = NULL;
5095 uint32_t *bssid_preferred_factor_ptr = NULL;
5096
5097 len = sizeof(wmi_roam_filter_fixed_param);
5098 len += WMI_TLV_HDR_SIZE;
5099 len += roam_req->len;
5100
5101 buf = wmi_buf_alloc(wmi_handle, len);
5102 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305103 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305104 return QDF_STATUS_E_NOMEM;
5105 }
5106
5107 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5108 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5109 WMITLV_SET_HDR(&roam_filter->tlv_header,
5110 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5111 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5112 /* fill in fixed values */
5113 roam_filter->vdev_id = roam_req->session_id;
5114 roam_filter->flags = 0;
5115 roam_filter->op_bitmap = roam_req->op_bitmap;
5116 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5117 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5118 roam_filter->num_bssid_preferred_list =
5119 roam_req->num_bssid_preferred_list;
5120 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5121
5122 WMITLV_SET_HDR((buf_ptr),
5123 WMITLV_TAG_ARRAY_FIXED_STRUC,
5124 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5125 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5126 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5127 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5128 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5129 bssid_src_ptr += ATH_MAC_LEN;
5130 bssid_dst_ptr++;
5131 }
5132 buf_ptr += WMI_TLV_HDR_SIZE +
5133 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5134 WMITLV_SET_HDR((buf_ptr),
5135 WMITLV_TAG_ARRAY_FIXED_STRUC,
5136 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5137 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5138 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5139 qdf_mem_copy(&ssid_ptr->ssid,
5140 &roam_req->ssid_allowed_list[i].mac_ssid,
5141 roam_req->ssid_allowed_list[i].length);
5142 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5143 ssid_ptr++;
5144 }
5145 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5146 sizeof(wmi_ssid));
5147 WMITLV_SET_HDR((buf_ptr),
5148 WMITLV_TAG_ARRAY_FIXED_STRUC,
5149 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5150 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5151 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5152 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5153 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5154 (wmi_mac_addr *)bssid_dst_ptr);
5155 bssid_src_ptr += ATH_MAC_LEN;
5156 bssid_dst_ptr++;
5157 }
5158 buf_ptr += WMI_TLV_HDR_SIZE +
5159 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5160 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5161 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5162 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5163 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5164 *bssid_preferred_factor_ptr =
5165 roam_req->bssid_favored_factor[i];
5166 bssid_preferred_factor_ptr++;
5167 }
5168 buf_ptr += WMI_TLV_HDR_SIZE +
5169 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5170
5171 status = wmi_unified_cmd_send(wmi_handle, buf,
5172 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305173 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305174 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305175 status);
5176 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305177 }
Govind Singh67922e82016-04-01 16:48:57 +05305178
5179 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305180}
5181
Govind Singh4eacd2b2016-03-07 14:24:22 +05305182/** send_set_epno_network_list_cmd_tlv() - set epno network list
5183 * @wmi_handle: wmi handle
5184 * @req: epno config params request structure
5185 *
5186 * This function reads the incoming epno config request structure
5187 * and constructs the WMI message to the firmware.
5188 *
5189 * Returns: 0 on success, error number otherwise
5190 */
Govind Singhb53420c2016-03-09 14:32:57 +05305191QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305192 struct wifi_enhanched_pno_params *req)
5193{
5194 wmi_nlo_config_cmd_fixed_param *cmd;
5195 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305196 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305197 u_int8_t i, *buf_ptr;
5198 wmi_buf_t buf;
5199 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305200 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305201
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305202 /* Fixed Params */
5203 len = sizeof(*cmd);
5204 if (req->num_networks) {
5205 /* TLV place holder for array of structures
5206 * then each nlo_configured_parameters(nlo_list) TLV.
5207 */
5208 len += WMI_TLV_HDR_SIZE;
5209 len += (sizeof(nlo_configured_parameters)
5210 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5211 /* TLV for array of uint32 channel_list */
5212 len += WMI_TLV_HDR_SIZE;
5213 /* TLV for nlo_channel_prediction_cfg */
5214 len += WMI_TLV_HDR_SIZE;
5215 /* TLV for candidate score params */
5216 len += sizeof(enlo_candidate_score_params);
5217 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305218
5219 buf = wmi_buf_alloc(wmi_handle, len);
5220 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305221 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5222 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305223 }
5224
5225 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5226
5227 buf_ptr = (u_int8_t *) cmd;
5228 WMITLV_SET_HDR(&cmd->tlv_header,
5229 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5230 WMITLV_GET_STRUCT_TLVLEN(
5231 wmi_nlo_config_cmd_fixed_param));
5232 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305233
5234 /* set flag to reset if num of networks are 0 */
5235 cmd->flags = (req->num_networks == 0 ?
5236 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305237
5238 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5239
Govind Singhb53420c2016-03-09 14:32:57 +05305240 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305241 WMI_LOGD("SSID count: %d flags: %d",
5242 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305243
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305244 /* Fill nlo_config only when num_networks are non zero */
5245 if (cmd->no_of_ssids) {
5246 /* Fill networks */
5247 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5248 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5249 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305250
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305251 nlo_list = (nlo_configured_parameters *) buf_ptr;
5252 for (i = 0; i < cmd->no_of_ssids; i++) {
5253 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5254 WMITLV_TAG_ARRAY_BYTE,
5255 WMITLV_GET_STRUCT_TLVLEN(
5256 nlo_configured_parameters));
5257 /* Copy ssid and it's length */
5258 nlo_list[i].ssid.valid = true;
5259 nlo_list[i].ssid.ssid.ssid_len =
5260 req->networks[i].ssid.length;
5261 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5262 req->networks[i].ssid.mac_ssid,
5263 nlo_list[i].ssid.ssid.ssid_len);
5264 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5265 nlo_list[i].ssid.ssid.ssid_len,
5266 (char *) nlo_list[i].ssid.ssid.ssid,
5267 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305268
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305269 /* Copy pno flags */
5270 nlo_list[i].bcast_nw_type.valid = true;
5271 nlo_list[i].bcast_nw_type.bcast_nw_type =
5272 req->networks[i].flags;
5273 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305274 nlo_list[i].bcast_nw_type.bcast_nw_type);
5275
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305276 /* Copy auth bit field */
5277 nlo_list[i].auth_type.valid = true;
5278 nlo_list[i].auth_type.auth_type =
5279 req->networks[i].auth_bit_field;
5280 WMI_LOGD("Auth bit field (%u)",
5281 nlo_list[i].auth_type.auth_type);
5282 }
5283
5284 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5285 /* Fill the channel list */
5286 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5287 buf_ptr += WMI_TLV_HDR_SIZE;
5288
5289 /* Fill prediction_param */
5290 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5291 buf_ptr += WMI_TLV_HDR_SIZE;
5292
5293 /* Fill epno candidate score params */
5294 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5295 WMITLV_SET_HDR(buf_ptr,
5296 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5297 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5298 cand_score_params->min5GHz_rssi =
5299 req->min_5ghz_rssi;
5300 cand_score_params->min24GHz_rssi =
5301 req->min_24ghz_rssi;
5302 cand_score_params->initial_score_max =
5303 req->initial_score_max;
5304 cand_score_params->current_connection_bonus =
5305 req->current_connection_bonus;
5306 cand_score_params->same_network_bonus =
5307 req->same_network_bonus;
5308 cand_score_params->secure_bonus =
5309 req->secure_bonus;
5310 cand_score_params->band5GHz_bonus =
5311 req->band_5ghz_bonus;
5312 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305313 }
5314
Govind Singh4eacd2b2016-03-07 14:24:22 +05305315 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305316 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305317 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305318 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305319 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305320 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305321 }
5322
Govind Singhb53420c2016-03-09 14:32:57 +05305323 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305324 req->session_id);
5325
Govind Singh67922e82016-04-01 16:48:57 +05305326 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305327}
5328
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305329
Govind Singh4eacd2b2016-03-07 14:24:22 +05305330/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5331 * @wmi_handle: wmi handle
5332 * @ipa_offload: ipa offload control parameter
5333 *
5334 * Returns: 0 on success, error number otherwise
5335 */
Govind Singhb53420c2016-03-09 14:32:57 +05305336QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305337 struct ipa_offload_control_params *ipa_offload)
5338{
5339 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5340 wmi_buf_t wmi_buf;
5341 uint32_t len;
5342 u_int8_t *buf_ptr;
5343
5344 len = sizeof(*cmd);
5345 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5346 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305347 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5348 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305349 }
5350
Govind Singhb53420c2016-03-09 14:32:57 +05305351 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305352 ipa_offload->offload_type, ipa_offload->enable);
5353
5354 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5355
5356 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5357 WMITLV_SET_HDR(&cmd->tlv_header,
5358 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5359 WMITLV_GET_STRUCT_TLVLEN(
5360 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5361
5362 cmd->offload_type = ipa_offload->offload_type;
5363 cmd->vdev_id = ipa_offload->vdev_id;
5364 cmd->enable = ipa_offload->enable;
5365
5366 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5367 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305368 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305369 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305370 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305371 }
5372
Govind Singhb53420c2016-03-09 14:32:57 +05305373 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305374}
5375
5376/**
5377 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5378 * @wmi_handle: wmi handle
5379 * @pgetcapab: get capabilities params
5380 *
5381 * This function send request to fw to get extscan capabilities.
5382 *
5383 * Return: CDF status
5384 */
Govind Singhb53420c2016-03-09 14:32:57 +05305385QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305386 struct extscan_capabilities_params *pgetcapab)
5387{
5388 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5389 wmi_buf_t wmi_buf;
5390 uint32_t len;
5391 uint8_t *buf_ptr;
5392
5393 len = sizeof(*cmd);
5394 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5395 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305396 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5397 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305398 }
5399 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5400
5401 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5402 WMITLV_SET_HDR(&cmd->tlv_header,
5403 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5404 WMITLV_GET_STRUCT_TLVLEN
5405 (wmi_extscan_get_capabilities_cmd_fixed_param));
5406
5407 cmd->request_id = pgetcapab->request_id;
5408
5409 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5410 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305411 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305412 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305413 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305414 }
Govind Singhb53420c2016-03-09 14:32:57 +05305415 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305416}
5417
5418/**
5419 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5420 * @wmi_handle: wmi handle
5421 * @pcached_results: cached results parameters
5422 *
5423 * This function send request to fw to get cached results.
5424 *
5425 * Return: CDF status
5426 */
Govind Singhb53420c2016-03-09 14:32:57 +05305427QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305428 struct extscan_cached_result_params *pcached_results)
5429{
5430 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5431 wmi_buf_t wmi_buf;
5432 uint32_t len;
5433 uint8_t *buf_ptr;
5434
5435 len = sizeof(*cmd);
5436 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5437 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305438 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5439 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305440 }
5441 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5442
5443 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
5444 WMITLV_SET_HDR(&cmd->tlv_header,
5445 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
5446 WMITLV_GET_STRUCT_TLVLEN
5447 (wmi_extscan_get_cached_results_cmd_fixed_param));
5448
5449 cmd->request_id = pcached_results->request_id;
5450 cmd->vdev_id = pcached_results->session_id;
5451 cmd->control_flags = pcached_results->flush;
5452
5453 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5454 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305455 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305456 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305457 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305458 }
Govind Singhb53420c2016-03-09 14:32:57 +05305459 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305460}
5461
5462/**
5463 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
5464 * @wmi_handle: wmi handle
5465 * @reset_req: Reset change request params
5466 *
5467 * This function sends stop change monitor request to fw.
5468 *
5469 * Return: CDF status
5470 */
Govind Singhb53420c2016-03-09 14:32:57 +05305471QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305472 struct extscan_capabilities_reset_params *reset_req)
5473{
5474 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5475 wmi_buf_t wmi_buf;
5476 uint32_t len;
5477 uint8_t *buf_ptr;
5478 int change_list = 0;
5479
5480 len = sizeof(*cmd);
5481
5482 /* reset significant change tlv is set to 0 */
5483 len += WMI_TLV_HDR_SIZE;
5484 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
5485 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5486 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305487 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5488 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305489 }
5490 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5491
5492 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5493 buf_ptr;
5494 WMITLV_SET_HDR(&cmd->tlv_header,
5495 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5496 WMITLV_GET_STRUCT_TLVLEN
5497 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5498
5499 cmd->request_id = reset_req->request_id;
5500 cmd->vdev_id = reset_req->session_id;
5501 cmd->mode = 0;
5502
5503 buf_ptr += sizeof(*cmd);
5504 WMITLV_SET_HDR(buf_ptr,
5505 WMITLV_TAG_ARRAY_STRUC,
5506 change_list *
5507 sizeof(wmi_extscan_wlan_change_bssid_param));
5508 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
5509 sizeof
5510 (wmi_extscan_wlan_change_bssid_param));
5511
5512 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5513 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305514 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305515 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305516 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305517 }
Govind Singhb53420c2016-03-09 14:32:57 +05305518 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305519}
5520
5521/**
5522 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
5523 * @wmi_handle: wmi handle
5524 * @psigchange: change monitor request params
5525 * @buf: wmi buffer
5526 * @buf_len: buffer length
5527 *
5528 * This function fills elements of change monitor request buffer.
5529 *
5530 * Return: CDF status
5531 */
Govind Singhb53420c2016-03-09 14:32:57 +05305532static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305533 struct extscan_set_sig_changereq_params
5534 *psigchange, wmi_buf_t *buf, int *buf_len)
5535{
5536 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5537 wmi_extscan_wlan_change_bssid_param *dest_chglist;
5538 uint8_t *buf_ptr;
5539 int j;
5540 int len = sizeof(*cmd);
5541 int numap = psigchange->num_ap;
5542 struct ap_threshold_params *src_ap = psigchange->ap;
5543
5544 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +05305545 WMI_LOGE("%s: Invalid number of bssid's", __func__);
5546 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305547 }
5548 len += WMI_TLV_HDR_SIZE;
5549 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
5550
5551 *buf = wmi_buf_alloc(wmi_handle, len);
5552 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305553 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305554 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305555 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305556 }
5557 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5558 cmd =
5559 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5560 buf_ptr;
5561 WMITLV_SET_HDR(&cmd->tlv_header,
5562 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5563 WMITLV_GET_STRUCT_TLVLEN
5564 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5565
5566 cmd->request_id = psigchange->request_id;
5567 cmd->vdev_id = psigchange->session_id;
5568 cmd->total_entries = numap;
5569 cmd->mode = 1;
5570 cmd->num_entries_in_page = numap;
5571 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
5572 cmd->max_rssi_samples = psigchange->rssi_sample_size;
5573 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
5574 cmd->max_out_of_range_count = psigchange->min_breaching;
5575
5576 buf_ptr += sizeof(*cmd);
5577 WMITLV_SET_HDR(buf_ptr,
5578 WMITLV_TAG_ARRAY_STRUC,
5579 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5580 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
5581 (buf_ptr + WMI_TLV_HDR_SIZE);
5582
5583 for (j = 0; j < numap; j++) {
5584 WMITLV_SET_HDR(dest_chglist,
5585 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5586 WMITLV_GET_STRUCT_TLVLEN
5587 (wmi_extscan_wlan_change_bssid_param));
5588
5589 dest_chglist->lower_rssi_limit = src_ap->low;
5590 dest_chglist->upper_rssi_limit = src_ap->high;
5591 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
5592 &dest_chglist->bssid);
5593
Govind Singhb53420c2016-03-09 14:32:57 +05305594 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305595 dest_chglist->lower_rssi_limit);
5596 dest_chglist++;
5597 src_ap++;
5598 }
5599 buf_ptr += WMI_TLV_HDR_SIZE +
5600 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5601 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305602 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305603}
5604
5605/**
5606 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
5607 * @wmi_handle: wmi handle
5608 * @psigchange: change monitor request params
5609 *
5610 * This function sends start change monitor request to fw.
5611 *
5612 * Return: CDF status
5613 */
Govind Singhb53420c2016-03-09 14:32:57 +05305614QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305615 struct extscan_set_sig_changereq_params *
5616 psigchange)
5617{
Govind Singhb53420c2016-03-09 14:32:57 +05305618 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305619 wmi_buf_t buf;
5620 int len;
5621
5622
Govind Singhb53420c2016-03-09 14:32:57 +05305623 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305624 psigchange, &buf,
5625 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305626 if (qdf_status != QDF_STATUS_SUCCESS) {
5627 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305628 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305629 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305630 }
5631 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305632 WMI_LOGE("%s: Failed to get buffer", __func__);
5633 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305634 }
5635 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5636 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305637 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305638 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305639 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305640 }
Govind Singhb53420c2016-03-09 14:32:57 +05305641 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305642}
5643
5644/**
5645 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
5646 * @wmi_handle: wmi handle
5647 * @photlist_reset: hotlist reset params
5648 *
5649 * This function configures hotlist monitor to stop in fw.
5650 *
5651 * Return: CDF status
5652 */
Govind Singhb53420c2016-03-09 14:32:57 +05305653QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305654 struct extscan_bssid_hotlist_reset_params *photlist_reset)
5655{
5656 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
5657 wmi_buf_t wmi_buf;
5658 uint32_t len;
5659 uint8_t *buf_ptr;
5660 int hotlist_entries = 0;
5661
5662 len = sizeof(*cmd);
5663
5664 /* reset bssid hotlist with tlv set to 0 */
5665 len += WMI_TLV_HDR_SIZE;
5666 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
5667
5668 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5669 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305670 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5671 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305672 }
5673
5674 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5675 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
5676 buf_ptr;
5677 WMITLV_SET_HDR(&cmd->tlv_header,
5678 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
5679 WMITLV_GET_STRUCT_TLVLEN
5680 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
5681
5682 cmd->request_id = photlist_reset->request_id;
5683 cmd->vdev_id = photlist_reset->session_id;
5684 cmd->mode = 0;
5685
5686 buf_ptr += sizeof(*cmd);
5687 WMITLV_SET_HDR(buf_ptr,
5688 WMITLV_TAG_ARRAY_STRUC,
5689 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5690 buf_ptr += WMI_TLV_HDR_SIZE +
5691 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5692
5693 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5694 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305695 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305696 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305697 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305698 }
Govind Singhb53420c2016-03-09 14:32:57 +05305699 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305700}
5701
5702/**
5703 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
5704 * @wmi_handle: wmi handle
5705 * @pstopcmd: stop scan command request params
5706 *
5707 * This function sends stop extscan request to fw.
5708 *
5709 * Return: CDF Status.
5710 */
Govind Singhb53420c2016-03-09 14:32:57 +05305711QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305712 struct extscan_stop_req_params *pstopcmd)
5713{
5714 wmi_extscan_stop_cmd_fixed_param *cmd;
5715 wmi_buf_t wmi_buf;
5716 uint32_t len;
5717 uint8_t *buf_ptr;
5718
5719 len = sizeof(*cmd);
5720 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5721 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305722 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5723 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305724 }
5725 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5726 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
5727 WMITLV_SET_HDR(&cmd->tlv_header,
5728 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
5729 WMITLV_GET_STRUCT_TLVLEN
5730 (wmi_extscan_stop_cmd_fixed_param));
5731
5732 cmd->request_id = pstopcmd->request_id;
5733 cmd->vdev_id = pstopcmd->session_id;
5734
5735 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5736 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305737 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305738 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305739 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305740 }
5741
Govind Singhb53420c2016-03-09 14:32:57 +05305742 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305743}
5744
5745/**
5746 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
5747 * @wmi_handle: wmi handle
5748 * @pstart: scan command request params
5749 * @buf: event buffer
5750 * @buf_len: length of buffer
5751 *
5752 * This function fills individual elements of extscan request and
5753 * TLV for buckets, channel list.
5754 *
5755 * Return: CDF Status.
5756 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005757static
Govind Singhb53420c2016-03-09 14:32:57 +05305758QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305759 struct wifi_scan_cmd_req_params *pstart,
5760 wmi_buf_t *buf, int *buf_len)
5761{
5762 wmi_extscan_start_cmd_fixed_param *cmd;
5763 wmi_extscan_bucket *dest_blist;
5764 wmi_extscan_bucket_channel *dest_clist;
5765 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
5766 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
5767 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
5768
5769 uint8_t *buf_ptr;
5770 int i, k, count = 0;
5771 int len = sizeof(*cmd);
5772 int nbuckets = pstart->numBuckets;
5773 int nchannels = 0;
5774
5775 /* These TLV's are are NULL by default */
5776 uint32_t ie_len_with_pad = 0;
5777 int num_ssid = 0;
5778 int num_bssid = 0;
5779 int ie_len = 0;
5780
5781 uint32_t base_period = pstart->basePeriod;
5782
5783 /* TLV placeholder for ssid_list (NULL) */
5784 len += WMI_TLV_HDR_SIZE;
5785 len += num_ssid * sizeof(wmi_ssid);
5786
5787 /* TLV placeholder for bssid_list (NULL) */
5788 len += WMI_TLV_HDR_SIZE;
5789 len += num_bssid * sizeof(wmi_mac_addr);
5790
5791 /* TLV placeholder for ie_data (NULL) */
5792 len += WMI_TLV_HDR_SIZE;
5793 len += ie_len * sizeof(uint32_t);
5794
5795 /* TLV placeholder for bucket */
5796 len += WMI_TLV_HDR_SIZE;
5797 len += nbuckets * sizeof(wmi_extscan_bucket);
5798
5799 /* TLV channel placeholder */
5800 len += WMI_TLV_HDR_SIZE;
5801 for (i = 0; i < nbuckets; i++) {
5802 nchannels += src_bucket->numChannels;
5803 src_bucket++;
5804 }
5805
Govind Singhb53420c2016-03-09 14:32:57 +05305806 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305807 __func__, nbuckets, nchannels);
5808 len += nchannels * sizeof(wmi_extscan_bucket_channel);
5809 /* Allocate the memory */
5810 *buf = wmi_buf_alloc(wmi_handle, len);
5811 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305812 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05305813 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305814 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305815 }
5816 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5817 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
5818 WMITLV_SET_HDR(&cmd->tlv_header,
5819 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
5820 WMITLV_GET_STRUCT_TLVLEN
5821 (wmi_extscan_start_cmd_fixed_param));
5822
5823 cmd->request_id = pstart->requestId;
5824 cmd->vdev_id = pstart->sessionId;
5825 cmd->base_period = pstart->basePeriod;
5826 cmd->num_buckets = nbuckets;
5827 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05305828 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305829 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05305830 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305831 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05305832#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05305833 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
5834 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05305835 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
5836 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
5837#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05305838 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5839
5840 /* The max dwell time is retrieved from the first channel
5841 * of the first bucket and kept common for all channels.
5842 */
5843 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
5844 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
5845 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
5846 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
5847 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5848 cmd->max_table_usage = pstart->report_threshold_percent;
5849 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
5850
5851 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05305852 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305853 cmd->probe_delay = 0;
5854 cmd->probe_spacing_time = 0;
5855 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305856 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
5857 WMI_SCAN_ADD_CCK_RATES |
5858 WMI_SCAN_ADD_OFDM_RATES |
5859 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
5860 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05305861 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
5862 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05305863 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305864 cmd->num_ssids = 0;
5865 cmd->num_bssid = 0;
5866 cmd->ie_len = 0;
5867 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
5868 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
5869
5870 buf_ptr += sizeof(*cmd);
5871 WMITLV_SET_HDR(buf_ptr,
5872 WMITLV_TAG_ARRAY_FIXED_STRUC,
5873 num_ssid * sizeof(wmi_ssid));
5874 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
5875
5876 WMITLV_SET_HDR(buf_ptr,
5877 WMITLV_TAG_ARRAY_FIXED_STRUC,
5878 num_bssid * sizeof(wmi_mac_addr));
5879 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
5880
5881 ie_len_with_pad = 0;
5882 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5883 ie_len_with_pad);
5884 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
5885
5886 WMITLV_SET_HDR(buf_ptr,
5887 WMITLV_TAG_ARRAY_STRUC,
5888 nbuckets * sizeof(wmi_extscan_bucket));
5889 dest_blist = (wmi_extscan_bucket *)
5890 (buf_ptr + WMI_TLV_HDR_SIZE);
5891 src_bucket = pstart->buckets;
5892
5893 /* Retrieve scanning information from each bucket and
5894 * channels and send it to the target
5895 */
5896 for (i = 0; i < nbuckets; i++) {
5897 WMITLV_SET_HDR(dest_blist,
5898 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5899 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
5900
5901 dest_blist->bucket_id = src_bucket->bucket;
5902 dest_blist->base_period_multiplier =
5903 src_bucket->period / base_period;
5904 dest_blist->min_period = src_bucket->period;
5905 dest_blist->max_period = src_bucket->max_period;
5906 dest_blist->exp_backoff = src_bucket->exponent;
5907 dest_blist->exp_max_step_count = src_bucket->step_count;
5908 dest_blist->channel_band = src_bucket->band;
5909 dest_blist->num_channels = src_bucket->numChannels;
5910 dest_blist->notify_extscan_events = 0;
5911
5912 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
5913 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07005914 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
5915 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305916
5917 if (src_bucket->reportEvents &
5918 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
5919 dest_blist->forwarding_flags =
5920 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
5921 dest_blist->notify_extscan_events |=
5922 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
5923 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
5924 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
5925 } else {
5926 dest_blist->forwarding_flags =
5927 WMI_EXTSCAN_NO_FORWARDING;
5928 }
5929
5930 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
5931 dest_blist->configuration_flags = 0;
5932 else
5933 dest_blist->configuration_flags =
5934 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
5935
Govind Singhb53420c2016-03-09 14:32:57 +05305936 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305937 __func__, dest_blist->notify_extscan_events,
5938 dest_blist->configuration_flags,
5939 dest_blist->forwarding_flags);
5940
5941 dest_blist->min_dwell_time_active =
5942 src_bucket->min_dwell_time_active;
5943 dest_blist->max_dwell_time_active =
5944 src_bucket->max_dwell_time_active;
5945 dest_blist->min_dwell_time_passive =
5946 src_bucket->min_dwell_time_passive;
5947 dest_blist->max_dwell_time_passive =
5948 src_bucket->max_dwell_time_passive;
5949 src_channel = src_bucket->channels;
5950
5951 /* save the channel info to later populate
5952 * the channel TLV
5953 */
5954 for (k = 0; k < src_bucket->numChannels; k++) {
5955 save_channel[count++].channel = src_channel->channel;
5956 src_channel++;
5957 }
5958 dest_blist++;
5959 src_bucket++;
5960 }
5961 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
5962 WMITLV_SET_HDR(buf_ptr,
5963 WMITLV_TAG_ARRAY_STRUC,
5964 nchannels * sizeof(wmi_extscan_bucket_channel));
5965 dest_clist = (wmi_extscan_bucket_channel *)
5966 (buf_ptr + WMI_TLV_HDR_SIZE);
5967
5968 /* Active or passive scan is based on the bucket dwell time
5969 * and channel specific active,passive scans are not
5970 * supported yet
5971 */
5972 for (i = 0; i < nchannels; i++) {
5973 WMITLV_SET_HDR(dest_clist,
5974 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
5975 WMITLV_GET_STRUCT_TLVLEN
5976 (wmi_extscan_bucket_channel));
5977 dest_clist->channel = save_channel[i].channel;
5978 dest_clist++;
5979 }
5980 buf_ptr += WMI_TLV_HDR_SIZE +
5981 (nchannels * sizeof(wmi_extscan_bucket_channel));
5982 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305983 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305984}
5985
5986/**
5987 * send_start_extscan_cmd_tlv() - start extscan command to fw.
5988 * @wmi_handle: wmi handle
5989 * @pstart: scan command request params
5990 *
5991 * This function sends start extscan request to fw.
5992 *
5993 * Return: CDF Status.
5994 */
Govind Singhb53420c2016-03-09 14:32:57 +05305995QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305996 struct wifi_scan_cmd_req_params *pstart)
5997{
Govind Singhb53420c2016-03-09 14:32:57 +05305998 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305999 wmi_buf_t buf;
6000 int len;
6001
6002 /* Fill individual elements of extscan request and
6003 * TLV for buckets, channel list.
6004 */
Govind Singhb53420c2016-03-09 14:32:57 +05306005 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306006 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306007 if (qdf_status != QDF_STATUS_SUCCESS) {
6008 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6009 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306010 }
6011 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306012 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306013 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306014 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306015 }
6016 if (wmi_unified_cmd_send(wmi_handle, buf,
6017 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306018 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306019 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306020 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306021 }
6022
Govind Singhb53420c2016-03-09 14:32:57 +05306023 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306024}
6025
6026/**
6027 * send_plm_stop_cmd_tlv() - plm stop request
6028 * @wmi_handle: wmi handle
6029 * @plm: plm request parameters
6030 *
6031 * This function request FW to stop PLM.
6032 *
6033 * Return: CDF status
6034 */
Govind Singhb53420c2016-03-09 14:32:57 +05306035QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306036 const struct plm_req_params *plm)
6037{
6038 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6039 int32_t len;
6040 wmi_buf_t buf;
6041 uint8_t *buf_ptr;
6042 int ret;
6043
6044 len = sizeof(*cmd);
6045 buf = wmi_buf_alloc(wmi_handle, len);
6046 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306047 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6048 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306049 }
6050
6051 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6052
6053 buf_ptr = (uint8_t *) cmd;
6054
6055 WMITLV_SET_HDR(&cmd->tlv_header,
6056 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6057 WMITLV_GET_STRUCT_TLVLEN
6058 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6059
6060 cmd->vdev_id = plm->session_id;
6061
6062 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306063 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306064
6065 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6066 WMI_VDEV_PLMREQ_STOP_CMDID);
6067 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306068 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306069 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306070 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306071 }
6072
Govind Singhb53420c2016-03-09 14:32:57 +05306073 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306074}
6075
6076/**
6077 * send_plm_start_cmd_tlv() - plm start request
6078 * @wmi_handle: wmi handle
6079 * @plm: plm request parameters
6080 *
6081 * This function request FW to start PLM.
6082 *
6083 * Return: CDF status
6084 */
Govind Singhb53420c2016-03-09 14:32:57 +05306085QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306086 const struct plm_req_params *plm,
6087 uint32_t *gchannel_list)
6088{
6089 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6090 uint32_t *channel_list;
6091 int32_t len;
6092 wmi_buf_t buf;
6093 uint8_t *buf_ptr;
6094 uint8_t count;
6095 int ret;
6096
6097 /* TLV place holder for channel_list */
6098 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6099 len += sizeof(uint32_t) * plm->plm_num_ch;
6100
6101 buf = wmi_buf_alloc(wmi_handle, len);
6102 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306103 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6104 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306105 }
6106 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6107
6108 buf_ptr = (uint8_t *) cmd;
6109
6110 WMITLV_SET_HDR(&cmd->tlv_header,
6111 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6112 WMITLV_GET_STRUCT_TLVLEN
6113 (wmi_vdev_plmreq_start_cmd_fixed_param));
6114
6115 cmd->vdev_id = plm->session_id;
6116
6117 cmd->meas_token = plm->meas_token;
6118 cmd->dialog_token = plm->diag_token;
6119 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306120 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306121 cmd->off_duration = plm->meas_duration;
6122 cmd->burst_cycle = plm->burst_len;
6123 cmd->tx_power = plm->desired_tx_pwr;
6124 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6125 cmd->num_chans = plm->plm_num_ch;
6126
6127 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6128
Govind Singhb53420c2016-03-09 14:32:57 +05306129 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6130 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6131 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6132 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6133 WMI_LOGD("off_duration: %d", cmd->off_duration);
6134 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6135 WMI_LOGD("tx_power: %d", cmd->tx_power);
6136 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306137
6138 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6139 (cmd->num_chans * sizeof(uint32_t)));
6140
6141 buf_ptr += WMI_TLV_HDR_SIZE;
6142 if (cmd->num_chans) {
6143 channel_list = (uint32_t *) buf_ptr;
6144 for (count = 0; count < cmd->num_chans; count++) {
6145 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306146 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306147 channel_list[count] =
6148 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306149 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306150 }
6151 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6152 }
6153
6154 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6155 WMI_VDEV_PLMREQ_START_CMDID);
6156 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306157 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306158 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306159 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306160 }
6161
Govind Singhb53420c2016-03-09 14:32:57 +05306162 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306163}
6164
6165/**
6166 * send_pno_stop_cmd_tlv() - PNO stop request
6167 * @wmi_handle: wmi handle
6168 * @vdev_id: vdev id
6169 *
6170 * This function request FW to stop ongoing PNO operation.
6171 *
6172 * Return: CDF status
6173 */
Govind Singhb53420c2016-03-09 14:32:57 +05306174QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306175{
6176 wmi_nlo_config_cmd_fixed_param *cmd;
6177 int32_t len = sizeof(*cmd);
6178 wmi_buf_t buf;
6179 uint8_t *buf_ptr;
6180 int ret;
6181
6182 /*
6183 * TLV place holder for array of structures nlo_configured_parameters
6184 * TLV place holder for array of uint32_t channel_list
6185 * TLV place holder for chnl prediction cfg
6186 */
6187 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6188 buf = wmi_buf_alloc(wmi_handle, len);
6189 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306190 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6191 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306192 }
6193
6194 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6195 buf_ptr = (uint8_t *) cmd;
6196
6197 WMITLV_SET_HDR(&cmd->tlv_header,
6198 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6199 WMITLV_GET_STRUCT_TLVLEN
6200 (wmi_nlo_config_cmd_fixed_param));
6201
6202 cmd->vdev_id = vdev_id;
6203 cmd->flags = WMI_NLO_CONFIG_STOP;
6204 buf_ptr += sizeof(*cmd);
6205
6206 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6207 buf_ptr += WMI_TLV_HDR_SIZE;
6208
6209 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6210 buf_ptr += WMI_TLV_HDR_SIZE;
6211
6212 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6213 buf_ptr += WMI_TLV_HDR_SIZE;
6214
6215
6216 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6217 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6218 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306219 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306220 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306221 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306222 }
6223
Govind Singhb53420c2016-03-09 14:32:57 +05306224 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306225}
6226
6227/**
Govind Singhccb0c272016-04-01 16:30:08 +05306228 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6229 * @buf_ptr: Buffer passed by upper layers
6230 * @pno: Buffer to be sent to the firmware
6231 *
6232 * Copy the PNO Channel prediction configuration parameters
6233 * passed by the upper layers to a WMI format TLV and send it
6234 * down to the firmware.
6235 *
6236 * Return: None
6237 */
6238static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6239 struct pno_scan_req_params *pno)
6240{
6241 nlo_channel_prediction_cfg *channel_prediction_cfg =
6242 (nlo_channel_prediction_cfg *) buf_ptr;
6243 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6244 WMITLV_TAG_ARRAY_BYTE,
6245 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306246#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306247 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6248 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6249 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6250 channel_prediction_cfg->full_scan_period_ms =
6251 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306252#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306253 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6254 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6255 channel_prediction_cfg->enable,
6256 channel_prediction_cfg->top_k_num,
6257 channel_prediction_cfg->stationary_threshold,
6258 channel_prediction_cfg->full_scan_period_ms);
6259}
6260
6261/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306262 * send_pno_start_cmd_tlv() - PNO start request
6263 * @wmi_handle: wmi handle
6264 * @pno: PNO request
6265 *
6266 * This function request FW to start PNO request.
6267 * Request: CDF status
6268 */
Govind Singhb53420c2016-03-09 14:32:57 +05306269QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306270 struct pno_scan_req_params *pno,
6271 uint32_t *gchannel_freq_list)
6272{
6273 wmi_nlo_config_cmd_fixed_param *cmd;
6274 nlo_configured_parameters *nlo_list;
6275 uint32_t *channel_list;
6276 int32_t len;
6277 wmi_buf_t buf;
6278 uint8_t *buf_ptr;
6279 uint8_t i;
6280 int ret;
6281
6282 /*
6283 * TLV place holder for array nlo_configured_parameters(nlo_list)
6284 * TLV place holder for array of uint32_t channel_list
6285 * TLV place holder for chnnl prediction cfg
6286 */
6287 len = sizeof(*cmd) +
6288 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6289
Govind Singhb53420c2016-03-09 14:32:57 +05306290 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306291 WMI_NLO_MAX_CHAN);
6292 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306293 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306294 len += sizeof(nlo_channel_prediction_cfg);
6295
6296 buf = wmi_buf_alloc(wmi_handle, len);
6297 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306298 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6299 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306300 }
6301
6302 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6303
6304 buf_ptr = (uint8_t *) cmd;
6305 WMITLV_SET_HDR(&cmd->tlv_header,
6306 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6307 WMITLV_GET_STRUCT_TLVLEN
6308 (wmi_nlo_config_cmd_fixed_param));
6309 cmd->vdev_id = pno->sessionId;
6310 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6311
Govind Singh87542482016-06-08 19:40:11 +05306312#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306313 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6314 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306315#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306316 /* Current FW does not support min-max range for dwell time */
6317 cmd->active_dwell_time = pno->active_max_time;
6318 cmd->passive_dwell_time = pno->passive_max_time;
6319
6320 /* Copy scan interval */
6321 cmd->fast_scan_period = pno->fast_scan_period;
6322 cmd->slow_scan_period = pno->slow_scan_period;
6323 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306324 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306325 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306326 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306327
6328 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6329
Govind Singhb53420c2016-03-09 14:32:57 +05306330 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6331 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306332 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6333 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6334 buf_ptr += WMI_TLV_HDR_SIZE;
6335
6336 nlo_list = (nlo_configured_parameters *) buf_ptr;
6337 for (i = 0; i < cmd->no_of_ssids; i++) {
6338 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6339 WMITLV_TAG_ARRAY_BYTE,
6340 WMITLV_GET_STRUCT_TLVLEN
6341 (nlo_configured_parameters));
6342 /* Copy ssid and it's length */
6343 nlo_list[i].ssid.valid = true;
6344 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306345 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306346 pno->aNetworks[i].ssid.mac_ssid,
6347 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306348 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306349 nlo_list[i].ssid.ssid.ssid_len,
6350 (char *)nlo_list[i].ssid.ssid.ssid,
6351 nlo_list[i].ssid.ssid.ssid_len);
6352
6353 /* Copy rssi threshold */
6354 if (pno->aNetworks[i].rssiThreshold &&
6355 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6356 nlo_list[i].rssi_cond.valid = true;
6357 nlo_list[i].rssi_cond.rssi =
6358 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306359 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306360 nlo_list[i].rssi_cond.rssi);
6361 }
6362 nlo_list[i].bcast_nw_type.valid = true;
6363 nlo_list[i].bcast_nw_type.bcast_nw_type =
6364 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306365 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306366 nlo_list[i].bcast_nw_type.bcast_nw_type);
6367 }
6368 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6369
6370 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306371 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306372 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306373 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306374 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6375 (cmd->num_of_channels * sizeof(uint32_t)));
6376 buf_ptr += WMI_TLV_HDR_SIZE;
6377
6378 channel_list = (uint32_t *) buf_ptr;
6379 for (i = 0; i < cmd->num_of_channels; i++) {
6380 channel_list[i] = pno->aNetworks[0].aChannels[i];
6381
6382 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6383 channel_list[i] = gchannel_freq_list[i];
6384
Govind Singhb53420c2016-03-09 14:32:57 +05306385 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306386 }
6387 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6388 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6389 sizeof(nlo_channel_prediction_cfg));
6390 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306391 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306392 buf_ptr += WMI_TLV_HDR_SIZE;
6393 /** TODO: Discrete firmware doesn't have command/option to configure
6394 * App IE which comes from wpa_supplicant as of part PNO start request.
6395 */
6396 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6397 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6398 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306399 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306400 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306401 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306402 }
6403
Govind Singhb53420c2016-03-09 14:32:57 +05306404 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306405}
6406
6407/* send_set_ric_req_cmd_tlv() - set ric request element
6408 * @wmi_handle: wmi handle
6409 * @msg: message
6410 * @is_add_ts: is addts required
6411 *
6412 * This function sets ric request element for 11r roaming.
6413 *
6414 * Return: CDF status
6415 */
Govind Singhb53420c2016-03-09 14:32:57 +05306416QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306417 void *msg, uint8_t is_add_ts)
6418{
6419 wmi_ric_request_fixed_param *cmd;
6420 wmi_ric_tspec *tspec_param;
6421 wmi_buf_t buf;
6422 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306423 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306424 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6425 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6426
6427 buf = wmi_buf_alloc(wmi_handle, len);
6428 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306429 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6430 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306431 }
6432
6433 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6434
6435 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6436 WMITLV_SET_HDR(&cmd->tlv_header,
6437 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6438 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6439 if (is_add_ts)
6440 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
6441 else
6442 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
6443 cmd->num_ric_request = 1;
6444 cmd->is_add_ric = is_add_ts;
6445
6446 buf_ptr += sizeof(wmi_ric_request_fixed_param);
6447 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
6448
6449 buf_ptr += WMI_TLV_HDR_SIZE;
6450 tspec_param = (wmi_ric_tspec *) buf_ptr;
6451 WMITLV_SET_HDR(&tspec_param->tlv_header,
6452 WMITLV_TAG_STRUC_wmi_ric_tspec,
6453 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
6454
6455 if (is_add_ts)
6456 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05306457#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05306458 else
6459 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05306460#endif
6461 if (ptspecIE) {
6462 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05306463#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05306464 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
6465 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306466#else
Govind Singh87542482016-06-08 19:40:11 +05306467 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
6468 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306469#endif /* ANI_LITTLE_BIT_ENDIAN */
6470
Govind Singh87542482016-06-08 19:40:11 +05306471 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
6472 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
6473 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
6474 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
6475 tspec_param->inactivity_interval = ptspecIE->inactInterval;
6476 tspec_param->suspension_interval = ptspecIE->suspendInterval;
6477 tspec_param->svc_start_time = ptspecIE->svcStartTime;
6478 tspec_param->min_data_rate = ptspecIE->minDataRate;
6479 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
6480 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
6481 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
6482 tspec_param->delay_bound = ptspecIE->delayBound;
6483 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
6484 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
6485 tspec_param->medium_time = 0;
6486 }
Govind Singhb53420c2016-03-09 14:32:57 +05306487 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306488
6489 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6490 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306491 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306492 __func__);
6493 if (is_add_ts)
6494 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05306495 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05306496 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306497 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306498 }
6499
Govind Singhb53420c2016-03-09 14:32:57 +05306500 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306501}
6502
6503/**
6504 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
6505 * @wmi_handle: wmi handle
6506 * @clear_req: ll stats clear request command params
6507 *
Govind Singhb53420c2016-03-09 14:32:57 +05306508 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306509 */
Govind Singhb53420c2016-03-09 14:32:57 +05306510QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306511 const struct ll_stats_clear_params *clear_req,
6512 uint8_t addr[IEEE80211_ADDR_LEN])
6513{
6514 wmi_clear_link_stats_cmd_fixed_param *cmd;
6515 int32_t len;
6516 wmi_buf_t buf;
6517 uint8_t *buf_ptr;
6518 int ret;
6519
6520 len = sizeof(*cmd);
6521 buf = wmi_buf_alloc(wmi_handle, len);
6522
6523 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306524 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6525 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306526 }
6527
6528 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306529 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306530 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
6531
6532 WMITLV_SET_HDR(&cmd->tlv_header,
6533 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
6534 WMITLV_GET_STRUCT_TLVLEN
6535 (wmi_clear_link_stats_cmd_fixed_param));
6536
6537 cmd->stop_stats_collection_req = clear_req->stop_req;
6538 cmd->vdev_id = clear_req->sta_id;
6539 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
6540
6541 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6542 &cmd->peer_macaddr);
6543
Govind Singhb53420c2016-03-09 14:32:57 +05306544 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
6545 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
6546 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
6547 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
6548 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306549 cmd->peer_macaddr); */
6550
6551 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6552 WMI_CLEAR_LINK_STATS_CMDID);
6553 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306554 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306555 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306556 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306557 }
6558
Govind Singhb53420c2016-03-09 14:32:57 +05306559 WMI_LOGD("Clear Link Layer Stats request sent successfully");
6560 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306561}
6562
6563/**
6564 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
6565 * @wmi_handle: wmi handle
6566 * @setReq: ll stats set request command params
6567 *
Govind Singhb53420c2016-03-09 14:32:57 +05306568 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306569 */
Govind Singhb53420c2016-03-09 14:32:57 +05306570QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306571 const struct ll_stats_set_params *set_req)
6572{
6573 wmi_start_link_stats_cmd_fixed_param *cmd;
6574 int32_t len;
6575 wmi_buf_t buf;
6576 uint8_t *buf_ptr;
6577 int ret;
6578
6579 len = sizeof(*cmd);
6580 buf = wmi_buf_alloc(wmi_handle, len);
6581
6582 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306583 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6584 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306585 }
6586
6587 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306588 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306589 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
6590
6591 WMITLV_SET_HDR(&cmd->tlv_header,
6592 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
6593 WMITLV_GET_STRUCT_TLVLEN
6594 (wmi_start_link_stats_cmd_fixed_param));
6595
6596 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
6597 cmd->aggressive_statistics_gathering =
6598 set_req->aggressive_statistics_gathering;
6599
Govind Singhb53420c2016-03-09 14:32:57 +05306600 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
6601 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
6602 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306603
6604 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6605 WMI_START_LINK_STATS_CMDID);
6606 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306607 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306608 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306609 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306610 }
6611
Govind Singhb53420c2016-03-09 14:32:57 +05306612 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306613}
6614
6615/**
6616 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
6617 * @wmi_handle:wmi handle
6618 * @get_req:ll stats get request command params
6619 * @addr: mac address
6620 *
Govind Singhb53420c2016-03-09 14:32:57 +05306621 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306622 */
Govind Singhb53420c2016-03-09 14:32:57 +05306623QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306624 const struct ll_stats_get_params *get_req,
6625 uint8_t addr[IEEE80211_ADDR_LEN])
6626{
6627 wmi_request_link_stats_cmd_fixed_param *cmd;
6628 int32_t len;
6629 wmi_buf_t buf;
6630 uint8_t *buf_ptr;
6631 int ret;
6632
6633 len = sizeof(*cmd);
6634 buf = wmi_buf_alloc(wmi_handle, len);
6635
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05306636 if (!buf) {
6637 WMI_LOGE("%s: buf allocation failed", __func__);
6638 return QDF_STATUS_E_NOMEM;
6639 }
6640
Govind Singh4eacd2b2016-03-07 14:24:22 +05306641 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306642 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306643 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
6644
6645 WMITLV_SET_HDR(&cmd->tlv_header,
6646 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
6647 WMITLV_GET_STRUCT_TLVLEN
6648 (wmi_request_link_stats_cmd_fixed_param));
6649
6650 cmd->request_id = get_req->req_id;
6651 cmd->stats_type = get_req->param_id_mask;
6652 cmd->vdev_id = get_req->sta_id;
6653
6654 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6655 &cmd->peer_macaddr);
6656
Govind Singhb53420c2016-03-09 14:32:57 +05306657 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
6658 WMI_LOGD("Request ID : %d", cmd->request_id);
6659 WMI_LOGD("Stats Type : %d", cmd->stats_type);
6660 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
6661 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306662
6663 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6664 WMI_REQUEST_LINK_STATS_CMDID);
6665 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306666 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306667 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306668 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306669 }
6670
Govind Singhb53420c2016-03-09 14:32:57 +05306671 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306672}
6673
6674/**
6675 * send_get_stats_cmd_tlv() - get stats request
6676 * @wmi_handle: wmi handle
6677 * @get_stats_param: stats params
6678 * @addr: mac address
6679 *
6680 * Return: CDF status
6681 */
Govind Singhb53420c2016-03-09 14:32:57 +05306682QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306683 struct pe_stats_req *get_stats_param,
6684 uint8_t addr[IEEE80211_ADDR_LEN])
6685{
6686 wmi_buf_t buf;
6687 wmi_request_stats_cmd_fixed_param *cmd;
6688 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6689
6690 buf = wmi_buf_alloc(wmi_handle, len);
6691 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306692 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
6693 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306694 }
6695
6696
6697 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6698 WMITLV_SET_HDR(&cmd->tlv_header,
6699 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6700 WMITLV_GET_STRUCT_TLVLEN
6701 (wmi_request_stats_cmd_fixed_param));
6702 cmd->stats_id =
6703 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05306704 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306705 cmd->vdev_id = get_stats_param->session_id;
6706 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05306707 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306708 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6709 WMI_REQUEST_STATS_CMDID)) {
6710
Govind Singhb53420c2016-03-09 14:32:57 +05306711 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306712 __func__);
6713 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306714 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306715 }
6716
Govind Singhb53420c2016-03-09 14:32:57 +05306717 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306718
6719}
6720
Govind Singh20c5dac2016-03-07 15:33:31 +05306721/**
6722 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
6723 * @wmi_handle: wmi handle
6724 * @rssi_req: get RSSI request
6725 *
6726 * Return: CDF status
6727 */
Govind Singhb53420c2016-03-09 14:32:57 +05306728QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05306729{
6730 wmi_buf_t buf;
6731 wmi_request_stats_cmd_fixed_param *cmd;
6732 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6733
6734 buf = wmi_buf_alloc(wmi_handle, len);
6735 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306736 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6737 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306738 }
6739
6740 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6741 WMITLV_SET_HDR(&cmd->tlv_header,
6742 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6743 WMITLV_GET_STRUCT_TLVLEN
6744 (wmi_request_stats_cmd_fixed_param));
6745 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6746 if (wmi_unified_cmd_send
6747 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306748 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306749 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306750 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306751 }
6752
Govind Singhb53420c2016-03-09 14:32:57 +05306753 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306754}
6755
6756/**
6757 * send_snr_cmd_tlv() - get RSSI from fw
6758 * @wmi_handle: wmi handle
6759 * @vdev_id: vdev id
6760 *
6761 * Return: CDF status
6762 */
Govind Singhb53420c2016-03-09 14:32:57 +05306763QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05306764{
6765 wmi_buf_t buf;
6766 wmi_request_stats_cmd_fixed_param *cmd;
6767 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6768
6769 buf = wmi_buf_alloc(wmi_handle, len);
6770 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306771 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6772 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306773 }
6774
6775 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6776 cmd->vdev_id = vdev_id;
6777
6778 WMITLV_SET_HDR(&cmd->tlv_header,
6779 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6780 WMITLV_GET_STRUCT_TLVLEN
6781 (wmi_request_stats_cmd_fixed_param));
6782 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6783 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6784 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306785 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306786 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306787 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306788 }
6789
Govind Singhb53420c2016-03-09 14:32:57 +05306790 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306791}
6792
6793/**
6794 * send_link_status_req_cmd_tlv() - process link status request from UMAC
6795 * @wmi_handle: wmi handle
6796 * @link_status: get link params
6797 *
6798 * Return: CDF status
6799 */
Govind Singhb53420c2016-03-09 14:32:57 +05306800QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306801 struct link_status_params *link_status)
6802{
6803 wmi_buf_t buf;
6804 wmi_request_stats_cmd_fixed_param *cmd;
6805 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6806
6807 buf = wmi_buf_alloc(wmi_handle, len);
6808 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306809 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6810 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306811 }
6812
6813 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6814 WMITLV_SET_HDR(&cmd->tlv_header,
6815 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6816 WMITLV_GET_STRUCT_TLVLEN
6817 (wmi_request_stats_cmd_fixed_param));
6818 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
6819 cmd->vdev_id = link_status->session_id;
6820 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6821 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306822 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306823 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306824 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306825 }
6826
Govind Singhb53420c2016-03-09 14:32:57 +05306827 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306828}
6829
6830#ifdef FEATURE_WLAN_LPHB
6831
6832/**
6833 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
6834 * @wmi_handle: wmi handle
6835 * @lphb_conf_req: configuration info
6836 *
6837 * Return: CDF status
6838 */
Govind Singhb53420c2016-03-09 14:32:57 +05306839QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306840 wmi_hb_set_enable_cmd_fixed_param *params)
6841{
Govind Singh67922e82016-04-01 16:48:57 +05306842 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306843 wmi_buf_t buf = NULL;
6844 uint8_t *buf_ptr;
6845 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
6846 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
6847
6848
6849 buf = wmi_buf_alloc(wmi_handle, len);
6850 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306851 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6852 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306853 }
6854
6855 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6856 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
6857 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
6858 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
6859 WMITLV_GET_STRUCT_TLVLEN
6860 (wmi_hb_set_enable_cmd_fixed_param));
6861
6862 /* fill in values */
6863 hb_enable_fp->vdev_id = params->session;
6864 hb_enable_fp->enable = params->enable;
6865 hb_enable_fp->item = params->item;
6866 hb_enable_fp->session = params->session;
6867
6868 status = wmi_unified_cmd_send(wmi_handle, buf,
6869 len, WMI_HB_SET_ENABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306870 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306871 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_ENABLE returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306872 status);
Govind Singh67922e82016-04-01 16:48:57 +05306873 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306874 }
6875
Govind Singh67922e82016-04-01 16:48:57 +05306876 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306877}
6878
6879/**
6880 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
6881 * @wmi_handle: wmi handle
6882 * @lphb_conf_req: lphb config request
6883 *
6884 * Return: CDF status
6885 */
Govind Singhb53420c2016-03-09 14:32:57 +05306886QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306887 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
6888{
Govind Singh67922e82016-04-01 16:48:57 +05306889 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306890 wmi_buf_t buf = NULL;
6891 uint8_t *buf_ptr;
6892 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
6893 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
6894
6895 buf = wmi_buf_alloc(wmi_handle, len);
6896 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306897 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6898 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306899 }
6900
6901 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6902 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
6903 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
6904 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
6905 WMITLV_GET_STRUCT_TLVLEN
6906 (wmi_hb_set_tcp_params_cmd_fixed_param));
6907
6908 /* fill in values */
6909 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
6910 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
6911 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
6912 hb_tcp_params_fp->seq = lphb_conf_req->seq;
6913 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
6914 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
6915 hb_tcp_params_fp->interval = lphb_conf_req->interval;
6916 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
6917 hb_tcp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05306918 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05306919 &lphb_conf_req->gateway_mac,
6920 sizeof(hb_tcp_params_fp->gateway_mac));
6921
6922 status = wmi_unified_cmd_send(wmi_handle, buf,
6923 len, WMI_HB_SET_TCP_PARAMS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306924 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306925 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306926 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306927 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306928 }
6929
Govind Singh67922e82016-04-01 16:48:57 +05306930 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306931}
6932
6933/**
6934 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
6935 * @wmi_handle: wmi handle
6936 * @lphb_conf_req: lphb config request
6937 *
6938 * Return: CDF status
6939 */
Govind Singhb53420c2016-03-09 14:32:57 +05306940QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306941 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
6942{
Govind Singh67922e82016-04-01 16:48:57 +05306943 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306944 wmi_buf_t buf = NULL;
6945 uint8_t *buf_ptr;
6946 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
6947 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
6948
6949 buf = wmi_buf_alloc(wmi_handle, len);
6950 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306951 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6952 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306953 }
6954
6955 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6956 hb_tcp_filter_fp =
6957 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
6958 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
6959 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
6960 WMITLV_GET_STRUCT_TLVLEN
6961 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
6962
6963 /* fill in values */
6964 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
6965 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
6966 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
6967 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
6968 memcpy((void *)&hb_tcp_filter_fp->filter,
6969 (void *)&g_hb_tcp_filter_fp->filter,
6970 WMI_WLAN_HB_MAX_FILTER_SIZE);
6971
6972 status = wmi_unified_cmd_send(wmi_handle, buf,
6973 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306974 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306975 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306976 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306977 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306978 }
6979
Govind Singh67922e82016-04-01 16:48:57 +05306980 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306981}
6982
6983/**
6984 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
6985 * @wmi_handle: wmi handle
6986 * @lphb_conf_req: lphb config request
6987 *
6988 * Return: CDF status
6989 */
Govind Singhb53420c2016-03-09 14:32:57 +05306990QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306991 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
6992{
Govind Singh67922e82016-04-01 16:48:57 +05306993 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306994 wmi_buf_t buf = NULL;
6995 uint8_t *buf_ptr;
6996 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
6997 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
6998
6999 buf = wmi_buf_alloc(wmi_handle, len);
7000 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307001 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7002 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307003 }
7004
7005 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7006 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
7007 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
7008 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
7009 WMITLV_GET_STRUCT_TLVLEN
7010 (wmi_hb_set_udp_params_cmd_fixed_param));
7011
7012 /* fill in values */
7013 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
7014 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
7015 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
7016 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
7017 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
7018 hb_udp_params_fp->interval = lphb_conf_req->interval;
7019 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
7020 hb_udp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05307021 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05307022 &lphb_conf_req->gateway_mac,
7023 sizeof(lphb_conf_req->gateway_mac));
7024
7025 status = wmi_unified_cmd_send(wmi_handle, buf,
7026 len, WMI_HB_SET_UDP_PARAMS_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307027 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307028 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307029 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307030 wmi_buf_free(buf);
7031 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307032
Govind Singh67922e82016-04-01 16:48:57 +05307033 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307034}
7035
7036/**
7037 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
7038 * @wmi_handle: wmi handle
7039 * @lphb_conf_req: lphb config request
7040 *
7041 * Return: CDF status
7042 */
Govind Singhb53420c2016-03-09 14:32:57 +05307043QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307044 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
7045{
Govind Singh67922e82016-04-01 16:48:57 +05307046 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307047 wmi_buf_t buf = NULL;
7048 uint8_t *buf_ptr;
7049 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
7050 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
7051
7052 buf = wmi_buf_alloc(wmi_handle, len);
7053 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307054 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7055 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307056 }
7057
7058 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7059 hb_udp_filter_fp =
7060 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
7061 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
7062 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
7063 WMITLV_GET_STRUCT_TLVLEN
7064 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
7065
7066 /* fill in values */
7067 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
7068 hb_udp_filter_fp->length = lphb_conf_req->length;
7069 hb_udp_filter_fp->offset = lphb_conf_req->offset;
7070 hb_udp_filter_fp->session = lphb_conf_req->session;
7071 memcpy((void *)&hb_udp_filter_fp->filter,
7072 (void *)&lphb_conf_req->filter,
7073 WMI_WLAN_HB_MAX_FILTER_SIZE);
7074
7075 status = wmi_unified_cmd_send(wmi_handle, buf,
7076 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307077 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307078 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307079 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307080 wmi_buf_free(buf);
7081 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307082
Govind Singh67922e82016-04-01 16:48:57 +05307083 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307084}
7085#endif /* FEATURE_WLAN_LPHB */
7086
7087/**
7088 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7089 * @wmi_handle: wmi handle
7090 * @ta_dhcp_ind: DHCP indication parameter
7091 *
7092 * Return: CDF Status
7093 */
Govind Singhb53420c2016-03-09 14:32:57 +05307094QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307095 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7096{
Govind Singh67922e82016-04-01 16:48:57 +05307097 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307098 wmi_buf_t buf = NULL;
7099 uint8_t *buf_ptr;
7100 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7101 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7102
7103
7104 buf = wmi_buf_alloc(wmi_handle, len);
7105 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307106 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7107 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307108 }
7109
7110 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7111 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7112 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7113 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7114 WMITLV_GET_STRUCT_TLVLEN
7115 (wmi_peer_set_param_cmd_fixed_param));
7116
7117 /* fill in values */
7118 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7119 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7120 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307121 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307122 &ta_dhcp_ind->peer_macaddr,
7123 sizeof(ta_dhcp_ind->peer_macaddr));
7124
7125 status = wmi_unified_cmd_send(wmi_handle, buf,
7126 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307127 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307128 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307129 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307130 wmi_buf_free(buf);
7131 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307132
Govind Singh67922e82016-04-01 16:48:57 +05307133 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307134}
7135
7136/**
7137 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7138 * @wmi_handle: wmi handle
7139 * @pLinkSpeed: link speed info
7140 *
7141 * Return: CDF status
7142 */
Govind Singhb53420c2016-03-09 14:32:57 +05307143QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307144 wmi_mac_addr peer_macaddr)
7145{
7146 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7147 wmi_buf_t wmi_buf;
7148 uint32_t len;
7149 uint8_t *buf_ptr;
7150
7151 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7152 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7153 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307154 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7155 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307156 }
7157 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7158
7159 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7160 WMITLV_SET_HDR(&cmd->tlv_header,
7161 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7162 WMITLV_GET_STRUCT_TLVLEN
7163 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7164
7165 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307166 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307167 &peer_macaddr,
7168 sizeof(peer_macaddr));
7169
7170
7171 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7172 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307173 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307174 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307175 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307176 }
Govind Singhb53420c2016-03-09 14:32:57 +05307177 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307178}
7179
7180/**
7181 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7182 * @wmi_handle: wmi handler
7183 * @egap_params: pointer to egap_params
7184 *
7185 * Return: 0 for success, otherwise appropriate error code
7186 */
Govind Singhb53420c2016-03-09 14:32:57 +05307187QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307188 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7189{
7190 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7191 wmi_buf_t buf;
7192 int32_t err;
7193
7194 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7195 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307196 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7197 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307198 }
7199 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7200 WMITLV_SET_HDR(&cmd->tlv_header,
7201 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7202 WMITLV_GET_STRUCT_TLVLEN(
7203 wmi_ap_ps_egap_param_cmd_fixed_param));
7204
7205 cmd->enable = egap_params->enable;
7206 cmd->inactivity_time = egap_params->inactivity_time;
7207 cmd->wait_time = egap_params->wait_time;
7208 cmd->flags = egap_params->flags;
7209 err = wmi_unified_cmd_send(wmi_handle, buf,
7210 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7211 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307212 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307213 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307214 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307215 }
7216
Govind Singhb53420c2016-03-09 14:32:57 +05307217 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307218}
7219
7220/**
7221 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7222 * @wmi_handl: wmi handle
7223 * @cmd: Profiling command index
7224 * @value1: parameter1 value
7225 * @value2: parameter2 value
7226 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307227 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307228 */
Govind Singhb53420c2016-03-09 14:32:57 +05307229QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307230 uint32_t cmd, uint32_t value1, uint32_t value2)
7231{
7232 wmi_buf_t buf;
7233 int32_t len = 0;
7234 int ret;
7235 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7236 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7237 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7238 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7239
7240 switch (cmd) {
7241 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7242 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7243 buf = wmi_buf_alloc(wmi_handle, len);
7244 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307245 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307246 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307247 }
7248 prof_trig_cmd =
7249 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7250 wmi_buf_data(buf);
7251 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7252 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7253 WMITLV_GET_STRUCT_TLVLEN
7254 (wmi_wlan_profile_trigger_cmd_fixed_param));
7255 prof_trig_cmd->enable = value1;
7256 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7257 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7258 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307259 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307260 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307261 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307262 return ret;
7263 }
7264 break;
7265
7266 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7267 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7268 buf = wmi_buf_alloc(wmi_handle, len);
7269 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307270 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307271 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307272 }
7273 profile_getdata_cmd =
7274 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7275 wmi_buf_data(buf);
7276 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7277 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7278 WMITLV_GET_STRUCT_TLVLEN
7279 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7280 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7281 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7282 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307283 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307284 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307285 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307286 return ret;
7287 }
7288 break;
7289
7290 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7291 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7292 buf = wmi_buf_alloc(wmi_handle, len);
7293 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307294 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307295 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307296 }
7297 hist_intvl_cmd =
7298 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7299 wmi_buf_data(buf);
7300 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7301 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7302 WMITLV_GET_STRUCT_TLVLEN
7303 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7304 hist_intvl_cmd->profile_id = value1;
7305 hist_intvl_cmd->value = value2;
7306 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7307 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7308 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307309 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307310 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307311 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307312 return ret;
7313 }
7314 break;
7315
7316 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7317 len =
7318 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7319 buf = wmi_buf_alloc(wmi_handle, len);
7320 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307321 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307322 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307323 }
7324 profile_enable_cmd =
7325 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7326 wmi_buf_data(buf);
7327 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7328 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7329 WMITLV_GET_STRUCT_TLVLEN
7330 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7331 profile_enable_cmd->profile_id = value1;
7332 profile_enable_cmd->enable = value2;
7333 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7334 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7335 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307336 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307337 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307338 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307339 return ret;
7340 }
7341 break;
7342
7343 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307344 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307345 break;
7346 }
7347
7348 return 0;
7349}
7350
7351#ifdef FEATURE_WLAN_RA_FILTERING
7352/**
7353 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
7354 * @wmi_handle: wmi handle
7355 * @vdev_id: vdev id
7356 *
7357 * Return: CDF status
7358 */
Govind Singhb53420c2016-03-09 14:32:57 +05307359QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307360 uint8_t vdev_id, uint8_t default_pattern,
7361 uint16_t rate_limit_interval)
7362{
7363
7364 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7365 wmi_buf_t buf;
7366 uint8_t *buf_ptr;
7367 int32_t len;
7368 int ret;
7369
7370 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7371 WMI_TLV_HDR_SIZE +
7372 0 * sizeof(WOW_BITMAP_PATTERN_T) +
7373 WMI_TLV_HDR_SIZE +
7374 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7375 WMI_TLV_HDR_SIZE +
7376 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7377 WMI_TLV_HDR_SIZE +
7378 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7379 WMI_TLV_HDR_SIZE +
7380 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7381
7382 buf = wmi_buf_alloc(wmi_handle, len);
7383 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307384 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7385 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307386 }
7387
7388 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7389 buf_ptr = (uint8_t *) cmd;
7390
7391 WMITLV_SET_HDR(&cmd->tlv_header,
7392 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7393 WMITLV_GET_STRUCT_TLVLEN
7394 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7395 cmd->vdev_id = vdev_id;
7396 cmd->pattern_id = default_pattern,
7397 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
7398 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7399
7400 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
7401 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7402 buf_ptr += WMI_TLV_HDR_SIZE;
7403
7404 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7405 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7406 buf_ptr += WMI_TLV_HDR_SIZE;
7407
7408 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7409 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7410 buf_ptr += WMI_TLV_HDR_SIZE;
7411
7412 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7413 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7414 buf_ptr += WMI_TLV_HDR_SIZE;
7415
7416 /* Fill TLV for pattern_info_timeout but no data. */
7417 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7418 buf_ptr += WMI_TLV_HDR_SIZE;
7419
7420 /* Fill TLV for ra_ratelimit_interval. */
7421 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
7422 buf_ptr += WMI_TLV_HDR_SIZE;
7423
7424 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
7425
Govind Singhb53420c2016-03-09 14:32:57 +05307426 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05307427 rate_limit_interval, vdev_id);
7428
7429 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7430 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7431 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307432 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307433 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307434 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307435 }
7436
Govind Singhb53420c2016-03-09 14:32:57 +05307437 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307438
7439}
7440#endif /* FEATURE_WLAN_RA_FILTERING */
7441
7442/**
7443 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7444 * @wmi_handle: wmi handle
7445 * @vdev_id: vdev id
7446 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307447 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307448 */
Govind Singhb53420c2016-03-09 14:32:57 +05307449QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307450{
7451 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7452 wmi_buf_t buf;
7453 int32_t len = sizeof(*cmd);
7454
Govind Singhb53420c2016-03-09 14:32:57 +05307455 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307456 buf = wmi_buf_alloc(wmi_handle, len);
7457 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307458 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307459 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307460 }
7461 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7462 wmi_buf_data(buf);
7463 WMITLV_SET_HDR(&cmd->tlv_header,
7464 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7465 WMITLV_GET_STRUCT_TLVLEN
7466 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7467 cmd->vdev_id = vdev_id;
7468 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7469 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7470 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307471 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307472 __func__);
7473 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307474 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307475 }
7476
7477 return 0;
7478}
7479
7480/**
7481 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7482 * @wmi_handle: wmi handle
7483 * @vdev_id: vdev id
7484 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307485 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307486 */
Govind Singhb53420c2016-03-09 14:32:57 +05307487QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307488 uint8_t vdev_id)
7489{
7490 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7491 wmi_buf_t buf;
7492 int32_t len = sizeof(*cmd);
7493
Govind Singhb53420c2016-03-09 14:32:57 +05307494 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307495 buf = wmi_buf_alloc(wmi_handle, len);
7496 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307497 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307498 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307499 }
7500 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7501 WMITLV_SET_HDR(&cmd->tlv_header,
7502 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7503 WMITLV_GET_STRUCT_TLVLEN
7504 (wmi_csa_offload_enable_cmd_fixed_param));
7505 cmd->vdev_id = vdev_id;
7506 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7507 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7508 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307509 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307510 __func__);
7511 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307512 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307513 }
7514
7515 return 0;
7516}
7517
7518/**
7519 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7520 * @wmi_handle: wmi handle
7521 * @startOemDataReq: start request params
7522 *
7523 * Return: CDF status
7524 */
Govind Singhb53420c2016-03-09 14:32:57 +05307525QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007526 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307527 uint8_t *data)
7528{
7529 wmi_buf_t buf;
7530 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307531 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307532
7533 buf = wmi_buf_alloc(wmi_handle,
7534 (data_len + WMI_TLV_HDR_SIZE));
7535 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307536 WMI_LOGE(FL("wmi_buf_alloc failed"));
7537 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307538 }
7539
7540 cmd = (uint8_t *) wmi_buf_data(buf);
7541
7542 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7543 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307544 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307545 data_len);
7546
Govind Singhb53420c2016-03-09 14:32:57 +05307547 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307548 data_len);
7549
7550 ret = wmi_unified_cmd_send(wmi_handle, buf,
7551 (data_len +
7552 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7553
Govind Singh67922e82016-04-01 16:48:57 +05307554 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307555 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307556 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307557 }
7558
Govind Singh67922e82016-04-01 16:48:57 +05307559 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307560}
7561
7562/**
7563 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7564 * @wmi_handle: wmi handle
7565 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7566 *
7567 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7568 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7569 * to firmware based on phyerr filtering
7570 * offload status.
7571 *
7572 * Return: 1 success, 0 failure
7573 */
Govind Singhb53420c2016-03-09 14:32:57 +05307574QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307575send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7576 bool dfs_phyerr_filter_offload)
7577{
7578 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7579 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7580 wmi_buf_t buf;
7581 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307582 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307583
7584
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007585 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307586 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307587 __func__);
7588 len = sizeof(*disable_phyerr_offload_cmd);
7589 buf = wmi_buf_alloc(wmi_handle, len);
7590 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307591 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307592 return 0;
7593 }
7594 disable_phyerr_offload_cmd =
7595 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7596 wmi_buf_data(buf);
7597
7598 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7599 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7600 WMITLV_GET_STRUCT_TLVLEN
7601 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7602
7603 /*
7604 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7605 * to the firmware to disable the phyerror
7606 * filtering offload.
7607 */
7608 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7609 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307610 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307611 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307612 __func__, ret);
7613 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307614 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307615 }
Govind Singhb53420c2016-03-09 14:32:57 +05307616 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307617 __func__);
7618 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307619 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307620 __func__);
7621
7622 len = sizeof(*enable_phyerr_offload_cmd);
7623 buf = wmi_buf_alloc(wmi_handle, len);
7624 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307625 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7626 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307627 }
7628
7629 enable_phyerr_offload_cmd =
7630 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7631 wmi_buf_data(buf);
7632
7633 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7634 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7635 WMITLV_GET_STRUCT_TLVLEN
7636 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7637
7638 /*
7639 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7640 * to the firmware to enable the phyerror
7641 * filtering offload.
7642 */
7643 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7644 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7645
Govind Singh67922e82016-04-01 16:48:57 +05307646 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307647 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307648 __func__, ret);
7649 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307650 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307651 }
Govind Singhb53420c2016-03-09 14:32:57 +05307652 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307653 __func__);
7654 }
7655
Govind Singhb53420c2016-03-09 14:32:57 +05307656 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307657}
7658
7659#if !defined(REMOVE_PKT_LOG)
7660/**
7661 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7662 * @wmi_handle: wmi handle
7663 * @pktlog_event: pktlog event
7664 * @cmd_id: pktlog cmd id
7665 *
7666 * Return: CDF status
7667 */
Govind Singhb53420c2016-03-09 14:32:57 +05307668QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307669 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307670 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307671{
7672 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7673 WMI_CMD_ID CMD_ID;
7674 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7675 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7676 int len = 0;
7677 wmi_buf_t buf;
7678
7679 PKTLOG_EVENT = pktlog_event;
7680 CMD_ID = cmd_id;
7681
7682 switch (CMD_ID) {
7683 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7684 len = sizeof(*cmd);
7685 buf = wmi_buf_alloc(wmi_handle, len);
7686 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307687 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7688 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307689 }
7690 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7691 wmi_buf_data(buf);
7692 WMITLV_SET_HDR(&cmd->tlv_header,
7693 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7694 WMITLV_GET_STRUCT_TLVLEN
7695 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7696 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307697 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7698 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007699 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307700 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7701 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307702 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307703 goto wmi_send_failed;
7704 }
7705 break;
7706 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7707 len = sizeof(*disable_cmd);
7708 buf = wmi_buf_alloc(wmi_handle, len);
7709 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307710 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7711 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307712 }
7713 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7714 wmi_buf_data(buf);
7715 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7716 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7717 WMITLV_GET_STRUCT_TLVLEN
7718 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007719 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307720 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7721 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307722 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307723 goto wmi_send_failed;
7724 }
7725 break;
7726 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307727 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307728 break;
7729 }
7730
Govind Singhb53420c2016-03-09 14:32:57 +05307731 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307732
7733wmi_send_failed:
7734 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307735 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307736}
7737#endif /* REMOVE_PKT_LOG */
7738
7739/**
7740 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
7741 * @wmi_handle: wmi handle
7742 * @vdev_id: vdev id
7743 * @bitmap: Event bitmap
7744 * @enable: enable/disable
7745 *
7746 * Return: CDF status
7747 */
Govind Singhb53420c2016-03-09 14:32:57 +05307748QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307749 uint32_t vdev_id,
7750 uint32_t bitmap,
7751 bool enable)
7752{
7753 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
7754 uint16_t len;
7755 wmi_buf_t buf;
7756 int ret;
7757
7758 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
7759 buf = wmi_buf_alloc(wmi_handle, len);
7760 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307761 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7762 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307763 }
7764 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
7765 WMITLV_SET_HDR(&cmd->tlv_header,
7766 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
7767 WMITLV_GET_STRUCT_TLVLEN
7768 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
7769 cmd->vdev_id = vdev_id;
7770 cmd->is_add = enable;
7771 cmd->event_bitmap = bitmap;
7772
7773 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7774 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
7775 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307776 WMI_LOGE("Failed to config wow wakeup event");
Govind Singh20c5dac2016-03-07 15:33:31 +05307777 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307778 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307779 }
7780
Govind Singhb53420c2016-03-09 14:32:57 +05307781 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
Govind Singh20c5dac2016-03-07 15:33:31 +05307782 enable ? "enabled" : "disabled");
7783
Govind Singhb53420c2016-03-09 14:32:57 +05307784 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307785}
7786
7787/**
7788 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
7789 * @wmi_handle: wmi handle
7790 * @vdev_id: vdev id
7791 * @ptrn_id: pattern id
7792 * @ptrn: pattern
7793 * @ptrn_len: pattern length
7794 * @ptrn_offset: pattern offset
7795 * @mask: mask
7796 * @mask_len: mask length
7797 * @user: true for user configured pattern and false for default pattern
7798 * @default_patterns: default patterns
7799 *
7800 * Return: CDF status
7801 */
Govind Singhb53420c2016-03-09 14:32:57 +05307802QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307803 uint8_t vdev_id, uint8_t ptrn_id,
7804 const uint8_t *ptrn, uint8_t ptrn_len,
7805 uint8_t ptrn_offset, const uint8_t *mask,
7806 uint8_t mask_len, bool user,
7807 uint8_t default_patterns)
7808{
7809 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7810 WOW_BITMAP_PATTERN_T *bitmap_pattern;
7811 wmi_buf_t buf;
7812 uint8_t *buf_ptr;
7813 int32_t len;
7814 int ret;
7815
7816
7817 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7818 WMI_TLV_HDR_SIZE +
7819 1 * sizeof(WOW_BITMAP_PATTERN_T) +
7820 WMI_TLV_HDR_SIZE +
7821 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7822 WMI_TLV_HDR_SIZE +
7823 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7824 WMI_TLV_HDR_SIZE +
7825 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7826 WMI_TLV_HDR_SIZE +
7827 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7828
7829 buf = wmi_buf_alloc(wmi_handle, len);
7830 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307831 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7832 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307833 }
7834
7835 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7836 buf_ptr = (uint8_t *) cmd;
7837
7838 WMITLV_SET_HDR(&cmd->tlv_header,
7839 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7840 WMITLV_GET_STRUCT_TLVLEN
7841 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7842 cmd->vdev_id = vdev_id;
7843 cmd->pattern_id = ptrn_id;
7844
7845 cmd->pattern_type = WOW_BITMAP_PATTERN;
7846 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7847
7848 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7849 sizeof(WOW_BITMAP_PATTERN_T));
7850 buf_ptr += WMI_TLV_HDR_SIZE;
7851 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
7852
7853 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
7854 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
7855 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
7856
Govind Singhb53420c2016-03-09 14:32:57 +05307857 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
7858 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05307859
7860 bitmap_pattern->pattern_offset = ptrn_offset;
7861 bitmap_pattern->pattern_len = ptrn_len;
7862
7863 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
7864 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
7865
7866 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
7867 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
7868
7869 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
7870 bitmap_pattern->pattern_id = ptrn_id;
7871
Govind Singhb53420c2016-03-09 14:32:57 +05307872 WMI_LOGI("vdev id : %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307873 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
7874 bitmap_pattern->pattern_offset, user);
Govind Singh87542482016-06-08 19:40:11 +05307875#ifdef CONFIG_MCL
Govind Singhb53420c2016-03-09 14:32:57 +05307876 WMI_LOGI("Pattern : ");
7877 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307878 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
7879
Govind Singhb53420c2016-03-09 14:32:57 +05307880 WMI_LOGI("Mask : ");
7881 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307882 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
Govind Singh87542482016-06-08 19:40:11 +05307883#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05307884
7885 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
7886
7887 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7888 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7889 buf_ptr += WMI_TLV_HDR_SIZE;
7890
7891 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7892 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7893 buf_ptr += WMI_TLV_HDR_SIZE;
7894
7895 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7896 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7897 buf_ptr += WMI_TLV_HDR_SIZE;
7898
7899 /* Fill TLV for pattern_info_timeout but no data. */
7900 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7901 buf_ptr += WMI_TLV_HDR_SIZE;
7902
7903 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
7904 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
7905 buf_ptr += WMI_TLV_HDR_SIZE;
7906 *(A_UINT32 *) buf_ptr = 0;
7907
7908 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7909 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7910 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307911 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307912 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307913 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307914 }
7915
Govind Singhb53420c2016-03-09 14:32:57 +05307916 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307917}
7918
7919/**
7920 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
7921 * @wmi_handle: wmi handle
7922 * @ptrn_id: pattern id
7923 * @vdev_id: vdev id
7924 *
7925 * Return: CDF status
7926 */
Govind Singhb53420c2016-03-09 14:32:57 +05307927QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle, uint8_t ptrn_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307928 uint8_t vdev_id)
7929{
7930 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
7931 wmi_buf_t buf;
7932 int32_t len;
7933 int ret;
7934
7935 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
7936
7937
7938 buf = wmi_buf_alloc(wmi_handle, len);
7939 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307940 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7941 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307942 }
7943
7944 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7945
7946 WMITLV_SET_HDR(&cmd->tlv_header,
7947 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
7948 WMITLV_GET_STRUCT_TLVLEN(
7949 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
7950 cmd->vdev_id = vdev_id;
7951 cmd->pattern_id = ptrn_id;
7952 cmd->pattern_type = WOW_BITMAP_PATTERN;
7953
Govind Singhb53420c2016-03-09 14:32:57 +05307954 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05307955 cmd->pattern_id, vdev_id);
7956
7957 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7958 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
7959 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307960 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307961 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307962 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307963 }
7964
Govind Singhb53420c2016-03-09 14:32:57 +05307965 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307966}
7967
7968/**
7969 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
7970 * @wmi_handle: wmi handle
7971 *
7972 * Sends host wakeup indication to FW. On receiving this indication,
7973 * FW will come out of WOW.
7974 *
7975 * Return: CDF status
7976 */
Govind Singhb53420c2016-03-09 14:32:57 +05307977QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307978{
7979 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
7980 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05307981 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307982 int32_t len;
7983 int ret;
7984
7985 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
7986
7987 buf = wmi_buf_alloc(wmi_handle, len);
7988 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307989 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7990 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307991 }
7992
7993 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
7994 wmi_buf_data(buf);
7995 WMITLV_SET_HDR(&cmd->tlv_header,
7996 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
7997 WMITLV_GET_STRUCT_TLVLEN
7998 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
7999
8000
8001 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8002 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8003 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308004 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308005 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308006 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308007 }
8008
Govind Singhb53420c2016-03-09 14:32:57 +05308009 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308010}
8011
8012/**
8013 * send_del_ts_cmd_tlv() - send DELTS request to fw
8014 * @wmi_handle: wmi handle
8015 * @msg: delts params
8016 *
8017 * Return: CDF status
8018 */
Govind Singhb53420c2016-03-09 14:32:57 +05308019QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308020 uint8_t ac)
8021{
8022 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8023 wmi_buf_t buf;
8024 int32_t len = sizeof(*cmd);
8025
8026 buf = wmi_buf_alloc(wmi_handle, len);
8027 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308028 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8029 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308030 }
8031 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8032 WMITLV_SET_HDR(&cmd->tlv_header,
8033 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8034 WMITLV_GET_STRUCT_TLVLEN
8035 (wmi_vdev_wmm_delts_cmd_fixed_param));
8036 cmd->vdev_id = vdev_id;
8037 cmd->ac = ac;
8038
Govind Singhb53420c2016-03-09 14:32:57 +05308039 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308040 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8041 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8042 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308043 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308044 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308045 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308046 }
8047
Govind Singhb53420c2016-03-09 14:32:57 +05308048 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308049}
8050
8051/**
8052 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8053 * @wmi_handle: handle to wmi
8054 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8055 *
Govind Singhb53420c2016-03-09 14:32:57 +05308056 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308057 * ADD_TS requestes to firmware in loop for all the ACs with
8058 * active flow.
8059 *
8060 * Return: CDF status
8061 */
Govind Singhb53420c2016-03-09 14:32:57 +05308062QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308063 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8064{
8065 int i = 0;
8066 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8067 wmi_buf_t buf;
8068 int32_t len = sizeof(*cmd);
8069
8070 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8071 /* if flow in this AC is active */
8072 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8073 /*
8074 * as per implementation of wma_add_ts_req() we
8075 * are not waiting any response from firmware so
8076 * apart from sending ADDTS to firmware just send
8077 * success to upper layers
8078 */
Govind Singhb53420c2016-03-09 14:32:57 +05308079 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308080
8081 buf = wmi_buf_alloc(wmi_handle, len);
8082 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308083 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8084 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308085 }
8086 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8087 wmi_buf_data(buf);
8088 WMITLV_SET_HDR(&cmd->tlv_header,
8089 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8090 WMITLV_GET_STRUCT_TLVLEN
8091 (wmi_vdev_wmm_addts_cmd_fixed_param));
8092 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8093 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308094 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308095 traffic.userPrio);
8096 cmd->medium_time_us =
8097 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8098 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308099 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308100 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8101 cmd->medium_time_us, cmd->downgrade_type);
8102 if (wmi_unified_cmd_send
8103 (wmi_handle, buf, len,
8104 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308105 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308106 __func__);
8107 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308108 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308109 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308110 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308111 }
8112 }
8113 }
8114
Govind Singhb53420c2016-03-09 14:32:57 +05308115 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308116}
8117
8118/**
8119 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8120 * @wmi_handle: wmi handle
8121 * @msg: ADDTS params
8122 *
8123 * Return: CDF status
8124 */
Govind Singhb53420c2016-03-09 14:32:57 +05308125QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308126 struct add_ts_param *msg)
8127{
8128 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8129 wmi_buf_t buf;
8130 int32_t len = sizeof(*cmd);
8131
Govind Singhb53420c2016-03-09 14:32:57 +05308132 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308133
8134 buf = wmi_buf_alloc(wmi_handle, len);
8135 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308136 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8137 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308138 }
8139 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8140 WMITLV_SET_HDR(&cmd->tlv_header,
8141 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8142 WMITLV_GET_STRUCT_TLVLEN
8143 (wmi_vdev_wmm_addts_cmd_fixed_param));
8144 cmd->vdev_id = msg->sme_session_id;
8145 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8146 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8147 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308148 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308149 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8150 cmd->downgrade_type, __func__, __LINE__);
8151 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8152 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308153 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8154 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308155 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308156 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308157 }
8158
Govind Singhb53420c2016-03-09 14:32:57 +05308159 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308160}
8161
8162/**
8163 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
8164 * @wmi_handle: wmi handle
8165 * @vdev_id: vdev id
8166 * @enable: Flag to enable/disable packet filter
8167 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308168 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308169 */
Govind Singhb53420c2016-03-09 14:32:57 +05308170QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308171 uint8_t vdev_id, bool enable)
8172{
8173 int32_t len;
8174 int ret = 0;
8175 wmi_buf_t buf;
8176 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
8177
8178 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
8179
8180 buf = wmi_buf_alloc(wmi_handle, len);
8181 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308182 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308183 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308184 }
8185
8186 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
8187 WMITLV_SET_HDR(&cmd->tlv_header,
8188 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
8189 WMITLV_GET_STRUCT_TLVLEN(
8190 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
8191
8192 cmd->vdev_id = vdev_id;
8193 if (enable)
8194 cmd->enable = PACKET_FILTER_SET_ENABLE;
8195 else
8196 cmd->enable = PACKET_FILTER_SET_DISABLE;
8197
Govind Singhb53420c2016-03-09 14:32:57 +05308198 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308199 __func__, cmd->enable, vdev_id);
8200
8201 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8202 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308203 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308204 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308205 wmi_buf_free(buf);
8206 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308207
8208 return ret;
8209}
8210
8211/**
8212 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
8213 * @wmi_handle: wmi handle
8214 * @vdev_id: vdev id
8215 * @rcv_filter_param: Packet filter parameters
8216 * @filter_id: Filter id
8217 * @enable: Flag to add/delete packet filter configuration
8218 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308219 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308220 */
Govind Singhb53420c2016-03-09 14:32:57 +05308221QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308222 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8223 uint8_t filter_id, bool enable)
8224{
8225 int len, i;
8226 int err = 0;
8227 wmi_buf_t buf;
8228 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8229
8230
8231 /* allocate the memory */
8232 len = sizeof(*cmd);
8233 buf = wmi_buf_alloc(wmi_handle, len);
8234 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308235 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308236 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308237 }
8238
8239 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8240 WMITLV_SET_HDR(&cmd->tlv_header,
8241 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8242 WMITLV_GET_STRUCT_TLVLEN
8243 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8244
8245 cmd->vdev_id = vdev_id;
8246 cmd->filter_id = filter_id;
8247 if (enable)
8248 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8249 else
8250 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8251
8252 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308253 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308254 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8255 rcv_filter_param->numFieldParams);
8256 cmd->filter_type = rcv_filter_param->filterType;
8257 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8258
8259 for (i = 0; i < cmd->num_params; i++) {
8260 cmd->paramsData[i].proto_type =
8261 rcv_filter_param->paramsData[i].protocolLayer;
8262 cmd->paramsData[i].cmp_type =
8263 rcv_filter_param->paramsData[i].cmpFlag;
8264 cmd->paramsData[i].data_length =
8265 rcv_filter_param->paramsData[i].dataLength;
8266 cmd->paramsData[i].data_offset =
8267 rcv_filter_param->paramsData[i].dataOffset;
8268 memcpy(&cmd->paramsData[i].compareData,
8269 rcv_filter_param->paramsData[i].compareData,
8270 sizeof(cmd->paramsData[i].compareData));
8271 memcpy(&cmd->paramsData[i].dataMask,
8272 rcv_filter_param->paramsData[i].dataMask,
8273 sizeof(cmd->paramsData[i].dataMask));
8274 }
8275 }
8276
Govind Singhb53420c2016-03-09 14:32:57 +05308277 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308278 cmd->filter_action, cmd->filter_id, cmd->num_params);
8279 /* send the command along with data */
8280 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8281 WMI_PACKET_FILTER_CONFIG_CMDID);
8282 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308283 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308284 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308285 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308286 }
8287
8288
8289 return 0;
8290}
8291
8292/**
8293 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
8294 * @wmi_handle: wmi handle
8295 * @vdev_id: vdev id
8296 * @multicastAddr: mcast address
8297 * @clearList: clear list flag
8298 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308299 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308300 */
Govind Singhb53420c2016-03-09 14:32:57 +05308301QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308302 uint8_t vdev_id,
Govind Singhb53420c2016-03-09 14:32:57 +05308303 struct qdf_mac_addr multicast_addr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308304 bool clearList)
8305{
8306 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
8307 wmi_buf_t buf;
8308 int err;
8309
8310 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8311 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308312 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308313 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308314 }
8315
8316 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308317 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308318
8319 WMITLV_SET_HDR(&cmd->tlv_header,
8320 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
8321 WMITLV_GET_STRUCT_TLVLEN
8322 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
8323 cmd->action =
8324 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
8325 cmd->vdev_id = vdev_id;
8326 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
Dustin Brown4103e4a2016-11-14 16:11:26 -08008327
8328 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
8329 cmd->action, vdev_id, clearList, multicast_addr.bytes);
8330
Govind Singh20c5dac2016-03-07 15:33:31 +05308331 err = wmi_unified_cmd_send(wmi_handle, buf,
8332 sizeof(*cmd),
8333 WMI_SET_MCASTBCAST_FILTER_CMDID);
8334 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308335 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308336 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308337 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308338 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308339
Dustin Brown4103e4a2016-11-14 16:11:26 -08008340 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308341}
8342
8343/**
8344 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
8345 * @wmi_handle: wmi handle
8346 * @vdev_id: vdev id
8347 * @params: GTK offload parameters
8348 *
8349 * Return: CDF status
8350 */
Govind Singhb53420c2016-03-09 14:32:57 +05308351QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308352 struct gtk_offload_params *params,
8353 bool enable_offload,
8354 uint32_t gtk_offload_opcode)
8355{
8356 int len;
8357 wmi_buf_t buf;
8358 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308359 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308360
Govind Singhb53420c2016-03-09 14:32:57 +05308361 WMI_LOGD("%s Enter", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308362
8363 len = sizeof(*cmd);
8364
8365 /* alloc wmi buffer */
8366 buf = wmi_buf_alloc(wmi_handle, len);
8367 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308368 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8369 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308370 goto out;
8371 }
8372
8373 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8374 WMITLV_SET_HDR(&cmd->tlv_header,
8375 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8376 WMITLV_GET_STRUCT_TLVLEN
8377 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8378
8379 cmd->vdev_id = vdev_id;
8380
8381 /* Request target to enable GTK offload */
Siddarth Poddar9500f2e2016-04-01 17:45:06 +05308382 if (enable_offload == WMI_GTK_OFFLOAD_ENABLE) {
Govind Singh20c5dac2016-03-07 15:33:31 +05308383 cmd->flags = gtk_offload_opcode;
8384
8385 /* Copy the keys and replay counter */
Govind Singhb53420c2016-03-09 14:32:57 +05308386 qdf_mem_copy(cmd->KCK, params->aKCK, WMI_GTK_OFFLOAD_KCK_BYTES);
8387 qdf_mem_copy(cmd->KEK, params->aKEK, WMI_GTK_OFFLOAD_KEK_BYTES);
8388 qdf_mem_copy(cmd->replay_counter, &params->ullKeyReplayCounter,
Govind Singh20c5dac2016-03-07 15:33:31 +05308389 GTK_REPLAY_COUNTER_BYTES);
8390 } else {
8391 cmd->flags = gtk_offload_opcode;
8392 }
8393
Dustin Brown4103e4a2016-11-14 16:11:26 -08008394 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
8395
Govind Singh20c5dac2016-03-07 15:33:31 +05308396 /* send the wmi command */
8397 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8398 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308399 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
Govind Singh20c5dac2016-03-07 15:33:31 +05308400 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308401 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308402 }
8403
Govind Singh20c5dac2016-03-07 15:33:31 +05308404out:
Govind Singhb53420c2016-03-09 14:32:57 +05308405 WMI_LOGD("%s Exit", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308406 return status;
8407}
8408
8409/**
8410 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
8411 * @wmi_handle: wmi handle
8412 * @params: GTK offload params
8413 *
8414 * Return: CDF status
8415 */
Govind Singhb53420c2016-03-09 14:32:57 +05308416QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308417 uint8_t vdev_id,
8418 uint64_t offload_req_opcode)
8419{
8420 int len;
8421 wmi_buf_t buf;
8422 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308423 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308424
8425 len = sizeof(*cmd);
8426
8427 /* alloc wmi buffer */
8428 buf = wmi_buf_alloc(wmi_handle, len);
8429 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308430 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8431 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308432 goto out;
8433 }
8434
8435 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8436 WMITLV_SET_HDR(&cmd->tlv_header,
8437 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8438 WMITLV_GET_STRUCT_TLVLEN
8439 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8440
8441 /* Request for GTK offload status */
8442 cmd->flags = offload_req_opcode;
8443 cmd->vdev_id = vdev_id;
8444
8445 /* send the wmi command */
8446 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8447 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308448 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
Govind Singh20c5dac2016-03-07 15:33:31 +05308449 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308450 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308451 }
8452
8453out:
8454 return status;
8455}
8456
8457/**
8458 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8459 * @wmi_handle: wmi handle
8460 * @pAddPeriodicTxPtrnParams: tx ptrn params
8461 *
8462 * Retrun: CDF status
8463 */
Govind Singhb53420c2016-03-09 14:32:57 +05308464QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308465 struct periodic_tx_pattern *
8466 pAddPeriodicTxPtrnParams,
8467 uint8_t vdev_id)
8468{
8469 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8470 wmi_buf_t wmi_buf;
8471 uint32_t len;
8472 uint8_t *buf_ptr;
8473 uint32_t ptrn_len, ptrn_len_aligned;
8474 int j;
8475
8476 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8477 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8478 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8479 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8480
8481 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8482 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308483 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8484 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308485 }
8486
8487 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8488
8489 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8490 WMITLV_SET_HDR(&cmd->tlv_header,
8491 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8492 WMITLV_GET_STRUCT_TLVLEN
8493 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8494
8495 /* Pass the pattern id to delete for the corresponding vdev id */
8496 cmd->vdev_id = vdev_id;
8497 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8498 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8499 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8500
8501 /* Pattern info */
8502 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8503 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8504 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308505 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308506 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308507 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308508
Govind Singhb53420c2016-03-09 14:32:57 +05308509 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308510 __func__, cmd->pattern_id, cmd->vdev_id);
8511
8512 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8513 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308514 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308515 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308516 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308517 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308518 }
Govind Singhb53420c2016-03-09 14:32:57 +05308519 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308520}
8521
8522/**
8523 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8524 * @wmi_handle: wmi handle
8525 * @vdev_id: vdev id
8526 * @pattern_id: pattern id
8527 *
8528 * Retrun: CDF status
8529 */
Govind Singhb53420c2016-03-09 14:32:57 +05308530QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308531 uint8_t vdev_id,
8532 uint8_t pattern_id)
8533{
8534 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8535 wmi_buf_t wmi_buf;
8536 uint32_t len =
8537 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8538
8539 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8540 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308541 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8542 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308543 }
8544
8545 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8546 wmi_buf_data(wmi_buf);
8547 WMITLV_SET_HDR(&cmd->tlv_header,
8548 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8549 WMITLV_GET_STRUCT_TLVLEN
8550 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8551
8552 /* Pass the pattern id to delete for the corresponding vdev id */
8553 cmd->vdev_id = vdev_id;
8554 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308555 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308556 __func__, cmd->pattern_id, cmd->vdev_id);
8557
8558 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8559 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308560 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308561 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308562 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308563 }
Govind Singhb53420c2016-03-09 14:32:57 +05308564 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308565}
8566
8567/**
8568 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8569 * @wmi_handle: wmi handle
8570 * @preq: stats ext params
8571 *
8572 * Return: CDF status
8573 */
Govind Singhb53420c2016-03-09 14:32:57 +05308574QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308575 struct stats_ext_params *preq)
8576{
Govind Singh67922e82016-04-01 16:48:57 +05308577 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308578 wmi_req_stats_ext_cmd_fixed_param *cmd;
8579 wmi_buf_t buf;
8580 uint16_t len;
8581 uint8_t *buf_ptr;
8582
8583 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8584
8585 buf = wmi_buf_alloc(wmi_handle, len);
8586 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308587 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308588 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308589 }
8590
8591 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8592 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8593
8594 WMITLV_SET_HDR(&cmd->tlv_header,
8595 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8596 WMITLV_GET_STRUCT_TLVLEN
8597 (wmi_req_stats_ext_cmd_fixed_param));
8598 cmd->vdev_id = preq->vdev_id;
8599 cmd->data_len = preq->request_data_len;
8600
Govind Singhb53420c2016-03-09 14:32:57 +05308601 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308602 __func__, preq->request_data_len, preq->vdev_id);
8603
8604 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8605 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8606
8607 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308608 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308609
8610 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8611 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308612 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308613 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308614 ret);
8615 wmi_buf_free(buf);
8616 }
8617
8618 return ret;
8619}
8620
8621/**
8622 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8623 * @wmi_handle: wmi handle
8624 * @params: ext wow params
8625 *
8626 * Return:0 for success or error code
8627 */
Govind Singhb53420c2016-03-09 14:32:57 +05308628QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308629 struct ext_wow_params *params)
8630{
8631 wmi_extwow_enable_cmd_fixed_param *cmd;
8632 wmi_buf_t buf;
8633 int32_t len;
8634 int ret;
8635
8636 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8637 buf = wmi_buf_alloc(wmi_handle, len);
8638 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308639 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8640 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308641 }
8642
8643 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8644
8645 WMITLV_SET_HDR(&cmd->tlv_header,
8646 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8647 WMITLV_GET_STRUCT_TLVLEN
8648 (wmi_extwow_enable_cmd_fixed_param));
8649
8650 cmd->vdev_id = params->vdev_id;
8651 cmd->type = params->type;
8652 cmd->wakeup_pin_num = params->wakeup_pin_num;
8653
Govind Singhb53420c2016-03-09 14:32:57 +05308654 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308655 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8656
8657 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8658 WMI_EXTWOW_ENABLE_CMDID);
8659 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308660 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308661 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308662 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308663 }
8664
Govind Singhb53420c2016-03-09 14:32:57 +05308665 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308666
8667}
8668
8669/**
8670 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8671 * @wmi_handle: wmi handle
8672 * @app_type1_params: app type1 params
8673 *
8674 * Return: CDF status
8675 */
Govind Singhb53420c2016-03-09 14:32:57 +05308676QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308677 struct app_type1_params *app_type1_params)
8678{
8679 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8680 wmi_buf_t buf;
8681 int32_t len;
8682 int ret;
8683
8684 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8685 buf = wmi_buf_alloc(wmi_handle, len);
8686 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308687 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8688 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308689 }
8690
8691 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8692 wmi_buf_data(buf);
8693
8694 WMITLV_SET_HDR(&cmd->tlv_header,
8695 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8696 WMITLV_GET_STRUCT_TLVLEN
8697 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8698
8699 cmd->vdev_id = app_type1_params->vdev_id;
8700 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8701 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308702 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308703 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308704 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308705 cmd->passwd_len = app_type1_params->pass_length;
8706
Govind Singhb53420c2016-03-09 14:32:57 +05308707 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308708 "identification_id %.8s id_length %u "
8709 "password %.16s pass_length %u",
8710 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8711 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8712
8713 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8714 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8715 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308716 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308717 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308718 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308719 }
8720
Govind Singhb53420c2016-03-09 14:32:57 +05308721 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308722}
8723
8724/**
8725 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8726 * @wmi_handle: wmi handle
8727 * @appType2Params: app type2 params
8728 *
8729 * Return: CDF status
8730 */
Govind Singhb53420c2016-03-09 14:32:57 +05308731QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308732 struct app_type2_params *appType2Params)
8733{
8734 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8735 wmi_buf_t buf;
8736 int32_t len;
8737 int ret;
8738
8739 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8740 buf = wmi_buf_alloc(wmi_handle, len);
8741 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308742 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8743 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308744 }
8745
8746 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8747 wmi_buf_data(buf);
8748
8749 WMITLV_SET_HDR(&cmd->tlv_header,
8750 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8751 WMITLV_GET_STRUCT_TLVLEN
8752 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8753
8754 cmd->vdev_id = appType2Params->vdev_id;
8755
Govind Singhb53420c2016-03-09 14:32:57 +05308756 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308757 cmd->rc4_key_len = appType2Params->rc4_key_len;
8758
8759 cmd->ip_id = appType2Params->ip_id;
8760 cmd->ip_device_ip = appType2Params->ip_device_ip;
8761 cmd->ip_server_ip = appType2Params->ip_server_ip;
8762
8763 cmd->tcp_src_port = appType2Params->tcp_src_port;
8764 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8765 cmd->tcp_seq = appType2Params->tcp_seq;
8766 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8767
8768 cmd->keepalive_init = appType2Params->keepalive_init;
8769 cmd->keepalive_min = appType2Params->keepalive_min;
8770 cmd->keepalive_max = appType2Params->keepalive_max;
8771 cmd->keepalive_inc = appType2Params->keepalive_inc;
8772
8773 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8774 &cmd->gateway_mac);
8775 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8776 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8777
Govind Singhb53420c2016-03-09 14:32:57 +05308778 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308779 "rc4_key %.16s rc4_key_len %u "
8780 "ip_id %x ip_device_ip %x ip_server_ip %x "
8781 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8782 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8783 "keepalive_max %u keepalive_inc %u "
8784 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8785 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8786 cmd->rc4_key, cmd->rc4_key_len,
8787 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8788 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8789 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8790 cmd->keepalive_max, cmd->keepalive_inc,
8791 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8792
8793 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8794 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8795 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308796 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308797 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308798 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308799 }
8800
Govind Singhb53420c2016-03-09 14:32:57 +05308801 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308802
8803}
8804
8805/**
8806 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8807 * @wmi_handle: wmi handle
8808 * @timer_val: auto shutdown timer value
8809 *
8810 * Return: CDF status
8811 */
Govind Singhb53420c2016-03-09 14:32:57 +05308812QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308813 uint32_t timer_val)
8814{
Govind Singh67922e82016-04-01 16:48:57 +05308815 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308816 wmi_buf_t buf = NULL;
8817 uint8_t *buf_ptr;
8818 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8819 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8820
Govind Singhb53420c2016-03-09 14:32:57 +05308821 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308822 __func__, timer_val);
8823
8824 buf = wmi_buf_alloc(wmi_handle, len);
8825 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308826 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8827 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308828 }
8829
8830 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8831 wmi_auto_sh_cmd =
8832 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8833 wmi_auto_sh_cmd->timer_value = timer_val;
8834
8835 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8836 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8837 WMITLV_GET_STRUCT_TLVLEN
8838 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8839
8840 status = wmi_unified_cmd_send(wmi_handle, buf,
8841 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308842 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308843 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308844 __func__, status);
8845 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308846 }
8847
Govind Singh67922e82016-04-01 16:48:57 +05308848 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308849}
8850
8851/**
8852 * send_nan_req_cmd_tlv() - to send nan request to target
8853 * @wmi_handle: wmi handle
8854 * @nan_req: request data which will be non-null
8855 *
8856 * Return: CDF status
8857 */
Govind Singhb53420c2016-03-09 14:32:57 +05308858QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308859 struct nan_req_params *nan_req)
8860{
Govind Singh67922e82016-04-01 16:48:57 +05308861 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308862 wmi_nan_cmd_param *cmd;
8863 wmi_buf_t buf;
8864 uint16_t len = sizeof(*cmd);
8865 uint16_t nan_data_len, nan_data_len_aligned;
8866 uint8_t *buf_ptr;
8867
8868 /*
8869 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8870 * +------------+----------+-----------------------+--------------+
8871 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8872 * +------------+----------+-----------------------+--------------+
8873 */
8874 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308875 WMI_LOGE("%s:nan req is not valid", __func__);
8876 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308877 }
8878 nan_data_len = nan_req->request_data_len;
8879 nan_data_len_aligned = roundup(nan_req->request_data_len,
8880 sizeof(uint32_t));
8881 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8882 buf = wmi_buf_alloc(wmi_handle, len);
8883 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308884 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8885 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308886 }
8887 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8888 cmd = (wmi_nan_cmd_param *) buf_ptr;
8889 WMITLV_SET_HDR(&cmd->tlv_header,
8890 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8891 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8892 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308893 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308894 __func__, nan_req->request_data_len);
8895 buf_ptr += sizeof(wmi_nan_cmd_param);
8896 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8897 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308898 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308899
8900 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8901 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308902 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308903 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308904 __func__, ret);
8905 wmi_buf_free(buf);
8906 }
8907
8908 return ret;
8909}
8910
8911/**
8912 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8913 * @wmi_handle: wmi handle
8914 * @pDhcpSrvOffloadInfo: DHCP server offload info
8915 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308916 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308917 */
Govind Singhb53420c2016-03-09 14:32:57 +05308918QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308919 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8920{
8921 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8922 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308923 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308924
8925 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8926 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308927 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308928 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308929 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308930 }
8931
8932 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308933 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308934
8935 WMITLV_SET_HDR(&cmd->tlv_header,
8936 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8937 WMITLV_GET_STRUCT_TLVLEN
8938 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8939 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8940 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8941 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8942 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8943 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308944 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308945 sizeof(*cmd),
8946 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308947 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308948 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308949 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308950 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308951 }
Govind Singhb53420c2016-03-09 14:32:57 +05308952 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308953 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308954
8955 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308956}
8957
8958/**
8959 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8960 * @wmi_handle: wmi handle
8961 * @flashing: flashing request
8962 *
8963 * Return: CDF status
8964 */
Govind Singhb53420c2016-03-09 14:32:57 +05308965QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308966 struct flashing_req_params *flashing)
8967{
8968 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308969 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308970 wmi_buf_t buf;
8971 uint8_t *buf_ptr;
8972 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8973
8974 buf = wmi_buf_alloc(wmi_handle, len);
8975 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308976 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308977 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308978 }
8979 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8980 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8981 WMITLV_SET_HDR(&cmd->tlv_header,
8982 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8983 WMITLV_GET_STRUCT_TLVLEN
8984 (wmi_set_led_flashing_cmd_fixed_param));
8985 cmd->pattern_id = flashing->pattern_id;
8986 cmd->led_x0 = flashing->led_x0;
8987 cmd->led_x1 = flashing->led_x1;
8988
8989 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8990 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308991 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308992 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308993 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308994 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308995 }
Govind Singh67922e82016-04-01 16:48:57 +05308996
8997 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308998}
8999
9000/**
9001 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9002 * @wmi_handle: wmi handle
9003 * @ch_avoid_update_req: channel avoid update params
9004 *
9005 * Return: CDF status
9006 */
Govind Singhb53420c2016-03-09 14:32:57 +05309007QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309008{
Govind Singh67922e82016-04-01 16:48:57 +05309009 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309010 wmi_buf_t buf = NULL;
9011 uint8_t *buf_ptr;
9012 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9013 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9014
9015
9016 buf = wmi_buf_alloc(wmi_handle, len);
9017 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309018 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9019 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309020 }
9021
9022 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9023 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9024 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9025 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9026 WMITLV_GET_STRUCT_TLVLEN
9027 (wmi_chan_avoid_update_cmd_param));
9028
9029 status = wmi_unified_cmd_send(wmi_handle, buf,
9030 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309031 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309032 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309033 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9034 " returned Error %d", status);
9035 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309036 }
9037
Govind Singh67922e82016-04-01 16:48:57 +05309038 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309039}
9040
9041/**
9042 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9043 * @wmi_handle: wmi handle
9044 * @reg_dmn: reg domain
9045 * @regdmn2G: 2G reg domain
9046 * @regdmn5G: 5G reg domain
9047 * @ctl2G: 2G test limit
9048 * @ctl5G: 5G test limit
9049 *
9050 * Return: none
9051 */
Govind Singhb53420c2016-03-09 14:32:57 +05309052QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309053 uint32_t reg_dmn, uint16_t regdmn2G,
9054 uint16_t regdmn5G, int8_t ctl2G,
9055 int8_t ctl5G)
9056{
9057 wmi_buf_t buf;
9058 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9059 int32_t len = sizeof(*cmd);
9060
9061
9062 buf = wmi_buf_alloc(wmi_handle, len);
9063 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309064 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9065 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309066 }
9067 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9068 WMITLV_SET_HDR(&cmd->tlv_header,
9069 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9070 WMITLV_GET_STRUCT_TLVLEN
9071 (wmi_pdev_set_regdomain_cmd_fixed_param));
9072 cmd->reg_domain = reg_dmn;
9073 cmd->reg_domain_2G = regdmn2G;
9074 cmd->reg_domain_5G = regdmn5G;
9075 cmd->conformance_test_limit_2G = ctl2G;
9076 cmd->conformance_test_limit_5G = ctl5G;
9077
9078 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9079 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309080 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309081 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309082 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309083 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309084 }
9085
Govind Singhb53420c2016-03-09 14:32:57 +05309086 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309087}
9088
9089
9090/**
9091 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9092 * @wmi_handle: wmi handle
9093 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9094 *
9095 * This function sets tdls off channel mode
9096 *
9097 * Return: 0 on success; Negative errno otherwise
9098 */
Govind Singhb53420c2016-03-09 14:32:57 +05309099QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309100 struct tdls_channel_switch_params *chan_switch_params)
9101{
9102 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9103 wmi_buf_t wmi_buf;
9104 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9105
9106 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9107 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309108 WMI_LOGE(FL("wmi_buf_alloc failed"));
9109 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309110 }
9111 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9112 wmi_buf_data(wmi_buf);
9113 WMITLV_SET_HDR(&cmd->tlv_header,
9114 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9115 WMITLV_GET_STRUCT_TLVLEN(
9116 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9117
9118 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9119 &cmd->peer_macaddr);
9120 cmd->vdev_id = chan_switch_params->vdev_id;
9121 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9122 cmd->is_peer_responder = chan_switch_params->is_responder;
9123 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9124 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9125 cmd->offchan_oper_class = chan_switch_params->oper_class;
9126
Govind Singhb53420c2016-03-09 14:32:57 +05309127 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309128 cmd->peer_macaddr.mac_addr31to0,
9129 cmd->peer_macaddr.mac_addr47to32);
9130
Govind Singhb53420c2016-03-09 14:32:57 +05309131 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309132 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9133 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9134 ),
9135 cmd->vdev_id,
9136 cmd->offchan_mode,
9137 cmd->offchan_num,
9138 cmd->offchan_bw_bitmap,
9139 cmd->is_peer_responder,
9140 cmd->offchan_oper_class);
9141
9142 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9143 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309144 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309145 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309146 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309147 }
9148
9149
Govind Singhb53420c2016-03-09 14:32:57 +05309150 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309151}
9152
9153/**
9154 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9155 * @wmi_handle: wmi handle
9156 * @pwmaTdlsparams: TDLS params
9157 *
9158 * Return: 0 for sucess or error code
9159 */
Govind Singhb53420c2016-03-09 14:32:57 +05309160QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309161 void *tdls_param, uint8_t tdls_state)
9162{
9163 wmi_tdls_set_state_cmd_fixed_param *cmd;
9164 wmi_buf_t wmi_buf;
9165
9166 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9167 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9168
9169 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9170 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309171 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9172 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309173 }
9174 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9175 WMITLV_SET_HDR(&cmd->tlv_header,
9176 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9177 WMITLV_GET_STRUCT_TLVLEN
9178 (wmi_tdls_set_state_cmd_fixed_param));
9179 cmd->vdev_id = wmi_tdls->vdev_id;
9180 cmd->state = tdls_state;
9181 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9182 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9183 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9184 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9185 cmd->rssi_delta = wmi_tdls->rssi_delta;
9186 cmd->tdls_options = wmi_tdls->tdls_options;
9187 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9188 cmd->tdls_peer_traffic_response_timeout_ms =
9189 wmi_tdls->peer_traffic_response_timeout;
9190 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9191 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9192 cmd->tdls_puapsd_rx_frame_threshold =
9193 wmi_tdls->puapsd_rx_frame_threshold;
9194 cmd->teardown_notification_ms =
9195 wmi_tdls->teardown_notification_ms;
9196 cmd->tdls_peer_kickout_threshold =
9197 wmi_tdls->tdls_peer_kickout_threshold;
9198
Govind Singhb53420c2016-03-09 14:32:57 +05309199 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309200 "notification_interval_ms: %d, "
9201 "tx_discovery_threshold: %d, "
9202 "tx_teardown_threshold: %d, "
9203 "rssi_teardown_threshold: %d, "
9204 "rssi_delta: %d, "
9205 "tdls_options: 0x%x, "
9206 "tdls_peer_traffic_ind_window: %d, "
9207 "tdls_peer_traffic_response_timeout: %d, "
9208 "tdls_puapsd_mask: 0x%x, "
9209 "tdls_puapsd_inactivity_time: %d, "
9210 "tdls_puapsd_rx_frame_threshold: %d, "
9211 "teardown_notification_ms: %d, "
9212 "tdls_peer_kickout_threshold: %d",
9213 __func__, tdls_state, cmd->state,
9214 cmd->notification_interval_ms,
9215 cmd->tx_discovery_threshold,
9216 cmd->tx_teardown_threshold,
9217 cmd->rssi_teardown_threshold,
9218 cmd->rssi_delta,
9219 cmd->tdls_options,
9220 cmd->tdls_peer_traffic_ind_window,
9221 cmd->tdls_peer_traffic_response_timeout_ms,
9222 cmd->tdls_puapsd_mask,
9223 cmd->tdls_puapsd_inactivity_time_ms,
9224 cmd->tdls_puapsd_rx_frame_threshold,
9225 cmd->teardown_notification_ms,
9226 cmd->tdls_peer_kickout_threshold);
9227
9228 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9229 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309230 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309231 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309232 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309233 }
Govind Singhb53420c2016-03-09 14:32:57 +05309234 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309235
Govind Singhb53420c2016-03-09 14:32:57 +05309236 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309237}
9238
9239/**
9240 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9241 * @wmi_handle: wmi handle
9242 * @peerStateParams: TDLS peer state params
9243 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309244 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309245 */
Govind Singhb53420c2016-03-09 14:32:57 +05309246QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309247 struct tdls_peer_state_params *peerStateParams,
9248 uint32_t *ch_mhz)
9249{
9250 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9251 wmi_tdls_peer_capabilities *peer_cap;
9252 wmi_channel *chan_info;
9253 wmi_buf_t wmi_buf;
9254 uint8_t *buf_ptr;
9255 uint32_t i;
9256 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9257 sizeof(wmi_tdls_peer_capabilities);
9258
9259
9260 len += WMI_TLV_HDR_SIZE +
9261 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9262
9263 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9264 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309265 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9266 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309267 }
9268
9269 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9270 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9271 WMITLV_SET_HDR(&cmd->tlv_header,
9272 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9273 WMITLV_GET_STRUCT_TLVLEN
9274 (wmi_tdls_peer_update_cmd_fixed_param));
9275
9276 cmd->vdev_id = peerStateParams->vdevId;
9277 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9278 &cmd->peer_macaddr);
9279
9280
9281 cmd->peer_state = peerStateParams->peerState;
9282
Govind Singhb53420c2016-03-09 14:32:57 +05309283 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309284 "peer_macaddr.mac_addr31to0: 0x%x, "
9285 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9286 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9287 cmd->peer_macaddr.mac_addr31to0,
9288 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9289
9290 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9291 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9292 WMITLV_SET_HDR(&peer_cap->tlv_header,
9293 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9294 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9295
9296 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9297 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9298 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9299 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9300 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9301 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9302 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9303 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9304
9305 /* Ack and More Data Ack are sent as 0, so no need to set
9306 * but fill SP
9307 */
9308 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9309 peerStateParams->peerCap.peerMaxSp);
9310
9311 peer_cap->buff_sta_support =
9312 peerStateParams->peerCap.peerBuffStaSupport;
9313 peer_cap->off_chan_support =
9314 peerStateParams->peerCap.peerOffChanSupport;
9315 peer_cap->peer_curr_operclass =
9316 peerStateParams->peerCap.peerCurrOperClass;
9317 /* self curr operclass is not being used and so pass op class for
9318 * preferred off chan in it.
9319 */
9320 peer_cap->self_curr_operclass =
9321 peerStateParams->peerCap.opClassForPrefOffChan;
9322 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9323 peer_cap->peer_operclass_len =
9324 peerStateParams->peerCap.peerOperClassLen;
9325
Govind Singhb53420c2016-03-09 14:32:57 +05309326 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309327 __func__, peer_cap->peer_operclass_len);
9328 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9329 peer_cap->peer_operclass[i] =
9330 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309331 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309332 __func__, i, peer_cap->peer_operclass[i]);
9333 }
9334
9335 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9336 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9337 peer_cap->pref_offchan_bw =
9338 peerStateParams->peerCap.prefOffChanBandwidth;
9339
Govind Singhb53420c2016-03-09 14:32:57 +05309340 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309341 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9342 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9343 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9344 " %d, pref_offchan_bw: %d",
9345 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9346 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9347 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9348 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9349 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9350
9351 /* next fill variable size array of peer chan info */
9352 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9353 WMITLV_SET_HDR(buf_ptr,
9354 WMITLV_TAG_ARRAY_STRUC,
9355 sizeof(wmi_channel) *
9356 peerStateParams->peerCap.peerChanLen);
9357 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9358
9359 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9360 WMITLV_SET_HDR(&chan_info->tlv_header,
9361 WMITLV_TAG_STRUC_wmi_channel,
9362 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9363 chan_info->mhz = ch_mhz[i];
9364 chan_info->band_center_freq1 = chan_info->mhz;
9365 chan_info->band_center_freq2 = 0;
9366
Govind Singhb53420c2016-03-09 14:32:57 +05309367 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309368
9369 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9370 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309371 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309372 peerStateParams->peerCap.peerChan[i].chanId,
9373 peerStateParams->peerCap.peerChan[i].dfsSet);
9374 }
9375
9376 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9377 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9378 else
9379 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9380
9381 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9382 peerStateParams->peerCap.
9383 peerChan[i].pwr);
9384
9385 WMI_SET_CHANNEL_REG_POWER(chan_info,
9386 peerStateParams->peerCap.peerChan[i].
9387 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309388 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309389 peerStateParams->peerCap.peerChan[i].pwr);
9390
9391 chan_info++;
9392 }
9393
9394 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9395 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309396 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309397 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309398 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309399 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309400 }
9401
9402
Govind Singhb53420c2016-03-09 14:32:57 +05309403 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309404}
9405
9406/*
9407 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9408 * firmware
9409 * @wmi_handle: Pointer to wmi handle
9410 * @mem_dump_req: Pointer for mem_dump_req
9411 *
9412 * This function sends memory dump request to firmware
9413 *
Govind Singhb53420c2016-03-09 14:32:57 +05309414 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309415 *
9416 */
Govind Singhb53420c2016-03-09 14:32:57 +05309417QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309418 struct fw_dump_req_param *mem_dump_req)
9419{
9420 wmi_get_fw_mem_dump_fixed_param *cmd;
9421 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309422 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309423 int32_t len;
9424 wmi_buf_t buf;
9425 u_int8_t *buf_ptr;
9426 int ret, loop;
9427
9428 /*
9429 * len = sizeof(fixed param) that includes tlv header +
9430 * tlv header for array of struc +
9431 * sizeof (each struct)
9432 */
9433 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9434 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9435 buf = wmi_buf_alloc(wmi_handle, len);
9436
9437 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309438 WMI_LOGE(FL("Failed allocate wmi buffer"));
9439 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309440 }
9441
9442 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309443 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309444 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9445
9446 WMITLV_SET_HDR(&cmd->tlv_header,
9447 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9448 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9449
9450 cmd->request_id = mem_dump_req->request_id;
9451 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9452
9453 /* TLV indicating array of structures to follow */
9454 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9455 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9456 sizeof(wmi_fw_mem_dump) *
9457 cmd->num_fw_mem_dump_segs);
9458
9459 buf_ptr += WMI_TLV_HDR_SIZE;
9460 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9461
Govind Singhb53420c2016-03-09 14:32:57 +05309462 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309463 mem_dump_req->request_id, mem_dump_req->num_seg);
9464 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309465 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309466 ((uint8_t *)(mem_dump_req->segment) +
9467 loop * sizeof(*seg_req));
9468 WMITLV_SET_HDR(&dump_params->tlv_header,
9469 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9470 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9471 dump_params->seg_id = seg_req->seg_id;
9472 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9473 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9474 dump_params->seg_length = seg_req->seg_length;
9475 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9476 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309477 WMI_LOGI(FL("seg_number:%d"), loop);
9478 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309479 dump_params->seg_id, dump_params->seg_start_addr_lo,
9480 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309481 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309482 dump_params->seg_length, dump_params->dest_addr_lo,
9483 dump_params->dest_addr_hi);
9484 dump_params++;
9485 }
9486
9487 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9488 WMI_GET_FW_MEM_DUMP_CMDID);
9489 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309490 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309491 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309492 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309493 }
9494
Govind Singhb53420c2016-03-09 14:32:57 +05309495 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9496 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309497}
9498
9499/*
9500 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9501 * @wmi_handle: Pointer to WMi handle
9502 * @ie_data: Pointer for ie data
9503 *
9504 * This function sends IE information to firmware
9505 *
Govind Singhb53420c2016-03-09 14:32:57 +05309506 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309507 *
9508 */
Govind Singhb53420c2016-03-09 14:32:57 +05309509QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309510 struct vdev_ie_info_param *ie_info)
9511{
9512 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9513 wmi_buf_t buf;
9514 uint8_t *buf_ptr;
9515 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309516 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309517
9518
9519 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9520 /* Allocate memory for the WMI command */
9521 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9522
9523 buf = wmi_buf_alloc(wmi_handle, len);
9524 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309525 WMI_LOGE(FL("wmi_buf_alloc failed"));
9526 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309527 }
9528
9529 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309530 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309531
9532 /* Populate the WMI command */
9533 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9534
9535 WMITLV_SET_HDR(&cmd->tlv_header,
9536 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9537 WMITLV_GET_STRUCT_TLVLEN(
9538 wmi_vdev_set_ie_cmd_fixed_param));
9539 cmd->vdev_id = ie_info->vdev_id;
9540 cmd->ie_id = ie_info->ie_id;
9541 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009542 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309543
Govind Singhb53420c2016-03-09 14:32:57 +05309544 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309545 ie_info->length, ie_info->vdev_id);
9546
9547 buf_ptr += sizeof(*cmd);
9548 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9549 buf_ptr += WMI_TLV_HDR_SIZE;
9550
Govind Singhb53420c2016-03-09 14:32:57 +05309551 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309552
9553 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9554 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309555 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309556 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309557 wmi_buf_free(buf);
9558 }
9559
9560 return ret;
9561}
9562
Jeff Johnson9366d7a2016-10-07 13:03:02 -07009563static
Govind Singh9ddd5162016-03-07 16:30:32 +05309564void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05309565 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05309566{
Govind Singhe7f2f342016-05-23 12:12:52 +05309567 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05309568 resource_cfg->num_peers = tgt_res_cfg->num_peers;
9569 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
9570 resource_cfg->num_offload_reorder_buffs =
9571 tgt_res_cfg->num_offload_reorder_buffs;
9572 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
9573 resource_cfg->num_tids = tgt_res_cfg->num_tids;
9574 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
9575 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
9576 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
9577 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
9578 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
9579 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
9580 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
9581 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
9582 resource_cfg->scan_max_pending_req =
9583 tgt_res_cfg->scan_max_pending_req;
9584 resource_cfg->bmiss_offload_max_vdev =
9585 tgt_res_cfg->bmiss_offload_max_vdev;
9586 resource_cfg->roam_offload_max_vdev =
9587 tgt_res_cfg->roam_offload_max_vdev;
9588 resource_cfg->roam_offload_max_ap_profiles =
9589 tgt_res_cfg->roam_offload_max_ap_profiles;
9590 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
9591 resource_cfg->num_mcast_table_elems =
9592 tgt_res_cfg->num_mcast_table_elems;
9593 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
9594 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
9595 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
9596 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
9597 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
9598 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
9599 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
9600 resource_cfg->vow_config = tgt_res_cfg->vow_config;
9601 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
9602 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
9603 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
9604 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
9605 resource_cfg->num_tdls_conn_table_entries =
9606 tgt_res_cfg->num_tdls_conn_table_entries;
9607 resource_cfg->beacon_tx_offload_max_vdev =
9608 tgt_res_cfg->beacon_tx_offload_max_vdev;
9609 resource_cfg->num_multicast_filter_entries =
9610 tgt_res_cfg->num_multicast_filter_entries;
9611 resource_cfg->num_wow_filters =
9612 tgt_res_cfg->num_wow_filters;
9613 resource_cfg->num_keep_alive_pattern =
9614 tgt_res_cfg->num_keep_alive_pattern;
9615 resource_cfg->keep_alive_pattern_size =
9616 tgt_res_cfg->keep_alive_pattern_size;
9617 resource_cfg->max_tdls_concurrent_sleep_sta =
9618 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
9619 resource_cfg->max_tdls_concurrent_buffer_sta =
9620 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
9621 resource_cfg->wmi_send_separate =
9622 tgt_res_cfg->wmi_send_separate;
9623 resource_cfg->num_ocb_vdevs =
9624 tgt_res_cfg->num_ocb_vdevs;
9625 resource_cfg->num_ocb_channels =
9626 tgt_res_cfg->num_ocb_channels;
9627 resource_cfg->num_ocb_schedules =
9628 tgt_res_cfg->num_ocb_schedules;
9629
9630}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309631#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309632/**
9633 * send_init_cmd_tlv() - wmi init command
9634 * @wmi_handle: pointer to wmi handle
9635 * @res_cfg: resource config
9636 * @num_mem_chunks: no of mem chunck
9637 * @mem_chunk: pointer to mem chunck structure
9638 *
9639 * This function sends IE information to firmware
9640 *
Govind Singhb53420c2016-03-09 14:32:57 +05309641 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309642 *
9643 */
Govind Singhb53420c2016-03-09 14:32:57 +05309644QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309645 wmi_resource_config *tgt_res_cfg,
9646 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
9647 bool action)
9648{
9649 wmi_buf_t buf;
9650 wmi_init_cmd_fixed_param *cmd;
9651 wmi_abi_version my_vers;
9652 int num_whitelist;
9653 uint8_t *buf_ptr;
9654 wmi_resource_config *resource_cfg;
9655 wlan_host_memory_chunk *host_mem_chunks;
9656 uint32_t mem_chunk_len = 0;
9657 uint16_t idx;
9658 int len;
9659 int ret;
9660
9661 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
9662 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
9663 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
9664 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309665 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
9666 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309667 }
9668
9669 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9670 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
9671 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
9672
9673 host_mem_chunks = (wlan_host_memory_chunk *)
9674 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
9675 + WMI_TLV_HDR_SIZE);
9676
9677 WMITLV_SET_HDR(&cmd->tlv_header,
9678 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
9679 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
9680
Govind Singhb53420c2016-03-09 14:32:57 +05309681 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +05309682 WMITLV_SET_HDR(&resource_cfg->tlv_header,
9683 WMITLV_TAG_STRUC_wmi_resource_config,
9684 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
9685
9686 for (idx = 0; idx < num_mem_chunks; ++idx) {
9687 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
9688 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
9689 WMITLV_GET_STRUCT_TLVLEN
9690 (wlan_host_memory_chunk));
9691 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
9692 host_mem_chunks[idx].size = mem_chunks[idx].len;
9693 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309694 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +05309695 idx, host_mem_chunks[idx].size,
9696 host_mem_chunks[idx].ptr);
9697 }
9698 cmd->num_host_mem_chunks = num_mem_chunks;
9699 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
9700 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
9701 WMITLV_TAG_ARRAY_STRUC,
9702 (sizeof(wlan_host_memory_chunk) *
9703 num_mem_chunks));
9704
9705 num_whitelist = sizeof(version_whitelist) /
9706 sizeof(wmi_whitelist_version_info);
9707 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
9708 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
9709 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
9710 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
9711 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
9712 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +05309713#ifdef CONFIG_MCL
9714 /* This needs to be enabled for WIN Lithium after removing dependency
9715 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +05309716 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
9717 &my_vers,
9718 &wmi_handle->fw_abi_version,
9719 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +05309720#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309721 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05309722 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
9723 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
9724 cmd->host_abi_vers.abi_version_ns_0,
9725 cmd->host_abi_vers.abi_version_ns_1,
9726 cmd->host_abi_vers.abi_version_ns_2,
9727 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +05309728#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309729 /* Save version sent from host -
9730 * Will be used to check ready event
9731 */
Govind Singhb53420c2016-03-09 14:32:57 +05309732 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309733 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309734#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309735 if (action) {
9736 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9737 WMI_INIT_CMDID);
9738 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309739 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +05309740 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309741 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309742 }
9743 } else {
9744 wmi_handle->saved_wmi_init_cmd.buf = buf;
9745 wmi_handle->saved_wmi_init_cmd.buf_len = len;
9746 }
9747
Govind Singhb53420c2016-03-09 14:32:57 +05309748 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309749
9750}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309751#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309752/**
9753 * send_saved_init_cmd_tlv() - wmi init command
9754 * @wmi_handle: pointer to wmi handle
9755 *
9756 * This function sends IE information to firmware
9757 *
Govind Singhb53420c2016-03-09 14:32:57 +05309758 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309759 *
9760 */
Govind Singhb53420c2016-03-09 14:32:57 +05309761QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +05309762{
9763 int status;
9764
9765 if (!wmi_handle->saved_wmi_init_cmd.buf ||
9766 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05309767 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
9768 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309769 }
9770 status = wmi_unified_cmd_send(wmi_handle,
9771 wmi_handle->saved_wmi_init_cmd.buf,
9772 wmi_handle->saved_wmi_init_cmd.buf_len,
9773 WMI_INIT_CMDID);
9774 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +05309775 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +05309776 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309777 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309778 }
9779 wmi_handle->saved_wmi_init_cmd.buf = NULL;
9780 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
9781
Govind Singhb53420c2016-03-09 14:32:57 +05309782 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309783}
9784
Govind Singhb53420c2016-03-09 14:32:57 +05309785QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05309786{
9787 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
9788 wmi_service_ready_event_fixed_param *ev;
9789
9790
9791 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
9792
9793 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
9794 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05309795 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309796
Govind Singh87542482016-06-08 19:40:11 +05309797#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309798 /*Save fw version from service ready message */
9799 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05309800 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309801 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309802#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309803 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309804}
9805
9806/**
9807 * wmi_unified_save_fw_version_cmd() - save fw version
9808 * @wmi_handle: pointer to wmi handle
9809 * @res_cfg: resource config
9810 * @num_mem_chunks: no of mem chunck
9811 * @mem_chunk: pointer to mem chunck structure
9812 *
9813 * This function sends IE information to firmware
9814 *
Govind Singhb53420c2016-03-09 14:32:57 +05309815 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309816 *
9817 */
Govind Singhb53420c2016-03-09 14:32:57 +05309818QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309819 void *evt_buf)
9820{
9821 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
9822 wmi_ready_event_fixed_param *ev = NULL;
9823
9824 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
9825 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +05309826#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309827 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
9828 &ev->fw_abi_vers)) {
9829 /*
9830 * Error: Our host version and the given firmware version
9831 * are incompatible.
9832 **/
Govind Singhb53420c2016-03-09 14:32:57 +05309833 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +05309834 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
9835 __func__,
9836 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
9837 abi_version_0),
9838 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
9839 abi_version_0),
9840 wmi_handle->final_abi_vers.abi_version_ns_0,
9841 wmi_handle->final_abi_vers.abi_version_ns_1,
9842 wmi_handle->final_abi_vers.abi_version_ns_2,
9843 wmi_handle->final_abi_vers.abi_version_ns_3,
9844 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
9845 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
9846 ev->fw_abi_vers.abi_version_ns_0,
9847 ev->fw_abi_vers.abi_version_ns_1,
9848 ev->fw_abi_vers.abi_version_ns_2,
9849 ev->fw_abi_vers.abi_version_ns_3);
9850
Govind Singhb53420c2016-03-09 14:32:57 +05309851 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309852 }
Govind Singhb53420c2016-03-09 14:32:57 +05309853 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309854 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +05309855 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309856 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309857#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309858
Govind Singhb53420c2016-03-09 14:32:57 +05309859 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309860}
Govind Singha4836fd2016-03-07 16:45:38 +05309861
9862/**
9863 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
9864 * @wmi_handle: wmi handle
9865 * @custom_addr: base mac address
9866 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309867 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +05309868 */
Govind Singhb53420c2016-03-09 14:32:57 +05309869QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309870 uint8_t *custom_addr)
9871{
9872 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
9873 wmi_buf_t buf;
9874 int err;
9875
9876 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9877 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309878 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309879 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309880 }
9881
9882 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309883 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +05309884
9885 WMITLV_SET_HDR(&cmd->tlv_header,
9886 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
9887 WMITLV_GET_STRUCT_TLVLEN
9888 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
9889 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -07009890 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +05309891 err = wmi_unified_cmd_send(wmi_handle, buf,
9892 sizeof(*cmd),
9893 WMI_PDEV_SET_BASE_MACADDR_CMDID);
9894 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05309895 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05309896 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309897 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309898 }
9899
9900 return 0;
9901}
9902
9903/**
9904 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
9905 * @handle: wmi handle
9906 * @event: Event received from FW
9907 * @len: Length of the event
9908 *
9909 * Enables the low frequency events and disables the high frequency
9910 * events. Bit 17 indicates if the event if low/high frequency.
9911 * 1 - high frequency, 0 - low frequency
9912 *
9913 * Return: 0 on successfully enabling/disabling the events
9914 */
Govind Singhb53420c2016-03-09 14:32:57 +05309915QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309916 uint8_t *event,
9917 uint32_t len)
9918{
9919 uint32_t num_of_diag_events_logs;
9920 wmi_diag_event_log_config_fixed_param *cmd;
9921 wmi_buf_t buf;
9922 uint8_t *buf_ptr;
9923 uint32_t *cmd_args, *evt_args;
9924 uint32_t buf_len, i;
9925
9926 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
9927 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
9928
Govind Singhb53420c2016-03-09 14:32:57 +05309929 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +05309930
9931 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
9932 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309933 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +05309934 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309935 }
9936 wmi_event = param_buf->fixed_param;
9937 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
9938 evt_args = param_buf->diag_events_logs_list;
9939 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +05309940 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309941 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +05309942 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309943 }
9944
Govind Singhb53420c2016-03-09 14:32:57 +05309945 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309946 __func__, num_of_diag_events_logs);
9947
9948 /* Free any previous allocation */
9949 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +05309950 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309951
9952 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +05309953 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +05309954 sizeof(uint32_t));
9955 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +05309956 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +05309957 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309958 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309959 }
9960 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
9961
9962 /* Prepare the send buffer */
9963 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
9964 (num_of_diag_events_logs * sizeof(uint32_t));
9965
9966 buf = wmi_buf_alloc(wmi_handle, buf_len);
9967 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309968 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9969 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309970 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05309971 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309972 }
9973
9974 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
9975 buf_ptr = (uint8_t *) cmd;
9976
9977 WMITLV_SET_HDR(&cmd->tlv_header,
9978 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
9979 WMITLV_GET_STRUCT_TLVLEN(
9980 wmi_diag_event_log_config_fixed_param));
9981
9982 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
9983
9984 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
9985
9986 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9987 (num_of_diag_events_logs * sizeof(uint32_t)));
9988
9989 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
9990
9991 /* Populate the events */
9992 for (i = 0; i < num_of_diag_events_logs; i++) {
9993 /* Low freq (0) - Enable (1) the event
9994 * High freq (1) - Disable (0) the event
9995 */
9996 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
9997 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
9998 /* Set the event ID */
9999 WMI_DIAG_ID_SET(cmd_args[i],
10000 WMI_DIAG_ID_GET(evt_args[i]));
10001 /* Set the type */
10002 WMI_DIAG_TYPE_SET(cmd_args[i],
10003 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053010004 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053010005 wmi_handle->events_logs_list[i] = evt_args[i];
10006 }
10007
10008 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
10009 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010010 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010011 __func__);
10012 wmi_buf_free(buf);
10013 /* Not clearing events_logs_list, though wmi cmd failed.
10014 * Host can still have this list
10015 */
Govind Singh67922e82016-04-01 16:48:57 +053010016 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010017 }
10018
10019 return 0;
10020}
10021
10022/**
10023 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
10024 * @wmi_handle: wmi handle
10025 * @start_log: Start logging related parameters
10026 *
10027 * Send the command to the FW based on which specific logging of diag
10028 * event/log id can be started/stopped
10029 *
10030 * Return: None
10031 */
Govind Singhb53420c2016-03-09 14:32:57 +053010032QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010033 struct wmi_wifi_start_log *start_log)
10034{
10035 wmi_diag_event_log_config_fixed_param *cmd;
10036 wmi_buf_t buf;
10037 uint8_t *buf_ptr;
10038 uint32_t len, count, log_level, i;
10039 uint32_t *cmd_args;
10040 uint32_t total_len;
10041 count = 0;
10042
10043 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010044 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053010045 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010046 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010047 }
10048 /* total_len stores the number of events where BITS 17 and 18 are set.
10049 * i.e., events of high frequency (17) and for extended debugging (18)
10050 */
10051 total_len = 0;
10052 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10053 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
10054 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
10055 total_len++;
10056 }
10057
10058 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10059 (total_len * sizeof(uint32_t));
10060
10061 buf = wmi_buf_alloc(wmi_handle, len);
10062 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010063 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010064 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010065 }
10066 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10067 buf_ptr = (uint8_t *) cmd;
10068
10069 WMITLV_SET_HDR(&cmd->tlv_header,
10070 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10071 WMITLV_GET_STRUCT_TLVLEN(
10072 wmi_diag_event_log_config_fixed_param));
10073
10074 cmd->num_of_diag_events_logs = total_len;
10075
10076 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10077
10078 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10079 (total_len * sizeof(uint32_t)));
10080
10081 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10082
Govind Singh224a7312016-06-21 14:33:26 +053010083 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053010084 log_level = 1;
10085 else
10086 log_level = 0;
10087
Govind Singhb53420c2016-03-09 14:32:57 +053010088 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053010089 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10090 uint32_t val = wmi_handle->events_logs_list[i];
10091 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
10092 (WMI_DIAG_EXT_FEATURE_GET(val))) {
10093
10094 WMI_DIAG_ID_SET(cmd_args[count],
10095 WMI_DIAG_ID_GET(val));
10096 WMI_DIAG_TYPE_SET(cmd_args[count],
10097 WMI_DIAG_TYPE_GET(val));
10098 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
10099 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053010100 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053010101 count++;
10102 }
10103 }
10104
10105 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10106 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010107 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010108 __func__);
10109 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010110 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010111 }
10112
Govind Singhb53420c2016-03-09 14:32:57 +053010113 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010114}
10115
10116/**
10117 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
10118 * @wmi_handle: WMI handle
10119 *
10120 * This function is used to send the flush command to the FW,
10121 * that will flush the fw logs that are residue in the FW
10122 *
10123 * Return: None
10124 */
Govind Singhb53420c2016-03-09 14:32:57 +053010125QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053010126{
10127 wmi_debug_mesg_flush_fixed_param *cmd;
10128 wmi_buf_t buf;
10129 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053010130 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010131
10132 buf = wmi_buf_alloc(wmi_handle, len);
10133 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010134 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010135 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010136 }
10137
10138 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
10139 WMITLV_SET_HDR(&cmd->tlv_header,
10140 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
10141 WMITLV_GET_STRUCT_TLVLEN(
10142 wmi_debug_mesg_flush_fixed_param));
10143 cmd->reserved0 = 0;
10144
10145 ret = wmi_unified_cmd_send(wmi_handle,
10146 buf,
10147 len,
10148 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010149 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010150 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053010151 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010152 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010153 }
Govind Singhb53420c2016-03-09 14:32:57 +053010154 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053010155
Govind Singh67922e82016-04-01 16:48:57 +053010156 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010157}
10158
10159/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010160 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010161 * @wmi_handle: wmi handle
10162 * @msg: PCL structure containing the PCL and the number of channels
10163 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010164 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053010165 * firmware. The DBS Manager is the consumer of this information in the WLAN
10166 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
10167 * to migrate to a new channel without host driver involvement. An example of
10168 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
10169 * manage the channel selection without firmware involvement.
10170 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010171 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
10172 * channel list. The weights corresponds to the channels sent in
10173 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
10174 * weightage compared to the non PCL channels.
10175 *
Govind Singha4836fd2016-03-07 16:45:38 +053010176 * Return: Success if the cmd is sent successfully to the firmware
10177 */
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010178QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
10179 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053010180{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010181 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010182 wmi_buf_t buf;
10183 uint8_t *buf_ptr;
10184 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010185 uint32_t chan_len;
10186
10187 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053010188
10189 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010190 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053010191
10192 buf = wmi_buf_alloc(wmi_handle, len);
10193 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010194 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10195 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010196 }
10197
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010198 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010199 buf_ptr = (uint8_t *) cmd;
10200 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010201 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
10202 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053010203
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010204 cmd->pdev_id = WMI_PDEV_ID_SOC;
10205 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053010206 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010207
10208 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053010209 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010210 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053010211 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010212 for (i = 0; i < chan_len ; i++) {
10213 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053010214 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010215 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010216 }
10217 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010218 WMI_PDEV_SET_PCL_CMDID)) {
10219 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010220 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010221 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010222 }
Govind Singhb53420c2016-03-09 14:32:57 +053010223 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010224}
10225
10226/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010227 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010228 * @wmi_handle: wmi handle
10229 * @msg: Structure containing the following parameters
10230 *
10231 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
10232 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
10233 *
10234 * Provides notification to the WLAN firmware that host driver is requesting a
10235 * HardWare (HW) Mode change. This command is needed to support iHelium in the
10236 * configurations that include the Dual Band Simultaneous (DBS) feature.
10237 *
10238 * Return: Success if the cmd is sent successfully to the firmware
10239 */
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010240QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010241 uint32_t hw_mode_index)
10242{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010243 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010244 wmi_buf_t buf;
10245 uint32_t len;
10246
10247 len = sizeof(*cmd);
10248
10249 buf = wmi_buf_alloc(wmi_handle, len);
10250 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010251 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10252 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010253 }
10254
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010255 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010256 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010257 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
10258 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
10259
10260 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010261 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053010262 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053010263
10264 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010265 WMI_PDEV_SET_HW_MODE_CMDID)) {
10266 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010267 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010268 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010269 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010270 }
10271
Govind Singhb53420c2016-03-09 14:32:57 +053010272 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010273}
10274
10275/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010276 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010277 * @wmi_handle: wmi handle
10278 * @msg: Dual MAC config parameters
10279 *
10280 * Configures WLAN firmware with the dual MAC features
10281 *
Govind Singhb53420c2016-03-09 14:32:57 +053010282 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053010283 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010284static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010285QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010286 struct wmi_dual_mac_config *msg)
10287{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010288 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010289 wmi_buf_t buf;
10290 uint32_t len;
10291
10292 len = sizeof(*cmd);
10293
10294 buf = wmi_buf_alloc(wmi_handle, len);
10295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010296 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10297 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010298 }
10299
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010300 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010301 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010302 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053010303 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010304 wmi_pdev_set_mac_config_cmd_fixed_param));
10305
10306 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010307 cmd->concurrent_scan_config_bits = msg->scan_config;
10308 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053010309 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053010310 __func__, msg->scan_config, msg->fw_mode_config);
10311
10312 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010313 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
10314 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010315 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010316 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010317 }
Govind Singhb53420c2016-03-09 14:32:57 +053010318 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010319}
10320
10321/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010322 * fill_arp_offload_params_tlv() - Fill ARP offload data
10323 * @wmi_handle: wmi handle
10324 * @offload_req: offload request
10325 * @buf_ptr: buffer pointer
10326 *
10327 * To fill ARP offload data to firmware
10328 * when target goes to wow mode.
10329 *
10330 * Return: None
10331 */
10332static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
10333 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10334{
10335
10336 int i;
10337 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
10338 bool enable_or_disable = offload_req->enableOrDisable;
10339
10340 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10341 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
10342 *buf_ptr += WMI_TLV_HDR_SIZE;
10343 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
10344 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
10345 WMITLV_SET_HDR(&arp_tuple->tlv_header,
10346 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
10347 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
10348
10349 /* Fill data for ARP and NS in the first tupple for LA */
10350 if ((enable_or_disable & WMI_OFFLOAD_ENABLE) && (i == 0)) {
10351 /* Copy the target ip addr and flags */
10352 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
10353 qdf_mem_copy(&arp_tuple->target_ipaddr,
10354 offload_req->params.hostIpv4Addr,
10355 WMI_IPV4_ADDR_LEN);
10356 WMI_LOGD("ARPOffload IP4 address: %pI4",
10357 offload_req->params.hostIpv4Addr);
10358 }
10359 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
10360 }
10361}
10362
10363#ifdef WLAN_NS_OFFLOAD
10364/**
10365 * fill_ns_offload_params_tlv() - Fill NS offload data
10366 * @wmi|_handle: wmi handle
10367 * @offload_req: offload request
10368 * @buf_ptr: buffer pointer
10369 *
10370 * To fill NS offload data to firmware
10371 * when target goes to wow mode.
10372 *
10373 * Return: None
10374 */
10375static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10376 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10377{
10378
10379 int i;
10380 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10381 struct ns_offload_req_params ns_req;
10382
10383 ns_req = offload_req->nsOffloadInfo;
10384 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10385 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10386 *buf_ptr += WMI_TLV_HDR_SIZE;
10387 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
10388 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10389 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10390 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10391 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
10392
10393 /*
10394 * Fill data only for NS offload in the first ARP tuple for LA
10395 */
10396 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10397 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10398 /* Copy the target/solicitation/remote ip addr */
10399 if (ns_req.targetIPv6AddrValid[i])
10400 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10401 &ns_req.targetIPv6Addr[i],
10402 sizeof(WMI_IPV6_ADDR));
10403 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10404 &ns_req.selfIPv6Addr[i],
10405 sizeof(WMI_IPV6_ADDR));
10406 if (ns_req.target_ipv6_addr_ac_type[i]) {
10407 ns_tuple->flags |=
10408 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10409 }
10410 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10411 i, &ns_req.selfIPv6Addr[i],
10412 &ns_req.targetIPv6Addr[i]);
10413
10414 /* target MAC is optional, check if it is valid,
10415 * if this is not valid, the target will use the known
10416 * local MAC address rather than the tuple
10417 */
10418 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10419 ns_req.self_macaddr.bytes,
10420 &ns_tuple->target_mac);
10421 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10422 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10423 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10424 }
10425 }
10426 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10427 }
10428}
10429
10430
10431/**
10432 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
10433 * @wmi: wmi handle
10434 * @offload_req: offload request
10435 * @buf_ptr: buffer pointer
10436 *
10437 * To fill extended NS offload extended data to firmware
10438 * when target goes to wow mode.
10439 *
10440 * Return: None
10441 */
10442static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10443 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10444{
10445 int i;
10446 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10447 uint32_t count, num_ns_ext_tuples;
10448 struct ns_offload_req_params ns_req;
10449
10450 ns_req = offload_req->nsOffloadInfo;
10451 count = offload_req->num_ns_offload_count;
10452 num_ns_ext_tuples = offload_req->num_ns_offload_count -
10453 WMI_MAX_NS_OFFLOADS;
10454
10455 /* Populate extended NS offload tuples */
10456 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10457 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10458 *buf_ptr += WMI_TLV_HDR_SIZE;
10459 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
10460 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10461 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10462 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10463 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
10464
10465 /*
10466 * Fill data only for NS offload in the first ARP tuple for LA
10467 */
10468 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10469 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10470 /* Copy the target/solicitation/remote ip addr */
10471 if (ns_req.targetIPv6AddrValid[i])
10472 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10473 &ns_req.targetIPv6Addr[i],
10474 sizeof(WMI_IPV6_ADDR));
10475 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10476 &ns_req.selfIPv6Addr[i],
10477 sizeof(WMI_IPV6_ADDR));
10478 if (ns_req.target_ipv6_addr_ac_type[i]) {
10479 ns_tuple->flags |=
10480 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10481 }
10482 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10483 i, &ns_req.selfIPv6Addr[i],
10484 &ns_req.targetIPv6Addr[i]);
10485
10486 /* target MAC is optional, check if it is valid,
10487 * if this is not valid, the target will use the
10488 * known local MAC address rather than the tuple
10489 */
10490 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10491 ns_req.self_macaddr.bytes,
10492 &ns_tuple->target_mac);
10493 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10494 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10495 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10496 }
10497 }
10498 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10499 }
10500}
10501#else
10502static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10503 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10504{
10505 return;
10506}
10507
10508static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10509 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10510{
10511 return;
10512}
10513#endif
10514
10515/**
Govind Singha4836fd2016-03-07 16:45:38 +053010516 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
10517 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010518 * @arp_offload_req: arp offload request
10519 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053010520 * @arp_only: flag
10521 *
10522 * To configure ARP NS off load data to firmware
10523 * when target goes to wow mode.
10524 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010525 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053010526 */
Govind Singhb53420c2016-03-09 14:32:57 +053010527QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010528 struct host_offload_req_param *arp_offload_req,
10529 struct host_offload_req_param *ns_offload_req,
10530 bool arp_only,
Govind Singha4836fd2016-03-07 16:45:38 +053010531 uint8_t vdev_id)
10532{
Govind Singha4836fd2016-03-07 16:45:38 +053010533 int32_t res;
10534 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010535 A_UINT8 *buf_ptr;
10536 wmi_buf_t buf;
10537 int32_t len;
10538 uint32_t count = 0, num_ns_ext_tuples = 0;
10539
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010540 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053010541
Govind Singha4836fd2016-03-07 16:45:38 +053010542 /*
10543 * TLV place holder size for array of NS tuples
10544 * TLV place holder size for array of ARP tuples
10545 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010546 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
10547 WMI_TLV_HDR_SIZE +
10548 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
10549 WMI_TLV_HDR_SIZE +
10550 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010551
10552 /*
10553 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
10554 * extra length for extended NS offload tuples which follows ARP offload
10555 * tuples. Host needs to fill this structure in following format:
10556 * 2 NS ofload tuples
10557 * 2 ARP offload tuples
10558 * N numbers of extended NS offload tuples if HDD has given more than
10559 * 2 NS offload addresses
10560 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010561 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053010562 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010563 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
10564 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010565 }
10566
10567 buf = wmi_buf_alloc(wmi_handle, len);
10568 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010569 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053010570 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010571 }
10572
10573 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
10574 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
10575 WMITLV_SET_HDR(&cmd->tlv_header,
10576 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
10577 WMITLV_GET_STRUCT_TLVLEN
10578 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
10579 cmd->flags = 0;
10580 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010581 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053010582
Govind Singhb53420c2016-03-09 14:32:57 +053010583 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053010584
Govind Singha4836fd2016-03-07 16:45:38 +053010585 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010586 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
10587 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
10588 if (num_ns_ext_tuples)
10589 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053010590
10591 res = wmi_unified_cmd_send(wmi_handle, buf, len,
10592 WMI_SET_ARP_NS_OFFLOAD_CMDID);
10593 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053010594 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053010595 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010596 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010597 }
10598
Govind Singhb53420c2016-03-09 14:32:57 +053010599 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010600}
10601
10602/**
10603 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
10604 * @wmi_handle: wmi handle
10605 * @request: SSID hotlist set request
10606 *
Govind Singhb53420c2016-03-09 14:32:57 +053010607 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053010608 */
Govind Singhb53420c2016-03-09 14:32:57 +053010609QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053010610send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
10611 struct ssid_hotlist_request_params *request)
10612{
10613 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
10614 wmi_buf_t wmi_buf;
10615 uint32_t len;
10616 uint32_t array_size;
10617 uint8_t *buf_ptr;
10618
10619 /* length of fixed portion */
10620 len = sizeof(*cmd);
10621
10622 /* length of variable portion */
10623 array_size =
10624 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
10625 len += WMI_TLV_HDR_SIZE + array_size;
10626
10627 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10628 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010629 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10630 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010631 }
10632
10633 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10634 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
10635 buf_ptr;
10636 WMITLV_SET_HDR
10637 (&cmd->tlv_header,
10638 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
10639 WMITLV_GET_STRUCT_TLVLEN
10640 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
10641
10642 cmd->request_id = request->request_id;
10643 cmd->requestor_id = 0;
10644 cmd->vdev_id = request->session_id;
10645 cmd->table_id = 0;
10646 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
10647 cmd->total_entries = request->ssid_count;
10648 cmd->num_entries_in_page = request->ssid_count;
10649 cmd->first_entry_index = 0;
10650
10651 buf_ptr += sizeof(*cmd);
10652 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
10653
10654 if (request->ssid_count) {
10655 wmi_extscan_hotlist_ssid_entry *entry;
10656 int i;
10657
10658 buf_ptr += WMI_TLV_HDR_SIZE;
10659 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
10660 for (i = 0; i < request->ssid_count; i++) {
10661 WMITLV_SET_HDR
10662 (entry,
10663 WMITLV_TAG_ARRAY_STRUC,
10664 WMITLV_GET_STRUCT_TLVLEN
10665 (wmi_extscan_hotlist_ssid_entry));
10666 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053010667 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053010668 request->ssids[i].ssid.mac_ssid,
10669 request->ssids[i].ssid.length);
10670 entry->band = request->ssids[i].band;
10671 entry->min_rssi = request->ssids[i].rssi_low;
10672 entry->max_rssi = request->ssids[i].rssi_high;
10673 entry++;
10674 }
10675 cmd->mode = WMI_EXTSCAN_MODE_START;
10676 } else {
10677 cmd->mode = WMI_EXTSCAN_MODE_STOP;
10678 }
10679
10680 if (wmi_unified_cmd_send
10681 (wmi_handle, wmi_buf, len,
10682 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010683 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053010684 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010685 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010686 }
10687
Govind Singhb53420c2016-03-09 14:32:57 +053010688 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010689}
10690
10691/**
10692 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
10693 * @wmi_handle: wmi handle
10694 * @vdev_id: vdev id
10695 *
10696 * This function sends roam synch complete event to fw.
10697 *
10698 * Return: CDF STATUS
10699 */
Govind Singhb53420c2016-03-09 14:32:57 +053010700QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010701 uint8_t vdev_id)
10702{
10703 wmi_roam_synch_complete_fixed_param *cmd;
10704 wmi_buf_t wmi_buf;
10705 uint8_t *buf_ptr;
10706 uint16_t len;
10707 len = sizeof(wmi_roam_synch_complete_fixed_param);
10708
10709 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10710 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010711 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10712 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010713 }
10714 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
10715 buf_ptr = (uint8_t *) cmd;
10716 WMITLV_SET_HDR(&cmd->tlv_header,
10717 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
10718 WMITLV_GET_STRUCT_TLVLEN
10719 (wmi_roam_synch_complete_fixed_param));
10720 cmd->vdev_id = vdev_id;
10721 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10722 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010723 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053010724 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010725 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010726 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010727 }
10728
Govind Singhb53420c2016-03-09 14:32:57 +053010729 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010730}
10731
10732/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053010733 * send_fw_test_cmd_tlv() - send fw test command to fw.
10734 * @wmi_handle: wmi handle
10735 * @wmi_fwtest: fw test command
10736 *
10737 * This function sends fw test command to fw.
10738 *
10739 * Return: CDF STATUS
10740 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010741static
Anurag Chouhan459e0152016-07-22 20:19:54 +053010742QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
10743 struct set_fwtest_params *wmi_fwtest)
10744{
10745 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10746 wmi_buf_t wmi_buf;
10747 uint16_t len;
10748
10749 len = sizeof(*cmd);
10750
10751 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10752 if (!wmi_buf) {
10753 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10754 return QDF_STATUS_E_NOMEM;
10755 }
10756
10757 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10758 WMITLV_SET_HDR(&cmd->tlv_header,
10759 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10760 WMITLV_GET_STRUCT_TLVLEN(
10761 wmi_fwtest_set_param_cmd_fixed_param));
10762 cmd->param_id = wmi_fwtest->arg;
10763 cmd->param_value = wmi_fwtest->value;
10764
10765 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10766 WMI_FWTEST_CMDID)) {
10767 WMI_LOGP("%s: failed to send fw test command", __func__);
10768 qdf_nbuf_free(wmi_buf);
10769 return QDF_STATUS_E_FAILURE;
10770 }
10771
10772 return QDF_STATUS_SUCCESS;
10773}
10774
10775/**
Govind Singha4836fd2016-03-07 16:45:38 +053010776 * send_unit_test_cmd_tlv() - send unit test command to fw.
10777 * @wmi_handle: wmi handle
10778 * @wmi_utest: unit test command
10779 *
10780 * This function send unit test command to fw.
10781 *
10782 * Return: CDF STATUS
10783 */
Govind Singhb53420c2016-03-09 14:32:57 +053010784QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010785 struct wmi_unit_test_cmd *wmi_utest)
10786{
10787 wmi_unit_test_cmd_fixed_param *cmd;
10788 wmi_buf_t wmi_buf;
10789 uint8_t *buf_ptr;
10790 int i;
10791 uint16_t len, args_tlv_len;
10792 A_UINT32 *unit_test_cmd_args;
10793
10794 args_tlv_len =
10795 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
10796 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
10797
10798 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10799 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010800 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10801 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010802 }
10803
10804 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10805 buf_ptr = (uint8_t *) cmd;
10806 WMITLV_SET_HDR(&cmd->tlv_header,
10807 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
10808 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
10809 cmd->vdev_id = wmi_utest->vdev_id;
10810 cmd->module_id = wmi_utest->module_id;
10811 cmd->num_args = wmi_utest->num_args;
10812 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
10813 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10814 (wmi_utest->num_args * sizeof(uint32_t)));
10815 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053010816 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053010817 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
10818 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010819 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010820 }
10821 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10822 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010823 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010824 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010825 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010826 }
10827
Govind Singhb53420c2016-03-09 14:32:57 +053010828 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010829}
10830
10831/**
10832 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
10833 * @wmi_handle: wma handle
10834 * @roaminvoke: roam invoke command
10835 *
10836 * Send roam invoke command to fw for fastreassoc.
10837 *
10838 * Return: CDF STATUS
10839 */
Govind Singhb53420c2016-03-09 14:32:57 +053010840QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010841 struct wmi_roam_invoke_cmd *roaminvoke,
10842 uint32_t ch_hz)
10843{
10844 wmi_roam_invoke_cmd_fixed_param *cmd;
10845 wmi_buf_t wmi_buf;
10846 u_int8_t *buf_ptr;
10847 u_int16_t len, args_tlv_len;
10848 A_UINT32 *channel_list;
10849 wmi_mac_addr *bssid_list;
10850
10851 /* Host sends only one channel and one bssid */
10852 args_tlv_len = 2 * WMI_TLV_HDR_SIZE + sizeof(A_UINT32) +
10853 sizeof(wmi_mac_addr);
10854 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
10855 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10856 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010857 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10858 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010859 }
10860
10861 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
10862 buf_ptr = (u_int8_t *) cmd;
10863 WMITLV_SET_HDR(&cmd->tlv_header,
10864 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
10865 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
10866 cmd->vdev_id = roaminvoke->vdev_id;
10867 cmd->flags = 0;
10868 cmd->roam_scan_mode = 0;
10869 cmd->roam_ap_sel_mode = 0;
10870 cmd->roam_delay = 0;
10871 cmd->num_chan = 1;
10872 cmd->num_bssid = 1;
10873 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
10874 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10875 (sizeof(u_int32_t)));
10876 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
10877 *channel_list = ch_hz;
10878 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
10879 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
10880 (sizeof(wmi_mac_addr)));
10881 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
10882 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
10883 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10884 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010885 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053010886 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010887 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010888 }
10889
Govind Singhb53420c2016-03-09 14:32:57 +053010890 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010891}
10892
10893/**
10894 * send_roam_scan_offload_cmd_tlv() - set roam offload command
10895 * @wmi_handle: wmi handle
10896 * @command: command
10897 * @vdev_id: vdev id
10898 *
10899 * This function set roam offload command to fw.
10900 *
10901 * Return: CDF status
10902 */
Govind Singhb53420c2016-03-09 14:32:57 +053010903QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010904 uint32_t command, uint32_t vdev_id)
10905{
Govind Singh67922e82016-04-01 16:48:57 +053010906 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010907 wmi_roam_scan_cmd_fixed_param *cmd_fp;
10908 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053010909 int len;
10910 uint8_t *buf_ptr;
10911
10912 len = sizeof(wmi_roam_scan_cmd_fixed_param);
10913 buf = wmi_buf_alloc(wmi_handle, len);
10914 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010915 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10916 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010917 }
10918
10919 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10920
10921 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
10922 WMITLV_SET_HDR(&cmd_fp->tlv_header,
10923 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
10924 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
10925 cmd_fp->vdev_id = vdev_id;
10926 cmd_fp->command_arg = command;
10927
10928 status = wmi_unified_cmd_send(wmi_handle, buf,
10929 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053010930 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010931 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010932 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010933 goto error;
10934 }
10935
Govind Singhb53420c2016-03-09 14:32:57 +053010936 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
10937 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010938
10939error:
10940 wmi_buf_free(buf);
10941
Govind Singh67922e82016-04-01 16:48:57 +053010942 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010943}
10944
10945/**
10946 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
10947 * @wmi_handle: wmi handle
10948 * @ap_profile_p: ap profile
10949 * @vdev_id: vdev id
10950 *
10951 * Send WMI_ROAM_AP_PROFILE to firmware
10952 *
10953 * Return: CDF status
10954 */
Govind Singhb53420c2016-03-09 14:32:57 +053010955QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010956 wmi_ap_profile *ap_profile_p,
10957 uint32_t vdev_id)
10958{
Govind Singha4836fd2016-03-07 16:45:38 +053010959 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010960 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010961 int len;
10962 uint8_t *buf_ptr;
10963 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
10964
10965 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
10966
10967 buf = wmi_buf_alloc(wmi_handle, len);
10968 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010969 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10970 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010971 }
10972
10973 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10974 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
10975 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
10976 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
10977 WMITLV_GET_STRUCT_TLVLEN
10978 (wmi_roam_ap_profile_fixed_param));
10979 /* fill in threshold values */
10980 roam_ap_profile_fp->vdev_id = vdev_id;
10981 roam_ap_profile_fp->id = 0;
10982 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
10983
Govind Singhb53420c2016-03-09 14:32:57 +053010984 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053010985 WMITLV_SET_HDR(buf_ptr,
10986 WMITLV_TAG_STRUC_wmi_ap_profile,
10987 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
10988 status = wmi_unified_cmd_send(wmi_handle, buf,
10989 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053010990 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010991 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010992 status);
Govind Singh67922e82016-04-01 16:48:57 +053010993 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010994 }
10995
Govind Singhb53420c2016-03-09 14:32:57 +053010996 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053010997
Govind Singh67922e82016-04-01 16:48:57 +053010998 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010999}
11000
11001/**
11002 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
11003 * @wmi_handle: wmi handle
11004 * @scan_period: scan period
11005 * @scan_age: scan age
11006 * @vdev_id: vdev id
11007 *
11008 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
11009 *
11010 * Return: CDF status
11011 */
Govind Singhb53420c2016-03-09 14:32:57 +053011012QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011013 uint32_t scan_period,
11014 uint32_t scan_age,
11015 uint32_t vdev_id)
11016{
Govind Singh67922e82016-04-01 16:48:57 +053011017 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011018 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053011019 int len;
11020 uint8_t *buf_ptr;
11021 wmi_roam_scan_period_fixed_param *scan_period_fp;
11022
11023 /* Send scan period values */
11024 len = sizeof(wmi_roam_scan_period_fixed_param);
11025 buf = wmi_buf_alloc(wmi_handle, len);
11026 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011027 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11028 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011029 }
11030
11031 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11032 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
11033 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
11034 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
11035 WMITLV_GET_STRUCT_TLVLEN
11036 (wmi_roam_scan_period_fixed_param));
11037 /* fill in scan period values */
11038 scan_period_fp->vdev_id = vdev_id;
11039 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
11040 scan_period_fp->roam_scan_age = scan_age;
11041
11042 status = wmi_unified_cmd_send(wmi_handle, buf,
11043 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053011044 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011045 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011046 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011047 goto error;
11048 }
11049
Govind Singhb53420c2016-03-09 14:32:57 +053011050 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011051 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053011052 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011053error:
11054 wmi_buf_free(buf);
11055
Govind Singh67922e82016-04-01 16:48:57 +053011056 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011057}
11058
11059/**
11060 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
11061 * @wmi_handle: wmi handle
11062 * @chan_count: channel count
11063 * @chan_list: channel list
11064 * @list_type: list type
11065 * @vdev_id: vdev id
11066 *
11067 * Set roam offload channel list.
11068 *
11069 * Return: CDF status
11070 */
Govind Singhb53420c2016-03-09 14:32:57 +053011071QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011072 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070011073 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053011074 uint8_t list_type, uint32_t vdev_id)
11075{
Govind Singha4836fd2016-03-07 16:45:38 +053011076 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011077 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011078 int len, list_tlv_len;
11079 int i;
11080 uint8_t *buf_ptr;
11081 wmi_roam_chan_list_fixed_param *chan_list_fp;
11082 A_UINT32 *roam_chan_list_array;
11083
11084 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053011085 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053011086 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053011087 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053011088 }
11089 /* Channel list is a table of 2 TLV's */
11090 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
11091 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
11092 buf = wmi_buf_alloc(wmi_handle, len);
11093 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011094 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11095 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011096 }
11097
11098 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11099 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
11100 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
11101 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
11102 WMITLV_GET_STRUCT_TLVLEN
11103 (wmi_roam_chan_list_fixed_param));
11104 chan_list_fp->vdev_id = vdev_id;
11105 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053011106 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053011107 /* external app is controlling channel list */
11108 chan_list_fp->chan_list_type =
11109 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
11110 } else {
11111 /* umac supplied occupied channel list in LFR */
11112 chan_list_fp->chan_list_type =
11113 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
11114 }
11115
11116 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
11117 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11118 (chan_list_fp->num_chan * sizeof(uint32_t)));
11119 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053011120 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053011121 for (i = 0; ((i < chan_list_fp->num_chan) &&
11122 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
11123 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053011124 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011125 }
11126
11127 status = wmi_unified_cmd_send(wmi_handle, buf,
11128 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053011129 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011130 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011131 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011132 goto error;
11133 }
11134
Govind Singhb53420c2016-03-09 14:32:57 +053011135 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
11136 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011137error:
11138 wmi_buf_free(buf);
11139
Govind Singh67922e82016-04-01 16:48:57 +053011140 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011141}
11142
11143/**
11144 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
11145 * @wmi_handle: wmi handle
11146 * @rssi_change_thresh: RSSI Change threshold
11147 * @bcn_rssi_weight: beacon RSSI weight
11148 * @vdev_id: vdev id
11149 *
11150 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
11151 *
11152 * Return: CDF status
11153 */
Govind Singhb53420c2016-03-09 14:32:57 +053011154QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011155 uint32_t vdev_id,
11156 int32_t rssi_change_thresh,
11157 uint32_t bcn_rssi_weight,
11158 uint32_t hirssi_delay_btw_scans)
11159{
Govind Singha4836fd2016-03-07 16:45:38 +053011160 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011161 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011162 int len;
11163 uint8_t *buf_ptr;
11164 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
11165
11166 /* Send rssi change parameters */
11167 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
11168 buf = wmi_buf_alloc(wmi_handle, len);
11169 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011170 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11171 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011172 }
11173
11174 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11175 rssi_change_fp =
11176 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
11177 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
11178 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
11179 WMITLV_GET_STRUCT_TLVLEN
11180 (wmi_roam_scan_rssi_change_threshold_fixed_param));
11181 /* fill in rssi change threshold (hysteresis) values */
11182 rssi_change_fp->vdev_id = vdev_id;
11183 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
11184 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
11185 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
11186
11187 status = wmi_unified_cmd_send(wmi_handle, buf,
11188 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053011189 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011190 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011191 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011192 goto error;
11193 }
11194
Govind Singhb53420c2016-03-09 14:32:57 +053011195 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053011196 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053011197 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
11198 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011199error:
11200 wmi_buf_free(buf);
11201
Govind Singh67922e82016-04-01 16:48:57 +053011202 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011203}
11204
11205/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
11206 * @wmi_handle: wmi handle.
11207 * @cmd: size of command structure.
11208 * @per_entry_size: per entry size.
11209 *
11210 * This utility function calculates how many hotlist entries can
11211 * fit in one page.
11212 *
11213 * Return: number of entries
11214 */
11215static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
11216 size_t cmd_size,
11217 size_t per_entry_size)
11218{
11219 uint32_t avail_space = 0;
11220 int num_entries = 0;
11221 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
11222
11223 /* Calculate number of hotlist entries that can
11224 * be passed in wma message request.
11225 */
11226 avail_space = max_msg_len - cmd_size;
11227 num_entries = avail_space / per_entry_size;
11228 return num_entries;
11229}
11230
11231/**
11232 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
11233 * @wmi_handle: wmi handle
11234 * @photlist: hotlist command params
11235 * @buf_len: buffer length
11236 *
11237 * This function fills individual elements for hotlist request and
11238 * TLV for bssid entries
11239 *
11240 * Return: CDF Status.
11241 */
Govind Singhb53420c2016-03-09 14:32:57 +053011242QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011243 struct ext_scan_setbssi_hotlist_params *
11244 photlist, int *buf_len)
11245{
11246 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
11247 wmi_extscan_hotlist_entry *dest_hotlist;
11248 struct ap_threshold_params *src_ap = photlist->ap;
11249 wmi_buf_t buf;
11250 uint8_t *buf_ptr;
11251
11252 int j, index = 0;
11253 int cmd_len = 0;
11254 int num_entries;
11255 int min_entries = 0;
11256 int numap = photlist->numAp;
11257 int len = sizeof(*cmd);
11258
11259 len += WMI_TLV_HDR_SIZE;
11260 cmd_len = len;
11261
11262 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
11263 cmd_len,
11264 sizeof(*dest_hotlist));
11265 /* setbssid hotlist expects the bssid list
11266 * to be non zero value
11267 */
11268 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011269 WMI_LOGE("%s: Invalid number of bssid's", __func__);
11270 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011271 }
11272
11273 /* Split the hot list entry pages and send multiple command
11274 * requests if the buffer reaches the maximum request size
11275 */
11276 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011277 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053011278 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
11279 buf = wmi_buf_alloc(wmi_handle, len);
11280 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011281 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
11282 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011283 }
11284 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11285 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
11286 buf_ptr;
11287 WMITLV_SET_HDR(&cmd->tlv_header,
11288 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
11289 WMITLV_GET_STRUCT_TLVLEN
11290 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
11291
11292 /* Multiple requests are sent until the num_entries_in_page
11293 * matches the total_entries
11294 */
11295 cmd->request_id = photlist->requestId;
11296 cmd->vdev_id = photlist->sessionId;
11297 cmd->total_entries = numap;
11298 cmd->mode = 1;
11299 cmd->num_entries_in_page = min_entries;
11300 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
11301 cmd->first_entry_index = index;
11302
Govind Singhb53420c2016-03-09 14:32:57 +053011303 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011304 __func__, cmd->vdev_id, cmd->total_entries,
11305 cmd->num_entries_in_page,
11306 cmd->lost_ap_scan_count);
11307
11308 buf_ptr += sizeof(*cmd);
11309 WMITLV_SET_HDR(buf_ptr,
11310 WMITLV_TAG_ARRAY_STRUC,
11311 min_entries * sizeof(wmi_extscan_hotlist_entry));
11312 dest_hotlist = (wmi_extscan_hotlist_entry *)
11313 (buf_ptr + WMI_TLV_HDR_SIZE);
11314
11315 /* Populate bssid, channel info and rssi
11316 * for the bssid's that are sent as hotlists.
11317 */
11318 for (j = 0; j < min_entries; j++) {
11319 WMITLV_SET_HDR(dest_hotlist,
11320 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
11321 WMITLV_GET_STRUCT_TLVLEN
11322 (wmi_extscan_hotlist_entry));
11323
11324 dest_hotlist->min_rssi = src_ap->low;
11325 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
11326 &dest_hotlist->bssid);
11327
Govind Singhb53420c2016-03-09 14:32:57 +053011328 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011329 __func__, dest_hotlist->channel,
11330 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053011331 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053011332 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
11333 __func__, dest_hotlist->bssid.mac_addr31to0,
11334 dest_hotlist->bssid.mac_addr47to32);
11335 dest_hotlist++;
11336 src_ap++;
11337 }
11338 buf_ptr += WMI_TLV_HDR_SIZE +
11339 (min_entries * sizeof(wmi_extscan_hotlist_entry));
11340
11341 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11342 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011343 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011344 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011345 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011346 }
11347 index = index + min_entries;
11348 num_entries = numap - min_entries;
11349 len = cmd_len;
11350 }
Govind Singhb53420c2016-03-09 14:32:57 +053011351 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011352}
11353
Govind Singhbca3b1b2016-05-02 17:59:24 +053011354/**
11355 * send_power_dbg_cmd_tlv() - send power debug commands
11356 * @wmi_handle: wmi handle
11357 * @param: wmi power debug parameter
11358 *
11359 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
11360 *
11361 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
11362 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011363static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
11364 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053011365{
11366 wmi_buf_t buf = NULL;
11367 QDF_STATUS status;
11368 int len, args_tlv_len;
11369 uint8_t *buf_ptr;
11370 uint8_t i;
11371 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
11372 uint32_t *cmd_args;
11373
11374 /* Prepare and send power debug cmd parameters */
11375 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
11376 len = sizeof(*cmd) + args_tlv_len;
11377 buf = wmi_buf_alloc(wmi_handle, len);
11378 if (!buf) {
11379 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11380 return QDF_STATUS_E_NOMEM;
11381 }
11382
11383 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11384 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
11385 WMITLV_SET_HDR(&cmd->tlv_header,
11386 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
11387 WMITLV_GET_STRUCT_TLVLEN
11388 (wmi_pdev_wal_power_debug_cmd_fixed_param));
11389
11390 cmd->pdev_id = param->pdev_id;
11391 cmd->module_id = param->module_id;
11392 cmd->num_args = param->num_args;
11393 buf_ptr += sizeof(*cmd);
11394 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11395 (param->num_args * sizeof(uint32_t)));
11396 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11397 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
11398 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
11399 cmd_args[i] = param->args[i];
11400 WMI_LOGI("%d,", param->args[i]);
11401 }
11402
11403 status = wmi_unified_cmd_send(wmi_handle, buf,
11404 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
11405 if (QDF_IS_STATUS_ERROR(status)) {
11406 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
11407 status);
11408 goto error;
11409 }
11410
11411 return QDF_STATUS_SUCCESS;
11412error:
11413 wmi_buf_free(buf);
11414
11415 return status;
11416}
11417
Govind Singhe7f2f342016-05-23 12:12:52 +053011418/**
11419 * init_cmd_send_tlv() - send initialization cmd to fw
11420 * @wmi_handle: wmi handle
11421 * @param tgt_res_cfg: pointer to target resource configuration
11422 * @param num_mem_chunks: Number of memory chunks
11423 * @param mem_chunks: pointer to target memory chunks
11424 *
11425 * Return: QDF_STATUS_SUCCESS for success or error code
11426 */
11427static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
11428 target_resource_config *tgt_res_cfg, uint8_t num_mem_chunks,
11429 struct wmi_host_mem_chunk *mem_chunks)
11430{
11431 wmi_buf_t buf;
11432 wmi_init_cmd_fixed_param *cmd;
11433 wmi_abi_version my_vers;
11434 int num_whitelist;
11435 uint8_t *buf_ptr;
11436 wmi_resource_config *resource_cfg;
11437 wlan_host_memory_chunk *host_mem_chunks;
11438 uint32_t mem_chunk_len = 0;
11439 uint16_t idx;
11440 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053011441 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053011442
11443 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11444 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11445 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11446 if (!buf) {
11447 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11448 return QDF_STATUS_E_FAILURE;
11449 }
11450
11451 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11452 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11453 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11454
11455 host_mem_chunks = (wlan_host_memory_chunk *)
11456 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11457 + WMI_TLV_HDR_SIZE);
11458
11459 WMITLV_SET_HDR(&cmd->tlv_header,
11460 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11461 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11462
11463 wmi_copy_resource_config(resource_cfg, tgt_res_cfg);
11464 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11465 WMITLV_TAG_STRUC_wmi_resource_config,
11466 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11467
11468 for (idx = 0; idx < num_mem_chunks; ++idx) {
11469 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11470 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11471 WMITLV_GET_STRUCT_TLVLEN
11472 (wlan_host_memory_chunk));
11473 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11474 host_mem_chunks[idx].size = mem_chunks[idx].len;
11475 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
11476 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
11477 idx, host_mem_chunks[idx].size,
11478 host_mem_chunks[idx].ptr);
11479 }
11480 cmd->num_host_mem_chunks = num_mem_chunks;
11481 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11482 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11483 WMITLV_TAG_ARRAY_STRUC,
11484 (sizeof(wlan_host_memory_chunk) *
11485 num_mem_chunks));
11486
11487 num_whitelist = sizeof(version_whitelist) /
11488 sizeof(wmi_whitelist_version_info);
11489 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11490 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11491 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11492 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11493 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11494 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
11495
Govind Singh87542482016-06-08 19:40:11 +053011496#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011497 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11498 &my_vers,
11499 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
11500 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011501#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011502 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
11503 __func__,
11504 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11505 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11506 cmd->host_abi_vers.abi_version_ns_0,
11507 cmd->host_abi_vers.abi_version_ns_1,
11508 cmd->host_abi_vers.abi_version_ns_2,
11509 cmd->host_abi_vers.abi_version_ns_3);
11510
11511 /* Save version sent from host -
11512 * Will be used to check ready event
11513 */
Govind Singh87542482016-06-08 19:40:11 +053011514#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011515 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
11516 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011517#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053011518 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
11519 if (QDF_IS_STATUS_ERROR(ret)) {
11520 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
11521 ret);
11522 wmi_buf_free(buf);
11523 }
11524 return ret;
11525
Govind Singhe7f2f342016-05-23 12:12:52 +053011526}
11527
11528/**
11529 * save_service_bitmap_tlv() - save service bitmap
11530 * @wmi_handle: wmi handle
11531 * @param evt_buf: pointer to event buffer
11532 *
11533 * Return: None
11534 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011535#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011536static
Govind Singhe7f2f342016-05-23 12:12:52 +053011537void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11538{
11539 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11540 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11541
11542 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
11543 param_buf->wmi_service_bitmap,
11544 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
11545}
11546#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011547static
Govind Singhe7f2f342016-05-23 12:12:52 +053011548void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11549{
11550 return;
11551}
11552
11553#endif
11554
11555/**
11556 * is_service_enabled_tlv() - Check if service enabled
11557 * @param wmi_handle: wmi handle
11558 * @param service_id: service identifier
11559 *
11560 * Return: 1 enabled, 0 disabled
11561 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011562#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011563static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11564 uint32_t service_id)
11565{
11566 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
11567 service_id);
11568}
11569#else
11570static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11571 uint32_t service_id)
11572{
11573 return false;
11574}
11575#endif
11576
11577/**
11578 * extract_service_ready_tlv() - extract service ready event
11579 * @wmi_handle: wmi handle
11580 * @param evt_buf: pointer to received event buffer
11581 * @param cap: pointer to hold target capability information extracted from even
11582 *
11583 * Return: QDF_STATUS_SUCCESS for success or error code
11584 */
11585static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
11586 void *evt_buf, target_capability_info *cap)
11587{
11588 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11589 wmi_service_ready_event_fixed_param *ev;
11590
11591
11592 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11593
11594 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11595 if (!ev) {
11596 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11597 return QDF_STATUS_E_FAILURE;
11598 }
11599
11600 cap->phy_capability = ev->phy_capability;
11601 cap->max_frag_entry = ev->max_frag_entry;
11602 cap->num_rf_chains = ev->num_rf_chains;
11603 cap->ht_cap_info = ev->ht_cap_info;
11604 cap->vht_cap_info = ev->vht_cap_info;
11605 cap->vht_supp_mcs = ev->vht_supp_mcs;
11606 cap->hw_min_tx_power = ev->hw_min_tx_power;
11607 cap->hw_max_tx_power = ev->hw_max_tx_power;
11608 cap->sys_cap_info = ev->sys_cap_info;
11609 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
11610 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
11611 cap->max_num_scan_channels = ev->max_num_scan_channels;
11612 cap->max_supported_macs = ev->max_supported_macs;
11613 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
11614 cap->txrx_chainmask = ev->txrx_chainmask;
11615 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
11616 cap->num_msdu_desc = ev->num_msdu_desc;
11617
11618 return QDF_STATUS_SUCCESS;
11619}
11620
11621/**
11622 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
11623 * @wmi_handle: wmi handle
11624 * @param evt_buf: Pointer to event buffer
11625 * @param cap: pointer to hold HAL reg capabilities
11626 *
11627 * Return: QDF_STATUS_SUCCESS for success or error code
11628 */
11629static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
11630 void *evt_buf, TARGET_HAL_REG_CAPABILITIES *cap)
11631{
11632 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11633
11634 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11635
11636 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
11637 sizeof(uint32_t)),
11638 sizeof(TARGET_HAL_REG_CAPABILITIES));
11639
11640 return QDF_STATUS_SUCCESS;
11641}
11642
11643/**
11644 * extract_host_mem_req_tlv() - Extract host memory request event
11645 * @wmi_handle: wmi handle
11646 * @param evt_buf: pointer to event buffer
11647 * @param num_entries: pointer to hold number of entries requested
11648 *
11649 * Return: Number of entries requested
11650 */
11651static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
11652 void *evt_buf, uint8_t *num_entries)
11653{
11654 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11655 wmi_service_ready_event_fixed_param *ev;
11656
11657 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11658
11659 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11660 if (!ev) {
11661 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11662 return NULL;
11663 }
11664
11665 *num_entries = ev->num_mem_reqs;
11666
11667 return (host_mem_req *)param_buf->mem_reqs;
11668}
11669
11670/**
11671 * save_fw_version_in_service_ready_tlv() - Save fw version in service
11672 * ready function
11673 * @wmi_handle: wmi handle
11674 * @param evt_buf: pointer to event buffer
11675 *
11676 * Return: QDF_STATUS_SUCCESS for success or error code
11677 */
11678static QDF_STATUS
11679save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11680{
11681 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11682 wmi_service_ready_event_fixed_param *ev;
11683
11684
11685 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11686
11687 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11688 if (!ev) {
11689 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11690 return QDF_STATUS_E_FAILURE;
11691 }
11692
Govind Singh87542482016-06-08 19:40:11 +053011693#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011694 /*Save fw version from service ready message */
11695 /*This will be used while sending INIT message */
11696 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
11697 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011698#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011699 return QDF_STATUS_SUCCESS;
11700}
11701
11702/**
11703 * ready_extract_init_status_tlv() - Extract init status from ready event
11704 * @wmi_handle: wmi handle
11705 * @param evt_buf: Pointer to event buffer
11706 *
11707 * Return: ready status
11708 */
11709static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
11710 void *evt_buf)
11711{
11712 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11713 wmi_ready_event_fixed_param *ev = NULL;
11714
11715
11716 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11717 ev = param_buf->fixed_param;
11718
11719 qdf_print("%s:%d\n", __func__, ev->status);
11720
11721 return ev->status;
11722}
11723
11724/**
11725 * ready_extract_mac_addr_tlv() - extract mac address from ready event
11726 * @wmi_handle: wmi handle
11727 * @param evt_buf: pointer to event buffer
11728 * @param macaddr: Pointer to hold MAC address
11729 *
11730 * Return: QDF_STATUS_SUCCESS for success or error code
11731 */
11732static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
11733 void *evt_buf, uint8_t *macaddr)
11734{
11735 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11736 wmi_ready_event_fixed_param *ev = NULL;
11737
11738
11739 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11740 ev = param_buf->fixed_param;
11741
11742 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
11743
11744 return QDF_STATUS_SUCCESS;
11745}
11746
11747/**
11748 * extract_dbglog_data_len_tlv() - extract debuglog data length
11749 * @wmi_handle: wmi handle
11750 * @param evt_buf: pointer to event buffer
11751 *
11752 * Return: length
11753 */
11754static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
11755 void *evt_buf, uint16_t *len)
11756{
11757 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
11758
11759 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
11760
11761 *len = param_buf->num_bufp;
11762
11763 return param_buf->bufp;
11764}
11765
11766/**
11767 * extract_vdev_start_resp_tlv() - extract vdev start response
11768 * @wmi_handle: wmi handle
11769 * @param evt_buf: pointer to event buffer
11770 * @param vdev_rsp: Pointer to hold vdev response
11771 *
11772 * Return: QDF_STATUS_SUCCESS for success or error code
11773 */
11774static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
11775 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
11776{
11777 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
11778 wmi_vdev_start_response_event_fixed_param *ev;
11779
11780 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
11781 if (!param_buf) {
11782 qdf_print("Invalid start response event buffer\n");
11783 return QDF_STATUS_E_INVAL;
11784 }
11785
11786 ev = param_buf->fixed_param;
11787 if (!ev) {
11788 qdf_print("Invalid start response event buffer\n");
11789 return QDF_STATUS_E_INVAL;
11790 }
11791
11792 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
11793
11794 vdev_rsp->vdev_id = ev->vdev_id;
11795 vdev_rsp->requestor_id = ev->requestor_id;
11796 vdev_rsp->resp_type = ev->resp_type;
11797 vdev_rsp->status = ev->status;
11798 vdev_rsp->chain_mask = ev->chain_mask;
11799 vdev_rsp->smps_mode = ev->smps_mode;
11800 vdev_rsp->mac_id = ev->mac_id;
11801 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
11802 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
11803
11804 return QDF_STATUS_SUCCESS;
11805}
11806
11807/**
11808 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
11809 * @wmi_handle: wmi handle
11810 * @param evt_buf: pointer to event buffer
11811 * @param vdev_map: Pointer to hold vdev map
11812 * @param tbttoffset_list: Pointer to tbtt offset list
11813 *
11814 * Return: QDF_STATUS_SUCCESS for success or error code
11815 */
11816static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
11817 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
11818{
11819 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
11820 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
11821
11822 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
11823 if (!param_buf) {
11824 qdf_print("Invalid tbtt update event buffer\n");
11825 return QDF_STATUS_E_INVAL;
11826 }
11827 tbtt_offset_event = param_buf->fixed_param;
11828
11829 *vdev_map = tbtt_offset_event->vdev_map;
11830 *tbttoffset_list = param_buf->tbttoffset_list;
11831
11832 return QDF_STATUS_SUCCESS;
11833}
11834
11835/**
11836 * extract_mgmt_rx_params_tlv() - extract management rx params from event
11837 * @wmi_handle: wmi handle
11838 * @param evt_buf: pointer to event buffer
11839 * @param hdr: Pointer to hold header
11840 * @param bufp: Pointer to hold pointer to rx param buffer
11841 *
11842 * Return: QDF_STATUS_SUCCESS for success or error code
11843 */
11844static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
11845 void *evt_buf, wmi_host_mgmt_rx_hdr *hdr, uint8_t **bufp)
11846{
11847 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
11848 wmi_mgmt_rx_hdr *ev_hdr = NULL;
11849
11850 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
11851 if (!param_tlvs) {
11852 WMI_LOGE("Get NULL point message from FW");
11853 return QDF_STATUS_E_INVAL;
11854 }
11855
11856 ev_hdr = param_tlvs->hdr;
11857 if (!hdr) {
11858 WMI_LOGE("Rx event is NULL");
11859 return QDF_STATUS_E_INVAL;
11860 }
11861
11862
11863 hdr->channel = ev_hdr->channel;
11864 hdr->snr = ev_hdr->snr;
11865 hdr->rate = ev_hdr->rate;
11866 hdr->phy_mode = ev_hdr->phy_mode;
11867 hdr->buf_len = ev_hdr->buf_len;
11868 hdr->status = ev_hdr->status;
11869 hdr->flags = ev_hdr->flags;
11870 hdr->rssi = ev_hdr->rssi;
11871 hdr->tsf_delta = ev_hdr->tsf_delta;
11872 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
11873
11874 *bufp = param_tlvs->bufp;
11875
11876 return QDF_STATUS_SUCCESS;
11877}
11878
11879/**
11880 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
11881 * @wmi_handle: wmi handle
11882 * @param evt_buf: pointer to event buffer
11883 * @param vdev_id: Pointer to hold vdev identifier
11884 *
11885 * Return: QDF_STATUS_SUCCESS for success or error code
11886 */
11887static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
11888 void *evt_buf, uint32_t *vdev_id)
11889{
11890 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
11891 wmi_vdev_stopped_event_fixed_param *resp_event;
11892
11893 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
11894 if (!param_buf) {
11895 WMI_LOGE("Invalid event buffer");
11896 return QDF_STATUS_E_INVAL;
11897 }
11898 resp_event = param_buf->fixed_param;
11899 *vdev_id = resp_event->vdev_id;
11900
11901 return QDF_STATUS_SUCCESS;
11902}
11903
11904/**
11905 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
11906 * @wmi_handle: wmi handle
11907 * @param evt_buf: pointer to event buffer
11908 * @param param: Pointer to hold roam param
11909 *
11910 * Return: QDF_STATUS_SUCCESS for success or error code
11911 */
11912static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
11913 void *evt_buf, wmi_host_roam_event *param)
11914{
11915 WMI_ROAM_EVENTID_param_tlvs *param_buf;
11916 wmi_roam_event_fixed_param *evt;
11917
11918 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
11919 if (!param_buf) {
11920 WMI_LOGE("Invalid roam event buffer");
11921 return QDF_STATUS_E_INVAL;
11922 }
11923
11924 evt = param_buf->fixed_param;
11925 qdf_mem_zero(param, sizeof(*param));
11926
11927 param->vdev_id = evt->vdev_id;
11928 param->reason = evt->reason;
11929 param->rssi = evt->rssi;
11930
11931 return QDF_STATUS_SUCCESS;
11932}
11933
11934/**
11935 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
11936 * @wmi_handle: wmi handle
11937 * @param evt_buf: pointer to event buffer
11938 * @param param: Pointer to hold vdev scan param
11939 *
11940 * Return: QDF_STATUS_SUCCESS for success or error code
11941 */
11942static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
11943 void *evt_buf, wmi_host_scan_event *param)
11944{
11945 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
11946 wmi_scan_event_fixed_param *evt = NULL;
11947
11948 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
11949 evt = param_buf->fixed_param;
11950
11951 qdf_mem_zero(param, sizeof(*param));
11952 switch (evt->event) {
11953 case WMI_SCAN_EVENT_STARTED:
11954 param->event = WMI_HOST_SCAN_EVENT_STARTED;
11955 break;
11956 case WMI_SCAN_EVENT_COMPLETED:
11957 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
11958 break;
11959 case WMI_SCAN_EVENT_BSS_CHANNEL:
11960 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
11961 break;
11962 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
11963 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
11964 break;
11965 case WMI_SCAN_EVENT_DEQUEUED:
11966 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
11967 break;
11968 case WMI_SCAN_EVENT_PREEMPTED:
11969 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
11970 break;
11971 case WMI_SCAN_EVENT_START_FAILED:
11972 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
11973 break;
11974 case WMI_SCAN_EVENT_RESTARTED:
11975 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
11976 break;
11977 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
11978 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
11979 break;
11980 case WMI_SCAN_EVENT_MAX:
11981 default:
11982 param->event = WMI_HOST_SCAN_EVENT_MAX;
11983 break;
11984 };
11985
11986 switch (evt->reason) {
11987 case WMI_SCAN_REASON_NONE:
11988 param->reason = WMI_HOST_SCAN_REASON_NONE;
11989 break;
11990 case WMI_SCAN_REASON_COMPLETED:
11991 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
11992 break;
11993 case WMI_SCAN_REASON_CANCELLED:
11994 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
11995 break;
11996 case WMI_SCAN_REASON_PREEMPTED:
11997 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
11998 break;
11999 case WMI_SCAN_REASON_TIMEDOUT:
12000 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
12001 break;
12002 case WMI_SCAN_REASON_INTERNAL_FAILURE:
12003 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
12004 break;
12005 case WMI_SCAN_REASON_MAX:
12006 default:
12007 param->reason = WMI_HOST_SCAN_REASON_MAX;
12008 break;
12009 };
12010
12011 param->channel_freq = evt->channel_freq;
12012 param->requestor = evt->requestor;
12013 param->scan_id = evt->scan_id;
12014 param->vdev_id = evt->vdev_id;
12015
12016 return QDF_STATUS_SUCCESS;
12017}
12018
12019/**
12020 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
12021 * @wmi_handle: wmi handle
12022 * @param evt_buf: pointer to event buffer
12023 * @param param: Pointer to hold MGMT TX completion params
12024 *
12025 * Return: QDF_STATUS_SUCCESS for success or error code
12026 */
12027static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
12028 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
12029{
12030 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
12031 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
12032
12033 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
12034 evt_buf;
12035 if (!param_buf) {
12036 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
12037 return QDF_STATUS_E_INVAL;
12038 }
12039 cmpl_params = param_buf->fixed_param;
12040
12041 param->desc_id = cmpl_params->desc_id;
12042 param->status = cmpl_params->status;
12043
12044 return QDF_STATUS_SUCCESS;
12045}
12046
12047/**
12048 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
12049 * @wmi_handle: wmi handle
12050 * @param evt_buf: pointer to event buffer
12051 * @param vdev_map: Pointer to hold vdev map
12052 *
12053 * Return: QDF_STATUS_SUCCESS for success or error code
12054 */
12055static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
12056 void *evt_buf, uint32_t *vdev_map)
12057{
12058 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12059 wmi_host_swba_event_fixed_param *swba_event;
12060
12061 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12062 if (!param_buf) {
12063 WMI_LOGE("Invalid swba event buffer");
12064 return QDF_STATUS_E_INVAL;
12065 }
12066 swba_event = param_buf->fixed_param;
12067 *vdev_map = swba_event->vdev_map;
12068
12069 return QDF_STATUS_SUCCESS;
12070}
12071
12072/**
12073 * extract_swba_tim_info_tlv() - extract swba tim info from event
12074 * @wmi_handle: wmi handle
12075 * @param evt_buf: pointer to event buffer
12076 * @param idx: Index to bcn info
12077 * @param tim_info: Pointer to hold tim info
12078 *
12079 * Return: QDF_STATUS_SUCCESS for success or error code
12080 */
12081static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
12082 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
12083{
12084 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12085 wmi_tim_info *tim_info_ev;
12086
12087 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12088 if (!param_buf) {
12089 WMI_LOGE("Invalid swba event buffer");
12090 return QDF_STATUS_E_INVAL;
12091 }
12092
12093 tim_info_ev = &param_buf->tim_info[idx];
12094
12095 tim_info->tim_len = tim_info_ev->tim_len;
12096 tim_info->tim_mcast = tim_info_ev->tim_mcast;
12097 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
12098 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
12099 tim_info->tim_changed = tim_info_ev->tim_changed;
12100 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
12101
12102 return QDF_STATUS_SUCCESS;
12103}
12104
12105/**
12106 * extract_swba_noa_info_tlv() - extract swba NoA information from event
12107 * @wmi_handle: wmi handle
12108 * @param evt_buf: pointer to event buffer
12109 * @param idx: Index to bcn info
12110 * @param p2p_desc: Pointer to hold p2p NoA info
12111 *
12112 * Return: QDF_STATUS_SUCCESS for success or error code
12113 */
12114static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
12115 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
12116{
12117 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12118 wmi_p2p_noa_info *p2p_noa_info;
12119 uint8_t i = 0;
12120
12121 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12122 if (!param_buf) {
12123 WMI_LOGE("Invalid swba event buffer");
12124 return QDF_STATUS_E_INVAL;
12125 }
12126
12127 p2p_noa_info = &param_buf->p2p_noa_info[idx];
12128
12129 p2p_desc->modified = false;
12130 p2p_desc->num_descriptors = 0;
12131 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
12132 p2p_desc->modified = true;
12133 p2p_desc->index =
12134 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
12135 p2p_desc->oppPS =
12136 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
12137 p2p_desc->ctwindow =
12138 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
12139 p2p_desc->num_descriptors =
12140 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
12141 (p2p_noa_info);
12142 for (i = 0; i < p2p_desc->num_descriptors; i++) {
12143 p2p_desc->noa_descriptors[i].type_count =
12144 (uint8_t) p2p_noa_info->noa_descriptors[i].
12145 type_count;
12146 p2p_desc->noa_descriptors[i].duration =
12147 p2p_noa_info->noa_descriptors[i].duration;
12148 p2p_desc->noa_descriptors[i].interval =
12149 p2p_noa_info->noa_descriptors[i].interval;
12150 p2p_desc->noa_descriptors[i].start_time =
12151 p2p_noa_info->noa_descriptors[i].start_time;
12152 }
12153 }
12154
12155 return QDF_STATUS_SUCCESS;
12156}
12157
12158/**
12159 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
12160 * @wmi_handle: wmi handle
12161 * @param evt_buf: pointer to event buffer
12162 * @param ev: Pointer to hold peer param
12163 *
12164 * Return: QDF_STATUS_SUCCESS for success or error code
12165 */
12166static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
12167 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
12168{
12169 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
12170 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
12171
12172 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
12173 kickout_event = param_buf->fixed_param;
12174
12175 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
12176 ev->peer_macaddr);
12177
12178 ev->reason = kickout_event->reason;
12179 ev->rssi = kickout_event->rssi;
12180
12181 return QDF_STATUS_SUCCESS;
12182}
12183
12184/**
12185 * extract_all_stats_counts_tlv() - extract all stats count from event
12186 * @wmi_handle: wmi handle
12187 * @param evt_buf: pointer to event buffer
12188 * @param stats_param: Pointer to hold stats count
12189 *
12190 * Return: QDF_STATUS_SUCCESS for success or error code
12191 */
12192static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
12193 void *evt_buf, wmi_host_stats_event *stats_param)
12194{
12195 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12196 wmi_stats_event_fixed_param *ev;
12197
12198 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12199
12200 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12201 if (!ev) {
12202 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
12203 return QDF_STATUS_E_FAILURE;
12204 }
12205
12206 switch (ev->stats_id) {
12207 case WMI_REQUEST_PEER_STAT:
12208 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
12209 break;
12210
12211 case WMI_REQUEST_AP_STAT:
12212 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
12213 break;
12214
12215 case WMI_REQUEST_PDEV_STAT:
12216 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
12217 break;
12218
12219 case WMI_REQUEST_VDEV_STAT:
12220 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
12221 break;
12222
12223 case WMI_REQUEST_BCNFLT_STAT:
12224 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
12225 break;
12226
12227 case WMI_REQUEST_VDEV_RATE_STAT:
12228 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
12229 break;
12230
12231 default:
12232 stats_param->stats_id = 0;
12233 break;
12234
12235 }
12236
12237 stats_param->num_pdev_stats = ev->num_pdev_stats;
12238 stats_param->num_pdev_ext_stats = 0;
12239 stats_param->num_vdev_stats = ev->num_vdev_stats;
12240 stats_param->num_peer_stats = ev->num_peer_stats;
12241 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
12242 stats_param->num_chan_stats = ev->num_chan_stats;
12243
12244 return QDF_STATUS_SUCCESS;
12245}
12246
12247/**
12248 * extract_pdev_stats_tlv() - extract pdev stats from event
12249 * @wmi_handle: wmi handle
12250 * @param evt_buf: pointer to event buffer
12251 * @param index: Index into pdev stats
12252 * @param pdev_stats: Pointer to hold pdev stats
12253 *
12254 * Return: QDF_STATUS_SUCCESS for success or error code
12255 */
12256static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
12257 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
12258{
12259 return QDF_STATUS_SUCCESS;
12260}
12261
12262/**
12263 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
12264 * @wmi_handle: wmi handle
12265 * @param evt_buf: pointer to event buffer
12266 * @param index: Index into extended pdev stats
12267 * @param pdev_ext_stats: Pointer to hold extended pdev stats
12268 *
12269 * Return: QDF_STATUS_SUCCESS for success or error code
12270 */
12271static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
12272 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
12273{
12274 return QDF_STATUS_SUCCESS;
12275}
12276
12277/**
12278 * extract_vdev_stats_tlv() - extract vdev stats from event
12279 * @wmi_handle: wmi handle
12280 * @param evt_buf: pointer to event buffer
12281 * @param index: Index into vdev stats
12282 * @param vdev_stats: Pointer to hold vdev stats
12283 *
12284 * Return: QDF_STATUS_SUCCESS for success or error code
12285 */
12286static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
12287 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
12288{
12289 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12290 wmi_stats_event_fixed_param *ev_param;
12291 uint8_t *data;
12292
12293 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12294 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12295 data = (uint8_t *) param_buf->data;
12296
12297 if (index < ev_param->num_vdev_stats) {
12298 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
12299 ((ev_param->num_pdev_stats) *
12300 sizeof(wmi_pdev_stats)) +
12301 (index * sizeof(wmi_vdev_stats)));
12302
12303 vdev_stats->vdev_id = ev->vdev_id;
12304 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
12305 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
12306
12307 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
12308 sizeof(ev->tx_frm_cnt));
12309 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
12310 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
12311 ev->multiple_retry_cnt,
12312 sizeof(ev->multiple_retry_cnt));
12313 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
12314 sizeof(ev->fail_cnt));
12315 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
12316 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
12317 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
12318 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
12319 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
12320 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
12321 sizeof(ev->tx_rate_history));
12322 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
12323 sizeof(ev->bcn_rssi_history));
12324
12325 }
12326
12327 return QDF_STATUS_SUCCESS;
12328}
12329
12330/**
12331 * extract_peer_stats_tlv() - extract peer stats from event
12332 * @wmi_handle: wmi handle
12333 * @param evt_buf: pointer to event buffer
12334 * @param index: Index into peer stats
12335 * @param peer_stats: Pointer to hold peer stats
12336 *
12337 * Return: QDF_STATUS_SUCCESS for success or error code
12338 */
12339static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
12340 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
12341{
12342 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12343 wmi_stats_event_fixed_param *ev_param;
12344 uint8_t *data;
12345
12346 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12347 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12348 data = (uint8_t *) param_buf->data;
12349
12350 if (index < ev_param->num_peer_stats) {
12351 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
12352 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12353 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12354 (index * sizeof(wmi_peer_stats)));
12355
12356 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
12357
12358 OS_MEMCPY(&(peer_stats->peer_macaddr),
12359 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
12360
12361 peer_stats->peer_rssi = ev->peer_rssi;
12362 peer_stats->peer_tx_rate = ev->peer_tx_rate;
12363 peer_stats->peer_rx_rate = ev->peer_rx_rate;
12364 }
12365
12366 return QDF_STATUS_SUCCESS;
12367}
12368
12369/**
12370 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
12371 * @wmi_handle: wmi handle
12372 * @param evt_buf: pointer to event buffer
12373 * @param index: Index into bcn fault stats
12374 * @param bcnflt_stats: Pointer to hold bcn fault stats
12375 *
12376 * Return: QDF_STATUS_SUCCESS for success or error code
12377 */
12378static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
12379 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
12380{
12381 return QDF_STATUS_SUCCESS;
12382}
12383
12384/**
12385 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
12386 * @wmi_handle: wmi handle
12387 * @param evt_buf: pointer to event buffer
12388 * @param index: Index into extended peer stats
12389 * @param peer_extd_stats: Pointer to hold extended peer stats
12390 *
12391 * Return: QDF_STATUS_SUCCESS for success or error code
12392 */
12393static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
12394 void *evt_buf, uint32_t index,
12395 wmi_host_peer_extd_stats *peer_extd_stats)
12396{
12397 return QDF_STATUS_SUCCESS;
12398}
12399
12400/**
12401 * extract_chan_stats_tlv() - extract chan stats from event
12402 * @wmi_handle: wmi handle
12403 * @param evt_buf: pointer to event buffer
12404 * @param index: Index into chan stats
12405 * @param vdev_extd_stats: Pointer to hold chan stats
12406 *
12407 * Return: QDF_STATUS_SUCCESS for success or error code
12408 */
12409static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
12410 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
12411{
12412 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12413 wmi_stats_event_fixed_param *ev_param;
12414 uint8_t *data;
12415
12416 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12417 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12418 data = (uint8_t *) param_buf->data;
12419
12420 if (index < ev_param->num_chan_stats) {
12421 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
12422 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12423 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12424 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
12425 (index * sizeof(wmi_chan_stats)));
12426
12427
12428 /* Non-TLV doesnt have num_chan_stats */
12429 chan_stats->chan_mhz = ev->chan_mhz;
12430 chan_stats->sampling_period_us = ev->sampling_period_us;
12431 chan_stats->rx_clear_count = ev->rx_clear_count;
12432 chan_stats->tx_duration_us = ev->tx_duration_us;
12433 chan_stats->rx_duration_us = ev->rx_duration_us;
12434 }
12435
12436 return QDF_STATUS_SUCCESS;
12437}
12438
12439/**
12440 * extract_profile_ctx_tlv() - extract profile context from event
12441 * @wmi_handle: wmi handle
12442 * @param evt_buf: pointer to event buffer
12443 * @idx: profile stats index to extract
12444 * @param profile_ctx: Pointer to hold profile context
12445 *
12446 * Return: QDF_STATUS_SUCCESS for success or error code
12447 */
12448static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
12449 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
12450{
12451 return QDF_STATUS_SUCCESS;
12452}
12453
12454/**
12455 * extract_profile_data_tlv() - extract profile data from event
12456 * @wmi_handle: wmi handle
12457 * @param evt_buf: pointer to event buffer
12458 * @param profile_data: Pointer to hold profile data
12459 *
12460 * Return: QDF_STATUS_SUCCESS for success or error code
12461 */
12462static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
12463 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
12464{
12465
12466 return QDF_STATUS_SUCCESS;
12467}
12468
12469/**
12470 * extract_chan_info_event_tlv() - extract chan information from event
12471 * @wmi_handle: wmi handle
12472 * @param evt_buf: pointer to event buffer
12473 * @param chan_info: Pointer to hold chan information
12474 *
12475 * Return: QDF_STATUS_SUCCESS for success or error code
12476 */
12477static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
12478 void *evt_buf, wmi_host_chan_info_event *chan_info)
12479{
12480 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
12481 wmi_chan_info_event_fixed_param *ev;
12482
12483 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
12484
12485 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
12486 if (!ev) {
12487 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
12488 return QDF_STATUS_E_FAILURE;
12489 }
12490
12491 chan_info->err_code = ev->err_code;
12492 chan_info->freq = ev->freq;
12493 chan_info->cmd_flags = ev->cmd_flags;
12494 chan_info->noise_floor = ev->noise_floor;
12495 chan_info->rx_clear_count = ev->rx_clear_count;
12496 chan_info->cycle_count = ev->cycle_count;
12497
12498 return QDF_STATUS_SUCCESS;
12499}
12500
12501/**
12502 * extract_channel_hopping_event_tlv() - extract channel hopping param
12503 * from event
12504 * @wmi_handle: wmi handle
12505 * @param evt_buf: pointer to event buffer
12506 * @param ch_hopping: Pointer to hold channel hopping param
12507 *
12508 * Return: QDF_STATUS_SUCCESS for success or error code
12509 */
12510static QDF_STATUS extract_channel_hopping_event_tlv(wmi_unified_t wmi_handle,
12511 void *evt_buf, wmi_host_pdev_channel_hopping_event *chan_info)
12512{
12513 return QDF_STATUS_SUCCESS;
12514}
12515
Kiran Venkatappa06520822016-08-10 23:55:40 +053012516/**
12517 * extract_service_ready_ext_tlv() - extract basic extended service ready params
12518 * from event
12519 * @wmi_handle: wmi handle
12520 * @param evt_buf: pointer to event buffer
12521 * @param param: Pointer to hold evt buf
12522 *
12523 * Return: QDF_STATUS_SUCCESS for success or error code
12524 */
12525static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
12526 uint8_t *event, struct wmi_host_service_ext_param *param)
12527{
12528 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12529 wmi_service_ready_ext_event_fixed_param *ev;
12530 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
12531 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
12532
12533 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12534 if (!param_buf)
12535 return -EINVAL;
12536
12537 ev = param_buf->fixed_param;
12538 if (!ev)
12539 return -EINVAL;
12540
12541 /* Move this to host based bitmap */
12542 param->default_conc_scan_config_bits =
12543 ev->default_conc_scan_config_bits;
12544 param->default_fw_config_bits = ev->default_fw_config_bits;
12545 param->he_cap_info = ev->he_cap_info;
12546 param->mpdu_density = ev->mpdu_density;
12547 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
12548 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
12549
12550 hw_caps = param_buf->soc_hw_mode_caps;
12551 param->num_hw_modes = hw_caps->num_hw_modes;
12552
12553 reg_caps = param_buf->soc_hal_reg_caps;
12554 param->num_phy = reg_caps->num_phy;
12555
12556 return QDF_STATUS_SUCCESS;
12557}
12558
12559/**
12560 * extract_hw_mode_cap_service_ready_ext_tlv() -
12561 * extract HW mode cap from service ready event
12562 * @wmi_handle: wmi handle
12563 * @param evt_buf: pointer to event buffer
12564 * @param param: Pointer to hold evt buf
12565 * @param hw_mode_idx: hw mode idx should be less than num_mode
12566 *
12567 * Return: QDF_STATUS_SUCCESS for success or error code
12568 */
12569static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
12570 wmi_unified_t wmi_handle,
12571 uint8_t *event, uint8_t hw_mode_idx,
12572 struct wmi_host_hw_mode_caps *param)
12573{
12574 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12575 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
12576
12577 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12578 if (!param_buf)
12579 return -EINVAL;
12580
12581 hw_caps = param_buf->soc_hw_mode_caps;
12582 if (hw_mode_idx >= hw_caps->num_hw_modes)
12583 return -EINVAL;
12584
12585 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
12586 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
12587
12588 return QDF_STATUS_SUCCESS;
12589}
12590
12591/**
12592 * extract_mac_phy_cap_service_ready_ext_tlv() -
12593 * extract MAC phy cap from service ready event
12594 * @wmi_handle: wmi handle
12595 * @param evt_buf: pointer to event buffer
12596 * @param param: Pointer to hold evt buf
12597 * @param hw_mode_idx: hw mode idx should be less than num_mode
12598 *
12599 * Return: QDF_STATUS_SUCCESS for success or error code
12600 */
12601static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
12602 wmi_unified_t wmi_handle,
12603 uint8_t *event, uint8_t hw_mode_idx,
12604 struct wmi_host_mac_phy_caps *param)
12605{
12606 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12607 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
12608 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
12609
12610 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12611 if (!param_buf)
12612 return -EINVAL;
12613
12614 hw_caps = param_buf->soc_hw_mode_caps;
12615 if (hw_mode_idx >= hw_caps->num_hw_modes)
12616 return -EINVAL;
12617
12618 mac_phy_caps = &param_buf->mac_phy_caps[hw_mode_idx];
12619
12620 param->hw_mode_id = mac_phy_caps->hw_mode_id;
12621 param->pdev_id = mac_phy_caps->pdev_id;
12622 param->phy_id = mac_phy_caps->phy_id;
12623 param->supports_11b = mac_phy_caps->supports_11b;
12624 param->supports_11g = mac_phy_caps->supports_11g;
12625 param->supports_11a = mac_phy_caps->supports_11a;
12626 param->supports_11n = mac_phy_caps->supports_11n;
12627 param->supports_11ac = mac_phy_caps->supports_11ac;
12628 param->supports_11ax = mac_phy_caps->supports_11ax;
12629
12630 param->supported_bands = mac_phy_caps->supported_bands;
12631 param->ampdu_density = mac_phy_caps->ampdu_density;
12632 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
12633 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
12634 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
12635 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
12636 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
12637 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
12638 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
12639 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
12640 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
12641 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
12642 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
12643 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
12644 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
12645 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
12646 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
12647 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
12648
12649 return QDF_STATUS_SUCCESS;
12650}
12651
12652/**
12653 * extract_reg_cap_service_ready_ext_tlv() -
12654 * extract REG cap from service ready event
12655 * @wmi_handle: wmi handle
12656 * @param evt_buf: pointer to event buffer
12657 * @param param: Pointer to hold evt buf
12658 * @param phy_idx: phy idx should be less than num_mode
12659 *
12660 * Return: QDF_STATUS_SUCCESS for success or error code
12661 */
12662static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
12663 wmi_unified_t wmi_handle,
12664 uint8_t *event, uint8_t phy_idx,
12665 struct WMI_HOST_HAL_REG_CAPABILITIES_EXT *param)
12666{
12667 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12668 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
12669 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
12670
12671 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12672 if (!param_buf)
12673 return -EINVAL;
12674
12675 reg_caps = param_buf->soc_hal_reg_caps;
12676 if (phy_idx >= reg_caps->num_phy)
12677 return -EINVAL;
12678
12679 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
12680
12681 param->phy_id = ext_reg_cap->phy_id;
12682 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
12683 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
12684 param->regcap1 = ext_reg_cap->regcap1;
12685 param->regcap2 = ext_reg_cap->regcap2;
12686 param->wireless_modes = ext_reg_cap->wireless_modes;
12687 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
12688 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
12689 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
12690 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
12691
12692 return QDF_STATUS_SUCCESS;
12693}
12694
Govind Singh06c18392016-06-10 10:33:19 +053012695#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhecf03cd2016-05-12 12:45:51 +053012696static bool is_management_record_tlv(uint32_t cmd_id)
12697{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053012698 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053012699 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053012700
Govind Singhecf03cd2016-05-12 12:45:51 +053012701 return false;
12702}
Govind Singh06c18392016-06-10 10:33:19 +053012703#endif
Govind Singhecf03cd2016-05-12 12:45:51 +053012704
Govind Singh5eb51532016-03-09 11:34:12 +053012705struct wmi_ops tlv_ops = {
12706 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
12707 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
12708 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053012709 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
12710 .send_hidden_ssid_vdev_restart_cmd =
12711 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012712 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
12713 .send_peer_param_cmd = send_peer_param_cmd_tlv,
12714 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012715 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012716 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012717 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070012718 .send_peer_rx_reorder_queue_setup_cmd =
12719 send_peer_rx_reorder_queue_setup_cmd_tlv,
12720 .send_peer_rx_reorder_queue_remove_cmd =
12721 send_peer_rx_reorder_queue_remove_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012722 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
12723 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
12724 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
12725 .send_suspend_cmd = send_suspend_cmd_tlv,
12726 .send_resume_cmd = send_resume_cmd_tlv,
12727 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
12728 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
12729 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
12730 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
12731 .send_dbglog_cmd = send_dbglog_cmd_tlv,
12732 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
12733 .send_stats_request_cmd = send_stats_request_cmd_tlv,
12734 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
12735 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012736#ifndef CONFIG_MCL
12737 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
12738#endif
Govind Singh5eb51532016-03-09 11:34:12 +053012739 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
12740 .send_scan_start_cmd = send_scan_start_cmd_tlv,
12741 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
12742 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012743 .send_mgmt_cmd = send_mgmt_cmd_tlv,
12744 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
12745 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012746 .send_set_sta_uapsd_auto_trig_cmd =
12747 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012748 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
12749 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
12750 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
12751 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
12752 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053012753 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
12754 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
12755 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
12756 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
12757 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
12758 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
12759 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012760 .send_ocb_start_timing_advert_cmd =
12761 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053012762 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
12763 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
12764 .send_set_mcc_channel_time_latency_cmd =
12765 send_set_mcc_channel_time_latency_cmd_tlv,
12766 .send_set_mcc_channel_time_quota_cmd =
12767 send_set_mcc_channel_time_quota_cmd_tlv,
12768 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
12769 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053012770 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012771 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
12772 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
12773 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012774 .send_probe_rsp_tmpl_send_cmd =
12775 send_probe_rsp_tmpl_send_cmd_tlv,
12776 .send_p2p_go_set_beacon_ie_cmd =
12777 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053012778 .send_setup_install_key_cmd =
12779 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012780 .send_set_gateway_params_cmd =
12781 send_set_gateway_params_cmd_tlv,
12782 .send_set_rssi_monitoring_cmd =
12783 send_set_rssi_monitoring_cmd_tlv,
12784 .send_scan_probe_setoui_cmd =
12785 send_scan_probe_setoui_cmd_tlv,
12786 .send_reset_passpoint_network_list_cmd =
12787 send_reset_passpoint_network_list_cmd_tlv,
12788 .send_set_passpoint_network_list_cmd =
12789 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053012790 .send_roam_scan_offload_rssi_thresh_cmd =
12791 send_roam_scan_offload_rssi_thresh_cmd_tlv,
12792 .send_roam_scan_filter_cmd =
12793 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012794 .send_set_epno_network_list_cmd =
12795 send_set_epno_network_list_cmd_tlv,
12796 .send_ipa_offload_control_cmd =
12797 send_ipa_offload_control_cmd_tlv,
12798 .send_extscan_get_capabilities_cmd =
12799 send_extscan_get_capabilities_cmd_tlv,
12800 .send_extscan_get_cached_results_cmd =
12801 send_extscan_get_cached_results_cmd_tlv,
12802 .send_extscan_stop_change_monitor_cmd =
12803 send_extscan_stop_change_monitor_cmd_tlv,
12804 .send_extscan_start_change_monitor_cmd =
12805 send_extscan_start_change_monitor_cmd_tlv,
12806 .send_extscan_stop_hotlist_monitor_cmd =
12807 send_extscan_stop_hotlist_monitor_cmd_tlv,
12808 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
12809 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
12810 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
12811 .send_plm_start_cmd = send_plm_start_cmd_tlv,
12812 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012813#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053012814 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012815#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053012816 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
12817 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
12818 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
12819 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
12820 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053012821 .send_snr_request_cmd = send_snr_request_cmd_tlv,
12822 .send_snr_cmd = send_snr_cmd_tlv,
12823 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012824#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053012825 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
12826 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
12827 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
12828 .send_lphb_config_udp_pkt_filter_cmd =
12829 send_lphb_config_udp_pkt_filter_cmd_tlv,
12830 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
12831 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
12832 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012833 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
12834 .send_process_update_edca_param_cmd =
12835 send_process_update_edca_param_cmd_tlv,
12836 .send_roam_scan_offload_mode_cmd =
12837 send_roam_scan_offload_mode_cmd_tlv,
12838 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
12839 .send_roam_scan_offload_ap_profile_cmd =
12840 send_roam_scan_offload_ap_profile_cmd_tlv,
12841#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053012842 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
12843 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012844#ifdef FEATURE_WLAN_RA_FILTERING
Govind Singh20c5dac2016-03-07 15:33:31 +053012845 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012846#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053012847 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
12848 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
12849 .send_dfs_phyerr_filter_offload_en_cmd =
12850 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053012851 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
12852 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
12853 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
12854 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
12855 .send_del_ts_cmd = send_del_ts_cmd_tlv,
12856 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
12857 .send_add_ts_cmd = send_add_ts_cmd_tlv,
12858 .send_enable_disable_packet_filter_cmd =
12859 send_enable_disable_packet_filter_cmd_tlv,
12860 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
12861 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
12862 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
12863 .send_process_gtk_offload_getinfo_cmd =
12864 send_process_gtk_offload_getinfo_cmd_tlv,
12865 .send_process_add_periodic_tx_ptrn_cmd =
12866 send_process_add_periodic_tx_ptrn_cmd_tlv,
12867 .send_process_del_periodic_tx_ptrn_cmd =
12868 send_process_del_periodic_tx_ptrn_cmd_tlv,
12869 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
12870 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
12871 .send_set_app_type2_params_in_fw_cmd =
12872 send_set_app_type2_params_in_fw_cmd_tlv,
12873 .send_set_auto_shutdown_timer_cmd =
12874 send_set_auto_shutdown_timer_cmd_tlv,
12875 .send_nan_req_cmd = send_nan_req_cmd_tlv,
12876 .send_process_dhcpserver_offload_cmd =
12877 send_process_dhcpserver_offload_cmd_tlv,
12878 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
12879 .send_process_ch_avoid_update_cmd =
12880 send_process_ch_avoid_update_cmd_tlv,
12881 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
12882 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
12883 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
12884 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
12885 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
12886 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012887#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012888 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012889#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012890 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053012891 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053012892 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053012893 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012894 .send_set_base_macaddr_indicate_cmd =
12895 send_set_base_macaddr_indicate_cmd_tlv,
12896 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
12897 .send_enable_specific_fw_logs_cmd =
12898 send_enable_specific_fw_logs_cmd_tlv,
12899 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012900 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012901 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012902 .send_pdev_set_dual_mac_config_cmd =
12903 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012904 .send_enable_arp_ns_offload_cmd =
12905 send_enable_arp_ns_offload_cmd_tlv,
12906 .send_app_type1_params_in_fw_cmd =
12907 send_app_type1_params_in_fw_cmd_tlv,
12908 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
12909 .send_process_roam_synch_complete_cmd =
12910 send_process_roam_synch_complete_cmd_tlv,
12911 .send_unit_test_cmd = send_unit_test_cmd_tlv,
12912 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
12913 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012914 .send_roam_scan_offload_scan_period_cmd =
12915 send_roam_scan_offload_scan_period_cmd_tlv,
12916 .send_roam_scan_offload_chan_list_cmd =
12917 send_roam_scan_offload_chan_list_cmd_tlv,
12918 .send_roam_scan_offload_rssi_change_cmd =
12919 send_roam_scan_offload_rssi_change_cmd_tlv,
12920 .send_get_buf_extscan_hotlist_cmd =
12921 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053012922 .send_adapt_dwelltime_params_cmd =
12923 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053012924 .init_cmd_send = init_cmd_send_tlv,
12925 .get_target_cap_from_service_ready = extract_service_ready_tlv,
12926 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
12927 .extract_host_mem_req = extract_host_mem_req_tlv,
12928 .save_service_bitmap = save_service_bitmap_tlv,
12929 .is_service_enabled = is_service_enabled_tlv,
12930 .save_fw_version = save_fw_version_in_service_ready_tlv,
12931 .ready_extract_init_status = ready_extract_init_status_tlv,
12932 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
12933 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
12934 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
12935 .extract_tbttoffset_update_params =
12936 extract_tbttoffset_update_params_tlv,
12937 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
12938 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
12939 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
12940 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
12941 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
12942 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
12943 .extract_swba_tim_info = extract_swba_tim_info_tlv,
12944 .extract_swba_noa_info = extract_swba_noa_info_tlv,
12945 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
12946 .extract_all_stats_count = extract_all_stats_counts_tlv,
12947 .extract_pdev_stats = extract_pdev_stats_tlv,
12948 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
12949 .extract_vdev_stats = extract_vdev_stats_tlv,
12950 .extract_peer_stats = extract_peer_stats_tlv,
12951 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
12952 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
12953 .extract_chan_stats = extract_chan_stats_tlv,
12954 .extract_profile_ctx = extract_profile_ctx_tlv,
12955 .extract_profile_data = extract_profile_data_tlv,
12956 .extract_chan_info_event = extract_chan_info_event_tlv,
12957 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053012958 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053012959 .send_encrypt_decrypt_send_cmd =
12960 send_encrypt_decrypt_send_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053012961 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053012962 .extract_service_ready_ext = extract_service_ready_ext_tlv,
12963 .extract_hw_mode_cap_service_ready_ext =
12964 extract_hw_mode_cap_service_ready_ext_tlv,
12965 .extract_mac_phy_cap_service_ready_ext =
12966 extract_mac_phy_cap_service_ready_ext_tlv,
12967 .extract_reg_cap_service_ready_ext =
12968 extract_reg_cap_service_ready_ext_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012969};
12970
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053012971#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053012972/**
12973 * populate_tlv_service() - populates wmi services
12974 *
12975 * @param wmi_service: Pointer to hold wmi_service
12976 * Return: None
12977 */
12978static void populate_tlv_service(uint32_t *wmi_service)
12979{
12980 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
12981 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
12982 wmi_service[wmi_service_roam_scan_offload] =
12983 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
12984 wmi_service[wmi_service_bcn_miss_offload] =
12985 WMI_SERVICE_BCN_MISS_OFFLOAD;
12986 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
12987 wmi_service[wmi_service_sta_advanced_pwrsave] =
12988 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
12989 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
12990 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
12991 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
12992 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
12993 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
12994 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
12995 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
12996 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
12997 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
12998 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
12999 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
13000 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
13001 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
13002 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
13003 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
13004 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
13005 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
13006 wmi_service[wmi_service_packet_power_save] =
13007 WMI_SERVICE_PACKET_POWER_SAVE;
13008 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
13009 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
13010 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
13011 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
13012 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
13013 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
13014 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
13015 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
13016 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
13017 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
13018 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
13019 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
13020 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
13021 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
13022 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
13023 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
13024 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
13025 wmi_service[wmi_service_mcc_bcn_interval_change] =
13026 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
13027 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
13028 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
13029 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
13030 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
13031 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
13032 wmi_service[wmi_service_lte_ant_share_support] =
13033 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
13034 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
13035 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
13036 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
13037 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
13038 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
13039 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
13040 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
13041 wmi_service[wmi_service_bcn_txrate_override] =
13042 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
13043 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
13044 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
13045 wmi_service[wmi_service_estimate_linkspeed] =
13046 WMI_SERVICE_ESTIMATE_LINKSPEED;
13047 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
13048 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
13049 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
13050 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
13051 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
13052 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
13053 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
13054 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
13055 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
13056 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
13057 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
13058 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
13059 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
13060 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
13061 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
13062 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
13063 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
13064 wmi_service[wmi_service_sap_auth_offload] =
13065 WMI_SERVICE_SAP_AUTH_OFFLOAD;
13066 wmi_service[wmi_service_dual_band_simultaneous_support] =
13067 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
13068 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
13069 wmi_service[wmi_service_ap_arpns_offload] =
13070 WMI_SERVICE_AP_ARPNS_OFFLOAD;
13071 wmi_service[wmi_service_per_band_chainmask_support] =
13072 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
13073 wmi_service[wmi_service_packet_filter_offload] =
13074 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
13075 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
13076 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
13077 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
13078 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
13079
13080 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
13081 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
13082 wmi_service[wmi_service_smart_antenna_sw_support] =
13083 WMI_SERVICE_UNAVAILABLE;
13084 wmi_service[wmi_service_smart_antenna_hw_support] =
13085 WMI_SERVICE_UNAVAILABLE;
13086 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
13087 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
13088 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
13089 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
13090 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
13091 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
13092 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
13093 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
13094 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
13095 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
13096 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
13097
13098 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
13099 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
13100 wmi_service[wmi_service_periodic_chan_stat_support] =
13101 WMI_SERVICE_UNAVAILABLE;
13102 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
13103 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
13104 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
13105}
13106
13107/**
13108 * populate_tlv_event_id() - populates wmi event ids
13109 *
13110 * @param event_ids: Pointer to hold event ids
13111 * Return: None
13112 */
13113static void populate_tlv_events_id(uint32_t *event_ids)
13114{
13115 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
13116 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
13117 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
13118 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
13119 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
13120 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
13121 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
13122 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
13123 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
13124 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
13125 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
13126 event_ids[wmi_service_ready_ext_event_id] =
13127 WMI_SERVICE_READY_EXT_EVENTID;
13128 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
13129 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
13130 event_ids[wmi_vdev_install_key_complete_event_id] =
13131 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
13132 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
13133 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
13134
13135 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
13136 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
13137 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
13138 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
13139 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
13140 event_ids[wmi_peer_estimated_linkspeed_event_id] =
13141 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
13142 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
13143 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
13144 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
13145 event_ids[wmi_tbttoffset_update_event_id] =
13146 WMI_TBTTOFFSET_UPDATE_EVENTID;
13147 event_ids[wmi_offload_bcn_tx_status_event_id] =
13148 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
13149 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
13150 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
13151 event_ids[wmi_mgmt_tx_completion_event_id] =
13152 WMI_MGMT_TX_COMPLETION_EVENTID;
13153
13154 event_ids[wmi_tx_delba_complete_event_id] =
13155 WMI_TX_DELBA_COMPLETE_EVENTID;
13156 event_ids[wmi_tx_addba_complete_event_id] =
13157 WMI_TX_ADDBA_COMPLETE_EVENTID;
13158 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
13159
13160 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
13161
13162 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
13163 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
13164
13165 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
13166
13167 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
13168
13169 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
13170
13171 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
13172 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
13173 event_ids[wmi_do_wow_disable_ack_event_id] =
13174 WMI_D0_WOW_DISABLE_ACK_EVENTID;
13175 event_ids[wmi_wow_initial_wakeup_event_id] =
13176 WMI_WOW_INITIAL_WAKEUP_EVENTID;
13177
13178 event_ids[wmi_rtt_meas_report_event_id] =
13179 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
13180 event_ids[wmi_tsf_meas_report_event_id] =
13181 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
13182 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
13183 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
13184 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
13185 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
13186 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
13187 event_ids[wmi_update_fw_mem_dump_event_id] =
13188 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
13189 event_ids[wmi_diag_event_id_log_supported_event_id] =
13190 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
13191 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
13192 event_ids[wmi_nlo_scan_complete_event_id] =
13193 WMI_NLO_SCAN_COMPLETE_EVENTID;
13194 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
13195 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
13196
13197 event_ids[wmi_gtk_offload_status_event_id] =
13198 WMI_GTK_OFFLOAD_STATUS_EVENTID;
13199 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
13200 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
13201 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
13202
13203 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
13204
13205 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
13206
13207 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
13208 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
13209 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
13210 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
13211 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
13212 event_ids[wmi_wlan_profile_data_event_id] =
13213 WMI_WLAN_PROFILE_DATA_EVENTID;
13214 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
13215 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
13216 event_ids[wmi_vdev_get_keepalive_event_id] =
13217 WMI_VDEV_GET_KEEPALIVE_EVENTID;
13218 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
13219
13220 event_ids[wmi_diag_container_event_id] =
13221 WMI_DIAG_DATA_CONTAINER_EVENTID;
13222
13223 event_ids[wmi_host_auto_shutdown_event_id] =
13224 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
13225
13226 event_ids[wmi_update_whal_mib_stats_event_id] =
13227 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
13228
13229 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
13230 event_ids[wmi_update_vdev_rate_stats_event_id] =
13231 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
13232
13233 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
13234
13235 /** Set OCB Sched Response, deprecated */
13236 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
13237
13238 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
13239 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
13240 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
13241
13242 /* GPIO Event */
13243 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
13244 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
13245
13246 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
13247 event_ids[wmi_rfkill_state_change_event_id] =
13248 WMI_RFKILL_STATE_CHANGE_EVENTID;
13249
13250 /* TDLS Event */
13251 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
13252
13253 event_ids[wmi_batch_scan_enabled_event_id] =
13254 WMI_BATCH_SCAN_ENABLED_EVENTID;
13255 event_ids[wmi_batch_scan_result_event_id] =
13256 WMI_BATCH_SCAN_RESULT_EVENTID;
13257 /* OEM Event */
13258 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
13259 event_ids[wmi_oem_meas_report_event_id] =
13260 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
13261 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
13262
13263 /* NAN Event */
13264 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
13265
13266 /* LPI Event */
13267 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
13268 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
13269 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
13270
13271 /* ExtScan events */
13272 event_ids[wmi_extscan_start_stop_event_id] =
13273 WMI_EXTSCAN_START_STOP_EVENTID;
13274 event_ids[wmi_extscan_operation_event_id] =
13275 WMI_EXTSCAN_OPERATION_EVENTID;
13276 event_ids[wmi_extscan_table_usage_event_id] =
13277 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
13278 event_ids[wmi_extscan_cached_results_event_id] =
13279 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
13280 event_ids[wmi_extscan_wlan_change_results_event_id] =
13281 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
13282 event_ids[wmi_extscan_hotlist_match_event_id] =
13283 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
13284 event_ids[wmi_extscan_capabilities_event_id] =
13285 WMI_EXTSCAN_CAPABILITIES_EVENTID;
13286 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
13287 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
13288
13289 /* mDNS offload events */
13290 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
13291
13292 /* SAP Authentication offload events */
13293 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
13294 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
13295
13296 /** Out-of-context-of-bss (OCB) events */
13297 event_ids[wmi_ocb_set_config_resp_event_id] =
13298 WMI_OCB_SET_CONFIG_RESP_EVENTID;
13299 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
13300 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
13301 event_ids[wmi_dcc_get_stats_resp_event_id] =
13302 WMI_DCC_GET_STATS_RESP_EVENTID;
13303 event_ids[wmi_dcc_update_ndl_resp_event_id] =
13304 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
13305 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
13306 /* System-On-Chip events */
13307 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
13308 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
13309 event_ids[wmi_soc_hw_mode_transition_event_id] =
13310 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
13311 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
13312 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
13313}
13314
13315/**
13316 * populate_pdev_param_tlv() - populates pdev params
13317 *
13318 * @param pdev_param: Pointer to hold pdev params
13319 * Return: None
13320 */
13321static void populate_pdev_param_tlv(uint32_t *pdev_param)
13322{
13323 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
13324 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
13325 pdev_param[wmi_pdev_param_txpower_limit2g] =
13326 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
13327 pdev_param[wmi_pdev_param_txpower_limit5g] =
13328 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
13329 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
13330 pdev_param[wmi_pdev_param_beacon_gen_mode] =
13331 WMI_PDEV_PARAM_BEACON_GEN_MODE;
13332 pdev_param[wmi_pdev_param_beacon_tx_mode] =
13333 WMI_PDEV_PARAM_BEACON_TX_MODE;
13334 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
13335 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
13336 pdev_param[wmi_pdev_param_protection_mode] =
13337 WMI_PDEV_PARAM_PROTECTION_MODE;
13338 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
13339 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
13340 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
13341 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
13342 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
13343 pdev_param[wmi_pdev_param_sta_kickout_th] =
13344 WMI_PDEV_PARAM_STA_KICKOUT_TH;
13345 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
13346 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
13347 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
13348 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
13349 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
13350 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
13351 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
13352 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
13353 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
13354 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
13355 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
13356 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
13357 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
13358 pdev_param[wmi_pdev_param_ltr_sleep_override] =
13359 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
13360 pdev_param[wmi_pdev_param_ltr_rx_override] =
13361 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
13362 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
13363 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
13364 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
13365 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
13366 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
13367 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
13368 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
13369 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
13370 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
13371 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
13372 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
13373 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
13374 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
13375 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
13376 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
13377 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
13378 pdev_param[wmi_pdev_param_peer_stats_update_period] =
13379 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
13380 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
13381 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
13382 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
13383 pdev_param[wmi_pdev_param_arp_ac_override] =
13384 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
13385 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
13386 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
13387 pdev_param[wmi_pdev_param_ani_poll_period] =
13388 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
13389 pdev_param[wmi_pdev_param_ani_listen_period] =
13390 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
13391 pdev_param[wmi_pdev_param_ani_ofdm_level] =
13392 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
13393 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
13394 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
13395 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
13396 pdev_param[wmi_pdev_param_idle_ps_config] =
13397 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
13398 pdev_param[wmi_pdev_param_power_gating_sleep] =
13399 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
13400 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
13401 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
13402 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
13403 pdev_param[wmi_pdev_param_hw_rfkill_config] =
13404 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
13405 pdev_param[wmi_pdev_param_low_power_rf_enable] =
13406 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
13407 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
13408 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
13409 pdev_param[wmi_pdev_param_power_collapse_enable] =
13410 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
13411 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
13412 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
13413 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
13414 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
13415 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
13416 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
13417 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
13418 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
13419 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
13420 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
13421 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
13422 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
13423 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
13424 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
13425 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
13426 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
13427 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
13428 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
13429 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
13430 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
13431 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
13432 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
13433 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
13434 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
13435 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
13436 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
13437 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
13438 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
13439 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
13440 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
13441 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
13442 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
13443 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
13444 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
13445 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
13446 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
13447 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
13448 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
13449 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
13450 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
13451 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
13452 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
13453 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
13454 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
13455 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
13456 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
13457 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
13458 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
13459 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
13460 WMI_UNAVAILABLE_PARAM;
13461 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
13462 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
13463 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
13464 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
13465 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
13466 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
13467 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
13468 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
13469 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
13470 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
13471 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
13472 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
13473 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
13474 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
13475 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
13476 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
13477 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
13478 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
13479 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
13480 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
13481 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
13482 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
13483 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
13484 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
13485 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
13486 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
13487 WMI_UNAVAILABLE_PARAM;
13488 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
13489 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
13490 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
13491 WMI_UNAVAILABLE_PARAM;
13492 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
13493 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
13494 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
13495 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
13496 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
13497 WMI_UNAVAILABLE_PARAM;
13498 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
13499 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
13500 WMI_UNAVAILABLE_PARAM;
13501 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] = WMI_UNAVAILABLE_PARAM;
13502 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
13503}
13504
13505/**
13506 * populate_vdev_param_tlv() - populates vdev params
13507 *
13508 * @param vdev_param: Pointer to hold vdev params
13509 * Return: None
13510 */
13511static void populate_vdev_param_tlv(uint32_t *vdev_param)
13512{
13513 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
13514 vdev_param[wmi_vdev_param_fragmentation_threshold] =
13515 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
13516 vdev_param[wmi_vdev_param_beacon_interval] =
13517 WMI_VDEV_PARAM_BEACON_INTERVAL;
13518 vdev_param[wmi_vdev_param_listen_interval] =
13519 WMI_VDEV_PARAM_LISTEN_INTERVAL;
13520 vdev_param[wmi_vdev_param_multicast_rate] =
13521 WMI_VDEV_PARAM_MULTICAST_RATE;
13522 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
13523 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
13524 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
13525 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
13526 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
13527 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
13528 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
13529 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
13530 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
13531 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
13532 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
13533 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
13534 vdev_param[wmi_vdev_param_bmiss_count_max] =
13535 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
13536 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
13537 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
13538 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
13539 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
13540 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
13541 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
13542 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
13543 vdev_param[wmi_vdev_param_disable_htprotection] =
13544 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
13545 vdev_param[wmi_vdev_param_sta_quickkickout] =
13546 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
13547 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
13548 vdev_param[wmi_vdev_param_protection_mode] =
13549 WMI_VDEV_PARAM_PROTECTION_MODE;
13550 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
13551 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
13552 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
13553 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
13554 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
13555 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
13556 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
13557 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
13558 vdev_param[wmi_vdev_param_bcast_data_rate] =
13559 WMI_VDEV_PARAM_BCAST_DATA_RATE;
13560 vdev_param[wmi_vdev_param_mcast_data_rate] =
13561 WMI_VDEV_PARAM_MCAST_DATA_RATE;
13562 vdev_param[wmi_vdev_param_mcast_indicate] =
13563 WMI_VDEV_PARAM_MCAST_INDICATE;
13564 vdev_param[wmi_vdev_param_dhcp_indicate] =
13565 WMI_VDEV_PARAM_DHCP_INDICATE;
13566 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
13567 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
13568 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
13569 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
13570 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
13571 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
13572 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
13573 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
13574 vdev_param[wmi_vdev_param_ap_enable_nawds] =
13575 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
13576 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
13577 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
13578 vdev_param[wmi_vdev_param_packet_powersave] =
13579 WMI_VDEV_PARAM_PACKET_POWERSAVE;
13580 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
13581 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
13582 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
13583 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
13584 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
13585 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
13586 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
13587 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
13588 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
13589 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
13590 vdev_param[wmi_vdev_param_early_rx_slop_step] =
13591 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
13592 vdev_param[wmi_vdev_param_early_rx_init_slop] =
13593 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
13594 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
13595 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
13596 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
13597 vdev_param[wmi_vdev_param_snr_num_for_cal] =
13598 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
13599 vdev_param[wmi_vdev_param_roam_fw_offload] =
13600 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
13601 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
13602 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
13603 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
13604 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
13605 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
13606 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
13607 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
13608 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
13609 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
13610 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
13611 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
13612 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
13613 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
13614 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
13615 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
13616 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
13617 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
13618 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
13619 vdev_param[wmi_vdev_param_inactivity_cnt] =
13620 WMI_VDEV_PARAM_INACTIVITY_CNT;
13621 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
13622 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
13623 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
13624 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
13625 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
13626 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
13627 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
13628 vdev_param[wmi_vdev_param_rx_leak_window] =
13629 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
13630 vdev_param[wmi_vdev_param_stats_avg_factor] =
13631 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
13632 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
13633 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
13634 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
13635 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
13636 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
13637 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
13638}
13639#endif
13640
Govind Singh5eb51532016-03-09 11:34:12 +053013641/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013642 * wmi_tlv_attach() - Attach TLV APIs
Govind Singh5eb51532016-03-09 11:34:12 +053013643 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013644 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053013645 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013646#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013647void wmi_tlv_attach(wmi_unified_t wmi_handle)
13648{
13649 wmi_handle->ops = &tlv_ops;
13650#ifdef WMI_INTERFACE_EVENT_LOGGING
13651 wmi_handle->log_info.buf_offset_command = 2;
13652 wmi_handle->log_info.buf_offset_event = 4;
13653 wmi_handle->log_info.is_management_record =
13654 is_management_record_tlv;
13655#endif
13656 populate_tlv_service(wmi_handle->services);
13657 populate_tlv_events_id(wmi_handle->wmi_events);
13658 populate_pdev_param_tlv(wmi_handle->pdev_param);
13659 populate_vdev_param_tlv(wmi_handle->vdev_param);
13660}
13661#else
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013662void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053013663{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013664 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053013665#ifdef WMI_INTERFACE_EVENT_LOGGING
13666 wmi_handle->log_info.buf_offset_command = 2;
13667 wmi_handle->log_info.buf_offset_event = 4;
13668 wmi_handle->log_info.is_management_record =
13669 is_management_record_tlv;
13670#endif
Govind Singh5eb51532016-03-09 11:34:12 +053013671}
Govind Singhe7f2f342016-05-23 12:12:52 +053013672#endif