blob: 3ad2d51a68c5fef9ac8b7ed13629d8c6650d8f0c [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
2 * Copyright (c) 2016 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#include "wmi_unified_tlv.h"
29#include "wmi_unified_api.h"
30#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053031#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053032#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053033#include "wmi_version_whitelist.h"
Govind Singh5eb51532016-03-09 11:34:12 +053034
35/**
36 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
37 * @wmi_handle: wmi handle
38 * @param: pointer to hold vdev create parameter
39 * @macaddr: vdev mac address
40 *
Govind Singhe7f2f342016-05-23 12:12:52 +053041 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053042 */
Govind Singhb53420c2016-03-09 14:32:57 +053043QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053044 uint8_t macaddr[IEEE80211_ADDR_LEN],
45 struct vdev_create_params *param)
46{
47 wmi_vdev_create_cmd_fixed_param *cmd;
48 wmi_buf_t buf;
49 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053050 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070051 int num_bands = 2;
52 uint8_t *buf_ptr;
53 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053054
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070055 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053056 buf = wmi_buf_alloc(wmi_handle, len);
57 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053058 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053059 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053060 }
61 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
62 WMITLV_SET_HDR(&cmd->tlv_header,
63 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
64 WMITLV_GET_STRUCT_TLVLEN
65 (wmi_vdev_create_cmd_fixed_param));
66 cmd->vdev_id = param->if_id;
67 cmd->vdev_type = param->type;
68 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070069 cmd->num_cfg_txrx_streams = num_bands;
Govind Singh4df47142016-04-16 19:24:23 -070070 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +053071 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +053072 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +053073 __func__, param->if_id,
74 macaddr[0], macaddr[1], macaddr[2],
75 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070076 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
77 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
78 (num_bands * sizeof(wmi_vdev_txrx_streams)));
79 buf_ptr += WMI_TLV_HDR_SIZE;
80
Govind Singh224a7312016-06-21 14:33:26 +053081 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070082 param->type, param->subtype,
83 param->nss_2g, param->nss_5g);
84 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
85 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
86 txrx_streams->supported_tx_streams = param->nss_2g;
87 txrx_streams->supported_rx_streams = param->nss_2g;
88 WMITLV_SET_HDR(&txrx_streams->tlv_header,
89 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
90 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
91
92 txrx_streams++;
93 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
94 txrx_streams->supported_tx_streams = param->nss_5g;
95 txrx_streams->supported_rx_streams = param->nss_5g;
96 WMITLV_SET_HDR(&txrx_streams->tlv_header,
97 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
98 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +053099 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530100 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530101 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530102 wmi_buf_free(buf);
103 }
104
105 return ret;
106}
107
108/**
109 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
110 * @wmi_handle: wmi handle
111 * @if_id: vdev id
112 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530113 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530114 */
Govind Singhb53420c2016-03-09 14:32:57 +0530115QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530116 uint8_t if_id)
117{
118 wmi_vdev_delete_cmd_fixed_param *cmd;
119 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530120 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530121
122 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
123 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530124 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530125 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530126 }
127
128 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
129 WMITLV_SET_HDR(&cmd->tlv_header,
130 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
131 WMITLV_GET_STRUCT_TLVLEN
132 (wmi_vdev_delete_cmd_fixed_param));
133 cmd->vdev_id = if_id;
134 ret = wmi_unified_cmd_send(wmi_handle, buf,
135 sizeof(wmi_vdev_delete_cmd_fixed_param),
136 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530137 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530138 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530139 wmi_buf_free(buf);
140 }
Govind Singhb53420c2016-03-09 14:32:57 +0530141 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530142
143 return ret;
144}
145
146/**
147 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
148 * @wmi: wmi handle
149 * @vdev_id: vdev id
150 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530151 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530152 */
Govind Singhb53420c2016-03-09 14:32:57 +0530153QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530154 uint8_t vdev_id)
155{
156 wmi_vdev_stop_cmd_fixed_param *cmd;
157 wmi_buf_t buf;
158 int32_t len = sizeof(*cmd);
159
160 buf = wmi_buf_alloc(wmi, len);
161 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530162 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530163 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530164 }
165 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
166 WMITLV_SET_HDR(&cmd->tlv_header,
167 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
168 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
169 cmd->vdev_id = vdev_id;
170 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530171 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530172 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530173 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530174 }
175
176 return 0;
177}
178
179/**
180 * send_vdev_down_cmd_tlv() - send vdev down command to fw
181 * @wmi: wmi handle
182 * @vdev_id: vdev id
183 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530184 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530185 */
Govind Singhb53420c2016-03-09 14:32:57 +0530186QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530187{
188 wmi_vdev_down_cmd_fixed_param *cmd;
189 wmi_buf_t buf;
190 int32_t len = sizeof(*cmd);
191
192 buf = wmi_buf_alloc(wmi, len);
193 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530194 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530195 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530196 }
197 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
198 WMITLV_SET_HDR(&cmd->tlv_header,
199 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
200 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
201 cmd->vdev_id = vdev_id;
202 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530203 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530204 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530205 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530206 }
Govind Singhb53420c2016-03-09 14:32:57 +0530207 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530208
209 return 0;
210}
211
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530212#ifdef CONFIG_MCL
213static inline void copy_channel_info(
214 wmi_vdev_start_request_cmd_fixed_param * cmd,
215 wmi_channel *chan,
216 struct vdev_start_params *req)
217{
218 chan->mhz = req->chan_freq;
219
220 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
221
222 chan->band_center_freq1 = req->band_center_freq1;
223 chan->band_center_freq2 = req->band_center_freq2;
224
225 if (req->is_half_rate)
226 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
227 else if (req->is_quarter_rate)
228 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
229
230 if (req->is_dfs) {
231 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
232 cmd->disable_hw_ack = req->dis_hw_ack;
233 }
234
235 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
236 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
237
238}
239#else
240static inline void copy_channel_info(
241 wmi_vdev_start_request_cmd_fixed_param * cmd,
242 wmi_channel *chan,
243 struct vdev_start_params *req)
244{
245 chan->mhz = req->channel.mhz;
246
247 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
248
249 chan->band_center_freq1 = req->channel.cfreq1;
250 chan->band_center_freq2 = req->channel.cfreq2;
251
252 if (req->channel.half_rate)
253 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
254 else if (req->channel.quarter_rate)
255 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
256
257 if (req->channel.dfs_set) {
258 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
259 cmd->disable_hw_ack = req->disable_hw_ack;
260 }
261
262 /* FIXME: Find out min, max and regulatory power levels */
263 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
264 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
265
266}
267#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530268/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530269 * send_vdev_start_cmd_tlv() - send vdev start request to fw
270 * @wmi_handle: wmi handle
271 * @req: vdev start params
272 *
273 * Return: QDF status
274 */
275QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
276 struct vdev_start_params *req)
277{
278 wmi_vdev_start_request_cmd_fixed_param *cmd;
279 wmi_buf_t buf;
280 wmi_channel *chan;
281 int32_t len, ret;
282 uint8_t *buf_ptr;
283
284 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
285 buf = wmi_buf_alloc(wmi_handle, len);
286 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530287 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530288 return QDF_STATUS_E_NOMEM;
289 }
290 buf_ptr = (uint8_t *) wmi_buf_data(buf);
291 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
292 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
293 WMITLV_SET_HDR(&cmd->tlv_header,
294 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
295 WMITLV_GET_STRUCT_TLVLEN
296 (wmi_vdev_start_request_cmd_fixed_param));
297 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
298 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
299 cmd->vdev_id = req->vdev_id;
300
301 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530302 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530303
304 cmd->beacon_interval = req->beacon_intval;
305 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530306
307 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530308 cmd->beacon_interval = req->beacon_intval;
309 cmd->dtim_period = req->dtim_period;
310
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530311 /* Copy the SSID */
312 if (req->ssid.length) {
313 if (req->ssid.length < sizeof(cmd->ssid.ssid))
314 cmd->ssid.ssid_len = req->ssid.length;
315 else
316 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
317 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
318 cmd->ssid.ssid_len);
319 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530320
321 if (req->hidden_ssid)
322 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
323
324 if (req->pmf_enabled)
325 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530326 }
327
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530328 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530329 cmd->preferred_rx_streams = req->preferred_rx_streams;
330 cmd->preferred_tx_streams = req->preferred_tx_streams;
331
332 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
333 sizeof(wmi_channel));
334 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
335 cmd->num_noa_descriptors *
336 sizeof(wmi_p2p_noa_descriptor));
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530337 WMI_LOGA("\n%s: vdev_id %d freq %d chanmode %d is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530338 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
339 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
340 "Tx SS %d, Rx SS %d",
341 __func__, req->vdev_id, chan->mhz, req->chan_mode,
342 req->is_dfs, req->beacon_intval, cmd->dtim_period,
343 chan->band_center_freq1, chan->band_center_freq2,
344 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
345 req->preferred_tx_streams, req->preferred_rx_streams);
346
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530347 if (req->is_restart)
348 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
349 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530350 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530351 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
352 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530353 if (ret) {
354 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530355 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530356 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530357 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530358
359 return QDF_STATUS_SUCCESS;
360}
361
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530362/**
363 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
364 * @wmi_handle: wmi handle
365 * @restart_params: vdev restart params
366 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530367 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530368 */
369QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
370 struct hidden_ssid_vdev_restart_params *restart_params)
371{
372 wmi_vdev_start_request_cmd_fixed_param *cmd;
373 wmi_buf_t buf;
374 wmi_channel *chan;
375 int32_t len;
376 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530377 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530378
379 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
380 buf = wmi_buf_alloc(wmi_handle, len);
381 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530382 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530383 return QDF_STATUS_E_NOMEM;
384 }
385 buf_ptr = (uint8_t *) wmi_buf_data(buf);
386 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
387 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
388
389 WMITLV_SET_HDR(&cmd->tlv_header,
390 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
391 WMITLV_GET_STRUCT_TLVLEN
392 (wmi_vdev_start_request_cmd_fixed_param));
393
394 WMITLV_SET_HDR(&chan->tlv_header,
395 WMITLV_TAG_STRUC_wmi_channel,
396 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
397
398 cmd->vdev_id = restart_params->session_id;
399 cmd->ssid.ssid_len = restart_params->ssid_len;
400 qdf_mem_copy(cmd->ssid.ssid,
401 restart_params->ssid,
402 cmd->ssid.ssid_len);
403 cmd->flags = restart_params->flags;
404 cmd->requestor_id = restart_params->requestor_id;
405 cmd->disable_hw_ack = restart_params->disable_hw_ack;
406
407 chan->mhz = restart_params->mhz;
408 chan->band_center_freq1 =
409 restart_params->band_center_freq1;
410 chan->band_center_freq2 =
411 restart_params->band_center_freq2;
412 chan->info = restart_params->info;
413 chan->reg_info_1 = restart_params->reg_info_1;
414 chan->reg_info_2 = restart_params->reg_info_2;
415
416 cmd->num_noa_descriptors = 0;
417 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
418 sizeof(wmi_channel));
419 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
420 cmd->num_noa_descriptors *
421 sizeof(wmi_p2p_noa_descriptor));
422
423 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
424 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530425 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530426 wmi_buf_free(buf);
427 return QDF_STATUS_E_FAILURE;
428 }
429 return QDF_STATUS_SUCCESS;
430}
431
432
433/**
Govind Singh5eb51532016-03-09 11:34:12 +0530434 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
435 * @wmi: wmi handle
436 * @peer_addr: peer mac address
437 * @param: pointer to hold peer flush tid parameter
438 *
439 * Return: 0 for sucess or error code
440 */
Govind Singhb53420c2016-03-09 14:32:57 +0530441QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530442 uint8_t peer_addr[IEEE80211_ADDR_LEN],
443 struct peer_flush_params *param)
444{
445 wmi_peer_flush_tids_cmd_fixed_param *cmd;
446 wmi_buf_t buf;
447 int32_t len = sizeof(*cmd);
448
449 buf = wmi_buf_alloc(wmi, len);
450 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530451 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530452 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530453 }
454 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
455 WMITLV_SET_HDR(&cmd->tlv_header,
456 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
457 WMITLV_GET_STRUCT_TLVLEN
458 (wmi_peer_flush_tids_cmd_fixed_param));
459 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
460 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
461 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530462 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530463 peer_addr, param->vdev_id,
464 param->peer_tid_bitmap);
465 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530466 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530467 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530468 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530469 }
470
471 return 0;
472}
473
474/**
475 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
476 * @wmi: wmi handle
477 * @peer_addr: peer mac addr
478 * @vdev_id: vdev id
479 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530480 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530481 */
Govind Singhb53420c2016-03-09 14:32:57 +0530482QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530483 uint8_t peer_addr[IEEE80211_ADDR_LEN],
484 uint8_t vdev_id)
485{
486 wmi_peer_delete_cmd_fixed_param *cmd;
487 wmi_buf_t buf;
488 int32_t len = sizeof(*cmd);
489 buf = wmi_buf_alloc(wmi, len);
490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530491 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530492 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530493 }
494 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
495 WMITLV_SET_HDR(&cmd->tlv_header,
496 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
497 WMITLV_GET_STRUCT_TLVLEN
498 (wmi_peer_delete_cmd_fixed_param));
499 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
500 cmd->vdev_id = vdev_id;
501
502 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530503 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530504 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530505 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530506 }
Govind Singhb53420c2016-03-09 14:32:57 +0530507 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530508
509 return 0;
510}
511
512/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530513 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
514 * to target id.
515 * @targ_paramid: Target parameter id to hold the result.
516 * @peer_param_id: host param id.
517 *
518 * Return: QDF_STATUS_SUCCESS for success
519 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
520 */
521#ifdef CONFIG_MCL
522static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
523 uint32_t *targ_paramid,
524 uint32_t peer_param_id)
525{
526 *targ_paramid = peer_param_id;
527 return QDF_STATUS_SUCCESS;
528}
529#else
530static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
531 uint32_t *targ_paramid,
532 uint32_t peer_param_id)
533{
534 switch (peer_param_id) {
535 case WMI_HOST_PEER_MIMO_PS_STATE:
536 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
537 break;
538 case WMI_HOST_PEER_AMPDU:
539 *targ_paramid = WMI_PEER_AMPDU;
540 break;
541 case WMI_HOST_PEER_AUTHORIZE:
542 *targ_paramid = WMI_PEER_AUTHORIZE;
543 break;
544 case WMI_HOST_PEER_CHWIDTH:
545 *targ_paramid = WMI_PEER_CHWIDTH;
546 break;
547 case WMI_HOST_PEER_NSS:
548 *targ_paramid = WMI_PEER_NSS;
549 break;
550 case WMI_HOST_PEER_USE_4ADDR:
551 *targ_paramid = WMI_PEER_USE_4ADDR;
552 break;
553 case WMI_HOST_PEER_MEMBERSHIP:
554 *targ_paramid = WMI_PEER_MEMBERSHIP;
555 break;
556 case WMI_HOST_PEER_USERPOS:
557 *targ_paramid = WMI_PEER_USERPOS;
558 break;
559 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
560 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
561 break;
562 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
563 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
564 break;
565 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
566 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
567 break;
568 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
569 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
570 break;
571 case WMI_HOST_PEER_PHYMODE:
572 *targ_paramid = WMI_PEER_PHYMODE;
573 break;
574 case WMI_HOST_PEER_USE_FIXED_PWR:
575 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
576 break;
577 case WMI_HOST_PEER_PARAM_FIXED_RATE:
578 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
579 break;
580 case WMI_HOST_PEER_SET_MU_WHITELIST:
581 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
582 break;
583 case WMI_HOST_PEER_SET_MAC_TX_RATE:
584 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
585 break;
586 case WMI_HOST_PEER_SET_MIN_TX_RATE:
587 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
588 break;
589 default:
590 return QDF_STATUS_E_NOSUPPORT;
591 }
592
593 return QDF_STATUS_SUCCESS;
594}
595#endif
596/**
Govind Singh5eb51532016-03-09 11:34:12 +0530597 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530598 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530599 * @peer_addr: peer mac address
600 * @param : pointer to hold peer set parameter
601 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530602 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530603 */
Govind Singhb53420c2016-03-09 14:32:57 +0530604QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530605 uint8_t peer_addr[IEEE80211_ADDR_LEN],
606 struct peer_set_params *param)
607{
608 wmi_peer_set_param_cmd_fixed_param *cmd;
609 wmi_buf_t buf;
610 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530611 uint32_t param_id;
612
613 if (convert_host_peer_id_to_target_id_tlv(&param_id,
614 param->param_id) != QDF_STATUS_SUCCESS)
615 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530616
617 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
618 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530619 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530620 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530621 }
622 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
623 WMITLV_SET_HDR(&cmd->tlv_header,
624 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
625 WMITLV_GET_STRUCT_TLVLEN
626 (wmi_peer_set_param_cmd_fixed_param));
627 cmd->vdev_id = param->vdev_id;
628 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530629 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530630 cmd->param_value = param->param_value;
631 err = wmi_unified_cmd_send(wmi, buf,
632 sizeof(wmi_peer_set_param_cmd_fixed_param),
633 WMI_PEER_SET_PARAM_CMDID);
634 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530635 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530636 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530637 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530638 }
639
640 return 0;
641}
642
643/**
644 * send_vdev_up_cmd_tlv() - send vdev up command in fw
645 * @wmi: wmi handle
646 * @bssid: bssid
647 * @vdev_up_params: pointer to hold vdev up parameter
648 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530649 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530650 */
Govind Singhb53420c2016-03-09 14:32:57 +0530651QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530652 uint8_t bssid[IEEE80211_ADDR_LEN],
653 struct vdev_up_params *params)
654{
655 wmi_vdev_up_cmd_fixed_param *cmd;
656 wmi_buf_t buf;
657 int32_t len = sizeof(*cmd);
658
Govind Singhb53420c2016-03-09 14:32:57 +0530659 WMI_LOGD("%s: VDEV_UP", __func__);
660 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530661 params->vdev_id, params->assoc_id, bssid);
662 buf = wmi_buf_alloc(wmi, len);
663 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530664 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530665 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530666 }
667 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
668 WMITLV_SET_HDR(&cmd->tlv_header,
669 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
670 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
671 cmd->vdev_id = params->vdev_id;
672 cmd->vdev_assoc_id = params->assoc_id;
673 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
674 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530675 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530676 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530677 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530678 }
679
680 return 0;
681}
682
683/**
684 * send_peer_create_cmd_tlv() - send peer create command to fw
685 * @wmi: wmi handle
686 * @peer_addr: peer mac address
687 * @peer_type: peer type
688 * @vdev_id: vdev id
689 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530690 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530691 */
Govind Singhb53420c2016-03-09 14:32:57 +0530692QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530693 struct peer_create_params *param)
694{
695 wmi_peer_create_cmd_fixed_param *cmd;
696 wmi_buf_t buf;
697 int32_t len = sizeof(*cmd);
698
699 buf = wmi_buf_alloc(wmi, len);
700 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530701 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530702 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530703 }
704 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
705 WMITLV_SET_HDR(&cmd->tlv_header,
706 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
707 WMITLV_GET_STRUCT_TLVLEN
708 (wmi_peer_create_cmd_fixed_param));
709 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
710 cmd->peer_type = param->peer_type;
711 cmd->vdev_id = param->vdev_id;
712
713 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530714 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530715 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530716 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530717 }
Govind Singhb53420c2016-03-09 14:32:57 +0530718 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530719 param->vdev_id);
720
721 return 0;
722}
723
724/**
Leo Changeee40872016-09-28 13:43:36 -0700725 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
726 * command to fw
727 * @wmi: wmi handle
728 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
729 *
730 * Return: 0 for success or error code
731 */
732QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
733 struct rx_reorder_queue_setup_params *param)
734{
735 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
736 wmi_buf_t buf;
737 int32_t len = sizeof(*cmd);
738
739 buf = wmi_buf_alloc(wmi, len);
740 if (!buf) {
741 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
742 return QDF_STATUS_E_NOMEM;
743 }
744 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
745 WMITLV_SET_HDR(&cmd->tlv_header,
746 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
747 WMITLV_GET_STRUCT_TLVLEN
748 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
749 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
750 cmd->vdev_id = param->vdev_id;
751 cmd->tid = param->tid;
752 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
753 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
754 cmd->queue_no = param->queue_no;
755
756 if (wmi_unified_cmd_send(wmi, buf, len,
757 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
758 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
759 __func__);
760 qdf_nbuf_free(buf);
761 return QDF_STATUS_E_FAILURE;
762 }
763 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
764 param->peer_macaddr, param->vdev_id, param->tid);
765
766 return QDF_STATUS_SUCCESS;
767}
768
769/**
770 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
771 * command to fw
772 * @wmi: wmi handle
773 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
774 *
775 * Return: 0 for success or error code
776 */
777QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
778 struct rx_reorder_queue_remove_params *param)
779{
780 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
781 wmi_buf_t buf;
782 int32_t len = sizeof(*cmd);
783
784 buf = wmi_buf_alloc(wmi, len);
785 if (!buf) {
786 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
787 return QDF_STATUS_E_NOMEM;
788 }
789 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
790 wmi_buf_data(buf);
791 WMITLV_SET_HDR(&cmd->tlv_header,
792 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
793 WMITLV_GET_STRUCT_TLVLEN
794 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
795 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
796 cmd->vdev_id = param->vdev_id;
797 cmd->tid_mask = param->peer_tid_bitmap;
798
799 if (wmi_unified_cmd_send(wmi, buf, len,
800 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
801 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
802 __func__);
803 qdf_nbuf_free(buf);
804 return QDF_STATUS_E_FAILURE;
805 }
806 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
807 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
808
809 return QDF_STATUS_SUCCESS;
810}
811
812/**
Govind Singh5eb51532016-03-09 11:34:12 +0530813 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
814 * @wmi_handle: wmi handle
815 * @value: value
816 * @mac_id: mac id to have radio context
817 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530818 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530819 */
Govind Singhb53420c2016-03-09 14:32:57 +0530820QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530821 uint32_t value, uint8_t mac_id)
822{
823 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
824 wmi_buf_t buf;
825 int32_t len = sizeof(*cmd);
826
Govind Singhb53420c2016-03-09 14:32:57 +0530827 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530828
829 buf = wmi_buf_alloc(wmi_handle, len);
830 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530831 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530832 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530833 }
834
835 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
836 WMITLV_SET_HDR(&cmd->tlv_header,
837 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
838 WMITLV_GET_STRUCT_TLVLEN
839 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530840 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530841 cmd->enable = value;
842
843 if (wmi_unified_cmd_send(wmi_handle, buf, len,
844 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530845 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530846 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530847 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530848 }
849
850 return 0;
851}
852
853/**
854 * send_pdev_utf_cmd_tlv() - send utf command to fw
855 * @wmi_handle: wmi handle
856 * @param: pointer to pdev_utf_params
857 * @mac_id: mac id to have radio context
858 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530859 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530860 */
Govind Singhb53420c2016-03-09 14:32:57 +0530861QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530862send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
863 struct pdev_utf_params *param,
864 uint8_t mac_id)
865{
866 wmi_buf_t buf;
867 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -0700868 /* if param->len is 0 no data is sent, return error */
869 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +0530870 static uint8_t msgref = 1;
871 uint8_t segNumber = 0, segInfo, numSegments;
872 uint16_t chunk_len, total_bytes;
873 uint8_t *bufpos;
874 struct seg_hdr_info segHdrInfo;
875
876 bufpos = param->utf_payload;
877 total_bytes = param->len;
878 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
879 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
880 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
881
882 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
883 numSegments++;
884
885 while (param->len) {
886 if (param->len > MAX_WMI_UTF_LEN)
887 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
888 else
889 chunk_len = param->len;
890
891 buf = wmi_buf_alloc(wmi_handle,
892 (chunk_len + sizeof(segHdrInfo) +
893 WMI_TLV_HDR_SIZE));
894 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530895 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530896 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530897 }
898
899 cmd = (uint8_t *) wmi_buf_data(buf);
900
901 segHdrInfo.len = total_bytes;
902 segHdrInfo.msgref = msgref;
903 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
904 segHdrInfo.segmentInfo = segInfo;
905 segHdrInfo.pad = 0;
906
Govind Singhb53420c2016-03-09 14:32:57 +0530907 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +0530908 " segHdrInfo.segmentInfo = %d",
909 __func__, segHdrInfo.len, segHdrInfo.msgref,
910 segHdrInfo.segmentInfo);
911
Govind Singhb53420c2016-03-09 14:32:57 +0530912 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +0530913 "chunk len %d", __func__, total_bytes, segNumber,
914 numSegments, chunk_len);
915
916 segNumber++;
917
918 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
919 (chunk_len + sizeof(segHdrInfo)));
920 cmd += WMI_TLV_HDR_SIZE;
921 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
922 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
923
924 ret = wmi_unified_cmd_send(wmi_handle, buf,
925 (chunk_len + sizeof(segHdrInfo) +
926 WMI_TLV_HDR_SIZE),
927 WMI_PDEV_UTF_CMDID);
928
Govind Singh67922e82016-04-01 16:48:57 +0530929 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530930 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530931 wmi_buf_free(buf);
932 break;
933 }
934
935 param->len -= chunk_len;
936 bufpos += chunk_len;
937 }
938
939 msgref++;
940
941 return ret;
942}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530943#ifdef CONFIG_MCL
944static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
945 uint32_t host_param)
946{
947 return host_param;
948}
949#else
950static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
951 uint32_t host_param)
952{
953 if (host_param < wmi_pdev_param_max)
954 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +0530955
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530956 return WMI_UNAVAILABLE_PARAM;
957}
958#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530959/**
960 * send_pdev_param_cmd_tlv() - set pdev parameters
961 * @wmi_handle: wmi handle
962 * @param: pointer to pdev parameter
963 * @mac_id: radio context
964 *
965 * Return: 0 on success, errno on failure
966 */
Govind Singhb53420c2016-03-09 14:32:57 +0530967QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530968send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
969 struct pdev_params *param,
970 uint8_t mac_id)
971{
Govind Singh67922e82016-04-01 16:48:57 +0530972 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530973 wmi_pdev_set_param_cmd_fixed_param *cmd;
974 wmi_buf_t buf;
975 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530976 uint32_t pdev_param;
977
978 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
979 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
980 WMI_LOGW("%s: Unavailable param %d\n",
981 __func__, param->param_id);
982 return QDF_STATUS_E_INVAL;
983 }
Govind Singh5eb51532016-03-09 11:34:12 +0530984
985 buf = wmi_buf_alloc(wmi_handle, len);
986 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530987 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530988 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530989 }
990 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
991 WMITLV_SET_HDR(&cmd->tlv_header,
992 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
993 WMITLV_GET_STRUCT_TLVLEN
994 (wmi_pdev_set_param_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530995 cmd->pdev_id = 0;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530996 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +0530997 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +0530998 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530999 param->param_value);
1000 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1001 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301002 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301003 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301004 wmi_buf_free(buf);
1005 }
1006 return ret;
1007}
1008
1009/**
1010 * send_suspend_cmd_tlv() - WMI suspend function
1011 * @param wmi_handle : handle to WMI.
1012 * @param param : pointer to hold suspend parameter
1013 * @mac_id: radio context
1014 *
1015 * Return 0 on success and -ve on failure.
1016 */
Govind Singhb53420c2016-03-09 14:32:57 +05301017QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301018 struct suspend_params *param,
1019 uint8_t mac_id)
1020{
1021 wmi_pdev_suspend_cmd_fixed_param *cmd;
1022 wmi_buf_t wmibuf;
1023 uint32_t len = sizeof(*cmd);
1024 int32_t ret;
1025
1026 /*
1027 * send the comand to Target to ignore the
1028 * PCIE reset so as to ensure that Host and target
1029 * states are in sync
1030 */
1031 wmibuf = wmi_buf_alloc(wmi_handle, len);
1032 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301033 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301034
1035 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1036 WMITLV_SET_HDR(&cmd->tlv_header,
1037 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1038 WMITLV_GET_STRUCT_TLVLEN
1039 (wmi_pdev_suspend_cmd_fixed_param));
1040 if (param->disable_target_intr)
1041 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1042 else
1043 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1044 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1045 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301046 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301047 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301048 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301049 }
1050
1051 return ret;
1052}
1053
1054/**
1055 * send_resume_cmd_tlv() - WMI resume function
1056 * @param wmi_handle : handle to WMI.
1057 * @mac_id: radio context
1058 *
1059 * Return: 0 on success and -ve on failure.
1060 */
Govind Singhb53420c2016-03-09 14:32:57 +05301061QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301062 uint8_t mac_id)
1063{
1064 wmi_buf_t wmibuf;
1065 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301066 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301067
1068 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1069 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301070 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301071 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1072 WMITLV_SET_HDR(&cmd->tlv_header,
1073 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1074 WMITLV_GET_STRUCT_TLVLEN
1075 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07001076 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +05301077 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1078 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301079 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301080 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301081 wmi_buf_free(wmibuf);
1082 }
1083
1084 return ret;
1085}
1086
1087/**
1088 * send_wow_enable_cmd_tlv() - WMI wow enable function
1089 * @param wmi_handle : handle to WMI.
1090 * @param param : pointer to hold wow enable parameter
1091 * @mac_id: radio context
1092 *
1093 * Return: 0 on success and -ve on failure.
1094 */
Govind Singhb53420c2016-03-09 14:32:57 +05301095QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301096 struct wow_cmd_params *param,
1097 uint8_t mac_id)
1098{
1099 wmi_wow_enable_cmd_fixed_param *cmd;
1100 wmi_buf_t buf;
1101 int32_t len;
1102 int32_t ret;
1103
1104 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1105
1106 buf = wmi_buf_alloc(wmi_handle, len);
1107 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301108 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1109 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301110 }
1111 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1112 WMITLV_SET_HDR(&cmd->tlv_header,
1113 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1114 WMITLV_GET_STRUCT_TLVLEN
1115 (wmi_wow_enable_cmd_fixed_param));
1116 cmd->enable = param->enable;
1117 if (param->can_suspend_link)
1118 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1119 else
1120 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
1121
Govind Singhb53420c2016-03-09 14:32:57 +05301122 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301123 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1124 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1125
1126 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1127 WMI_WOW_ENABLE_CMDID);
1128 if (ret)
1129 wmi_buf_free(buf);
1130
1131 return ret;
1132}
1133
1134/**
1135 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301136 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301137 * @peer_addr: peer mac address
1138 * @param: pointer to ap_ps parameter structure
1139 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301140 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301141 */
Govind Singhb53420c2016-03-09 14:32:57 +05301142QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301143 uint8_t *peer_addr,
1144 struct ap_ps_params *param)
1145{
1146 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1147 wmi_buf_t buf;
1148 int32_t err;
1149
1150 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1151 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301152 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301153 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301154 }
1155 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1156 WMITLV_SET_HDR(&cmd->tlv_header,
1157 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1158 WMITLV_GET_STRUCT_TLVLEN
1159 (wmi_ap_ps_peer_cmd_fixed_param));
1160 cmd->vdev_id = param->vdev_id;
1161 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1162 cmd->param = param->param;
1163 cmd->value = param->value;
1164 err = wmi_unified_cmd_send(wmi_handle, buf,
1165 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1166 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301167 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301168 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301169 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301170 }
1171
1172 return 0;
1173}
1174
1175/**
1176 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301177 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301178 * @peer_addr: peer mac address
1179 * @param: pointer to sta_ps parameter structure
1180 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301181 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301182 */
Govind Singhb53420c2016-03-09 14:32:57 +05301183QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301184 struct sta_ps_params *param)
1185{
1186 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1187 wmi_buf_t buf;
1188 int32_t len = sizeof(*cmd);
1189
1190 buf = wmi_buf_alloc(wmi_handle, len);
1191 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301192 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301193 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301194 }
1195
1196 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1197 WMITLV_SET_HDR(&cmd->tlv_header,
1198 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1199 WMITLV_GET_STRUCT_TLVLEN
1200 (wmi_sta_powersave_param_cmd_fixed_param));
1201 cmd->vdev_id = param->vdev_id;
1202 cmd->param = param->param;
1203 cmd->value = param->value;
1204
1205 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1206 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301207 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301208 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301209 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301210 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301211 }
1212
1213 return 0;
1214}
1215
1216/**
1217 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301218 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301219 * @param: ponirt to crash inject paramter structure
1220 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301221 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301222 */
Govind Singhb53420c2016-03-09 14:32:57 +05301223QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301224 struct crash_inject *param)
1225{
1226 int32_t ret = 0;
1227 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1228 uint16_t len = sizeof(*cmd);
1229 wmi_buf_t buf;
1230
1231 buf = wmi_buf_alloc(wmi_handle, len);
1232 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301233 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301234 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301235 }
1236
1237 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1238 WMITLV_SET_HDR(&cmd->tlv_header,
1239 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1240 WMITLV_GET_STRUCT_TLVLEN
1241 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1242 cmd->type = param->type;
1243 cmd->delay_time_ms = param->delay_time_ms;
1244
1245 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1246 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301247 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301248 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301249 __func__, ret);
1250 wmi_buf_free(buf);
1251 }
1252
1253 return ret;
1254}
1255
1256/**
1257 * send_dbglog_cmd_tlv() - set debug log level
1258 * @param wmi_handle : handle to WMI.
1259 * @param param : pointer to hold dbglog level parameter
1260 *
1261 * Return: 0 on success and -ve on failure.
1262 */
Govind Singhb53420c2016-03-09 14:32:57 +05301263QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301264send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1265 struct dbglog_params *dbglog_param)
1266{
1267 wmi_buf_t buf;
1268 wmi_debug_log_config_cmd_fixed_param *configmsg;
1269 A_STATUS status = A_OK;
1270 int32_t i;
1271 int32_t len;
1272 int8_t *buf_ptr;
1273 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1274
1275 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1276
1277 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1278 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1279 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1280 buf = wmi_buf_alloc(wmi_handle, len);
1281 if (buf == NULL)
1282 return A_NO_MEMORY;
1283
1284 configmsg =
1285 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1286 buf_ptr = (int8_t *) configmsg;
1287 WMITLV_SET_HDR(&configmsg->tlv_header,
1288 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1289 WMITLV_GET_STRUCT_TLVLEN
1290 (wmi_debug_log_config_cmd_fixed_param));
1291 configmsg->dbg_log_param = dbglog_param->param;
1292 configmsg->value = dbglog_param->val;
1293 /* Filling in the data part of second tlv -- should
1294 * follow first tlv _ WMI_TLV_HDR_SIZE */
1295 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1296 sizeof
1297 (wmi_debug_log_config_cmd_fixed_param)
1298 + WMI_TLV_HDR_SIZE);
1299 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1300 WMITLV_TAG_ARRAY_UINT32,
1301 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1302 if (dbglog_param->module_id_bitmap) {
1303 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1304 module_id_bitmap_array[i] =
1305 dbglog_param->module_id_bitmap[i];
1306 }
1307 }
1308
1309 status = wmi_unified_cmd_send(wmi_handle, buf,
1310 len, WMI_DBGLOG_CFG_CMDID);
1311
1312 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301313 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301314
1315 return status;
1316}
1317
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301318#ifdef CONFIG_MCL
1319static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1320 uint32_t host_param)
1321{
1322 return host_param;
1323}
1324#else
1325static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1326 uint32_t host_param)
1327{
1328 if (host_param < wmi_vdev_param_max)
1329 return wmi_handle->vdev_param[host_param];
1330
1331 return WMI_UNAVAILABLE_PARAM;
1332}
1333#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301334/**
1335 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1336 * @param wmi_handle : handle to WMI.
1337 * @param macaddr : MAC address
1338 * @param param : pointer to hold vdev set parameter
1339 *
1340 * Return: 0 on success and -ve on failure.
1341 */
Govind Singhb53420c2016-03-09 14:32:57 +05301342QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301343 struct vdev_set_params *param)
1344{
Govind Singh67922e82016-04-01 16:48:57 +05301345 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301346 wmi_vdev_set_param_cmd_fixed_param *cmd;
1347 wmi_buf_t buf;
1348 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301349 uint32_t vdev_param;
1350
1351 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1352 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1353 WMI_LOGW("%s:Vdev param %d not available", __func__,
1354 param->param_id);
1355 return QDF_STATUS_E_INVAL;
1356
1357 }
Govind Singh5eb51532016-03-09 11:34:12 +05301358
1359 buf = wmi_buf_alloc(wmi_handle, len);
1360 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301361 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301362 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301363 }
1364 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1365 WMITLV_SET_HDR(&cmd->tlv_header,
1366 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1367 WMITLV_GET_STRUCT_TLVLEN
1368 (wmi_vdev_set_param_cmd_fixed_param));
1369 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301370 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301371 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301372 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301373 param->if_id, param->param_id, param->param_value);
1374 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1375 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301376 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301377 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301378 wmi_buf_free(buf);
1379 }
1380
1381 return ret;
1382}
1383
1384/**
1385 * send_stats_request_cmd_tlv() - WMI request stats function
1386 * @param wmi_handle : handle to WMI.
1387 * @param macaddr : MAC address
1388 * @param param : pointer to hold stats request parameter
1389 *
1390 * Return: 0 on success and -ve on failure.
1391 */
Govind Singhb53420c2016-03-09 14:32:57 +05301392QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301393 uint8_t macaddr[IEEE80211_ADDR_LEN],
1394 struct stats_request_params *param)
1395{
Govind Singhd3156eb2016-02-26 17:50:39 +05301396 int32_t ret;
1397 wmi_request_stats_cmd_fixed_param *cmd;
1398 wmi_buf_t buf;
1399 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1400
1401 buf = wmi_buf_alloc(wmi_handle, len);
1402 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301403 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1404 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301405 }
1406
1407 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1408 WMITLV_SET_HDR(&cmd->tlv_header,
1409 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1410 WMITLV_GET_STRUCT_TLVLEN
1411 (wmi_request_stats_cmd_fixed_param));
1412 cmd->stats_id = param->stats_id;
1413 cmd->vdev_id = param->vdev_id;
1414 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1415 WMI_REQUEST_STATS_CMDID);
1416 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301417 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301418 wmi_buf_free(buf);
1419 }
1420
1421 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301422}
1423
Govind Singh87542482016-06-08 19:40:11 +05301424#ifdef CONFIG_WIN
1425/**
1426 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1427 * @param wmi_handle : handle to WMI.
1428 * @param macaddr : MAC address
1429 * @param param : pointer to hold stats request parameter
1430 *
1431 * Return: 0 on success and -ve on failure.
1432 */
1433QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
1434 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1435{
1436 return 0;
1437}
1438#else
Govind Singh5eb51532016-03-09 11:34:12 +05301439/**
1440 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1441 * @param wmi_handle : handle to WMI.
1442 * @param macaddr : MAC address
1443 * @param param : pointer to hold stats request parameter
1444 *
1445 * Return: 0 on success and -ve on failure.
1446 */
Govind Singhb53420c2016-03-09 14:32:57 +05301447QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301448 uint8_t macaddr[IEEE80211_ADDR_LEN],
1449 struct packet_enable_params *param)
1450{
1451 return 0;
1452}
Govind Singh87542482016-06-08 19:40:11 +05301453#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301454
Govind Singh87542482016-06-08 19:40:11 +05301455#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301456/**
1457 * send_beacon_send_cmd_tlv() - WMI beacon send function
1458 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301459 * @param param : pointer to hold beacon send cmd parameter
1460 *
1461 * Return: 0 on success and -ve on failure.
1462 */
Govind Singhb53420c2016-03-09 14:32:57 +05301463QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301464 struct beacon_params *param)
1465{
Govind Singhd3156eb2016-02-26 17:50:39 +05301466 int32_t ret;
1467 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1468 wmi_bcn_prb_info *bcn_prb_info;
1469 wmi_buf_t wmi_buf;
1470 uint8_t *buf_ptr;
1471 uint32_t wmi_buf_len;
1472
1473 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1474 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1475 param->tmpl_len_aligned;
1476 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1477 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301478 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301479 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301480 }
1481 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1482 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1483 WMITLV_SET_HDR(&cmd->tlv_header,
1484 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1485 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1486 cmd->vdev_id = param->vdev_id;
1487 cmd->tim_ie_offset = param->tim_ie_offset;
1488 cmd->buf_len = param->tmpl_len;
1489 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1490
1491 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1492 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1493 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1494 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1495 bcn_prb_info->caps = 0;
1496 bcn_prb_info->erp = 0;
1497 buf_ptr += sizeof(wmi_bcn_prb_info);
1498
1499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1500 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301501 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301502
1503 ret = wmi_unified_cmd_send(wmi_handle,
1504 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1505 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301506 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301507 wmi_buf_free(wmi_buf);
1508 }
Govind Singh5eb51532016-03-09 11:34:12 +05301509 return 0;
1510}
Govind Singh87542482016-06-08 19:40:11 +05301511#else
1512QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
1513 struct beacon_params *param)
1514{
1515 return 0;
1516}
1517
1518/**
1519 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1520 * @param wmi_handle : handle to WMI.
1521 * @param param : pointer to hold beacon send cmd parameter
1522 *
1523 * Return: 0 on success and -ve on failure.
1524 */
1525QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
1526 struct beacon_tmpl_params *param)
1527{
1528 int32_t ret;
1529 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1530 wmi_bcn_prb_info *bcn_prb_info;
1531 wmi_buf_t wmi_buf;
1532 uint8_t *buf_ptr;
1533 uint32_t wmi_buf_len;
1534
1535 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1536 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1537 param->tmpl_len_aligned;
1538 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1539 if (!wmi_buf) {
1540 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1541 return QDF_STATUS_E_NOMEM;
1542 }
1543 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1544 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1545 WMITLV_SET_HDR(&cmd->tlv_header,
1546 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1547 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1548 cmd->vdev_id = param->vdev_id;
1549 cmd->tim_ie_offset = param->tim_ie_offset;
1550 cmd->buf_len = param->tmpl_len;
1551 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1552
1553 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1554 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1555 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1556 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1557 bcn_prb_info->caps = 0;
1558 bcn_prb_info->erp = 0;
1559 buf_ptr += sizeof(wmi_bcn_prb_info);
1560
1561 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1562 buf_ptr += WMI_TLV_HDR_SIZE;
1563 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1564
1565 ret = wmi_unified_cmd_send(wmi_handle,
1566 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1567 if (ret) {
1568 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1569 wmi_buf_free(wmi_buf);
1570 }
1571 return 0;
1572}
1573#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301574
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301575#ifdef CONFIG_MCL
1576static inline void copy_peer_flags_tlv(
1577 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1578 struct peer_assoc_params *param)
1579{
1580 cmd->peer_flags = param->peer_flags;
1581}
1582#else
1583static inline void copy_peer_flags_tlv(
1584 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1585 struct peer_assoc_params *param)
1586{
1587 /*
1588 * The target only needs a subset of the flags maintained in the host.
1589 * Just populate those flags and send it down
1590 */
1591 cmd->peer_flags = 0;
1592
1593 /*
1594 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1595 */
1596 if (param->is_wme_set) {
1597
1598 if (param->qos_flag)
1599 cmd->peer_flags |= WMI_PEER_QOS;
1600 if (param->apsd_flag)
1601 cmd->peer_flags |= WMI_PEER_APSD;
1602 if (param->ht_flag)
1603 cmd->peer_flags |= WMI_PEER_HT;
1604 if (param->bw_40)
1605 cmd->peer_flags |= WMI_PEER_40MHZ;
1606 if (param->bw_80)
1607 cmd->peer_flags |= WMI_PEER_80MHZ;
1608 if (param->bw_160)
1609 cmd->peer_flags |= WMI_PEER_160MHZ;
1610
1611 /* Typically if STBC is enabled for VHT it should be enabled
1612 * for HT as well
1613 **/
1614 if (param->stbc_flag)
1615 cmd->peer_flags |= WMI_PEER_STBC;
1616
1617 /* Typically if LDPC is enabled for VHT it should be enabled
1618 * for HT as well
1619 **/
1620 if (param->ldpc_flag)
1621 cmd->peer_flags |= WMI_PEER_LDPC;
1622
1623 if (param->static_mimops_flag)
1624 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1625 if (param->dynamic_mimops_flag)
1626 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1627 if (param->spatial_mux_flag)
1628 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1629 if (param->vht_flag)
1630 cmd->peer_flags |= WMI_PEER_VHT;
1631 }
1632 /*
1633 * Suppress authorization for all AUTH modes that need 4-way handshake
1634 * (during re-association).
1635 * Authorization will be done for these modes on key installation.
1636 */
1637 if (param->auth_flag)
1638 cmd->peer_flags |= WMI_PEER_AUTH;
1639 if (param->need_ptk_4_way)
1640 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1641 else
1642 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1643 if (param->need_gtk_2_way)
1644 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1645 /* safe mode bypass the 4-way handshake */
1646 if (param->safe_mode_enabled)
1647 cmd->peer_flags &=
1648 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1649 /* Disable AMSDU for station transmit, if user configures it */
1650 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1651 * it
1652 * if (param->amsdu_disable) Add after FW support
1653 **/
1654
1655 /* Target asserts if node is marked HT and all MCS is set to 0.
1656 * Mark the node as non-HT if all the mcs rates are disabled through
1657 * iwpriv
1658 **/
1659 if (param->peer_ht_rates.num_rates == 0)
1660 cmd->peer_flags &= ~WMI_PEER_HT;
1661}
1662#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301663/**
1664 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1665 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301666 * @param param : pointer to peer assoc parameter
1667 *
1668 * Return: 0 on success and -ve on failure.
1669 */
Govind Singhb53420c2016-03-09 14:32:57 +05301670QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301671 struct peer_assoc_params *param)
1672{
Govind Singhd3156eb2016-02-26 17:50:39 +05301673 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1674 wmi_vht_rate_set *mcs;
1675 wmi_buf_t buf;
1676 int32_t len;
1677 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301678 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301679 uint32_t peer_legacy_rates_align;
1680 uint32_t peer_ht_rates_align;
1681
1682
1683 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1684 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301685
1686 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301687 (peer_legacy_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301688 WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301689 (peer_ht_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301690 sizeof(wmi_vht_rate_set);
1691
1692 buf = wmi_buf_alloc(wmi_handle, len);
1693 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301694 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301695 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301696 }
1697
1698 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1699 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1700 WMITLV_SET_HDR(&cmd->tlv_header,
1701 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1702 WMITLV_GET_STRUCT_TLVLEN
1703 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301704
Govind Singhd3156eb2016-02-26 17:50:39 +05301705 cmd->vdev_id = param->vdev_id;
Govind Singh3419aea2016-03-28 22:02:42 +05301706 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1707 sizeof(param->peer_macaddr));
Govind Singhd3156eb2016-02-26 17:50:39 +05301708 cmd->peer_new_assoc = param->peer_new_assoc;
1709 cmd->peer_associd = param->peer_associd;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301710 copy_peer_flags_tlv(cmd, param);
Govind Singhd3156eb2016-02-26 17:50:39 +05301711 cmd->peer_rate_caps = param->peer_rate_caps;
1712 cmd->peer_caps = param->peer_caps;
1713 cmd->peer_listen_intval = param->peer_listen_intval;
1714 cmd->peer_ht_caps = param->peer_ht_caps;
1715 cmd->peer_max_mpdu = param->peer_max_mpdu;
1716 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301717 cmd->peer_vht_caps = param->peer_vht_caps;
1718 cmd->peer_phymode = param->peer_phymode;
1719
1720 /* Update peer legacy rate information */
1721 buf_ptr += sizeof(*cmd);
1722 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301723 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301724 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301725 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301726 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301727 param->peer_legacy_rates.num_rates);
1728
1729 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001730 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301731 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301732 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301733 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301734 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301735 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301736 param->peer_ht_rates.num_rates);
1737
1738 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001739 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301740 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1741 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1742
1743 cmd->peer_nss = param->peer_nss;
1744 mcs = (wmi_vht_rate_set *) buf_ptr;
1745 if (param->vht_capable) {
1746 mcs->rx_max_rate = param->rx_max_rate;
1747 mcs->rx_mcs_set = param->rx_mcs_set;
1748 mcs->tx_max_rate = param->tx_max_rate;
1749 mcs->tx_mcs_set = param->tx_mcs_set;
1750 }
1751
Govind Singhb53420c2016-03-09 14:32:57 +05301752 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301753 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1754 "nss %d phymode %d peer_mpdu_density %d "
1755 "cmd->peer_vht_caps %x", __func__,
1756 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1757 cmd->peer_rate_caps, cmd->peer_caps,
1758 cmd->peer_listen_intval, cmd->peer_ht_caps,
1759 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1760 cmd->peer_mpdu_density,
1761 cmd->peer_vht_caps);
1762
1763 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1764 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301765 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301766 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301767 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301768 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301769 }
1770
1771 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301772}
1773
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301774/* copy_scan_notify_events() - Helper routine to copy scan notify events
1775 */
1776#ifdef CONFIG_MCL
1777static inline void copy_scan_notify_ev_flags(
1778 wmi_start_scan_cmd_fixed_param * cmd,
1779 struct scan_start_params *params)
1780{
1781 cmd->notify_scan_events = params->notify_scan_events;
1782 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1783}
1784#else
1785static inline void copy_scan_notify_ev_flags(
1786 wmi_start_scan_cmd_fixed_param * cmd,
1787 struct scan_start_params *params)
1788{
1789 cmd->notify_scan_events = WMI_SCAN_EVENT_STARTED |
1790 WMI_SCAN_EVENT_COMPLETED |
1791 WMI_SCAN_EVENT_BSS_CHANNEL |
1792 WMI_SCAN_EVENT_FOREIGN_CHANNEL |
1793 WMI_SCAN_EVENT_DEQUEUED
1794 ;
1795 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1796 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
1797
1798 if (params->is_phy_error)
1799 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
1800}
1801#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301802/**
1803 * send_scan_start_cmd_tlv() - WMI scan start function
1804 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301805 * @param param : pointer to hold scan start cmd parameter
1806 *
1807 * Return: 0 on success and -ve on failure.
1808 */
Govind Singhb53420c2016-03-09 14:32:57 +05301809QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301810 struct scan_start_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05301811{
Govind Singhd3156eb2016-02-26 17:50:39 +05301812 int32_t ret = 0;
1813 int32_t i;
1814 wmi_buf_t wmi_buf;
1815 wmi_start_scan_cmd_fixed_param *cmd;
1816 uint8_t *buf_ptr;
1817 uint32_t *tmp_ptr;
1818 wmi_ssid *ssid = NULL;
1819 wmi_mac_addr *bssid;
1820 int len = sizeof(*cmd);
1821
1822 /* Length TLV placeholder for array of uint32_t */
1823 len += WMI_TLV_HDR_SIZE;
1824 /* calculate the length of buffer required */
1825 if (params->num_chan)
1826 len += params->num_chan * sizeof(uint32_t);
1827
1828 /* Length TLV placeholder for array of wmi_ssid structures */
1829 len += WMI_TLV_HDR_SIZE;
1830 if (params->num_ssids)
1831 len += params->num_ssids * sizeof(wmi_ssid);
1832
1833 /* Length TLV placeholder for array of wmi_mac_addr structures */
1834 len += WMI_TLV_HDR_SIZE;
1835 len += sizeof(wmi_mac_addr);
1836
1837 /* Length TLV placeholder for array of bytes */
1838 len += WMI_TLV_HDR_SIZE;
1839 if (params->ie_len)
1840 len += roundup(params->ie_len, sizeof(uint32_t));
1841
1842 /* Allocate the memory */
1843 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1844 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301845 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301846 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05301847 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05301848 }
1849 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1850 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
1851 WMITLV_SET_HDR(&cmd->tlv_header,
1852 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
1853 WMITLV_GET_STRUCT_TLVLEN
1854 (wmi_start_scan_cmd_fixed_param));
1855
1856 cmd->scan_id = params->scan_id;
1857 cmd->scan_req_id = params->scan_req_id;
1858 cmd->vdev_id = params->vdev_id;
1859 cmd->scan_priority = params->scan_priority;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301860 copy_scan_notify_ev_flags(cmd, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05301861 cmd->dwell_time_active = params->dwell_time_active;
1862 cmd->dwell_time_passive = params->dwell_time_passive;
1863 cmd->min_rest_time = params->min_rest_time;
1864 cmd->max_rest_time = params->max_rest_time;
1865 cmd->repeat_probe_time = params->repeat_probe_time;
1866 cmd->probe_spacing_time = params->probe_spacing_time;
1867 cmd->idle_time = params->idle_time;
1868 cmd->max_scan_time = params->max_scan_time;
1869 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05301870 cmd->burst_duration = params->burst_duration;
1871 cmd->num_chan = params->num_chan;
1872 cmd->num_bssid = params->num_bssid;
1873 cmd->num_ssids = params->num_ssids;
1874 cmd->ie_len = params->ie_len;
1875 cmd->n_probes = params->n_probes;
1876 buf_ptr += sizeof(*cmd);
1877 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
1878 for (i = 0; i < params->num_chan; ++i)
1879 tmp_ptr[i] = params->chan_list[i];
1880
1881 WMITLV_SET_HDR(buf_ptr,
1882 WMITLV_TAG_ARRAY_UINT32,
1883 (params->num_chan * sizeof(uint32_t)));
1884 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05301885 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05301886 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05301887 goto error;
1888 }
1889
1890 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1891 (params->num_ssids * sizeof(wmi_ssid)));
1892
1893 if (params->num_ssids) {
1894 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
1895 for (i = 0; i < params->num_ssids; ++i) {
1896 ssid->ssid_len = params->ssid[i].length;
Govind Singhb53420c2016-03-09 14:32:57 +05301897 qdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05301898 params->ssid[i].length);
1899 ssid++;
1900 }
1901 }
1902 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
1903
1904 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1905 (params->num_bssid * sizeof(wmi_mac_addr)));
1906 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
1907 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
1908 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
1909
1910 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, params->ie_len_with_pad);
1911 if (params->ie_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05301912 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singhd3156eb2016-02-26 17:50:39 +05301913 (uint8_t *) params->ie_base +
1914 (params->uie_fieldOffset), params->ie_len);
1915 }
1916 buf_ptr += WMI_TLV_HDR_SIZE + params->ie_len_with_pad;
1917
1918 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1919 len, WMI_START_SCAN_CMDID);
1920 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301921 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301922 wmi_buf_free(wmi_buf);
1923 }
1924 return ret;
1925error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05301926 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05301927 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301928}
1929
1930/**
1931 * send_scan_stop_cmd_tlv() - WMI scan start function
1932 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301933 * @param param : pointer to hold scan start cmd parameter
1934 *
1935 * Return: 0 on success and -ve on failure.
1936 */
Govind Singhb53420c2016-03-09 14:32:57 +05301937QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301938 struct scan_stop_params *param)
1939{
Govind Singhd3156eb2016-02-26 17:50:39 +05301940 wmi_stop_scan_cmd_fixed_param *cmd;
1941 int ret;
1942 int len = sizeof(*cmd);
1943 wmi_buf_t wmi_buf;
1944
1945 /* Allocate the memory */
1946 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1947 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301948 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301949 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301950 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301951 goto error;
1952 }
1953
1954 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1955 WMITLV_SET_HDR(&cmd->tlv_header,
1956 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
1957 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
1958 cmd->vdev_id = param->vdev_id;
1959 cmd->requestor = param->requestor;
1960 cmd->scan_id = param->scan_id;
1961 /* stop the scan with the corresponding scan_id */
1962 cmd->req_type = param->req_type;
1963 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1964 len, WMI_STOP_SCAN_CMDID);
1965 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301966 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301967 wmi_buf_free(wmi_buf);
1968 }
1969
1970error:
1971 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301972}
1973
Govind Singh87542482016-06-08 19:40:11 +05301974#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301975/**
1976 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
1977 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301978 * @param param : pointer to hold scan channel list parameter
1979 *
1980 * Return: 0 on success and -ve on failure.
1981 */
Govind Singhb53420c2016-03-09 14:32:57 +05301982QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301983 struct scan_chan_list_params *chan_list)
1984{
1985 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05301986 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05301987 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301988 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05301989 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05301990 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05301991 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
1992
1993 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
1994 buf = wmi_buf_alloc(wmi_handle, len);
1995 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301996 WMI_LOGE("Failed to allocate memory");
1997 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301998 goto end;
1999 }
2000
2001 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2002 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2003 WMITLV_SET_HDR(&cmd->tlv_header,
2004 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2005 WMITLV_GET_STRUCT_TLVLEN
2006 (wmi_scan_chan_list_cmd_fixed_param));
2007
Govind Singhb53420c2016-03-09 14:32:57 +05302008 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302009
2010 cmd->num_scan_chans = chan_list->num_scan_chans;
2011 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2012 WMITLV_TAG_ARRAY_STRUC,
2013 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302014 chan_info = (wmi_channel_param *)
2015 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302016 tchan_info = chan_list->chan_info;
2017
2018 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2019 WMITLV_SET_HDR(&chan_info->tlv_header,
2020 WMITLV_TAG_STRUC_wmi_channel,
2021 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2022 chan_info->mhz = tchan_info->mhz;
2023 chan_info->band_center_freq1 =
2024 tchan_info->band_center_freq1;
2025 chan_info->band_center_freq2 =
2026 tchan_info->band_center_freq2;
2027 chan_info->info = tchan_info->info;
2028 chan_info->reg_info_1 = tchan_info->reg_info_1;
2029 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302030 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302031
2032 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2033 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2034 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2035 tchan_info++;
2036 chan_info++;
2037 }
2038
Govind Singh67922e82016-04-01 16:48:57 +05302039 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singhd3156eb2016-02-26 17:50:39 +05302040 WMI_SCAN_CHAN_LIST_CMDID);
2041
Govind Singh67922e82016-04-01 16:48:57 +05302042 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302043 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302044 wmi_buf_free(buf);
2045 }
Govind Singh67922e82016-04-01 16:48:57 +05302046
Govind Singhd3156eb2016-02-26 17:50:39 +05302047end:
Govind Singhb53420c2016-03-09 14:32:57 +05302048 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302049}
Govind Singh87542482016-06-08 19:40:11 +05302050#else
2051QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
2052 struct scan_chan_list_params *chan_list)
2053{
2054 wmi_buf_t buf;
2055 QDF_STATUS qdf_status;
2056 wmi_scan_chan_list_cmd_fixed_param *cmd;
2057 int i;
2058 uint8_t *buf_ptr;
2059 wmi_channel *chan_info;
2060 struct channel_param *tchan_info;
2061 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302062
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302063 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302064 buf = wmi_buf_alloc(wmi_handle, len);
2065 if (!buf) {
2066 WMI_LOGE("Failed to allocate memory");
2067 qdf_status = QDF_STATUS_E_NOMEM;
2068 goto end;
2069 }
2070
2071 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2072 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2073 WMITLV_SET_HDR(&cmd->tlv_header,
2074 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2075 WMITLV_GET_STRUCT_TLVLEN
2076 (wmi_scan_chan_list_cmd_fixed_param));
2077
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302078 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302079
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302080 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302081 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2082 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302083 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302084 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2085 tchan_info = &(chan_list->ch_param[0]);
2086
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302087 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302088 WMITLV_SET_HDR(&chan_info->tlv_header,
2089 WMITLV_TAG_STRUC_wmi_channel,
2090 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2091 chan_info->mhz = tchan_info->mhz;
2092 chan_info->band_center_freq1 =
2093 tchan_info->cfreq1;
2094 chan_info->band_center_freq2 =
2095 tchan_info->cfreq2;
2096
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302097 if (tchan_info->is_chan_passive)
2098 WMI_SET_CHANNEL_FLAG(chan_info,
2099 WMI_CHAN_FLAG_PASSIVE);
2100
2101 if (tchan_info->allow_vht)
2102 WMI_SET_CHANNEL_FLAG(chan_info,
2103 WMI_CHAN_FLAG_ALLOW_VHT);
2104 else if (tchan_info->allow_ht)
2105 WMI_SET_CHANNEL_FLAG(chan_info,
2106 WMI_CHAN_FLAG_ALLOW_HT);
2107 WMI_SET_CHANNEL_MODE(chan_info,
2108 tchan_info->phy_mode);
2109
2110 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2111 * after FW support
2112 */
2113
2114 /* also fill in power information */
2115 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2116 tchan_info->minpower);
2117 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2118 tchan_info->maxpower);
2119 WMI_SET_CHANNEL_REG_POWER(chan_info,
2120 tchan_info->maxregpower);
2121 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2122 tchan_info->antennamax);
2123 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2124 tchan_info->reg_class_id);
2125
Govind Singh87542482016-06-08 19:40:11 +05302126 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2127
Govind Singh87542482016-06-08 19:40:11 +05302128 tchan_info++;
2129 chan_info++;
2130 }
2131
2132 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
2133 WMI_SCAN_CHAN_LIST_CMDID);
2134
2135 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2136 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2137 wmi_buf_free(buf);
2138 }
2139
2140end:
2141 return qdf_status;
2142}
2143#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302144/**
2145 * send_mgmt_cmd_tlv() - WMI scan start function
2146 * @wmi_handle : handle to WMI.
2147 * @param : pointer to hold mgmt cmd parameter
2148 *
2149 * Return: 0 on success and -ve on failure.
2150 */
Govind Singhb53420c2016-03-09 14:32:57 +05302151QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302152 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302153{
Govind Singh427ee5a2016-02-26 18:09:36 +05302154 wmi_buf_t buf;
2155 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2156 int32_t cmd_len;
2157 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302158 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302159 uint8_t *bufp;
2160 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2161 mgmt_tx_dl_frm_len;
2162
2163 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2164 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2165
2166 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2167 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302168 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2169 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302170 }
2171
2172 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2173 bufp = (uint8_t *) cmd;
2174 WMITLV_SET_HDR(&cmd->tlv_header,
2175 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2176 WMITLV_GET_STRUCT_TLVLEN
2177 (wmi_mgmt_tx_send_cmd_fixed_param));
2178
2179 cmd->vdev_id = param->vdev_id;
2180
Govind Singh224a7312016-06-21 14:33:26 +05302181 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302182 cmd->chanfreq = param->chanfreq;
2183 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2184 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2185 sizeof(uint32_t)));
2186 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302187 qdf_mem_copy(bufp, param->pdata, bufp_len);
2188 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2189 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302190 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2191#if defined(HELIUMPLUS_PADDR64)
2192 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2193#endif
2194 cmd->frame_len = param->frm_len;
2195 cmd->buf_len = bufp_len;
2196
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002197 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002198 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002199
Govind Singh427ee5a2016-02-26 18:09:36 +05302200 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2201 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302202 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302203 goto err1;
2204 }
Govind Singhb53420c2016-03-09 14:32:57 +05302205 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302206
2207err1:
2208 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302209 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302210}
2211
2212/**
2213 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2214 * @wmi_handle: wmi handle
2215 * @param_value: parameter value
2216 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302217 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302218 */
Govind Singhb53420c2016-03-09 14:32:57 +05302219QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302220 uint32_t param_value)
2221{
Govind Singh67922e82016-04-01 16:48:57 +05302222 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302223 wmi_modem_power_state_cmd_param *cmd;
2224 wmi_buf_t buf;
2225 uint16_t len = sizeof(*cmd);
2226
2227 buf = wmi_buf_alloc(wmi_handle, len);
2228 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302229 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302230 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302231 }
2232 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2233 WMITLV_SET_HDR(&cmd->tlv_header,
2234 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2235 WMITLV_GET_STRUCT_TLVLEN
2236 (wmi_modem_power_state_cmd_param));
2237 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302238 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302239 param_value);
2240 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2241 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302242 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302243 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302244 wmi_buf_free(buf);
2245 }
Govind Singh67922e82016-04-01 16:48:57 +05302246
Govind Singh427ee5a2016-02-26 18:09:36 +05302247 return ret;
2248}
2249
2250/**
2251 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2252 * @wmi_handle: wmi handle
2253 * @vdev_id: vdev id
2254 * @val: value
2255 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302256 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302257 */
Govind Singhb53420c2016-03-09 14:32:57 +05302258QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302259 uint32_t vdev_id, uint8_t val)
2260{
2261 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2262 wmi_buf_t buf;
2263 int32_t len = sizeof(*cmd);
2264
Govind Singhb53420c2016-03-09 14:32:57 +05302265 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302266
2267 buf = wmi_buf_alloc(wmi_handle, len);
2268 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302269 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302270 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302271 }
2272 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2273 WMITLV_SET_HDR(&cmd->tlv_header,
2274 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2275 WMITLV_GET_STRUCT_TLVLEN
2276 (wmi_sta_powersave_mode_cmd_fixed_param));
2277 cmd->vdev_id = vdev_id;
2278 if (val)
2279 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2280 else
2281 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2282
2283 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2284 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302285 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302286 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302287 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302288 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302289 }
Govind Singh5eb51532016-03-09 11:34:12 +05302290 return 0;
2291}
2292
Govind Singh427ee5a2016-02-26 18:09:36 +05302293/**
2294 * send_set_mimops_cmd_tlv() - set MIMO powersave
2295 * @wmi_handle: wmi handle
2296 * @vdev_id: vdev id
2297 * @value: value
2298 *
Govind Singhb53420c2016-03-09 14:32:57 +05302299 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302300 */
Govind Singhb53420c2016-03-09 14:32:57 +05302301QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302302 uint8_t vdev_id, int value)
2303{
Govind Singh67922e82016-04-01 16:48:57 +05302304 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302305 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2306 wmi_buf_t buf;
2307 uint16_t len = sizeof(*cmd);
2308
2309 buf = wmi_buf_alloc(wmi_handle, len);
2310 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302311 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302312 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302313 }
2314 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2315 WMITLV_SET_HDR(&cmd->tlv_header,
2316 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2317 WMITLV_GET_STRUCT_TLVLEN
2318 (wmi_sta_smps_force_mode_cmd_fixed_param));
2319
2320 cmd->vdev_id = vdev_id;
2321
Houston Hoffmanb5168052016-04-14 02:18:01 -07002322 /* WMI_SMPS_FORCED_MODE values do not directly map
2323 * to SM power save values defined in the specification.
2324 * Make sure to send the right mapping.
2325 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302326 switch (value) {
2327 case 0:
2328 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2329 break;
2330 case 1:
2331 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2332 break;
2333 case 2:
2334 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2335 break;
2336 case 3:
2337 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2338 break;
2339 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302340 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2341 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302342 }
2343
Govind Singhb53420c2016-03-09 14:32:57 +05302344 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302345
2346 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2347 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302348 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302349 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302350 wmi_buf_free(buf);
2351 }
2352
2353 return ret;
2354}
2355
2356/**
2357 * send_set_smps_params_cmd_tlv() - set smps params
2358 * @wmi_handle: wmi handle
2359 * @vdev_id: vdev id
2360 * @value: value
2361 *
Govind Singhb53420c2016-03-09 14:32:57 +05302362 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302363 */
Govind Singhb53420c2016-03-09 14:32:57 +05302364QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302365 int value)
2366{
Govind Singh67922e82016-04-01 16:48:57 +05302367 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302368 wmi_sta_smps_param_cmd_fixed_param *cmd;
2369 wmi_buf_t buf;
2370 uint16_t len = sizeof(*cmd);
2371
2372 buf = wmi_buf_alloc(wmi_handle, len);
2373 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302374 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302375 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302376 }
2377 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2378 WMITLV_SET_HDR(&cmd->tlv_header,
2379 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2380 WMITLV_GET_STRUCT_TLVLEN
2381 (wmi_sta_smps_param_cmd_fixed_param));
2382
2383 cmd->vdev_id = vdev_id;
2384 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2385 cmd->param =
2386 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2387
Govind Singhb53420c2016-03-09 14:32:57 +05302388 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302389 cmd->param);
2390
2391 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2392 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302393 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302394 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302395 wmi_buf_free(buf);
2396 }
2397
2398 return ret;
2399}
2400
2401/**
2402 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2403 * @wmi_handle: wmi handle
2404 * @noa: p2p power save parameters
2405 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302406 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302407 */
Govind Singhb53420c2016-03-09 14:32:57 +05302408QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302409 struct p2p_ps_params *noa)
2410{
2411 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2412 wmi_p2p_noa_descriptor *noa_discriptor;
2413 wmi_buf_t buf;
2414 uint8_t *buf_ptr;
2415 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302416 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302417 uint32_t duration;
2418
Govind Singhb53420c2016-03-09 14:32:57 +05302419 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302420 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2421 buf = wmi_buf_alloc(wmi_handle, len);
2422 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302423 WMI_LOGE("Failed to allocate memory");
2424 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302425 goto end;
2426 }
2427
2428 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2429 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2430 WMITLV_SET_HDR(&cmd->tlv_header,
2431 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2432 WMITLV_GET_STRUCT_TLVLEN
2433 (wmi_p2p_set_noa_cmd_fixed_param));
2434 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2435 cmd->vdev_id = noa->session_id;
2436 cmd->enable = (duration) ? true : false;
2437 cmd->num_noa = 1;
2438
2439 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2440 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2441 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2442 sizeof
2443 (wmi_p2p_set_noa_cmd_fixed_param)
2444 + WMI_TLV_HDR_SIZE);
2445 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2446 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2447 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2448 noa_discriptor->type_count = noa->count;
2449 noa_discriptor->duration = duration;
2450 noa_discriptor->interval = noa->interval;
2451 noa_discriptor->start_time = 0;
2452
Govind Singhb53420c2016-03-09 14:32:57 +05302453 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302454 cmd->vdev_id, noa->count, noa_discriptor->duration,
2455 noa->interval);
2456 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2457 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302458 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302459 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302460 wmi_buf_free(buf);
2461 }
2462
2463end:
Govind Singhb53420c2016-03-09 14:32:57 +05302464 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302465 return status;
2466}
2467
2468
2469/**
2470 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2471 * @wmi_handle: wmi handle
2472 * @noa: p2p opp power save parameters
2473 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302474 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302475 */
Govind Singhb53420c2016-03-09 14:32:57 +05302476QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302477 struct p2p_ps_params *oppps)
2478{
2479 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2480 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302481 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302482
Govind Singhb53420c2016-03-09 14:32:57 +05302483 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302484 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2485 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302486 WMI_LOGE("Failed to allocate memory");
2487 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302488 goto end;
2489 }
2490
2491 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2492 WMITLV_SET_HDR(&cmd->tlv_header,
2493 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2494 WMITLV_GET_STRUCT_TLVLEN
2495 (wmi_p2p_set_oppps_cmd_fixed_param));
2496 cmd->vdev_id = oppps->session_id;
2497 if (oppps->ctwindow)
2498 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2499
2500 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302501 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302502 cmd->vdev_id, oppps->ctwindow);
2503 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2504 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302505 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302506 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302507 wmi_buf_free(buf);
2508 }
2509
2510end:
Govind Singhb53420c2016-03-09 14:32:57 +05302511 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302512 return status;
2513}
2514
2515/**
2516 * send_get_temperature_cmd_tlv() - get pdev temperature req
2517 * @wmi_handle: wmi handle
2518 *
Govind Singhb53420c2016-03-09 14:32:57 +05302519 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302520 */
Govind Singhb53420c2016-03-09 14:32:57 +05302521QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05302522{
2523 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
2524 wmi_buf_t wmi_buf;
2525 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
2526 uint8_t *buf_ptr;
2527
2528 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05302529 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
2530 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05302531 }
2532
2533 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2534 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302535 WMI_LOGE(FL("wmi_buf_alloc failed"));
2536 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302537 }
2538
2539 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2540
2541 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
2542 WMITLV_SET_HDR(&cmd->tlv_header,
2543 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
2544 WMITLV_GET_STRUCT_TLVLEN
2545 (wmi_pdev_get_temperature_cmd_fixed_param));
2546
2547 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
2548 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302549 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05302550 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302551 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302552 }
Govind Singh2edc80f2016-03-01 15:30:53 +05302553
Govind Singhb53420c2016-03-09 14:32:57 +05302554 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302555}
2556
2557/**
2558 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
2559 * @wmi_handle: wmi handle
2560 * @vdevid: vdev id
2561 * @peer_addr: peer mac address
2562 * @auto_triggerparam: auto trigger parameters
2563 * @num_ac: number of access category
2564 *
2565 * This function sets the trigger
2566 * uapsd params such as service interval, delay interval
2567 * and suspend interval which will be used by the firmware
2568 * to send trigger frames periodically when there is no
2569 * traffic on the transmit side.
2570 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302571 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302572 */
Govind Singhb53420c2016-03-09 14:32:57 +05302573QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302574 struct sta_uapsd_trig_params *param)
2575{
2576 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302577 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302578 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
2579 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
2580 uint32_t i;
2581 wmi_buf_t buf;
2582 uint8_t *buf_ptr;
2583
2584 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2585 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302586 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302587 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302588 }
2589
2590 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2591 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
2592 WMITLV_SET_HDR(&cmd->tlv_header,
2593 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
2594 WMITLV_GET_STRUCT_TLVLEN
2595 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
2596 cmd->vdev_id = param->vdevid;
2597 cmd->num_ac = param->num_ac;
2598 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
2599
2600 /* TLV indicating array of structures to follow */
2601 buf_ptr += sizeof(*cmd);
2602 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
2603
2604 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302605 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302606
2607 /*
2608 * Update tag and length for uapsd auto trigger params (this will take
2609 * care of updating tag and length if it is not pre-filled by caller).
2610 */
2611 for (i = 0; i < param->num_ac; i++) {
2612 WMITLV_SET_HDR((buf_ptr +
2613 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
2614 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
2615 WMITLV_GET_STRUCT_TLVLEN
2616 (wmi_sta_uapsd_auto_trig_param));
2617 }
2618
2619 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2620 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302621 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302622 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302623 wmi_buf_free(buf);
2624 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05302625
Govind Singh427ee5a2016-02-26 18:09:36 +05302626 return ret;
2627}
2628
Govind Singh2edc80f2016-03-01 15:30:53 +05302629/**
2630 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
2631 * @wmi_handle: pointer to the wmi handle
2632 * @utc: pointer to the UTC time struct
2633 *
2634 * Return: 0 on succes
2635 */
Govind Singhb53420c2016-03-09 14:32:57 +05302636QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302637 struct ocb_utc_param *utc)
2638{
Govind Singh67922e82016-04-01 16:48:57 +05302639 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302640 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
2641 uint8_t *buf_ptr;
2642 uint32_t len, i;
2643 wmi_buf_t buf;
2644
2645 len = sizeof(*cmd);
2646 buf = wmi_buf_alloc(wmi_handle, len);
2647 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302648 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302649 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302650 }
2651
2652 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2653 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
2654 WMITLV_SET_HDR(&cmd->tlv_header,
2655 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
2656 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
2657 cmd->vdev_id = utc->vdev_id;
2658
2659 for (i = 0; i < SIZE_UTC_TIME; i++)
2660 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
2661
2662 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
2663 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
2664
2665 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2666 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302667 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302668 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302669 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302670 }
2671
Govind Singh67922e82016-04-01 16:48:57 +05302672 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302673}
2674
2675/**
2676 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
2677 * frames on a channel
2678 * @wmi_handle: pointer to the wmi handle
2679 * @timing_advert: pointer to the timing advertisement struct
2680 *
2681 * Return: 0 on succes
2682 */
Govind Singhb53420c2016-03-09 14:32:57 +05302683QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302684 struct ocb_timing_advert_param *timing_advert)
2685{
Govind Singh67922e82016-04-01 16:48:57 +05302686 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302687 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
2688 uint8_t *buf_ptr;
2689 uint32_t len, len_template;
2690 wmi_buf_t buf;
2691
2692 len = sizeof(*cmd) +
2693 WMI_TLV_HDR_SIZE;
2694
2695 len_template = timing_advert->template_length;
2696 /* Add padding to the template if needed */
2697 if (len_template % 4 != 0)
2698 len_template += 4 - (len_template % 4);
2699 len += len_template;
2700
2701 buf = wmi_buf_alloc(wmi_handle, len);
2702 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302703 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302704 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302705 }
2706
2707 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2708 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
2709 WMITLV_SET_HDR(&cmd->tlv_header,
2710 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
2711 WMITLV_GET_STRUCT_TLVLEN(
2712 wmi_ocb_start_timing_advert_cmd_fixed_param));
2713 cmd->vdev_id = timing_advert->vdev_id;
2714 cmd->repeat_rate = timing_advert->repeat_rate;
2715 cmd->channel_freq = timing_advert->chan_freq;
2716 cmd->timestamp_offset = timing_advert->timestamp_offset;
2717 cmd->time_value_offset = timing_advert->time_value_offset;
2718 cmd->timing_advert_template_length = timing_advert->template_length;
2719 buf_ptr += sizeof(*cmd);
2720
2721 /* Add the timing advert template */
2722 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2723 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05302724 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05302725 (uint8_t *)timing_advert->template_value,
2726 timing_advert->template_length);
2727
2728 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2729 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302730 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302731 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302732 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302733 }
2734
Govind Singh67922e82016-04-01 16:48:57 +05302735 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302736}
2737
2738/**
2739 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
2740 * on a channel
2741 * @wmi_handle: pointer to the wmi handle
2742 * @timing_advert: pointer to the timing advertisement struct
2743 *
2744 * Return: 0 on succes
2745 */
Govind Singhb53420c2016-03-09 14:32:57 +05302746QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302747 struct ocb_timing_advert_param *timing_advert)
2748{
Govind Singh67922e82016-04-01 16:48:57 +05302749 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302750 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
2751 uint8_t *buf_ptr;
2752 uint32_t len;
2753 wmi_buf_t buf;
2754
2755 len = sizeof(*cmd);
2756 buf = wmi_buf_alloc(wmi_handle, len);
2757 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302758 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302759 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302760 }
2761
2762 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2763 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
2764 WMITLV_SET_HDR(&cmd->tlv_header,
2765 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
2766 WMITLV_GET_STRUCT_TLVLEN(
2767 wmi_ocb_stop_timing_advert_cmd_fixed_param));
2768 cmd->vdev_id = timing_advert->vdev_id;
2769 cmd->channel_freq = timing_advert->chan_freq;
2770
2771 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2772 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302773 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302774 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302775 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302776 }
2777
Govind Singh67922e82016-04-01 16:48:57 +05302778 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302779}
2780
2781/**
2782 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
2783 * @wmi_handle: pointer to the wmi handle
2784 * @request: pointer to the request
2785 *
2786 * Return: 0 on succes
2787 */
Govind Singhb53420c2016-03-09 14:32:57 +05302788QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302789 uint8_t vdev_id)
2790{
Govind Singhb53420c2016-03-09 14:32:57 +05302791 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302792 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
2793 uint8_t *buf_ptr;
2794 wmi_buf_t buf;
2795 int32_t len;
2796
2797 len = sizeof(*cmd);
2798 buf = wmi_buf_alloc(wmi_handle, len);
2799 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302800 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302801 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302802 }
2803 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2804
2805 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302806 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302807 WMITLV_SET_HDR(&cmd->tlv_header,
2808 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
2809 WMITLV_GET_STRUCT_TLVLEN(
2810 wmi_ocb_get_tsf_timer_cmd_fixed_param));
2811 cmd->vdev_id = vdev_id;
2812
2813 /* Send the WMI command */
2814 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2815 WMI_OCB_GET_TSF_TIMER_CMDID);
2816 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05302817 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302818 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302819 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302820 }
2821
Govind Singh67922e82016-04-01 16:48:57 +05302822 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302823}
2824
2825/**
2826 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
2827 * @wmi_handle: pointer to the wmi handle
2828 * @get_stats_param: pointer to the dcc stats
2829 *
2830 * Return: 0 on succes
2831 */
Govind Singhb53420c2016-03-09 14:32:57 +05302832QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302833 struct dcc_get_stats_param *get_stats_param)
2834{
Govind Singh67922e82016-04-01 16:48:57 +05302835 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302836 wmi_dcc_get_stats_cmd_fixed_param *cmd;
2837 wmi_dcc_channel_stats_request *channel_stats_array;
2838 wmi_buf_t buf;
2839 uint8_t *buf_ptr;
2840 uint32_t len;
2841 uint32_t i;
2842
2843 /* Validate the input */
2844 if (get_stats_param->request_array_len !=
2845 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302846 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05302847 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302848 }
2849
2850 /* Allocate memory for the WMI command */
2851 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
2852 get_stats_param->request_array_len;
2853
2854 buf = wmi_buf_alloc(wmi_handle, len);
2855 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302856 WMI_LOGE(FL("wmi_buf_alloc failed"));
2857 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302858 }
2859
2860 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302861 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302862
2863 /* Populate the WMI command */
2864 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
2865 buf_ptr += sizeof(*cmd);
2866
2867 WMITLV_SET_HDR(&cmd->tlv_header,
2868 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
2869 WMITLV_GET_STRUCT_TLVLEN(
2870 wmi_dcc_get_stats_cmd_fixed_param));
2871 cmd->vdev_id = get_stats_param->vdev_id;
2872 cmd->num_channels = get_stats_param->channel_count;
2873
2874 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2875 get_stats_param->request_array_len);
2876 buf_ptr += WMI_TLV_HDR_SIZE;
2877
2878 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302879 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05302880 get_stats_param->request_array_len);
2881 for (i = 0; i < cmd->num_channels; i++)
2882 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
2883 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
2884 WMITLV_GET_STRUCT_TLVLEN(
2885 wmi_dcc_channel_stats_request));
2886
2887 /* Send the WMI command */
2888 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2889 WMI_DCC_GET_STATS_CMDID);
2890
Govind Singh67922e82016-04-01 16:48:57 +05302891 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302892 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302893 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302894 }
2895
Govind Singh67922e82016-04-01 16:48:57 +05302896 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302897}
2898
2899/**
2900 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
2901 * @wmi_handle: pointer to the wmi handle
2902 * @vdev_id: vdev id
2903 * @dcc_stats_bitmap: dcc status bitmap
2904 *
2905 * Return: 0 on succes
2906 */
Govind Singhb53420c2016-03-09 14:32:57 +05302907QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302908 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
2909{
Govind Singh67922e82016-04-01 16:48:57 +05302910 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302911 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
2912 wmi_buf_t buf;
2913 uint8_t *buf_ptr;
2914 uint32_t len;
2915
2916 /* Allocate memory for the WMI command */
2917 len = sizeof(*cmd);
2918
2919 buf = wmi_buf_alloc(wmi_handle, len);
2920 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302921 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302922 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302923 }
2924
2925 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302926 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302927
2928 /* Populate the WMI command */
2929 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
2930
2931 WMITLV_SET_HDR(&cmd->tlv_header,
2932 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
2933 WMITLV_GET_STRUCT_TLVLEN(
2934 wmi_dcc_clear_stats_cmd_fixed_param));
2935 cmd->vdev_id = vdev_id;
2936 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
2937
2938 /* Send the WMI command */
2939 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2940 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302941 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302942 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302943 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302944 }
2945
Govind Singh67922e82016-04-01 16:48:57 +05302946 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302947}
2948
2949/**
2950 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
2951 * @wmi_handle: pointer to the wmi handle
2952 * @update_ndl_param: pointer to the request parameters
2953 *
2954 * Return: 0 on success
2955 */
Govind Singhb53420c2016-03-09 14:32:57 +05302956QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302957 struct dcc_update_ndl_param *update_ndl_param)
2958{
Govind Singhb53420c2016-03-09 14:32:57 +05302959 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05302960 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
2961 wmi_dcc_ndl_chan *ndl_chan_array;
2962 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
2963 uint32_t active_state_count;
2964 wmi_buf_t buf;
2965 uint8_t *buf_ptr;
2966 uint32_t len;
2967 uint32_t i;
2968
2969 /* validate the input */
2970 if (update_ndl_param->dcc_ndl_chan_list_len !=
2971 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302972 WMI_LOGE(FL("Invalid parameter"));
2973 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302974 }
2975 active_state_count = 0;
2976 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
2977 for (i = 0; i < update_ndl_param->channel_count; i++)
2978 active_state_count +=
2979 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
2980 if (update_ndl_param->dcc_ndl_active_state_list_len !=
2981 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302982 WMI_LOGE(FL("Invalid parameter"));
2983 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302984 }
2985
2986 /* Allocate memory for the WMI command */
2987 len = sizeof(*cmd) +
2988 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
2989 WMI_TLV_HDR_SIZE +
2990 update_ndl_param->dcc_ndl_active_state_list_len;
2991
2992 buf = wmi_buf_alloc(wmi_handle, len);
2993 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302994 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302995 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302996 }
2997
2998 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302999 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303000
3001 /* Populate the WMI command */
3002 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3003 buf_ptr += sizeof(*cmd);
3004
3005 WMITLV_SET_HDR(&cmd->tlv_header,
3006 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3007 WMITLV_GET_STRUCT_TLVLEN(
3008 wmi_dcc_update_ndl_cmd_fixed_param));
3009 cmd->vdev_id = update_ndl_param->vdev_id;
3010 cmd->num_channel = update_ndl_param->channel_count;
3011
3012 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3013 update_ndl_param->dcc_ndl_chan_list_len);
3014 buf_ptr += WMI_TLV_HDR_SIZE;
3015
3016 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303017 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303018 update_ndl_param->dcc_ndl_chan_list_len);
3019 for (i = 0; i < cmd->num_channel; i++)
3020 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3021 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3022 WMITLV_GET_STRUCT_TLVLEN(
3023 wmi_dcc_ndl_chan));
3024 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3025
3026 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3027 update_ndl_param->dcc_ndl_active_state_list_len);
3028 buf_ptr += WMI_TLV_HDR_SIZE;
3029
3030 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303031 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303032 update_ndl_param->dcc_ndl_active_state_list,
3033 update_ndl_param->dcc_ndl_active_state_list_len);
3034 for (i = 0; i < active_state_count; i++) {
3035 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3036 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3037 WMITLV_GET_STRUCT_TLVLEN(
3038 wmi_dcc_ndl_active_state_config));
3039 }
3040 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3041
3042 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303043 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303044 WMI_DCC_UPDATE_NDL_CMDID);
3045 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303046 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303047 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303048 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303049 }
3050
Govind Singh67922e82016-04-01 16:48:57 +05303051 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303052}
3053
3054/**
3055 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3056 * @wmi_handle: pointer to the wmi handle
3057 * @config: the OCB configuration
3058 *
3059 * Return: 0 on success
3060 */
Govind Singhb53420c2016-03-09 14:32:57 +05303061QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303062 struct ocb_config_param *config, uint32_t *ch_mhz)
3063{
Govind Singh67922e82016-04-01 16:48:57 +05303064 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303065 wmi_ocb_set_config_cmd_fixed_param *cmd;
3066 wmi_channel *chan;
3067 wmi_ocb_channel *ocb_chan;
3068 wmi_qos_parameter *qos_param;
3069 wmi_dcc_ndl_chan *ndl_chan;
3070 wmi_dcc_ndl_active_state_config *ndl_active_config;
3071 wmi_ocb_schedule_element *sched_elem;
3072 uint8_t *buf_ptr;
3073 wmi_buf_t buf;
3074 int32_t len;
3075 int32_t i, j, active_state_count;
3076
3077 /*
3078 * Validate the dcc_ndl_chan_list_len and count the number of active
3079 * states. Validate dcc_ndl_active_state_list_len.
3080 */
3081 active_state_count = 0;
3082 if (config->dcc_ndl_chan_list_len) {
3083 if (!config->dcc_ndl_chan_list ||
3084 config->dcc_ndl_chan_list_len !=
3085 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303086 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303087 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303088 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303089 }
3090
3091 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3092 i < config->channel_count; ++i, ++ndl_chan)
3093 active_state_count +=
3094 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3095
3096 if (active_state_count) {
3097 if (!config->dcc_ndl_active_state_list ||
3098 config->dcc_ndl_active_state_list_len !=
3099 active_state_count *
3100 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303101 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303102 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303103 }
3104 }
3105 }
3106
3107 len = sizeof(*cmd) +
3108 WMI_TLV_HDR_SIZE + config->channel_count *
3109 sizeof(wmi_channel) +
3110 WMI_TLV_HDR_SIZE + config->channel_count *
3111 sizeof(wmi_ocb_channel) +
3112 WMI_TLV_HDR_SIZE + config->channel_count *
3113 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3114 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3115 WMI_TLV_HDR_SIZE + active_state_count *
3116 sizeof(wmi_dcc_ndl_active_state_config) +
3117 WMI_TLV_HDR_SIZE + config->schedule_size *
3118 sizeof(wmi_ocb_schedule_element);
3119 buf = wmi_buf_alloc(wmi_handle, len);
3120 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303121 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303122 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303123 }
3124
3125 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3126 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3127 WMITLV_SET_HDR(&cmd->tlv_header,
3128 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3129 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3130 cmd->vdev_id = config->session_id;
3131 cmd->channel_count = config->channel_count;
3132 cmd->schedule_size = config->schedule_size;
3133 cmd->flags = config->flags;
3134 buf_ptr += sizeof(*cmd);
3135
3136 /* Add the wmi_channel info */
3137 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3138 config->channel_count*sizeof(wmi_channel));
3139 buf_ptr += WMI_TLV_HDR_SIZE;
3140 for (i = 0; i < config->channel_count; i++) {
3141 chan = (wmi_channel *)buf_ptr;
3142 WMITLV_SET_HDR(&chan->tlv_header,
3143 WMITLV_TAG_STRUC_wmi_channel,
3144 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3145 chan->mhz = config->channels[i].chan_freq;
3146 chan->band_center_freq1 = config->channels[i].chan_freq;
3147 chan->band_center_freq2 = 0;
3148 chan->info = 0;
3149
3150 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3151 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3152 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3153 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3154 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3155 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3156 config->channels[i].antenna_max);
3157
3158 if (config->channels[i].bandwidth < 10)
3159 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3160 else if (config->channels[i].bandwidth < 20)
3161 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3162 buf_ptr += sizeof(*chan);
3163 }
3164
3165 /* Add the wmi_ocb_channel info */
3166 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3167 config->channel_count*sizeof(wmi_ocb_channel));
3168 buf_ptr += WMI_TLV_HDR_SIZE;
3169 for (i = 0; i < config->channel_count; i++) {
3170 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3171 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3172 WMITLV_TAG_STRUC_wmi_ocb_channel,
3173 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3174 ocb_chan->bandwidth = config->channels[i].bandwidth;
3175 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3176 config->channels[i].mac_address.bytes,
3177 &ocb_chan->mac_address);
3178 buf_ptr += sizeof(*ocb_chan);
3179 }
3180
3181 /* Add the wmi_qos_parameter info */
3182 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3183 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3184 buf_ptr += WMI_TLV_HDR_SIZE;
3185 /* WMI_MAX_NUM_AC parameters for each channel */
3186 for (i = 0; i < config->channel_count; i++) {
3187 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3188 qos_param = (wmi_qos_parameter *)buf_ptr;
3189 WMITLV_SET_HDR(&qos_param->tlv_header,
3190 WMITLV_TAG_STRUC_wmi_qos_parameter,
3191 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3192 qos_param->aifsn =
3193 config->channels[i].qos_params[j].aifsn;
3194 qos_param->cwmin =
3195 config->channels[i].qos_params[j].cwmin;
3196 qos_param->cwmax =
3197 config->channels[i].qos_params[j].cwmax;
3198 buf_ptr += sizeof(*qos_param);
3199 }
3200 }
3201
3202 /* Add the wmi_dcc_ndl_chan (per channel) */
3203 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3204 config->dcc_ndl_chan_list_len);
3205 buf_ptr += WMI_TLV_HDR_SIZE;
3206 if (config->dcc_ndl_chan_list_len) {
3207 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303208 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303209 config->dcc_ndl_chan_list_len);
3210 for (i = 0; i < config->channel_count; i++)
3211 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3212 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3213 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3214 buf_ptr += config->dcc_ndl_chan_list_len;
3215 }
3216
3217 /* Add the wmi_dcc_ndl_active_state_config */
3218 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3219 sizeof(wmi_dcc_ndl_active_state_config));
3220 buf_ptr += WMI_TLV_HDR_SIZE;
3221 if (active_state_count) {
3222 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303223 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303224 config->dcc_ndl_active_state_list,
3225 active_state_count * sizeof(*ndl_active_config));
3226 for (i = 0; i < active_state_count; ++i)
3227 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3228 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3229 WMITLV_GET_STRUCT_TLVLEN(
3230 wmi_dcc_ndl_active_state_config));
3231 buf_ptr += active_state_count *
3232 sizeof(*ndl_active_config);
3233 }
3234
3235 /* Add the wmi_ocb_schedule_element info */
3236 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3237 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3238 buf_ptr += WMI_TLV_HDR_SIZE;
3239 for (i = 0; i < config->schedule_size; i++) {
3240 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3241 WMITLV_SET_HDR(&sched_elem->tlv_header,
3242 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3243 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3244 sched_elem->channel_freq = config->schedule[i].chan_freq;
3245 sched_elem->total_duration = config->schedule[i].total_duration;
3246 sched_elem->guard_interval = config->schedule[i].guard_interval;
3247 buf_ptr += sizeof(*sched_elem);
3248 }
3249
3250
3251 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3252 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303253 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303254 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303255 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303256 }
3257
Govind Singh67922e82016-04-01 16:48:57 +05303258 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303259}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303260
3261/**
3262 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3263 * @wmi_handle: wmi handle
3264 * @mcc_adaptive_scheduler: enable/disable
3265 *
3266 * This function enable/disable mcc adaptive scheduler in fw.
3267 *
Govind Singhb53420c2016-03-09 14:32:57 +05303268 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303269 */
Govind Singhb53420c2016-03-09 14:32:57 +05303270QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003271 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3272 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303273{
Govind Singh67922e82016-04-01 16:48:57 +05303274 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303275 wmi_buf_t buf = 0;
3276 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3277 uint16_t len =
3278 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3279
3280 buf = wmi_buf_alloc(wmi_handle, len);
3281 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303282 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3283 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303284 }
3285 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3286 wmi_buf_data(buf);
3287
3288 WMITLV_SET_HDR(&cmd->tlv_header,
3289 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3290 WMITLV_GET_STRUCT_TLVLEN
3291 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3292 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003293 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303294
3295 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3296 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303297 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303298 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303299 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303300 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303301 }
Govind Singh67922e82016-04-01 16:48:57 +05303302
3303 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303304}
3305
3306/**
3307 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3308 * @wmi: wmi handle
3309 * @mcc_channel: mcc channel
3310 * @mcc_channel_time_latency: MCC channel time latency.
3311 *
3312 * Currently used to set time latency for an MCC vdev/adapter using operating
3313 * channel of it and channel number. The info is provided run time using
3314 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3315 *
3316 * Return: CDF status
3317 */
Govind Singhb53420c2016-03-09 14:32:57 +05303318QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303319 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3320{
Govind Singh67922e82016-04-01 16:48:57 +05303321 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303322 wmi_buf_t buf = 0;
3323 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3324 uint16_t len = 0;
3325 uint8_t *buf_ptr = NULL;
3326 wmi_resmgr_chan_latency chan_latency;
3327 /* Note: we only support MCC time latency for a single channel */
3328 uint32_t num_channels = 1;
3329 uint32_t chan1_freq = mcc_channel_freq;
3330 uint32_t latency_chan1 = mcc_channel_time_latency;
3331
3332
3333 /* If 0ms latency is provided, then FW will set to a default.
3334 * Otherwise, latency must be at least 30ms.
3335 */
3336 if ((latency_chan1 > 0) &&
3337 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303338 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303339 "Minimum is 30ms (or 0 to use default value by "
3340 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303341 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303342 }
3343
3344 /* Set WMI CMD for channel time latency here */
3345 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3346 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3347 num_channels * sizeof(wmi_resmgr_chan_latency);
3348 buf = wmi_buf_alloc(wmi_handle, len);
3349 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303350 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3351 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303352 }
3353 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3354 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3355 wmi_buf_data(buf);
3356 WMITLV_SET_HDR(&cmdTL->tlv_header,
3357 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3358 WMITLV_GET_STRUCT_TLVLEN
3359 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3360 cmdTL->num_chans = num_channels;
3361 /* Update channel time latency information for home channel(s) */
3362 buf_ptr += sizeof(*cmdTL);
3363 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3364 num_channels * sizeof(wmi_resmgr_chan_latency));
3365 buf_ptr += WMI_TLV_HDR_SIZE;
3366 chan_latency.chan_mhz = chan1_freq;
3367 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303368 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303369 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3370 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303371 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303372 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303373 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303374 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303375 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303376 }
Govind Singh67922e82016-04-01 16:48:57 +05303377
3378 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303379}
3380
3381/**
3382 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3383 * @wmi: wmi handle
3384 * @adapter_1_chan_number: adapter 1 channel number
3385 * @adapter_1_quota: adapter 1 quota
3386 * @adapter_2_chan_number: adapter 2 channel number
3387 *
3388 * Return: CDF status
3389 */
Govind Singhb53420c2016-03-09 14:32:57 +05303390QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303391 uint32_t adapter_1_chan_freq,
3392 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3393{
Govind Singh67922e82016-04-01 16:48:57 +05303394 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303395 wmi_buf_t buf = 0;
3396 uint16_t len = 0;
3397 uint8_t *buf_ptr = NULL;
3398 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3399 wmi_resmgr_chan_time_quota chan_quota;
3400 uint32_t quota_chan1 = adapter_1_quota;
3401 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3402 uint32_t quota_chan2 = 100 - quota_chan1;
3403 /* Note: setting time quota for MCC requires info for 2 channels */
3404 uint32_t num_channels = 2;
3405 uint32_t chan1_freq = adapter_1_chan_freq;
3406 uint32_t chan2_freq = adapter_2_chan_freq;
3407
Govind Singhb53420c2016-03-09 14:32:57 +05303408 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303409 "freq2:%dMHz, Quota2:%dms", __func__,
3410 chan1_freq, quota_chan1, chan2_freq,
3411 quota_chan2);
3412
3413 /*
3414 * Perform sanity check on time quota values provided.
3415 */
3416 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3417 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303418 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303419 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303420 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303421 }
3422 /* Set WMI CMD for channel time quota here */
3423 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3424 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3425 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3426 buf = wmi_buf_alloc(wmi_handle, len);
3427 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303428 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3429 QDF_ASSERT(0);
3430 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303431 }
3432 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3433 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3434 wmi_buf_data(buf);
3435 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3436 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3437 WMITLV_GET_STRUCT_TLVLEN
3438 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3439 cmdTQ->num_chans = num_channels;
3440
3441 /* Update channel time quota information for home channel(s) */
3442 buf_ptr += sizeof(*cmdTQ);
3443 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3444 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3445 buf_ptr += WMI_TLV_HDR_SIZE;
3446 chan_quota.chan_mhz = chan1_freq;
3447 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303448 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303449 /* Construct channel and quota record for the 2nd MCC mode. */
3450 buf_ptr += sizeof(chan_quota);
3451 chan_quota.chan_mhz = chan2_freq;
3452 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05303453 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303454
3455 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3456 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303457 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303458 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303459 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303460 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303461 }
Govind Singh67922e82016-04-01 16:48:57 +05303462
3463 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303464}
3465
3466/**
3467 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3468 * @wmi_handle: Pointer to wmi handle
3469 * @thermal_info: Thermal command information
3470 *
3471 * This function sends the thermal management command
3472 * to the firmware
3473 *
Govind Singhb53420c2016-03-09 14:32:57 +05303474 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303475 */
Govind Singhb53420c2016-03-09 14:32:57 +05303476QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303477 struct thermal_cmd_params *thermal_info)
3478{
3479 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3480 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303481 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303482 uint32_t len = 0;
3483
3484 len = sizeof(*cmd);
3485
3486 buf = wmi_buf_alloc(wmi_handle, len);
3487 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303488 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3489 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303490 }
3491
3492 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3493
3494 WMITLV_SET_HDR(&cmd->tlv_header,
3495 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3496 WMITLV_GET_STRUCT_TLVLEN
3497 (wmi_thermal_mgmt_cmd_fixed_param));
3498
3499 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3500 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3501 cmd->enable = thermal_info->thermal_enable;
3502
Govind Singhb53420c2016-03-09 14:32:57 +05303503 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303504 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3505
3506 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3507 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303508 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303509 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303510 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303511 }
3512
Govind Singh67922e82016-04-01 16:48:57 +05303513 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303514}
3515
3516
3517/**
3518 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303519 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303520 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3521 *
3522 * This function sends down the LRO configuration parameters to
3523 * the firmware to enable LRO, sets the TCP flags and sets the
3524 * seed values for the toeplitz hash generation
3525 *
Govind Singhb53420c2016-03-09 14:32:57 +05303526 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303527 */
Govind Singhb53420c2016-03-09 14:32:57 +05303528QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303529 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3530{
3531 wmi_lro_info_cmd_fixed_param *cmd;
3532 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303533 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303534
3535
3536 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3537 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303538 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3539 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303540 }
3541
3542 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3543
3544 WMITLV_SET_HDR(&cmd->tlv_header,
3545 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3546 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3547
3548 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3549 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3550 wmi_lro_cmd->tcp_flag);
3551 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3552 wmi_lro_cmd->tcp_flag_mask);
3553 cmd->toeplitz_hash_ipv4_0_3 =
3554 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3555 cmd->toeplitz_hash_ipv4_4_7 =
3556 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3557 cmd->toeplitz_hash_ipv4_8_11 =
3558 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3559 cmd->toeplitz_hash_ipv4_12_15 =
3560 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3561 cmd->toeplitz_hash_ipv4_16 =
3562 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3563
3564 cmd->toeplitz_hash_ipv6_0_3 =
3565 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3566 cmd->toeplitz_hash_ipv6_4_7 =
3567 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3568 cmd->toeplitz_hash_ipv6_8_11 =
3569 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3570 cmd->toeplitz_hash_ipv6_12_15 =
3571 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3572 cmd->toeplitz_hash_ipv6_16_19 =
3573 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3574 cmd->toeplitz_hash_ipv6_20_23 =
3575 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3576 cmd->toeplitz_hash_ipv6_24_27 =
3577 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3578 cmd->toeplitz_hash_ipv6_28_31 =
3579 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3580 cmd->toeplitz_hash_ipv6_32_35 =
3581 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3582 cmd->toeplitz_hash_ipv6_36_39 =
3583 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3584 cmd->toeplitz_hash_ipv6_40 =
3585 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3586
Govind Singhb53420c2016-03-09 14:32:57 +05303587 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303588 cmd->lro_enable, cmd->tcp_flag_u32);
3589
3590 status = wmi_unified_cmd_send(wmi_handle, buf,
3591 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303592 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303593 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303594 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303595 }
3596
Govind Singh67922e82016-04-01 16:48:57 +05303597 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303598}
3599
Govind Singh4eacd2b2016-03-07 14:24:22 +05303600/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303601 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3602 * @wmi_handle: Pointer to wmi handle
3603 * @rate_report_params: Pointer to peer rate report parameters
3604 *
3605 *
3606 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3607 */
3608QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
3609 struct wmi_peer_rate_report_params *rate_report_params)
3610{
3611 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3612 wmi_buf_t buf = NULL;
3613 QDF_STATUS status = 0;
3614 uint32_t len = 0;
3615 uint32_t i, j;
3616
3617 len = sizeof(*cmd);
3618
3619 buf = wmi_buf_alloc(wmi_handle, len);
3620 if (!buf) {
3621 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
3622 return QDF_STATUS_E_FAILURE;
3623 }
3624
3625 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3626 wmi_buf_data(buf);
3627
3628 WMITLV_SET_HDR(
3629 &cmd->tlv_header,
3630 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3631 WMITLV_GET_STRUCT_TLVLEN(
3632 wmi_peer_set_rate_report_condition_fixed_param));
3633
3634 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3635 cmd->report_backoff_time = rate_report_params->backoff_time;
3636 cmd->report_timer_period = rate_report_params->timer_period;
3637 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
3638 cmd->cond_per_phy[i].val_cond_flags =
3639 rate_report_params->report_per_phy[i].cond_flags;
3640 cmd->cond_per_phy[i].rate_delta.min_delta =
3641 rate_report_params->report_per_phy[i].delta.delta_min;
3642 cmd->cond_per_phy[i].rate_delta.percentage =
3643 rate_report_params->report_per_phy[i].delta.percent;
3644 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3645 cmd->cond_per_phy[i].rate_threshold[j] =
3646 rate_report_params->report_per_phy[i].
3647 report_rate_threshold[j];
3648 }
3649 }
3650
3651 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
3652 cmd->enable_rate_report,
3653 cmd->report_backoff_time, cmd->report_timer_period);
3654
3655 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3656 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3657 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303658 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303659 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3660 __func__);
3661 }
3662 return status;
3663}
3664
3665/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303666 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3667 * @wmi_handle: wmi handle
3668 * @param: bcn ll cmd parameter
3669 *
Govind Singhb53420c2016-03-09 14:32:57 +05303670 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303671 */
Govind Singhb53420c2016-03-09 14:32:57 +05303672QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303673 wmi_bcn_send_from_host_cmd_fixed_param *param)
3674{
3675 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3676 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303677 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303678
3679 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3680 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303681 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3682 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303683 }
3684
3685 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3686 WMITLV_SET_HDR(&cmd->tlv_header,
3687 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3688 WMITLV_GET_STRUCT_TLVLEN
3689 (wmi_bcn_send_from_host_cmd_fixed_param));
3690 cmd->vdev_id = param->vdev_id;
3691 cmd->data_len = param->data_len;
3692 cmd->frame_ctrl = param->frame_ctrl;
3693 cmd->frag_ptr = param->frag_ptr;
3694 cmd->dtim_flag = param->dtim_flag;
3695
3696 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3697 WMI_PDEV_SEND_BCN_CMDID);
3698
Govind Singh67922e82016-04-01 16:48:57 +05303699 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303700 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303701 wmi_buf_free(wmi_buf);
3702 }
3703
3704 return ret;
3705}
3706
3707/**
3708 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
3709 * @wmi_handle: wmi handle
3710 * @vdev_id: vdev id
3711 * @max_retries: max retries
3712 * @retry_interval: retry interval
3713 * This function sets sta query related parameters in fw.
3714 *
Govind Singhb53420c2016-03-09 14:32:57 +05303715 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303716 */
3717
Govind Singhb53420c2016-03-09 14:32:57 +05303718QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303719 uint8_t vdev_id, uint32_t max_retries,
3720 uint32_t retry_interval)
3721{
3722 wmi_buf_t buf;
3723 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
3724 int len;
3725
3726 len = sizeof(*cmd);
3727 buf = wmi_buf_alloc(wmi_handle, len);
3728 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303729 WMI_LOGE(FL("wmi_buf_alloc failed"));
3730 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303731 }
3732
3733 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
3734 WMITLV_SET_HDR(&cmd->tlv_header,
3735 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
3736 WMITLV_GET_STRUCT_TLVLEN
3737 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
3738
3739
3740 cmd->vdev_id = vdev_id;
3741 cmd->sa_query_max_retry_count = max_retries;
3742 cmd->sa_query_retry_interval = retry_interval;
3743
Govind Singhb53420c2016-03-09 14:32:57 +05303744 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303745 vdev_id, retry_interval, max_retries);
3746
3747 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3748 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303749 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05303750 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303751 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303752 }
3753
Govind Singhb53420c2016-03-09 14:32:57 +05303754 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303755 return 0;
3756}
3757
3758/**
3759 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
3760 * @wmi_handle: wmi handle
3761 * @params: sta keep alive parameter
3762 *
3763 * This function sets keep alive related parameters in fw.
3764 *
3765 * Return: CDF status
3766 */
Govind Singhb53420c2016-03-09 14:32:57 +05303767QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303768 struct sta_params *params)
3769{
3770 wmi_buf_t buf;
3771 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
3772 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
3773 uint8_t *buf_ptr;
3774 int len;
Govind Singh67922e82016-04-01 16:48:57 +05303775 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303776
Govind Singhb53420c2016-03-09 14:32:57 +05303777 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303778
Govind Singh4eacd2b2016-03-07 14:24:22 +05303779 len = sizeof(*cmd) + sizeof(*arp_rsp);
3780 buf = wmi_buf_alloc(wmi_handle, len);
3781 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303782 WMI_LOGE("wmi_buf_alloc failed");
3783 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303784 }
3785
3786 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
3787 buf_ptr = (uint8_t *) cmd;
3788 WMITLV_SET_HDR(&cmd->tlv_header,
3789 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
3790 WMITLV_GET_STRUCT_TLVLEN
3791 (WMI_STA_KEEPALIVE_CMD_fixed_param));
3792 cmd->interval = params->timeperiod;
3793 cmd->enable = (params->timeperiod) ? 1 : 0;
3794 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05303795 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303796 params->timeperiod, params->method);
3797 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
3798 WMITLV_SET_HDR(&arp_rsp->tlv_header,
3799 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
3800 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
3801
3802 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
3803 if ((NULL == params->hostv4addr) ||
3804 (NULL == params->destv4addr) ||
3805 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303806 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05303807 "destv4addr:%p destmac:%p ", __func__,
3808 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303809 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303810 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303811 }
3812 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05303813 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303814 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05303815 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303816 WMI_IPV4_ADDR_LEN);
3817 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
3818 } else {
3819 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
3820 }
3821
Govind Singh67922e82016-04-01 16:48:57 +05303822 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3823 WMI_STA_KEEPALIVE_CMDID);
3824 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303825 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303826 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303827 }
3828
Govind Singhb53420c2016-03-09 14:32:57 +05303829 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303830 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303831}
3832
3833/**
3834 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
3835 * @wmi_handle: wmi handle
3836 * @if_id: vdev id
3837 * @gtx_info: GTX config params
3838 *
3839 * This function set GTX related params in firmware.
3840 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303841 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303842 */
Govind Singhb53420c2016-03-09 14:32:57 +05303843QDF_STATUS send_vdev_set_gtx_cfg_cmd_tlv(wmi_unified_t wmi_handle, uint32_t if_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303844 struct wmi_gtx_config *gtx_info)
3845{
3846 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
3847 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05303848 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303849 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303850
Govind Singh4eacd2b2016-03-07 14:24:22 +05303851 buf = wmi_buf_alloc(wmi_handle, len);
3852 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303853 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303854 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303855 }
3856 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
3857 WMITLV_SET_HDR(&cmd->tlv_header,
3858 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
3859 WMITLV_GET_STRUCT_TLVLEN
3860 (wmi_vdev_set_gtx_params_cmd_fixed_param));
3861 cmd->vdev_id = if_id;
3862
3863 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
3864 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
3865 cmd->userGtxMask = gtx_info->gtx_usrcfg;
3866 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
3867 cmd->gtxPERMargin = gtx_info->gtx_margin;
3868 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
3869 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
3870 cmd->gtxBWMask = gtx_info->gtx_bwmask;
3871
Govind Singhb53420c2016-03-09 14:32:57 +05303872 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05303873 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
3874 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
3875 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
3876 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
3877
Abhishek Singh716c46c2016-05-04 16:24:07 +05303878 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303879 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303880 if (QDF_IS_STATUS_ERROR(ret)) {
3881 WMI_LOGE("Failed to set GTX PARAMS");
3882 wmi_buf_free(buf);
3883 }
3884 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303885}
3886
3887/**
3888 * send_process_update_edca_param_cmd_tlv() - update EDCA params
3889 * @wmi_handle: wmi handle
3890 * @edca_params: edca parameters
3891 *
3892 * This function updates EDCA parameters to the target
3893 *
3894 * Return: CDF Status
3895 */
Govind Singhb53420c2016-03-09 14:32:57 +05303896QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303897 uint8_t vdev_id,
3898 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
3899{
3900 uint8_t *buf_ptr;
3901 wmi_buf_t buf;
3902 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
3903 wmi_wmm_vparams *wmm_param, *twmm_param;
3904 int len = sizeof(*cmd);
3905 int ac;
3906
3907 buf = wmi_buf_alloc(wmi_handle, len);
3908
3909 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303910 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3911 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303912 }
3913
3914 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3915 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
3916 WMITLV_SET_HDR(&cmd->tlv_header,
3917 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3918 WMITLV_GET_STRUCT_TLVLEN
3919 (wmi_vdev_set_wmm_params_cmd_fixed_param));
3920 cmd->vdev_id = vdev_id;
3921
3922 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
3923 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
3924 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
3925 WMITLV_SET_HDR(&wmm_param->tlv_header,
3926 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3927 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
3928 wmm_param->cwmin = twmm_param->cwmin;
3929 wmm_param->cwmax = twmm_param->cwmax;
3930 wmm_param->aifs = twmm_param->aifs;
3931 wmm_param->txoplimit = twmm_param->txoplimit;
3932 wmm_param->acm = twmm_param->acm;
3933 wmm_param->no_ack = twmm_param->no_ack;
3934 }
3935
3936 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3937 WMI_VDEV_SET_WMM_PARAMS_CMDID))
3938 goto fail;
3939
Govind Singhb53420c2016-03-09 14:32:57 +05303940 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303941
3942fail:
3943 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303944 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
3945 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303946}
3947
3948/**
3949 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
3950 * @wmi_handle: wmi handle
3951 * @vdev_id: vdev id
3952 * @probe_rsp_info: probe response info
3953 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303954 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303955 */
Govind Singhb53420c2016-03-09 14:32:57 +05303956QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303957 uint8_t vdev_id,
3958 struct wmi_probe_resp_params *probe_rsp_info,
3959 uint8_t *frm)
3960{
3961 wmi_prb_tmpl_cmd_fixed_param *cmd;
3962 wmi_bcn_prb_info *bcn_prb_info;
3963 wmi_buf_t wmi_buf;
3964 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
3965 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05303966 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303967
Govind Singhb53420c2016-03-09 14:32:57 +05303968 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303969
3970 tmpl_len = probe_rsp_info->probeRespTemplateLen;
3971 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
3972
3973 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
3974 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
3975 tmpl_len_aligned;
3976
3977 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05303978 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303979 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05303980 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303981 }
3982
3983 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3984 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303985 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303986 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303987 }
3988
3989 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3990
3991 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
3992 WMITLV_SET_HDR(&cmd->tlv_header,
3993 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
3994 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
3995 cmd->vdev_id = vdev_id;
3996 cmd->buf_len = tmpl_len;
3997 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
3998
3999 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4000 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4001 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4002 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4003 bcn_prb_info->caps = 0;
4004 bcn_prb_info->erp = 0;
4005 buf_ptr += sizeof(wmi_bcn_prb_info);
4006
4007 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4008 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304009 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304010
4011 ret = wmi_unified_cmd_send(wmi_handle,
4012 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304013 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304014 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304015 wmi_buf_free(wmi_buf);
4016 }
4017
4018 return ret;
4019}
4020
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304021#ifdef FEATURE_WLAN_WAPI
4022#define WPI_IV_LEN 16
4023
4024/**
4025 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4026 *
4027 * @dest_tx: destination address of tsc key counter
4028 * @src_tx: source address of tsc key counter
4029 * @dest_rx: destination address of rsc key counter
4030 * @src_rx: source address of rsc key counter
4031 *
4032 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4033 *
4034 * Return: None
4035 *
4036 */
4037static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4038 uint8_t *dest_rx, uint8_t *src_rx)
4039{
4040 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4041 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4042}
4043#else
4044static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4045 uint8_t *dest_rx, uint8_t *src_rx)
4046{
4047 return;
4048}
4049#endif
4050
4051/**
4052 * send_setup_install_key_cmd_tlv() - set key parameters
4053 * @wmi_handle: wmi handle
4054 * @key_params: key parameters
4055 *
4056 * This function fills structure from information
4057 * passed in key_params.
4058 *
4059 * Return: QDF_STATUS_SUCCESS - success
4060 * QDF_STATUS_E_FAILURE - failure
4061 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4062 */
4063QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
4064 struct set_key_params *key_params)
4065{
4066 wmi_vdev_install_key_cmd_fixed_param *cmd;
4067 wmi_buf_t buf;
4068 uint8_t *buf_ptr;
4069 uint32_t len;
4070 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304071 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304072
4073 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4074 WMI_TLV_HDR_SIZE;
4075
4076 buf = wmi_buf_alloc(wmi_handle, len);
4077 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304078 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304079 return QDF_STATUS_E_NOMEM;
4080 }
4081
4082 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4083 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4084 WMITLV_SET_HDR(&cmd->tlv_header,
4085 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4086 WMITLV_GET_STRUCT_TLVLEN
4087 (wmi_vdev_install_key_cmd_fixed_param));
4088 cmd->vdev_id = key_params->vdev_id;
4089 cmd->key_ix = key_params->key_idx;
4090 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4091 cmd->key_flags |= key_params->key_flags;
4092 cmd->key_cipher = key_params->key_cipher;
4093 if ((key_params->key_txmic_len) &&
4094 (key_params->key_rxmic_len)) {
4095 cmd->key_txmic_len = key_params->key_txmic_len;
4096 cmd->key_rxmic_len = key_params->key_rxmic_len;
4097 }
Govind Singh87542482016-06-08 19:40:11 +05304098#ifdef FEATURE_WLAN_WAPI
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304099 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4100 key_params->tx_iv,
4101 cmd->wpi_key_rsc_counter,
4102 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304103#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304104 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4105 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4106 roundup(key_params->key_len, sizeof(uint32_t)));
4107 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4108 qdf_mem_copy((void *)key_data,
4109 (const void *)key_params->key_data, key_params->key_len);
4110 cmd->key_len = key_params->key_len;
4111
4112 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4113 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304114 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304115 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304116
Govind Singh67922e82016-04-01 16:48:57 +05304117 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304118}
4119
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304120/**
4121 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4122 * @wmi_handle: wmi handle
4123 * @params: encrypt/decrypt params
4124 *
4125 * Return: QDF_STATUS_SUCCESS for success or error code
4126 */
4127QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4128 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4129{
4130 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4131 wmi_buf_t wmi_buf;
4132 uint8_t *buf_ptr;
4133 QDF_STATUS ret;
4134 uint32_t len;
4135
4136 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4137
4138 len = sizeof(*cmd) +
4139 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4140 WMI_TLV_HDR_SIZE;
4141 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4142 if (!wmi_buf) {
4143 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4144 __func__);
4145 return QDF_STATUS_E_NOMEM;
4146 }
4147
4148 buf_ptr = wmi_buf_data(wmi_buf);
4149 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4150
4151 WMITLV_SET_HDR(&cmd->tlv_header,
4152 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4153 WMITLV_GET_STRUCT_TLVLEN(
4154 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4155
4156 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4157 cmd->key_flag = encrypt_decrypt_params->key_flag;
4158 cmd->key_idx = encrypt_decrypt_params->key_idx;
4159 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4160 cmd->key_len = encrypt_decrypt_params->key_len;
4161 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4162 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4163
4164 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4165 encrypt_decrypt_params->key_len);
4166
4167 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4168 MAX_MAC_HEADER_LEN);
4169
4170 cmd->data_len = encrypt_decrypt_params->data_len;
4171
4172 if (cmd->data_len) {
4173 buf_ptr += sizeof(*cmd);
4174 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4175 roundup(encrypt_decrypt_params->data_len,
4176 sizeof(A_UINT32)));
4177 buf_ptr += WMI_TLV_HDR_SIZE;
4178 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4179 encrypt_decrypt_params->data_len);
4180 }
4181
4182 /* This conversion is to facilitate data to FW in little endian */
4183 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4184 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4185 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4186 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4187 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4188 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4189
4190 ret = wmi_unified_cmd_send(wmi_handle,
4191 wmi_buf, len,
4192 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4193 if (QDF_IS_STATUS_ERROR(ret)) {
4194 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4195 wmi_buf_free(wmi_buf);
4196 }
4197
4198 return ret;
4199}
4200
4201
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304202
Govind Singh4eacd2b2016-03-07 14:24:22 +05304203/**
4204 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4205 * @wmi_handle: wmi handle
4206 * @vdev_id: vdev id
4207 * @p2p_ie: p2p IE
4208 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304209 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304210 */
Govind Singhb53420c2016-03-09 14:32:57 +05304211QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304212 A_UINT32 vdev_id, uint8_t *p2p_ie)
4213{
Govind Singh67922e82016-04-01 16:48:57 +05304214 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304215 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4216 wmi_buf_t wmi_buf;
4217 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4218 uint8_t *buf_ptr;
4219
4220 ie_len = (uint32_t) (p2p_ie[1] + 2);
4221
4222 /* More than one P2P IE may be included in a single frame.
4223 If multiple P2P IEs are present, the complete P2P attribute
4224 data consists of the concatenation of the P2P Attribute
4225 fields of the P2P IEs. The P2P Attributes field of each
4226 P2P IE may be any length up to the maximum (251 octets).
4227 In this case host sends one P2P IE to firmware so the length
4228 should not exceed more than 251 bytes
4229 */
4230 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304231 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304232 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304233 }
4234
4235 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4236
4237 wmi_buf_len =
4238 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4239 WMI_TLV_HDR_SIZE;
4240
4241 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4242 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304243 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304244 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304245 }
4246
4247 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4248
4249 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4250 WMITLV_SET_HDR(&cmd->tlv_header,
4251 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4252 WMITLV_GET_STRUCT_TLVLEN
4253 (wmi_p2p_go_set_beacon_ie_fixed_param));
4254 cmd->vdev_id = vdev_id;
4255 cmd->ie_buf_len = ie_len;
4256
4257 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4258 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4259 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304260 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304261
Govind Singhb53420c2016-03-09 14:32:57 +05304262 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304263
4264 ret = wmi_unified_cmd_send(wmi_handle,
4265 wmi_buf, wmi_buf_len,
4266 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304267 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304268 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304269 wmi_buf_free(wmi_buf);
4270 }
4271
Govind Singhb53420c2016-03-09 14:32:57 +05304272 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304273 return ret;
4274}
4275
4276/**
4277 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4278 * @wmi_handle: wmi handle
4279 * @req: gateway parameter update request structure
4280 *
4281 * This function reads the incoming @req and fill in the destination
4282 * WMI structure and sends down the gateway configs down to the firmware
4283 *
Govind Singhb53420c2016-03-09 14:32:57 +05304284 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304285 */
Govind Singhb53420c2016-03-09 14:32:57 +05304286QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304287 struct gateway_update_req_param *req)
4288{
4289 wmi_roam_subnet_change_config_fixed_param *cmd;
4290 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304291 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304292 int len = sizeof(*cmd);
4293
4294 buf = wmi_buf_alloc(wmi_handle, len);
4295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304296 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4297 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304298 }
4299
4300 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4301 WMITLV_SET_HDR(&cmd->tlv_header,
4302 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4303 WMITLV_GET_STRUCT_TLVLEN(
4304 wmi_roam_subnet_change_config_fixed_param));
4305
4306 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304307 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4308 QDF_IPV4_ADDR_SIZE);
4309 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4310 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304311 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4312 &cmd->inet_gw_mac_addr);
4313 cmd->max_retries = req->max_retries;
4314 cmd->timeout = req->timeout;
4315 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4316 cmd->flag = 0;
4317 if (req->ipv4_addr_type)
4318 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4319
4320 if (req->ipv6_addr_type)
4321 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4322
4323 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4324 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304325 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304326 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304327 ret);
4328 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304329 }
4330
Govind Singh67922e82016-04-01 16:48:57 +05304331 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304332}
4333
4334/**
4335 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4336 * @wmi_handle: wmi handle
4337 * @req: rssi monitoring request structure
4338 *
4339 * This function reads the incoming @req and fill in the destination
4340 * WMI structure and send down the rssi monitoring configs down to the firmware
4341 *
4342 * Return: 0 on success; error number otherwise
4343 */
Govind Singhb53420c2016-03-09 14:32:57 +05304344QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304345 struct rssi_monitor_param *req)
4346{
4347 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4348 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304349 QDF_STATUS ret;
4350 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304351
4352 buf = wmi_buf_alloc(wmi_handle, len);
4353 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304354 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4355 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304356 }
4357
4358 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4359 WMITLV_SET_HDR(&cmd->tlv_header,
4360 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4361 WMITLV_GET_STRUCT_TLVLEN(
4362 wmi_rssi_breach_monitor_config_fixed_param));
4363
4364 cmd->vdev_id = req->session_id;
4365 cmd->request_id = req->request_id;
4366 cmd->lo_rssi_reenable_hysteresis = 0;
4367 cmd->hi_rssi_reenable_histeresis = 0;
4368 cmd->min_report_interval = 0;
4369 cmd->max_num_report = 1;
4370 if (req->control) {
4371 /* enable one threshold for each min/max */
4372 cmd->enabled_bitmap = 0x09;
4373 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4374 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4375 } else {
4376 cmd->enabled_bitmap = 0;
4377 cmd->low_rssi_breach_threshold[0] = 0;
4378 cmd->hi_rssi_breach_threshold[0] = 0;
4379 }
4380
4381 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4382 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304383 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304384 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304385 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304386 }
4387
Govind Singhb53420c2016-03-09 14:32:57 +05304388 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304389 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304390}
4391
4392/**
4393 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4394 * @wmi_handle: wmi handle
4395 * @psetoui: OUI parameters
4396 *
4397 * set scan probe OUI parameters in firmware
4398 *
4399 * Return: CDF status
4400 */
Govind Singhb53420c2016-03-09 14:32:57 +05304401QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304402 struct scan_mac_oui *psetoui)
4403{
4404 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4405 wmi_buf_t wmi_buf;
4406 uint32_t len;
4407 uint8_t *buf_ptr;
4408 uint32_t *oui_buf;
4409
4410 len = sizeof(*cmd);
4411 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4412 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304413 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4414 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304415 }
4416 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4417 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4418 WMITLV_SET_HDR(&cmd->tlv_header,
4419 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4420 WMITLV_GET_STRUCT_TLVLEN
4421 (wmi_scan_prob_req_oui_cmd_fixed_param));
4422
4423 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304424 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304425 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4426 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304427 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304428 cmd->prob_req_oui);
4429
4430 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4431 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304432 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304433 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304434 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304435 }
Govind Singhb53420c2016-03-09 14:32:57 +05304436 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304437}
4438
4439/**
4440 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
4441 * @wmi_handle: wmi handle
4442 * @req: passpoint network request structure
4443 *
4444 * This function sends down WMI command with network id set to wildcard id.
4445 * firmware shall clear all the config entries
4446 *
Govind Singhb53420c2016-03-09 14:32:57 +05304447 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304448 */
Govind Singhb53420c2016-03-09 14:32:57 +05304449QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304450 struct wifi_passpoint_req_param *req)
4451{
4452 wmi_passpoint_config_cmd_fixed_param *cmd;
4453 wmi_buf_t buf;
4454 uint32_t len;
4455 int ret;
4456
4457 len = sizeof(*cmd);
4458 buf = wmi_buf_alloc(wmi_handle, len);
4459 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304460 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4461 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304462 }
4463
4464 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
4465
4466 WMITLV_SET_HDR(&cmd->tlv_header,
4467 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4468 WMITLV_GET_STRUCT_TLVLEN(
4469 wmi_passpoint_config_cmd_fixed_param));
4470 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
4471
4472 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4473 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4474 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304475 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304476 __func__);
4477 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304478 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304479 }
4480
Govind Singhb53420c2016-03-09 14:32:57 +05304481 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304482}
4483
4484/**
4485 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
4486 * @wmi_handle: wmi handle
4487 * @req: passpoint network request structure
4488 *
4489 * This function reads the incoming @req and fill in the destination
4490 * WMI structure and send down the passpoint configs down to the firmware
4491 *
Govind Singhb53420c2016-03-09 14:32:57 +05304492 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304493 */
Govind Singhb53420c2016-03-09 14:32:57 +05304494QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304495 struct wifi_passpoint_req_param *req)
4496{
4497 wmi_passpoint_config_cmd_fixed_param *cmd;
4498 u_int8_t i, j, *bytes;
4499 wmi_buf_t buf;
4500 uint32_t len;
4501 int ret;
4502
4503 len = sizeof(*cmd);
4504 for (i = 0; i < req->num_networks; i++) {
4505 buf = wmi_buf_alloc(wmi_handle, len);
4506 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304507 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4508 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304509 }
4510
4511 cmd = (wmi_passpoint_config_cmd_fixed_param *)
4512 wmi_buf_data(buf);
4513
4514 WMITLV_SET_HDR(&cmd->tlv_header,
4515 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4516 WMITLV_GET_STRUCT_TLVLEN(
4517 wmi_passpoint_config_cmd_fixed_param));
4518 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05304519 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
4520 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304521 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05304522 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304523 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
4524 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05304525 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304526 j, bytes[0], bytes[1], bytes[2], bytes[3],
4527 bytes[4], bytes[5], bytes[6], bytes[7]);
4528
Govind Singhb53420c2016-03-09 14:32:57 +05304529 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05304530 &req->networks[i].roaming_consortium_ids[j],
4531 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
4532 }
Govind Singhb53420c2016-03-09 14:32:57 +05304533 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304534 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304535 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304536 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
4537
4538 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4539 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4540 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304541 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304542 __func__);
4543 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304544 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304545 }
4546 }
4547
Govind Singhb53420c2016-03-09 14:32:57 +05304548 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304549}
4550
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304551/**
4552 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
4553 * @wmi_handle: wmi handle
4554 * @scan_cmd_fp: start scan command ptr
4555 * @roam_req: roam request param
4556 *
4557 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
4558 * of WMI_ROAM_SCAN_MODE.
4559 *
4560 * Return: QDF status
4561 */
4562QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
4563 wmi_start_scan_cmd_fixed_param *
4564 scan_cmd_fp,
4565 struct roam_offload_scan_params *roam_req)
4566{
4567 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304568 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304569 int len;
4570 uint8_t *buf_ptr;
4571 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05304572
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304573#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4574 int auth_mode = roam_req->auth_mode;
4575 wmi_roam_offload_tlv_param *roam_offload_params;
4576 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
4577 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
4578 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304579 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304580#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4581 /* Need to create a buf with roam_scan command at
4582 * front and piggyback with scan command */
4583 len = sizeof(wmi_roam_scan_mode_fixed_param) +
4584#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4585 (2 * WMI_TLV_HDR_SIZE) +
4586#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4587 sizeof(wmi_start_scan_cmd_fixed_param);
4588#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4589 if (roam_req->is_roam_req_valid &&
4590 roam_req->roam_offload_enabled) {
4591 len += sizeof(wmi_roam_offload_tlv_param);
4592 len += WMI_TLV_HDR_SIZE;
4593 if ((auth_mode != WMI_AUTH_NONE) &&
4594 ((auth_mode != WMI_AUTH_OPEN) ||
4595 (auth_mode == WMI_AUTH_OPEN &&
4596 roam_req->mdid.mdie_present) ||
4597 roam_req->is_ese_assoc)) {
4598 len += WMI_TLV_HDR_SIZE;
4599 if (roam_req->is_ese_assoc)
4600 len +=
4601 sizeof(wmi_roam_ese_offload_tlv_param);
4602 else if (auth_mode == WMI_AUTH_FT_RSNA ||
4603 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
4604 (auth_mode == WMI_AUTH_OPEN &&
4605 roam_req->mdid.mdie_present))
4606 len +=
4607 sizeof(wmi_roam_11r_offload_tlv_param);
4608 else
4609 len +=
4610 sizeof(wmi_roam_11i_offload_tlv_param);
4611 } else {
4612 len += WMI_TLV_HDR_SIZE;
4613 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304614
4615 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
4616 + roundup(roam_req->assoc_ie_length,
4617 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304618 } else {
4619 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05304620 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304621 __func__, roam_req->roam_offload_enabled);
4622 else
Govind Singhe7f2f342016-05-23 12:12:52 +05304623 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304624 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304625 }
4626 if (roam_req->is_roam_req_valid &&
4627 roam_req->roam_offload_enabled) {
4628 roam_req->mode = roam_req->mode |
4629 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
4630 }
4631#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4632
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304633 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4634 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4635 len = sizeof(wmi_roam_scan_mode_fixed_param);
4636
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304637 buf = wmi_buf_alloc(wmi_handle, len);
4638 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304639 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304640 return QDF_STATUS_E_NOMEM;
4641 }
4642
4643 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304644
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304645 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
4646 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
4647 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
4648 WMITLV_GET_STRUCT_TLVLEN
4649 (wmi_roam_scan_mode_fixed_param));
4650
4651 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
4652 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304653 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4654 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4655 goto send_roam_scan_mode_cmd;
4656
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304657 /* Fill in scan parameters suitable for roaming scan */
4658 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304659
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304660 qdf_mem_copy(buf_ptr, scan_cmd_fp,
4661 sizeof(wmi_start_scan_cmd_fixed_param));
4662 /* Ensure there is no additional IEs */
4663 scan_cmd_fp->ie_len = 0;
4664 WMITLV_SET_HDR(buf_ptr,
4665 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
4666 WMITLV_GET_STRUCT_TLVLEN
4667 (wmi_start_scan_cmd_fixed_param));
4668#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4669 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
4670 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
4671 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4672 sizeof(wmi_roam_offload_tlv_param));
4673 buf_ptr += WMI_TLV_HDR_SIZE;
4674 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
4675 WMITLV_SET_HDR(buf_ptr,
4676 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
4677 WMITLV_GET_STRUCT_TLVLEN
4678 (wmi_roam_offload_tlv_param));
4679 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
4680 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
4681 roam_offload_params->select_5g_margin =
4682 roam_req->select_5ghz_margin;
4683 roam_offload_params->reassoc_failure_timeout =
4684 roam_req->reassoc_failure_timeout;
4685
4686 /* Fill the capabilities */
4687 roam_offload_params->capability =
4688 roam_req->roam_offload_params.capability;
4689 roam_offload_params->ht_caps_info =
4690 roam_req->roam_offload_params.ht_caps_info;
4691 roam_offload_params->ampdu_param =
4692 roam_req->roam_offload_params.ampdu_param;
4693 roam_offload_params->ht_ext_cap =
4694 roam_req->roam_offload_params.ht_ext_cap;
4695 roam_offload_params->ht_txbf =
4696 roam_req->roam_offload_params.ht_txbf;
4697 roam_offload_params->asel_cap =
4698 roam_req->roam_offload_params.asel_cap;
4699 roam_offload_params->qos_caps =
4700 roam_req->roam_offload_params.qos_caps;
4701 roam_offload_params->wmm_caps =
4702 roam_req->roam_offload_params.wmm_caps;
4703 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
4704 (uint8_t *)roam_req->roam_offload_params.mcsset,
4705 ROAM_OFFLOAD_NUM_MCS_SET);
4706
4707 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
4708 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
4709 * they are filled in the same order.Depending on the
4710 * authentication type, the other mode TLV's are nullified
4711 * and only headers are filled.*/
4712 if ((auth_mode != WMI_AUTH_NONE) &&
4713 ((auth_mode != WMI_AUTH_OPEN) ||
4714 (auth_mode == WMI_AUTH_OPEN
4715 && roam_req->mdid.mdie_present) ||
4716 roam_req->is_ese_assoc)) {
4717 if (roam_req->is_ese_assoc) {
4718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4719 WMITLV_GET_STRUCT_TLVLEN(0));
4720 buf_ptr += WMI_TLV_HDR_SIZE;
4721 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4722 WMITLV_GET_STRUCT_TLVLEN(0));
4723 buf_ptr += WMI_TLV_HDR_SIZE;
4724 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4725 sizeof(wmi_roam_ese_offload_tlv_param));
4726 buf_ptr += WMI_TLV_HDR_SIZE;
4727 roam_offload_ese =
4728 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
4729 qdf_mem_copy(roam_offload_ese->krk,
4730 roam_req->krk,
4731 sizeof(roam_req->krk));
4732 qdf_mem_copy(roam_offload_ese->btk,
4733 roam_req->btk,
4734 sizeof(roam_req->btk));
4735 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
4736 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
4737 WMITLV_GET_STRUCT_TLVLEN
4738 (wmi_roam_ese_offload_tlv_param));
4739 buf_ptr +=
4740 sizeof(wmi_roam_ese_offload_tlv_param);
4741 } else if (auth_mode == WMI_AUTH_FT_RSNA
4742 || auth_mode == WMI_AUTH_FT_RSNA_PSK
4743 || (auth_mode == WMI_AUTH_OPEN
4744 && roam_req->mdid.mdie_present)) {
4745 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4746 0);
4747 buf_ptr += WMI_TLV_HDR_SIZE;
4748 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4749 sizeof(wmi_roam_11r_offload_tlv_param));
4750 buf_ptr += WMI_TLV_HDR_SIZE;
4751 roam_offload_11r =
4752 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
4753 roam_offload_11r->r0kh_id_len =
4754 roam_req->rokh_id_length;
4755 qdf_mem_copy(roam_offload_11r->r0kh_id,
4756 roam_req->rokh_id,
4757 roam_offload_11r->r0kh_id_len);
4758 qdf_mem_copy(roam_offload_11r->psk_msk,
4759 roam_req->psk_pmk,
4760 sizeof(roam_req->psk_pmk));
4761 roam_offload_11r->psk_msk_len =
4762 roam_req->pmk_len;
4763 roam_offload_11r->mdie_present =
4764 roam_req->mdid.mdie_present;
4765 roam_offload_11r->mdid =
4766 roam_req->mdid.mobility_domain;
4767 if (auth_mode == WMI_AUTH_OPEN) {
4768 /* If FT-Open ensure pmk length
4769 and r0khid len are zero */
4770 roam_offload_11r->r0kh_id_len = 0;
4771 roam_offload_11r->psk_msk_len = 0;
4772 }
4773 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
4774 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
4775 WMITLV_GET_STRUCT_TLVLEN
4776 (wmi_roam_11r_offload_tlv_param));
4777 buf_ptr +=
4778 sizeof(wmi_roam_11r_offload_tlv_param);
4779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4780 WMITLV_GET_STRUCT_TLVLEN(0));
4781 buf_ptr += WMI_TLV_HDR_SIZE;
4782 } else {
4783 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4784 sizeof(wmi_roam_11i_offload_tlv_param));
4785 buf_ptr += WMI_TLV_HDR_SIZE;
4786 roam_offload_11i =
4787 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07004788 if (roam_req->roam_key_mgmt_offload_enabled &&
4789 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304790 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
4791 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304792 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304793 } else {
4794 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
4795 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304796 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304797 }
4798
4799 qdf_mem_copy(roam_offload_11i->pmk,
4800 roam_req->psk_pmk,
4801 sizeof(roam_req->psk_pmk));
4802 roam_offload_11i->pmk_len = roam_req->pmk_len;
4803 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
4804 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
4805 WMITLV_GET_STRUCT_TLVLEN
4806 (wmi_roam_11i_offload_tlv_param));
4807 buf_ptr +=
4808 sizeof(wmi_roam_11i_offload_tlv_param);
4809 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4810 0);
4811 buf_ptr += WMI_TLV_HDR_SIZE;
4812 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4813 0);
4814 buf_ptr += WMI_TLV_HDR_SIZE;
4815 }
4816 } else {
4817 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4818 WMITLV_GET_STRUCT_TLVLEN(0));
4819 buf_ptr += WMI_TLV_HDR_SIZE;
4820 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4821 WMITLV_GET_STRUCT_TLVLEN(0));
4822 buf_ptr += WMI_TLV_HDR_SIZE;
4823 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4824 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304825 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304826 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304827
4828 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4829 sizeof(*assoc_ies));
4830 buf_ptr += WMI_TLV_HDR_SIZE;
4831
4832 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
4833 WMITLV_SET_HDR(&assoc_ies->tlv_header,
4834 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
4835 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
4836 assoc_ies->buf_len = roam_req->assoc_ie_length;
4837
4838 buf_ptr += sizeof(*assoc_ies);
4839
4840 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4841 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
4842 buf_ptr += WMI_TLV_HDR_SIZE;
4843
4844 if (assoc_ies->buf_len != 0) {
4845 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
4846 assoc_ies->buf_len);
4847 }
4848
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304849 } else {
4850 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4851 WMITLV_GET_STRUCT_TLVLEN(0));
4852 buf_ptr += WMI_TLV_HDR_SIZE;
4853 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4854 WMITLV_GET_STRUCT_TLVLEN(0));
4855 buf_ptr += WMI_TLV_HDR_SIZE;
4856 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4857 WMITLV_GET_STRUCT_TLVLEN(0));
4858 buf_ptr += WMI_TLV_HDR_SIZE;
4859 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4860 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304861 buf_ptr += WMI_TLV_HDR_SIZE;
4862 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4863 WMITLV_GET_STRUCT_TLVLEN(0));
4864 buf_ptr += WMI_TLV_HDR_SIZE;
4865 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4866 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304867 }
4868#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304869
4870send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304871 status = wmi_unified_cmd_send(wmi_handle, buf,
4872 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05304873 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304874 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304875 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
4876 status);
4877 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304878 }
4879
Govind Singh67922e82016-04-01 16:48:57 +05304880 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304881}
4882
4883
4884/**
4885 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
4886 * rssi threashold
4887 * @wmi_handle: wmi handle
4888 * @roam_req: Roaming request buffer
4889 *
4890 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
4891 *
4892 * Return: QDF status
4893 */
4894QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
4895 struct roam_offload_scan_rssi_params *roam_req)
4896{
4897 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304898 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304899 int len;
4900 uint8_t *buf_ptr;
4901 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
4902 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
4903 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05304904 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304905
4906 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4907 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
4908 len += sizeof(wmi_roam_scan_extended_threshold_param);
4909 len += WMI_TLV_HDR_SIZE;
4910 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05304911 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
4912 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304913 buf = wmi_buf_alloc(wmi_handle, len);
4914 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304915 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304916 return QDF_STATUS_E_NOMEM;
4917 }
4918
4919 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4920 rssi_threshold_fp =
4921 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
4922 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
4923 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
4924 WMITLV_GET_STRUCT_TLVLEN
4925 (wmi_roam_scan_rssi_threshold_fixed_param));
4926 /* fill in threshold values */
4927 rssi_threshold_fp->vdev_id = roam_req->session_id;
4928 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
4929 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
4930 rssi_threshold_fp->hirssi_scan_max_count =
4931 roam_req->hi_rssi_scan_max_count;
4932 rssi_threshold_fp->hirssi_scan_delta =
4933 roam_req->hi_rssi_scan_rssi_delta;
4934 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
4935
4936 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4937 WMITLV_SET_HDR(buf_ptr,
4938 WMITLV_TAG_ARRAY_STRUC,
4939 sizeof(wmi_roam_scan_extended_threshold_param));
4940 buf_ptr += WMI_TLV_HDR_SIZE;
4941 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
4942
4943 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
4944 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
4945 ext_thresholds->boost_threshold_5g =
4946 roam_req->boost_threshold_5g;
4947
4948 ext_thresholds->boost_algorithm_5g =
4949 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4950 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
4951 ext_thresholds->penalty_algorithm_5g =
4952 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4953 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
4954 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
4955 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
4956 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
4957
4958 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
4959 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
4960 WMITLV_GET_STRUCT_TLVLEN
4961 (wmi_roam_scan_extended_threshold_param));
4962 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
4963 WMITLV_SET_HDR(buf_ptr,
4964 WMITLV_TAG_ARRAY_STRUC,
4965 sizeof(wmi_roam_earlystop_rssi_thres_param));
4966 buf_ptr += WMI_TLV_HDR_SIZE;
4967 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
4968 early_stop_thresholds->roam_earlystop_thres_min =
4969 roam_req->roam_earlystop_thres_min;
4970 early_stop_thresholds->roam_earlystop_thres_max =
4971 roam_req->roam_earlystop_thres_max;
4972 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
4973 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
4974 WMITLV_GET_STRUCT_TLVLEN
4975 (wmi_roam_earlystop_rssi_thres_param));
4976
Gupta, Kapil7e652922016-04-12 15:02:00 +05304977 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
4978 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4979 sizeof(wmi_roam_dense_thres_param));
4980 buf_ptr += WMI_TLV_HDR_SIZE;
4981 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
4982 dense_thresholds->roam_dense_rssi_thres_offset =
4983 roam_req->dense_rssi_thresh_offset;
4984 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
4985 dense_thresholds->roam_dense_traffic_thres =
4986 roam_req->traffic_threshold;
4987 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
4988 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
4989 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
4990 WMITLV_GET_STRUCT_TLVLEN
4991 (wmi_roam_dense_thres_param));
4992
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304993 status = wmi_unified_cmd_send(wmi_handle, buf,
4994 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05304995 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304996 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304997 status);
4998 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304999 }
5000
Govind Singh67922e82016-04-01 16:48:57 +05305001 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305002}
5003
5004/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305005 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5006 * configuration params
5007 * @wma_handle: wma handler
5008 * @dwelltime_params: pointer to dwelltime_params
5009 *
5010 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5011 */
5012QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5013 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5014{
5015 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5016 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5017 wmi_buf_t buf;
5018 uint8_t *buf_ptr;
5019 int32_t err;
5020 int len;
5021
5022 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5023 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5024 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5025 buf = wmi_buf_alloc(wmi_handle, len);
5026 if (!buf) {
5027 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5028 __func__);
5029 return QDF_STATUS_E_NOMEM;
5030 }
5031 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5032 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5033 WMITLV_SET_HDR(&dwell_param->tlv_header,
5034 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5035 WMITLV_GET_STRUCT_TLVLEN
5036 (wmi_scan_adaptive_dwell_config_fixed_param));
5037
5038 dwell_param->enable = dwelltime_params->is_enabled;
5039 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5040 WMITLV_SET_HDR(buf_ptr,
5041 WMITLV_TAG_ARRAY_STRUC,
5042 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5043 buf_ptr += WMI_TLV_HDR_SIZE;
5044
5045 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5046 WMITLV_SET_HDR(&cmd->tlv_header,
5047 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5048 WMITLV_GET_STRUCT_TLVLEN(
5049 wmi_scan_adaptive_dwell_parameters_tlv));
5050
5051 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5052 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5053 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5054 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5055 err = wmi_unified_cmd_send(wmi_handle, buf,
5056 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5057 if (err) {
5058 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5059 wmi_buf_free(buf);
5060 return QDF_STATUS_E_FAILURE;
5061 }
5062
5063 return QDF_STATUS_SUCCESS;
5064}
5065
5066
5067/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305068 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5069 * @wmi_handle: wmi handle
5070 * @roam_req: Request which contains the filters
5071 *
5072 * There are filters such as whitelist, blacklist and preferred
5073 * list that need to be applied to the scan results to form the
5074 * probable candidates for roaming.
5075 *
5076 * Return: Return success upon succesfully passing the
5077 * parameters to the firmware, otherwise failure.
5078 */
5079QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
5080 struct roam_scan_filter_params *roam_req)
5081{
5082 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305083 QDF_STATUS status;
5084 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305085 uint32_t len;
5086 uint8_t *buf_ptr;
5087 wmi_roam_filter_fixed_param *roam_filter;
5088 uint8_t *bssid_src_ptr = NULL;
5089 wmi_mac_addr *bssid_dst_ptr = NULL;
5090 wmi_ssid *ssid_ptr = NULL;
5091 uint32_t *bssid_preferred_factor_ptr = NULL;
5092
5093 len = sizeof(wmi_roam_filter_fixed_param);
5094 len += WMI_TLV_HDR_SIZE;
5095 len += roam_req->len;
5096
5097 buf = wmi_buf_alloc(wmi_handle, len);
5098 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305099 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305100 return QDF_STATUS_E_NOMEM;
5101 }
5102
5103 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5104 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5105 WMITLV_SET_HDR(&roam_filter->tlv_header,
5106 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5107 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5108 /* fill in fixed values */
5109 roam_filter->vdev_id = roam_req->session_id;
5110 roam_filter->flags = 0;
5111 roam_filter->op_bitmap = roam_req->op_bitmap;
5112 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5113 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5114 roam_filter->num_bssid_preferred_list =
5115 roam_req->num_bssid_preferred_list;
5116 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5117
5118 WMITLV_SET_HDR((buf_ptr),
5119 WMITLV_TAG_ARRAY_FIXED_STRUC,
5120 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5121 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5122 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5123 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5124 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5125 bssid_src_ptr += ATH_MAC_LEN;
5126 bssid_dst_ptr++;
5127 }
5128 buf_ptr += WMI_TLV_HDR_SIZE +
5129 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5130 WMITLV_SET_HDR((buf_ptr),
5131 WMITLV_TAG_ARRAY_FIXED_STRUC,
5132 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5133 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5134 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5135 qdf_mem_copy(&ssid_ptr->ssid,
5136 &roam_req->ssid_allowed_list[i].mac_ssid,
5137 roam_req->ssid_allowed_list[i].length);
5138 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5139 ssid_ptr++;
5140 }
5141 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5142 sizeof(wmi_ssid));
5143 WMITLV_SET_HDR((buf_ptr),
5144 WMITLV_TAG_ARRAY_FIXED_STRUC,
5145 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5146 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5147 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5148 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5149 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5150 (wmi_mac_addr *)bssid_dst_ptr);
5151 bssid_src_ptr += ATH_MAC_LEN;
5152 bssid_dst_ptr++;
5153 }
5154 buf_ptr += WMI_TLV_HDR_SIZE +
5155 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5156 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5157 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5158 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5159 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5160 *bssid_preferred_factor_ptr =
5161 roam_req->bssid_favored_factor[i];
5162 bssid_preferred_factor_ptr++;
5163 }
5164 buf_ptr += WMI_TLV_HDR_SIZE +
5165 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5166
5167 status = wmi_unified_cmd_send(wmi_handle, buf,
5168 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305169 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305170 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305171 status);
5172 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305173 }
Govind Singh67922e82016-04-01 16:48:57 +05305174
5175 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305176}
5177
Govind Singh4eacd2b2016-03-07 14:24:22 +05305178/** send_set_epno_network_list_cmd_tlv() - set epno network list
5179 * @wmi_handle: wmi handle
5180 * @req: epno config params request structure
5181 *
5182 * This function reads the incoming epno config request structure
5183 * and constructs the WMI message to the firmware.
5184 *
5185 * Returns: 0 on success, error number otherwise
5186 */
Govind Singhb53420c2016-03-09 14:32:57 +05305187QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305188 struct wifi_enhanched_pno_params *req)
5189{
5190 wmi_nlo_config_cmd_fixed_param *cmd;
5191 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305192 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305193 u_int8_t i, *buf_ptr;
5194 wmi_buf_t buf;
5195 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305196 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305197
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305198 /* Fixed Params */
5199 len = sizeof(*cmd);
5200 if (req->num_networks) {
5201 /* TLV place holder for array of structures
5202 * then each nlo_configured_parameters(nlo_list) TLV.
5203 */
5204 len += WMI_TLV_HDR_SIZE;
5205 len += (sizeof(nlo_configured_parameters)
5206 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5207 /* TLV for array of uint32 channel_list */
5208 len += WMI_TLV_HDR_SIZE;
5209 /* TLV for nlo_channel_prediction_cfg */
5210 len += WMI_TLV_HDR_SIZE;
5211 /* TLV for candidate score params */
5212 len += sizeof(enlo_candidate_score_params);
5213 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305214
5215 buf = wmi_buf_alloc(wmi_handle, len);
5216 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305217 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5218 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305219 }
5220
5221 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5222
5223 buf_ptr = (u_int8_t *) cmd;
5224 WMITLV_SET_HDR(&cmd->tlv_header,
5225 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5226 WMITLV_GET_STRUCT_TLVLEN(
5227 wmi_nlo_config_cmd_fixed_param));
5228 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305229
5230 /* set flag to reset if num of networks are 0 */
5231 cmd->flags = (req->num_networks == 0 ?
5232 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305233
5234 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5235
Govind Singhb53420c2016-03-09 14:32:57 +05305236 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305237 WMI_LOGD("SSID count: %d flags: %d",
5238 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305239
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305240 /* Fill nlo_config only when num_networks are non zero */
5241 if (cmd->no_of_ssids) {
5242 /* Fill networks */
5243 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5244 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5245 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305246
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305247 nlo_list = (nlo_configured_parameters *) buf_ptr;
5248 for (i = 0; i < cmd->no_of_ssids; i++) {
5249 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5250 WMITLV_TAG_ARRAY_BYTE,
5251 WMITLV_GET_STRUCT_TLVLEN(
5252 nlo_configured_parameters));
5253 /* Copy ssid and it's length */
5254 nlo_list[i].ssid.valid = true;
5255 nlo_list[i].ssid.ssid.ssid_len =
5256 req->networks[i].ssid.length;
5257 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5258 req->networks[i].ssid.mac_ssid,
5259 nlo_list[i].ssid.ssid.ssid_len);
5260 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5261 nlo_list[i].ssid.ssid.ssid_len,
5262 (char *) nlo_list[i].ssid.ssid.ssid,
5263 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305264
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305265 /* Copy pno flags */
5266 nlo_list[i].bcast_nw_type.valid = true;
5267 nlo_list[i].bcast_nw_type.bcast_nw_type =
5268 req->networks[i].flags;
5269 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305270 nlo_list[i].bcast_nw_type.bcast_nw_type);
5271
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305272 /* Copy auth bit field */
5273 nlo_list[i].auth_type.valid = true;
5274 nlo_list[i].auth_type.auth_type =
5275 req->networks[i].auth_bit_field;
5276 WMI_LOGD("Auth bit field (%u)",
5277 nlo_list[i].auth_type.auth_type);
5278 }
5279
5280 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5281 /* Fill the channel list */
5282 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5283 buf_ptr += WMI_TLV_HDR_SIZE;
5284
5285 /* Fill prediction_param */
5286 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5287 buf_ptr += WMI_TLV_HDR_SIZE;
5288
5289 /* Fill epno candidate score params */
5290 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5291 WMITLV_SET_HDR(buf_ptr,
5292 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5293 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5294 cand_score_params->min5GHz_rssi =
5295 req->min_5ghz_rssi;
5296 cand_score_params->min24GHz_rssi =
5297 req->min_24ghz_rssi;
5298 cand_score_params->initial_score_max =
5299 req->initial_score_max;
5300 cand_score_params->current_connection_bonus =
5301 req->current_connection_bonus;
5302 cand_score_params->same_network_bonus =
5303 req->same_network_bonus;
5304 cand_score_params->secure_bonus =
5305 req->secure_bonus;
5306 cand_score_params->band5GHz_bonus =
5307 req->band_5ghz_bonus;
5308 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305309 }
5310
Govind Singh4eacd2b2016-03-07 14:24:22 +05305311 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305312 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305313 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305314 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305315 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305316 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305317 }
5318
Govind Singhb53420c2016-03-09 14:32:57 +05305319 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305320 req->session_id);
5321
Govind Singh67922e82016-04-01 16:48:57 +05305322 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305323}
5324
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305325
Govind Singh4eacd2b2016-03-07 14:24:22 +05305326/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5327 * @wmi_handle: wmi handle
5328 * @ipa_offload: ipa offload control parameter
5329 *
5330 * Returns: 0 on success, error number otherwise
5331 */
Govind Singhb53420c2016-03-09 14:32:57 +05305332QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305333 struct ipa_offload_control_params *ipa_offload)
5334{
5335 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5336 wmi_buf_t wmi_buf;
5337 uint32_t len;
5338 u_int8_t *buf_ptr;
5339
5340 len = sizeof(*cmd);
5341 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5342 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305343 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5344 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305345 }
5346
Govind Singhb53420c2016-03-09 14:32:57 +05305347 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305348 ipa_offload->offload_type, ipa_offload->enable);
5349
5350 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5351
5352 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5353 WMITLV_SET_HDR(&cmd->tlv_header,
5354 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5355 WMITLV_GET_STRUCT_TLVLEN(
5356 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5357
5358 cmd->offload_type = ipa_offload->offload_type;
5359 cmd->vdev_id = ipa_offload->vdev_id;
5360 cmd->enable = ipa_offload->enable;
5361
5362 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5363 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305364 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305365 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305366 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305367 }
5368
Govind Singhb53420c2016-03-09 14:32:57 +05305369 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305370}
5371
5372/**
5373 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5374 * @wmi_handle: wmi handle
5375 * @pgetcapab: get capabilities params
5376 *
5377 * This function send request to fw to get extscan capabilities.
5378 *
5379 * Return: CDF status
5380 */
Govind Singhb53420c2016-03-09 14:32:57 +05305381QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305382 struct extscan_capabilities_params *pgetcapab)
5383{
5384 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5385 wmi_buf_t wmi_buf;
5386 uint32_t len;
5387 uint8_t *buf_ptr;
5388
5389 len = sizeof(*cmd);
5390 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5391 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305392 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5393 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305394 }
5395 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5396
5397 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5398 WMITLV_SET_HDR(&cmd->tlv_header,
5399 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5400 WMITLV_GET_STRUCT_TLVLEN
5401 (wmi_extscan_get_capabilities_cmd_fixed_param));
5402
5403 cmd->request_id = pgetcapab->request_id;
5404
5405 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5406 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305407 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305408 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305409 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305410 }
Govind Singhb53420c2016-03-09 14:32:57 +05305411 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305412}
5413
5414/**
5415 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5416 * @wmi_handle: wmi handle
5417 * @pcached_results: cached results parameters
5418 *
5419 * This function send request to fw to get cached results.
5420 *
5421 * Return: CDF status
5422 */
Govind Singhb53420c2016-03-09 14:32:57 +05305423QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305424 struct extscan_cached_result_params *pcached_results)
5425{
5426 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5427 wmi_buf_t wmi_buf;
5428 uint32_t len;
5429 uint8_t *buf_ptr;
5430
5431 len = sizeof(*cmd);
5432 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5433 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305434 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5435 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305436 }
5437 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5438
5439 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
5440 WMITLV_SET_HDR(&cmd->tlv_header,
5441 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
5442 WMITLV_GET_STRUCT_TLVLEN
5443 (wmi_extscan_get_cached_results_cmd_fixed_param));
5444
5445 cmd->request_id = pcached_results->request_id;
5446 cmd->vdev_id = pcached_results->session_id;
5447 cmd->control_flags = pcached_results->flush;
5448
5449 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5450 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305451 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305452 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305453 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305454 }
Govind Singhb53420c2016-03-09 14:32:57 +05305455 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305456}
5457
5458/**
5459 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
5460 * @wmi_handle: wmi handle
5461 * @reset_req: Reset change request params
5462 *
5463 * This function sends stop change monitor request to fw.
5464 *
5465 * Return: CDF status
5466 */
Govind Singhb53420c2016-03-09 14:32:57 +05305467QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305468 struct extscan_capabilities_reset_params *reset_req)
5469{
5470 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5471 wmi_buf_t wmi_buf;
5472 uint32_t len;
5473 uint8_t *buf_ptr;
5474 int change_list = 0;
5475
5476 len = sizeof(*cmd);
5477
5478 /* reset significant change tlv is set to 0 */
5479 len += WMI_TLV_HDR_SIZE;
5480 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
5481 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5482 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305483 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5484 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305485 }
5486 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5487
5488 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5489 buf_ptr;
5490 WMITLV_SET_HDR(&cmd->tlv_header,
5491 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5492 WMITLV_GET_STRUCT_TLVLEN
5493 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5494
5495 cmd->request_id = reset_req->request_id;
5496 cmd->vdev_id = reset_req->session_id;
5497 cmd->mode = 0;
5498
5499 buf_ptr += sizeof(*cmd);
5500 WMITLV_SET_HDR(buf_ptr,
5501 WMITLV_TAG_ARRAY_STRUC,
5502 change_list *
5503 sizeof(wmi_extscan_wlan_change_bssid_param));
5504 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
5505 sizeof
5506 (wmi_extscan_wlan_change_bssid_param));
5507
5508 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5509 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305510 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305511 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305512 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305513 }
Govind Singhb53420c2016-03-09 14:32:57 +05305514 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305515}
5516
5517/**
5518 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
5519 * @wmi_handle: wmi handle
5520 * @psigchange: change monitor request params
5521 * @buf: wmi buffer
5522 * @buf_len: buffer length
5523 *
5524 * This function fills elements of change monitor request buffer.
5525 *
5526 * Return: CDF status
5527 */
Govind Singhb53420c2016-03-09 14:32:57 +05305528static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305529 struct extscan_set_sig_changereq_params
5530 *psigchange, wmi_buf_t *buf, int *buf_len)
5531{
5532 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5533 wmi_extscan_wlan_change_bssid_param *dest_chglist;
5534 uint8_t *buf_ptr;
5535 int j;
5536 int len = sizeof(*cmd);
5537 int numap = psigchange->num_ap;
5538 struct ap_threshold_params *src_ap = psigchange->ap;
5539
5540 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +05305541 WMI_LOGE("%s: Invalid number of bssid's", __func__);
5542 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305543 }
5544 len += WMI_TLV_HDR_SIZE;
5545 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
5546
5547 *buf = wmi_buf_alloc(wmi_handle, len);
5548 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305549 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305550 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305551 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305552 }
5553 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5554 cmd =
5555 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5556 buf_ptr;
5557 WMITLV_SET_HDR(&cmd->tlv_header,
5558 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5559 WMITLV_GET_STRUCT_TLVLEN
5560 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5561
5562 cmd->request_id = psigchange->request_id;
5563 cmd->vdev_id = psigchange->session_id;
5564 cmd->total_entries = numap;
5565 cmd->mode = 1;
5566 cmd->num_entries_in_page = numap;
5567 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
5568 cmd->max_rssi_samples = psigchange->rssi_sample_size;
5569 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
5570 cmd->max_out_of_range_count = psigchange->min_breaching;
5571
5572 buf_ptr += sizeof(*cmd);
5573 WMITLV_SET_HDR(buf_ptr,
5574 WMITLV_TAG_ARRAY_STRUC,
5575 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5576 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
5577 (buf_ptr + WMI_TLV_HDR_SIZE);
5578
5579 for (j = 0; j < numap; j++) {
5580 WMITLV_SET_HDR(dest_chglist,
5581 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5582 WMITLV_GET_STRUCT_TLVLEN
5583 (wmi_extscan_wlan_change_bssid_param));
5584
5585 dest_chglist->lower_rssi_limit = src_ap->low;
5586 dest_chglist->upper_rssi_limit = src_ap->high;
5587 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
5588 &dest_chglist->bssid);
5589
Govind Singhb53420c2016-03-09 14:32:57 +05305590 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305591 dest_chglist->lower_rssi_limit);
5592 dest_chglist++;
5593 src_ap++;
5594 }
5595 buf_ptr += WMI_TLV_HDR_SIZE +
5596 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5597 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305598 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305599}
5600
5601/**
5602 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
5603 * @wmi_handle: wmi handle
5604 * @psigchange: change monitor request params
5605 *
5606 * This function sends start change monitor request to fw.
5607 *
5608 * Return: CDF status
5609 */
Govind Singhb53420c2016-03-09 14:32:57 +05305610QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305611 struct extscan_set_sig_changereq_params *
5612 psigchange)
5613{
Govind Singhb53420c2016-03-09 14:32:57 +05305614 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305615 wmi_buf_t buf;
5616 int len;
5617
5618
Govind Singhb53420c2016-03-09 14:32:57 +05305619 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305620 psigchange, &buf,
5621 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305622 if (qdf_status != QDF_STATUS_SUCCESS) {
5623 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305624 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305625 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305626 }
5627 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305628 WMI_LOGE("%s: Failed to get buffer", __func__);
5629 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305630 }
5631 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5632 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305633 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305634 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305635 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305636 }
Govind Singhb53420c2016-03-09 14:32:57 +05305637 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305638}
5639
5640/**
5641 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
5642 * @wmi_handle: wmi handle
5643 * @photlist_reset: hotlist reset params
5644 *
5645 * This function configures hotlist monitor to stop in fw.
5646 *
5647 * Return: CDF status
5648 */
Govind Singhb53420c2016-03-09 14:32:57 +05305649QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305650 struct extscan_bssid_hotlist_reset_params *photlist_reset)
5651{
5652 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
5653 wmi_buf_t wmi_buf;
5654 uint32_t len;
5655 uint8_t *buf_ptr;
5656 int hotlist_entries = 0;
5657
5658 len = sizeof(*cmd);
5659
5660 /* reset bssid hotlist with tlv set to 0 */
5661 len += WMI_TLV_HDR_SIZE;
5662 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
5663
5664 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5665 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305666 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5667 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305668 }
5669
5670 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5671 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
5672 buf_ptr;
5673 WMITLV_SET_HDR(&cmd->tlv_header,
5674 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
5675 WMITLV_GET_STRUCT_TLVLEN
5676 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
5677
5678 cmd->request_id = photlist_reset->request_id;
5679 cmd->vdev_id = photlist_reset->session_id;
5680 cmd->mode = 0;
5681
5682 buf_ptr += sizeof(*cmd);
5683 WMITLV_SET_HDR(buf_ptr,
5684 WMITLV_TAG_ARRAY_STRUC,
5685 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5686 buf_ptr += WMI_TLV_HDR_SIZE +
5687 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5688
5689 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5690 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305691 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305692 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305693 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305694 }
Govind Singhb53420c2016-03-09 14:32:57 +05305695 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305696}
5697
5698/**
5699 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
5700 * @wmi_handle: wmi handle
5701 * @pstopcmd: stop scan command request params
5702 *
5703 * This function sends stop extscan request to fw.
5704 *
5705 * Return: CDF Status.
5706 */
Govind Singhb53420c2016-03-09 14:32:57 +05305707QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305708 struct extscan_stop_req_params *pstopcmd)
5709{
5710 wmi_extscan_stop_cmd_fixed_param *cmd;
5711 wmi_buf_t wmi_buf;
5712 uint32_t len;
5713 uint8_t *buf_ptr;
5714
5715 len = sizeof(*cmd);
5716 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5717 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305718 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5719 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305720 }
5721 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5722 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
5723 WMITLV_SET_HDR(&cmd->tlv_header,
5724 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
5725 WMITLV_GET_STRUCT_TLVLEN
5726 (wmi_extscan_stop_cmd_fixed_param));
5727
5728 cmd->request_id = pstopcmd->request_id;
5729 cmd->vdev_id = pstopcmd->session_id;
5730
5731 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5732 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305733 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305734 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305735 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305736 }
5737
Govind Singhb53420c2016-03-09 14:32:57 +05305738 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305739}
5740
5741/**
5742 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
5743 * @wmi_handle: wmi handle
5744 * @pstart: scan command request params
5745 * @buf: event buffer
5746 * @buf_len: length of buffer
5747 *
5748 * This function fills individual elements of extscan request and
5749 * TLV for buckets, channel list.
5750 *
5751 * Return: CDF Status.
5752 */
Govind Singhb53420c2016-03-09 14:32:57 +05305753QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305754 struct wifi_scan_cmd_req_params *pstart,
5755 wmi_buf_t *buf, int *buf_len)
5756{
5757 wmi_extscan_start_cmd_fixed_param *cmd;
5758 wmi_extscan_bucket *dest_blist;
5759 wmi_extscan_bucket_channel *dest_clist;
5760 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
5761 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
5762 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
5763
5764 uint8_t *buf_ptr;
5765 int i, k, count = 0;
5766 int len = sizeof(*cmd);
5767 int nbuckets = pstart->numBuckets;
5768 int nchannels = 0;
5769
5770 /* These TLV's are are NULL by default */
5771 uint32_t ie_len_with_pad = 0;
5772 int num_ssid = 0;
5773 int num_bssid = 0;
5774 int ie_len = 0;
5775
5776 uint32_t base_period = pstart->basePeriod;
5777
5778 /* TLV placeholder for ssid_list (NULL) */
5779 len += WMI_TLV_HDR_SIZE;
5780 len += num_ssid * sizeof(wmi_ssid);
5781
5782 /* TLV placeholder for bssid_list (NULL) */
5783 len += WMI_TLV_HDR_SIZE;
5784 len += num_bssid * sizeof(wmi_mac_addr);
5785
5786 /* TLV placeholder for ie_data (NULL) */
5787 len += WMI_TLV_HDR_SIZE;
5788 len += ie_len * sizeof(uint32_t);
5789
5790 /* TLV placeholder for bucket */
5791 len += WMI_TLV_HDR_SIZE;
5792 len += nbuckets * sizeof(wmi_extscan_bucket);
5793
5794 /* TLV channel placeholder */
5795 len += WMI_TLV_HDR_SIZE;
5796 for (i = 0; i < nbuckets; i++) {
5797 nchannels += src_bucket->numChannels;
5798 src_bucket++;
5799 }
5800
Govind Singhb53420c2016-03-09 14:32:57 +05305801 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305802 __func__, nbuckets, nchannels);
5803 len += nchannels * sizeof(wmi_extscan_bucket_channel);
5804 /* Allocate the memory */
5805 *buf = wmi_buf_alloc(wmi_handle, len);
5806 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305807 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05305808 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305809 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305810 }
5811 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5812 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
5813 WMITLV_SET_HDR(&cmd->tlv_header,
5814 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
5815 WMITLV_GET_STRUCT_TLVLEN
5816 (wmi_extscan_start_cmd_fixed_param));
5817
5818 cmd->request_id = pstart->requestId;
5819 cmd->vdev_id = pstart->sessionId;
5820 cmd->base_period = pstart->basePeriod;
5821 cmd->num_buckets = nbuckets;
5822 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05305823 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305824 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05305825 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305826 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05305827#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05305828 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
5829 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05305830 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
5831 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
5832#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05305833 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5834
5835 /* The max dwell time is retrieved from the first channel
5836 * of the first bucket and kept common for all channels.
5837 */
5838 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
5839 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
5840 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
5841 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
5842 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5843 cmd->max_table_usage = pstart->report_threshold_percent;
5844 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
5845
5846 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05305847 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305848 cmd->probe_delay = 0;
5849 cmd->probe_spacing_time = 0;
5850 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305851 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
5852 WMI_SCAN_ADD_CCK_RATES |
5853 WMI_SCAN_ADD_OFDM_RATES |
5854 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
5855 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05305856 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
5857 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05305858 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305859 cmd->num_ssids = 0;
5860 cmd->num_bssid = 0;
5861 cmd->ie_len = 0;
5862 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
5863 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
5864
5865 buf_ptr += sizeof(*cmd);
5866 WMITLV_SET_HDR(buf_ptr,
5867 WMITLV_TAG_ARRAY_FIXED_STRUC,
5868 num_ssid * sizeof(wmi_ssid));
5869 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
5870
5871 WMITLV_SET_HDR(buf_ptr,
5872 WMITLV_TAG_ARRAY_FIXED_STRUC,
5873 num_bssid * sizeof(wmi_mac_addr));
5874 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
5875
5876 ie_len_with_pad = 0;
5877 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5878 ie_len_with_pad);
5879 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
5880
5881 WMITLV_SET_HDR(buf_ptr,
5882 WMITLV_TAG_ARRAY_STRUC,
5883 nbuckets * sizeof(wmi_extscan_bucket));
5884 dest_blist = (wmi_extscan_bucket *)
5885 (buf_ptr + WMI_TLV_HDR_SIZE);
5886 src_bucket = pstart->buckets;
5887
5888 /* Retrieve scanning information from each bucket and
5889 * channels and send it to the target
5890 */
5891 for (i = 0; i < nbuckets; i++) {
5892 WMITLV_SET_HDR(dest_blist,
5893 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5894 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
5895
5896 dest_blist->bucket_id = src_bucket->bucket;
5897 dest_blist->base_period_multiplier =
5898 src_bucket->period / base_period;
5899 dest_blist->min_period = src_bucket->period;
5900 dest_blist->max_period = src_bucket->max_period;
5901 dest_blist->exp_backoff = src_bucket->exponent;
5902 dest_blist->exp_max_step_count = src_bucket->step_count;
5903 dest_blist->channel_band = src_bucket->band;
5904 dest_blist->num_channels = src_bucket->numChannels;
5905 dest_blist->notify_extscan_events = 0;
5906
5907 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
5908 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07005909 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
5910 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305911
5912 if (src_bucket->reportEvents &
5913 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
5914 dest_blist->forwarding_flags =
5915 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
5916 dest_blist->notify_extscan_events |=
5917 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
5918 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
5919 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
5920 } else {
5921 dest_blist->forwarding_flags =
5922 WMI_EXTSCAN_NO_FORWARDING;
5923 }
5924
5925 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
5926 dest_blist->configuration_flags = 0;
5927 else
5928 dest_blist->configuration_flags =
5929 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
5930
Govind Singhb53420c2016-03-09 14:32:57 +05305931 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305932 __func__, dest_blist->notify_extscan_events,
5933 dest_blist->configuration_flags,
5934 dest_blist->forwarding_flags);
5935
5936 dest_blist->min_dwell_time_active =
5937 src_bucket->min_dwell_time_active;
5938 dest_blist->max_dwell_time_active =
5939 src_bucket->max_dwell_time_active;
5940 dest_blist->min_dwell_time_passive =
5941 src_bucket->min_dwell_time_passive;
5942 dest_blist->max_dwell_time_passive =
5943 src_bucket->max_dwell_time_passive;
5944 src_channel = src_bucket->channels;
5945
5946 /* save the channel info to later populate
5947 * the channel TLV
5948 */
5949 for (k = 0; k < src_bucket->numChannels; k++) {
5950 save_channel[count++].channel = src_channel->channel;
5951 src_channel++;
5952 }
5953 dest_blist++;
5954 src_bucket++;
5955 }
5956 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
5957 WMITLV_SET_HDR(buf_ptr,
5958 WMITLV_TAG_ARRAY_STRUC,
5959 nchannels * sizeof(wmi_extscan_bucket_channel));
5960 dest_clist = (wmi_extscan_bucket_channel *)
5961 (buf_ptr + WMI_TLV_HDR_SIZE);
5962
5963 /* Active or passive scan is based on the bucket dwell time
5964 * and channel specific active,passive scans are not
5965 * supported yet
5966 */
5967 for (i = 0; i < nchannels; i++) {
5968 WMITLV_SET_HDR(dest_clist,
5969 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
5970 WMITLV_GET_STRUCT_TLVLEN
5971 (wmi_extscan_bucket_channel));
5972 dest_clist->channel = save_channel[i].channel;
5973 dest_clist++;
5974 }
5975 buf_ptr += WMI_TLV_HDR_SIZE +
5976 (nchannels * sizeof(wmi_extscan_bucket_channel));
5977 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305978 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305979}
5980
5981/**
5982 * send_start_extscan_cmd_tlv() - start extscan command to fw.
5983 * @wmi_handle: wmi handle
5984 * @pstart: scan command request params
5985 *
5986 * This function sends start extscan request to fw.
5987 *
5988 * Return: CDF Status.
5989 */
Govind Singhb53420c2016-03-09 14:32:57 +05305990QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305991 struct wifi_scan_cmd_req_params *pstart)
5992{
Govind Singhb53420c2016-03-09 14:32:57 +05305993 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305994 wmi_buf_t buf;
5995 int len;
5996
5997 /* Fill individual elements of extscan request and
5998 * TLV for buckets, channel list.
5999 */
Govind Singhb53420c2016-03-09 14:32:57 +05306000 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306001 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306002 if (qdf_status != QDF_STATUS_SUCCESS) {
6003 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6004 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306005 }
6006 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306007 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306008 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306009 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306010 }
6011 if (wmi_unified_cmd_send(wmi_handle, buf,
6012 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306013 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306014 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306015 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306016 }
6017
Govind Singhb53420c2016-03-09 14:32:57 +05306018 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306019}
6020
6021/**
6022 * send_plm_stop_cmd_tlv() - plm stop request
6023 * @wmi_handle: wmi handle
6024 * @plm: plm request parameters
6025 *
6026 * This function request FW to stop PLM.
6027 *
6028 * Return: CDF status
6029 */
Govind Singhb53420c2016-03-09 14:32:57 +05306030QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306031 const struct plm_req_params *plm)
6032{
6033 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6034 int32_t len;
6035 wmi_buf_t buf;
6036 uint8_t *buf_ptr;
6037 int ret;
6038
6039 len = sizeof(*cmd);
6040 buf = wmi_buf_alloc(wmi_handle, len);
6041 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306042 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6043 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306044 }
6045
6046 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6047
6048 buf_ptr = (uint8_t *) cmd;
6049
6050 WMITLV_SET_HDR(&cmd->tlv_header,
6051 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6052 WMITLV_GET_STRUCT_TLVLEN
6053 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6054
6055 cmd->vdev_id = plm->session_id;
6056
6057 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306058 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306059
6060 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6061 WMI_VDEV_PLMREQ_STOP_CMDID);
6062 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306063 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306064 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306065 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306066 }
6067
Govind Singhb53420c2016-03-09 14:32:57 +05306068 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306069}
6070
6071/**
6072 * send_plm_start_cmd_tlv() - plm start request
6073 * @wmi_handle: wmi handle
6074 * @plm: plm request parameters
6075 *
6076 * This function request FW to start PLM.
6077 *
6078 * Return: CDF status
6079 */
Govind Singhb53420c2016-03-09 14:32:57 +05306080QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306081 const struct plm_req_params *plm,
6082 uint32_t *gchannel_list)
6083{
6084 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6085 uint32_t *channel_list;
6086 int32_t len;
6087 wmi_buf_t buf;
6088 uint8_t *buf_ptr;
6089 uint8_t count;
6090 int ret;
6091
6092 /* TLV place holder for channel_list */
6093 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6094 len += sizeof(uint32_t) * plm->plm_num_ch;
6095
6096 buf = wmi_buf_alloc(wmi_handle, len);
6097 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306098 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6099 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306100 }
6101 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6102
6103 buf_ptr = (uint8_t *) cmd;
6104
6105 WMITLV_SET_HDR(&cmd->tlv_header,
6106 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6107 WMITLV_GET_STRUCT_TLVLEN
6108 (wmi_vdev_plmreq_start_cmd_fixed_param));
6109
6110 cmd->vdev_id = plm->session_id;
6111
6112 cmd->meas_token = plm->meas_token;
6113 cmd->dialog_token = plm->diag_token;
6114 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306115 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306116 cmd->off_duration = plm->meas_duration;
6117 cmd->burst_cycle = plm->burst_len;
6118 cmd->tx_power = plm->desired_tx_pwr;
6119 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6120 cmd->num_chans = plm->plm_num_ch;
6121
6122 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6123
Govind Singhb53420c2016-03-09 14:32:57 +05306124 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6125 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6126 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6127 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6128 WMI_LOGD("off_duration: %d", cmd->off_duration);
6129 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6130 WMI_LOGD("tx_power: %d", cmd->tx_power);
6131 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306132
6133 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6134 (cmd->num_chans * sizeof(uint32_t)));
6135
6136 buf_ptr += WMI_TLV_HDR_SIZE;
6137 if (cmd->num_chans) {
6138 channel_list = (uint32_t *) buf_ptr;
6139 for (count = 0; count < cmd->num_chans; count++) {
6140 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306141 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306142 channel_list[count] =
6143 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306144 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306145 }
6146 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6147 }
6148
6149 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6150 WMI_VDEV_PLMREQ_START_CMDID);
6151 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306152 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306153 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306154 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306155 }
6156
Govind Singhb53420c2016-03-09 14:32:57 +05306157 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306158}
6159
6160/**
6161 * send_pno_stop_cmd_tlv() - PNO stop request
6162 * @wmi_handle: wmi handle
6163 * @vdev_id: vdev id
6164 *
6165 * This function request FW to stop ongoing PNO operation.
6166 *
6167 * Return: CDF status
6168 */
Govind Singhb53420c2016-03-09 14:32:57 +05306169QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306170{
6171 wmi_nlo_config_cmd_fixed_param *cmd;
6172 int32_t len = sizeof(*cmd);
6173 wmi_buf_t buf;
6174 uint8_t *buf_ptr;
6175 int ret;
6176
6177 /*
6178 * TLV place holder for array of structures nlo_configured_parameters
6179 * TLV place holder for array of uint32_t channel_list
6180 * TLV place holder for chnl prediction cfg
6181 */
6182 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6183 buf = wmi_buf_alloc(wmi_handle, len);
6184 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306185 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6186 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306187 }
6188
6189 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6190 buf_ptr = (uint8_t *) cmd;
6191
6192 WMITLV_SET_HDR(&cmd->tlv_header,
6193 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6194 WMITLV_GET_STRUCT_TLVLEN
6195 (wmi_nlo_config_cmd_fixed_param));
6196
6197 cmd->vdev_id = vdev_id;
6198 cmd->flags = WMI_NLO_CONFIG_STOP;
6199 buf_ptr += sizeof(*cmd);
6200
6201 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6202 buf_ptr += WMI_TLV_HDR_SIZE;
6203
6204 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6205 buf_ptr += WMI_TLV_HDR_SIZE;
6206
6207 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6208 buf_ptr += WMI_TLV_HDR_SIZE;
6209
6210
6211 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6212 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6213 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306214 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306215 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306216 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306217 }
6218
Govind Singhb53420c2016-03-09 14:32:57 +05306219 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306220}
6221
6222/**
Govind Singhccb0c272016-04-01 16:30:08 +05306223 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6224 * @buf_ptr: Buffer passed by upper layers
6225 * @pno: Buffer to be sent to the firmware
6226 *
6227 * Copy the PNO Channel prediction configuration parameters
6228 * passed by the upper layers to a WMI format TLV and send it
6229 * down to the firmware.
6230 *
6231 * Return: None
6232 */
6233static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6234 struct pno_scan_req_params *pno)
6235{
6236 nlo_channel_prediction_cfg *channel_prediction_cfg =
6237 (nlo_channel_prediction_cfg *) buf_ptr;
6238 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6239 WMITLV_TAG_ARRAY_BYTE,
6240 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306241#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306242 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6243 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6244 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6245 channel_prediction_cfg->full_scan_period_ms =
6246 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306247#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306248 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6249 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6250 channel_prediction_cfg->enable,
6251 channel_prediction_cfg->top_k_num,
6252 channel_prediction_cfg->stationary_threshold,
6253 channel_prediction_cfg->full_scan_period_ms);
6254}
6255
6256/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306257 * send_pno_start_cmd_tlv() - PNO start request
6258 * @wmi_handle: wmi handle
6259 * @pno: PNO request
6260 *
6261 * This function request FW to start PNO request.
6262 * Request: CDF status
6263 */
Govind Singhb53420c2016-03-09 14:32:57 +05306264QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306265 struct pno_scan_req_params *pno,
6266 uint32_t *gchannel_freq_list)
6267{
6268 wmi_nlo_config_cmd_fixed_param *cmd;
6269 nlo_configured_parameters *nlo_list;
6270 uint32_t *channel_list;
6271 int32_t len;
6272 wmi_buf_t buf;
6273 uint8_t *buf_ptr;
6274 uint8_t i;
6275 int ret;
6276
6277 /*
6278 * TLV place holder for array nlo_configured_parameters(nlo_list)
6279 * TLV place holder for array of uint32_t channel_list
6280 * TLV place holder for chnnl prediction cfg
6281 */
6282 len = sizeof(*cmd) +
6283 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6284
Govind Singhb53420c2016-03-09 14:32:57 +05306285 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306286 WMI_NLO_MAX_CHAN);
6287 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306288 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306289 len += sizeof(nlo_channel_prediction_cfg);
6290
6291 buf = wmi_buf_alloc(wmi_handle, len);
6292 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306293 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6294 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306295 }
6296
6297 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6298
6299 buf_ptr = (uint8_t *) cmd;
6300 WMITLV_SET_HDR(&cmd->tlv_header,
6301 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6302 WMITLV_GET_STRUCT_TLVLEN
6303 (wmi_nlo_config_cmd_fixed_param));
6304 cmd->vdev_id = pno->sessionId;
6305 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6306
Govind Singh87542482016-06-08 19:40:11 +05306307#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306308 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6309 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306310#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306311 /* Current FW does not support min-max range for dwell time */
6312 cmd->active_dwell_time = pno->active_max_time;
6313 cmd->passive_dwell_time = pno->passive_max_time;
6314
6315 /* Copy scan interval */
6316 cmd->fast_scan_period = pno->fast_scan_period;
6317 cmd->slow_scan_period = pno->slow_scan_period;
6318 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306319 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306320 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306321 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306322
6323 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6324
Govind Singhb53420c2016-03-09 14:32:57 +05306325 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6326 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306327 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6328 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6329 buf_ptr += WMI_TLV_HDR_SIZE;
6330
6331 nlo_list = (nlo_configured_parameters *) buf_ptr;
6332 for (i = 0; i < cmd->no_of_ssids; i++) {
6333 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6334 WMITLV_TAG_ARRAY_BYTE,
6335 WMITLV_GET_STRUCT_TLVLEN
6336 (nlo_configured_parameters));
6337 /* Copy ssid and it's length */
6338 nlo_list[i].ssid.valid = true;
6339 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306340 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306341 pno->aNetworks[i].ssid.mac_ssid,
6342 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306343 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306344 nlo_list[i].ssid.ssid.ssid_len,
6345 (char *)nlo_list[i].ssid.ssid.ssid,
6346 nlo_list[i].ssid.ssid.ssid_len);
6347
6348 /* Copy rssi threshold */
6349 if (pno->aNetworks[i].rssiThreshold &&
6350 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6351 nlo_list[i].rssi_cond.valid = true;
6352 nlo_list[i].rssi_cond.rssi =
6353 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306354 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306355 nlo_list[i].rssi_cond.rssi);
6356 }
6357 nlo_list[i].bcast_nw_type.valid = true;
6358 nlo_list[i].bcast_nw_type.bcast_nw_type =
6359 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306360 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306361 nlo_list[i].bcast_nw_type.bcast_nw_type);
6362 }
6363 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6364
6365 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306366 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306367 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306368 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306369 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6370 (cmd->num_of_channels * sizeof(uint32_t)));
6371 buf_ptr += WMI_TLV_HDR_SIZE;
6372
6373 channel_list = (uint32_t *) buf_ptr;
6374 for (i = 0; i < cmd->num_of_channels; i++) {
6375 channel_list[i] = pno->aNetworks[0].aChannels[i];
6376
6377 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6378 channel_list[i] = gchannel_freq_list[i];
6379
Govind Singhb53420c2016-03-09 14:32:57 +05306380 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306381 }
6382 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6383 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6384 sizeof(nlo_channel_prediction_cfg));
6385 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306386 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306387 buf_ptr += WMI_TLV_HDR_SIZE;
6388 /** TODO: Discrete firmware doesn't have command/option to configure
6389 * App IE which comes from wpa_supplicant as of part PNO start request.
6390 */
6391 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6392 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6393 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306394 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306395 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306396 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306397 }
6398
Govind Singhb53420c2016-03-09 14:32:57 +05306399 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306400}
6401
6402/* send_set_ric_req_cmd_tlv() - set ric request element
6403 * @wmi_handle: wmi handle
6404 * @msg: message
6405 * @is_add_ts: is addts required
6406 *
6407 * This function sets ric request element for 11r roaming.
6408 *
6409 * Return: CDF status
6410 */
Govind Singhb53420c2016-03-09 14:32:57 +05306411QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306412 void *msg, uint8_t is_add_ts)
6413{
6414 wmi_ric_request_fixed_param *cmd;
6415 wmi_ric_tspec *tspec_param;
6416 wmi_buf_t buf;
6417 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306418 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306419 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6420 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6421
6422 buf = wmi_buf_alloc(wmi_handle, len);
6423 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306424 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6425 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306426 }
6427
6428 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6429
6430 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6431 WMITLV_SET_HDR(&cmd->tlv_header,
6432 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6433 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6434 if (is_add_ts)
6435 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
6436 else
6437 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
6438 cmd->num_ric_request = 1;
6439 cmd->is_add_ric = is_add_ts;
6440
6441 buf_ptr += sizeof(wmi_ric_request_fixed_param);
6442 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
6443
6444 buf_ptr += WMI_TLV_HDR_SIZE;
6445 tspec_param = (wmi_ric_tspec *) buf_ptr;
6446 WMITLV_SET_HDR(&tspec_param->tlv_header,
6447 WMITLV_TAG_STRUC_wmi_ric_tspec,
6448 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
6449
6450 if (is_add_ts)
6451 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05306452#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05306453 else
6454 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05306455#endif
6456 if (ptspecIE) {
6457 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05306458#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05306459 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
6460 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306461#else
Govind Singh87542482016-06-08 19:40:11 +05306462 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
6463 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306464#endif /* ANI_LITTLE_BIT_ENDIAN */
6465
Govind Singh87542482016-06-08 19:40:11 +05306466 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
6467 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
6468 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
6469 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
6470 tspec_param->inactivity_interval = ptspecIE->inactInterval;
6471 tspec_param->suspension_interval = ptspecIE->suspendInterval;
6472 tspec_param->svc_start_time = ptspecIE->svcStartTime;
6473 tspec_param->min_data_rate = ptspecIE->minDataRate;
6474 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
6475 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
6476 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
6477 tspec_param->delay_bound = ptspecIE->delayBound;
6478 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
6479 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
6480 tspec_param->medium_time = 0;
6481 }
Govind Singhb53420c2016-03-09 14:32:57 +05306482 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306483
6484 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6485 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306486 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306487 __func__);
6488 if (is_add_ts)
6489 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05306490 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05306491 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306492 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306493 }
6494
Govind Singhb53420c2016-03-09 14:32:57 +05306495 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306496}
6497
6498/**
6499 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
6500 * @wmi_handle: wmi handle
6501 * @clear_req: ll stats clear request command params
6502 *
Govind Singhb53420c2016-03-09 14:32:57 +05306503 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306504 */
Govind Singhb53420c2016-03-09 14:32:57 +05306505QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306506 const struct ll_stats_clear_params *clear_req,
6507 uint8_t addr[IEEE80211_ADDR_LEN])
6508{
6509 wmi_clear_link_stats_cmd_fixed_param *cmd;
6510 int32_t len;
6511 wmi_buf_t buf;
6512 uint8_t *buf_ptr;
6513 int ret;
6514
6515 len = sizeof(*cmd);
6516 buf = wmi_buf_alloc(wmi_handle, len);
6517
6518 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306519 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6520 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306521 }
6522
6523 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306524 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306525 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
6526
6527 WMITLV_SET_HDR(&cmd->tlv_header,
6528 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
6529 WMITLV_GET_STRUCT_TLVLEN
6530 (wmi_clear_link_stats_cmd_fixed_param));
6531
6532 cmd->stop_stats_collection_req = clear_req->stop_req;
6533 cmd->vdev_id = clear_req->sta_id;
6534 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
6535
6536 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6537 &cmd->peer_macaddr);
6538
Govind Singhb53420c2016-03-09 14:32:57 +05306539 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
6540 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
6541 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
6542 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
6543 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306544 cmd->peer_macaddr); */
6545
6546 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6547 WMI_CLEAR_LINK_STATS_CMDID);
6548 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306549 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306550 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306551 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306552 }
6553
Govind Singhb53420c2016-03-09 14:32:57 +05306554 WMI_LOGD("Clear Link Layer Stats request sent successfully");
6555 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306556}
6557
6558/**
6559 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
6560 * @wmi_handle: wmi handle
6561 * @setReq: ll stats set request command params
6562 *
Govind Singhb53420c2016-03-09 14:32:57 +05306563 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306564 */
Govind Singhb53420c2016-03-09 14:32:57 +05306565QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306566 const struct ll_stats_set_params *set_req)
6567{
6568 wmi_start_link_stats_cmd_fixed_param *cmd;
6569 int32_t len;
6570 wmi_buf_t buf;
6571 uint8_t *buf_ptr;
6572 int ret;
6573
6574 len = sizeof(*cmd);
6575 buf = wmi_buf_alloc(wmi_handle, len);
6576
6577 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306578 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6579 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306580 }
6581
6582 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306583 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306584 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
6585
6586 WMITLV_SET_HDR(&cmd->tlv_header,
6587 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
6588 WMITLV_GET_STRUCT_TLVLEN
6589 (wmi_start_link_stats_cmd_fixed_param));
6590
6591 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
6592 cmd->aggressive_statistics_gathering =
6593 set_req->aggressive_statistics_gathering;
6594
Govind Singhb53420c2016-03-09 14:32:57 +05306595 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
6596 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
6597 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306598
6599 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6600 WMI_START_LINK_STATS_CMDID);
6601 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306602 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306603 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306604 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306605 }
6606
Govind Singhb53420c2016-03-09 14:32:57 +05306607 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306608}
6609
6610/**
6611 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
6612 * @wmi_handle:wmi handle
6613 * @get_req:ll stats get request command params
6614 * @addr: mac address
6615 *
Govind Singhb53420c2016-03-09 14:32:57 +05306616 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306617 */
Govind Singhb53420c2016-03-09 14:32:57 +05306618QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306619 const struct ll_stats_get_params *get_req,
6620 uint8_t addr[IEEE80211_ADDR_LEN])
6621{
6622 wmi_request_link_stats_cmd_fixed_param *cmd;
6623 int32_t len;
6624 wmi_buf_t buf;
6625 uint8_t *buf_ptr;
6626 int ret;
6627
6628 len = sizeof(*cmd);
6629 buf = wmi_buf_alloc(wmi_handle, len);
6630
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05306631 if (!buf) {
6632 WMI_LOGE("%s: buf allocation failed", __func__);
6633 return QDF_STATUS_E_NOMEM;
6634 }
6635
Govind Singh4eacd2b2016-03-07 14:24:22 +05306636 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306637 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306638 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
6639
6640 WMITLV_SET_HDR(&cmd->tlv_header,
6641 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
6642 WMITLV_GET_STRUCT_TLVLEN
6643 (wmi_request_link_stats_cmd_fixed_param));
6644
6645 cmd->request_id = get_req->req_id;
6646 cmd->stats_type = get_req->param_id_mask;
6647 cmd->vdev_id = get_req->sta_id;
6648
6649 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6650 &cmd->peer_macaddr);
6651
Govind Singhb53420c2016-03-09 14:32:57 +05306652 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
6653 WMI_LOGD("Request ID : %d", cmd->request_id);
6654 WMI_LOGD("Stats Type : %d", cmd->stats_type);
6655 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
6656 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306657
6658 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6659 WMI_REQUEST_LINK_STATS_CMDID);
6660 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306661 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306662 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306663 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306664 }
6665
Govind Singhb53420c2016-03-09 14:32:57 +05306666 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306667}
6668
6669/**
6670 * send_get_stats_cmd_tlv() - get stats request
6671 * @wmi_handle: wmi handle
6672 * @get_stats_param: stats params
6673 * @addr: mac address
6674 *
6675 * Return: CDF status
6676 */
Govind Singhb53420c2016-03-09 14:32:57 +05306677QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306678 struct pe_stats_req *get_stats_param,
6679 uint8_t addr[IEEE80211_ADDR_LEN])
6680{
6681 wmi_buf_t buf;
6682 wmi_request_stats_cmd_fixed_param *cmd;
6683 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6684
6685 buf = wmi_buf_alloc(wmi_handle, len);
6686 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306687 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
6688 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306689 }
6690
6691
6692 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6693 WMITLV_SET_HDR(&cmd->tlv_header,
6694 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6695 WMITLV_GET_STRUCT_TLVLEN
6696 (wmi_request_stats_cmd_fixed_param));
6697 cmd->stats_id =
6698 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05306699 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306700 cmd->vdev_id = get_stats_param->session_id;
6701 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05306702 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306703 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6704 WMI_REQUEST_STATS_CMDID)) {
6705
Govind Singhb53420c2016-03-09 14:32:57 +05306706 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306707 __func__);
6708 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306709 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306710 }
6711
Govind Singhb53420c2016-03-09 14:32:57 +05306712 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306713
6714}
6715
Govind Singh20c5dac2016-03-07 15:33:31 +05306716/**
6717 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
6718 * @wmi_handle: wmi handle
6719 * @rssi_req: get RSSI request
6720 *
6721 * Return: CDF status
6722 */
Govind Singhb53420c2016-03-09 14:32:57 +05306723QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05306724{
6725 wmi_buf_t buf;
6726 wmi_request_stats_cmd_fixed_param *cmd;
6727 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6728
6729 buf = wmi_buf_alloc(wmi_handle, len);
6730 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306731 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6732 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306733 }
6734
6735 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6736 WMITLV_SET_HDR(&cmd->tlv_header,
6737 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6738 WMITLV_GET_STRUCT_TLVLEN
6739 (wmi_request_stats_cmd_fixed_param));
6740 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6741 if (wmi_unified_cmd_send
6742 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306743 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306744 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306745 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306746 }
6747
Govind Singhb53420c2016-03-09 14:32:57 +05306748 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306749}
6750
6751/**
6752 * send_snr_cmd_tlv() - get RSSI from fw
6753 * @wmi_handle: wmi handle
6754 * @vdev_id: vdev id
6755 *
6756 * Return: CDF status
6757 */
Govind Singhb53420c2016-03-09 14:32:57 +05306758QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05306759{
6760 wmi_buf_t buf;
6761 wmi_request_stats_cmd_fixed_param *cmd;
6762 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6763
6764 buf = wmi_buf_alloc(wmi_handle, len);
6765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306766 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6767 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306768 }
6769
6770 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6771 cmd->vdev_id = vdev_id;
6772
6773 WMITLV_SET_HDR(&cmd->tlv_header,
6774 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6775 WMITLV_GET_STRUCT_TLVLEN
6776 (wmi_request_stats_cmd_fixed_param));
6777 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6778 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6779 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306780 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306781 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306782 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306783 }
6784
Govind Singhb53420c2016-03-09 14:32:57 +05306785 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306786}
6787
6788/**
6789 * send_link_status_req_cmd_tlv() - process link status request from UMAC
6790 * @wmi_handle: wmi handle
6791 * @link_status: get link params
6792 *
6793 * Return: CDF status
6794 */
Govind Singhb53420c2016-03-09 14:32:57 +05306795QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306796 struct link_status_params *link_status)
6797{
6798 wmi_buf_t buf;
6799 wmi_request_stats_cmd_fixed_param *cmd;
6800 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6801
6802 buf = wmi_buf_alloc(wmi_handle, len);
6803 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306804 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6805 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306806 }
6807
6808 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6809 WMITLV_SET_HDR(&cmd->tlv_header,
6810 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6811 WMITLV_GET_STRUCT_TLVLEN
6812 (wmi_request_stats_cmd_fixed_param));
6813 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
6814 cmd->vdev_id = link_status->session_id;
6815 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6816 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306817 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306818 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306819 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306820 }
6821
Govind Singhb53420c2016-03-09 14:32:57 +05306822 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306823}
6824
6825#ifdef FEATURE_WLAN_LPHB
6826
6827/**
6828 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
6829 * @wmi_handle: wmi handle
6830 * @lphb_conf_req: configuration info
6831 *
6832 * Return: CDF status
6833 */
Govind Singhb53420c2016-03-09 14:32:57 +05306834QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306835 wmi_hb_set_enable_cmd_fixed_param *params)
6836{
Govind Singh67922e82016-04-01 16:48:57 +05306837 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306838 wmi_buf_t buf = NULL;
6839 uint8_t *buf_ptr;
6840 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
6841 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
6842
6843
6844 buf = wmi_buf_alloc(wmi_handle, len);
6845 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306846 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6847 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306848 }
6849
6850 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6851 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
6852 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
6853 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
6854 WMITLV_GET_STRUCT_TLVLEN
6855 (wmi_hb_set_enable_cmd_fixed_param));
6856
6857 /* fill in values */
6858 hb_enable_fp->vdev_id = params->session;
6859 hb_enable_fp->enable = params->enable;
6860 hb_enable_fp->item = params->item;
6861 hb_enable_fp->session = params->session;
6862
6863 status = wmi_unified_cmd_send(wmi_handle, buf,
6864 len, WMI_HB_SET_ENABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306865 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306866 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_ENABLE returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306867 status);
Govind Singh67922e82016-04-01 16:48:57 +05306868 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306869 }
6870
Govind Singh67922e82016-04-01 16:48:57 +05306871 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306872}
6873
6874/**
6875 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
6876 * @wmi_handle: wmi handle
6877 * @lphb_conf_req: lphb config request
6878 *
6879 * Return: CDF status
6880 */
Govind Singhb53420c2016-03-09 14:32:57 +05306881QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306882 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
6883{
Govind Singh67922e82016-04-01 16:48:57 +05306884 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306885 wmi_buf_t buf = NULL;
6886 uint8_t *buf_ptr;
6887 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
6888 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
6889
6890 buf = wmi_buf_alloc(wmi_handle, len);
6891 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306892 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6893 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306894 }
6895
6896 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6897 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
6898 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
6899 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
6900 WMITLV_GET_STRUCT_TLVLEN
6901 (wmi_hb_set_tcp_params_cmd_fixed_param));
6902
6903 /* fill in values */
6904 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
6905 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
6906 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
6907 hb_tcp_params_fp->seq = lphb_conf_req->seq;
6908 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
6909 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
6910 hb_tcp_params_fp->interval = lphb_conf_req->interval;
6911 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
6912 hb_tcp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05306913 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05306914 &lphb_conf_req->gateway_mac,
6915 sizeof(hb_tcp_params_fp->gateway_mac));
6916
6917 status = wmi_unified_cmd_send(wmi_handle, buf,
6918 len, WMI_HB_SET_TCP_PARAMS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306919 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306920 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306921 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306922 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306923 }
6924
Govind Singh67922e82016-04-01 16:48:57 +05306925 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306926}
6927
6928/**
6929 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
6930 * @wmi_handle: wmi handle
6931 * @lphb_conf_req: lphb config request
6932 *
6933 * Return: CDF status
6934 */
Govind Singhb53420c2016-03-09 14:32:57 +05306935QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306936 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
6937{
Govind Singh67922e82016-04-01 16:48:57 +05306938 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306939 wmi_buf_t buf = NULL;
6940 uint8_t *buf_ptr;
6941 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
6942 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
6943
6944 buf = wmi_buf_alloc(wmi_handle, len);
6945 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306946 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6947 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306948 }
6949
6950 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6951 hb_tcp_filter_fp =
6952 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
6953 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
6954 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
6955 WMITLV_GET_STRUCT_TLVLEN
6956 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
6957
6958 /* fill in values */
6959 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
6960 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
6961 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
6962 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
6963 memcpy((void *)&hb_tcp_filter_fp->filter,
6964 (void *)&g_hb_tcp_filter_fp->filter,
6965 WMI_WLAN_HB_MAX_FILTER_SIZE);
6966
6967 status = wmi_unified_cmd_send(wmi_handle, buf,
6968 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306969 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306970 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306971 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05306972 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306973 }
6974
Govind Singh67922e82016-04-01 16:48:57 +05306975 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306976}
6977
6978/**
6979 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
6980 * @wmi_handle: wmi handle
6981 * @lphb_conf_req: lphb config request
6982 *
6983 * Return: CDF status
6984 */
Govind Singhb53420c2016-03-09 14:32:57 +05306985QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306986 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
6987{
Govind Singh67922e82016-04-01 16:48:57 +05306988 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306989 wmi_buf_t buf = NULL;
6990 uint8_t *buf_ptr;
6991 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
6992 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
6993
6994 buf = wmi_buf_alloc(wmi_handle, len);
6995 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306996 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6997 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306998 }
6999
7000 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7001 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
7002 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
7003 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
7004 WMITLV_GET_STRUCT_TLVLEN
7005 (wmi_hb_set_udp_params_cmd_fixed_param));
7006
7007 /* fill in values */
7008 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
7009 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
7010 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
7011 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
7012 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
7013 hb_udp_params_fp->interval = lphb_conf_req->interval;
7014 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
7015 hb_udp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05307016 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05307017 &lphb_conf_req->gateway_mac,
7018 sizeof(lphb_conf_req->gateway_mac));
7019
7020 status = wmi_unified_cmd_send(wmi_handle, buf,
7021 len, WMI_HB_SET_UDP_PARAMS_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307022 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307023 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307024 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307025 wmi_buf_free(buf);
7026 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307027
Govind Singh67922e82016-04-01 16:48:57 +05307028 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307029}
7030
7031/**
7032 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
7033 * @wmi_handle: wmi handle
7034 * @lphb_conf_req: lphb config request
7035 *
7036 * Return: CDF status
7037 */
Govind Singhb53420c2016-03-09 14:32:57 +05307038QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307039 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
7040{
Govind Singh67922e82016-04-01 16:48:57 +05307041 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307042 wmi_buf_t buf = NULL;
7043 uint8_t *buf_ptr;
7044 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
7045 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
7046
7047 buf = wmi_buf_alloc(wmi_handle, len);
7048 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307049 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7050 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307051 }
7052
7053 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7054 hb_udp_filter_fp =
7055 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
7056 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
7057 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
7058 WMITLV_GET_STRUCT_TLVLEN
7059 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
7060
7061 /* fill in values */
7062 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
7063 hb_udp_filter_fp->length = lphb_conf_req->length;
7064 hb_udp_filter_fp->offset = lphb_conf_req->offset;
7065 hb_udp_filter_fp->session = lphb_conf_req->session;
7066 memcpy((void *)&hb_udp_filter_fp->filter,
7067 (void *)&lphb_conf_req->filter,
7068 WMI_WLAN_HB_MAX_FILTER_SIZE);
7069
7070 status = wmi_unified_cmd_send(wmi_handle, buf,
7071 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307072 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307073 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307074 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307075 wmi_buf_free(buf);
7076 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307077
Govind Singh67922e82016-04-01 16:48:57 +05307078 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307079}
7080#endif /* FEATURE_WLAN_LPHB */
7081
7082/**
7083 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7084 * @wmi_handle: wmi handle
7085 * @ta_dhcp_ind: DHCP indication parameter
7086 *
7087 * Return: CDF Status
7088 */
Govind Singhb53420c2016-03-09 14:32:57 +05307089QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307090 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7091{
Govind Singh67922e82016-04-01 16:48:57 +05307092 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307093 wmi_buf_t buf = NULL;
7094 uint8_t *buf_ptr;
7095 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7096 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7097
7098
7099 buf = wmi_buf_alloc(wmi_handle, len);
7100 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307101 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7102 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307103 }
7104
7105 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7106 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7107 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7108 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7109 WMITLV_GET_STRUCT_TLVLEN
7110 (wmi_peer_set_param_cmd_fixed_param));
7111
7112 /* fill in values */
7113 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7114 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7115 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307116 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307117 &ta_dhcp_ind->peer_macaddr,
7118 sizeof(ta_dhcp_ind->peer_macaddr));
7119
7120 status = wmi_unified_cmd_send(wmi_handle, buf,
7121 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307122 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307123 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307124 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307125 wmi_buf_free(buf);
7126 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307127
Govind Singh67922e82016-04-01 16:48:57 +05307128 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307129}
7130
7131/**
7132 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7133 * @wmi_handle: wmi handle
7134 * @pLinkSpeed: link speed info
7135 *
7136 * Return: CDF status
7137 */
Govind Singhb53420c2016-03-09 14:32:57 +05307138QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307139 wmi_mac_addr peer_macaddr)
7140{
7141 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7142 wmi_buf_t wmi_buf;
7143 uint32_t len;
7144 uint8_t *buf_ptr;
7145
7146 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7147 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7148 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307149 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7150 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307151 }
7152 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7153
7154 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7155 WMITLV_SET_HDR(&cmd->tlv_header,
7156 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7157 WMITLV_GET_STRUCT_TLVLEN
7158 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7159
7160 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307161 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307162 &peer_macaddr,
7163 sizeof(peer_macaddr));
7164
7165
7166 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7167 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307168 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307169 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307170 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307171 }
Govind Singhb53420c2016-03-09 14:32:57 +05307172 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307173}
7174
7175/**
7176 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7177 * @wmi_handle: wmi handler
7178 * @egap_params: pointer to egap_params
7179 *
7180 * Return: 0 for success, otherwise appropriate error code
7181 */
Govind Singhb53420c2016-03-09 14:32:57 +05307182QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307183 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7184{
7185 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7186 wmi_buf_t buf;
7187 int32_t err;
7188
7189 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7190 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307191 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7192 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307193 }
7194 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7195 WMITLV_SET_HDR(&cmd->tlv_header,
7196 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7197 WMITLV_GET_STRUCT_TLVLEN(
7198 wmi_ap_ps_egap_param_cmd_fixed_param));
7199
7200 cmd->enable = egap_params->enable;
7201 cmd->inactivity_time = egap_params->inactivity_time;
7202 cmd->wait_time = egap_params->wait_time;
7203 cmd->flags = egap_params->flags;
7204 err = wmi_unified_cmd_send(wmi_handle, buf,
7205 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7206 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307207 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307208 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307209 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307210 }
7211
Govind Singhb53420c2016-03-09 14:32:57 +05307212 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307213}
7214
7215/**
7216 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7217 * @wmi_handl: wmi handle
7218 * @cmd: Profiling command index
7219 * @value1: parameter1 value
7220 * @value2: parameter2 value
7221 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307222 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307223 */
Govind Singhb53420c2016-03-09 14:32:57 +05307224QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307225 uint32_t cmd, uint32_t value1, uint32_t value2)
7226{
7227 wmi_buf_t buf;
7228 int32_t len = 0;
7229 int ret;
7230 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7231 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7232 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7233 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7234
7235 switch (cmd) {
7236 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7237 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7238 buf = wmi_buf_alloc(wmi_handle, len);
7239 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307240 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307241 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307242 }
7243 prof_trig_cmd =
7244 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7245 wmi_buf_data(buf);
7246 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7247 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7248 WMITLV_GET_STRUCT_TLVLEN
7249 (wmi_wlan_profile_trigger_cmd_fixed_param));
7250 prof_trig_cmd->enable = value1;
7251 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7252 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7253 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307254 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307255 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307256 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307257 return ret;
7258 }
7259 break;
7260
7261 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7262 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7263 buf = wmi_buf_alloc(wmi_handle, len);
7264 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307265 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307266 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307267 }
7268 profile_getdata_cmd =
7269 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7270 wmi_buf_data(buf);
7271 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7272 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7273 WMITLV_GET_STRUCT_TLVLEN
7274 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7275 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7276 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7277 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307278 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307279 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307280 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307281 return ret;
7282 }
7283 break;
7284
7285 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7286 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7287 buf = wmi_buf_alloc(wmi_handle, len);
7288 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307289 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307290 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307291 }
7292 hist_intvl_cmd =
7293 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7294 wmi_buf_data(buf);
7295 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7296 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7297 WMITLV_GET_STRUCT_TLVLEN
7298 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7299 hist_intvl_cmd->profile_id = value1;
7300 hist_intvl_cmd->value = value2;
7301 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7302 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7303 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307304 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307305 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307306 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307307 return ret;
7308 }
7309 break;
7310
7311 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7312 len =
7313 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7314 buf = wmi_buf_alloc(wmi_handle, len);
7315 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307316 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307317 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307318 }
7319 profile_enable_cmd =
7320 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7321 wmi_buf_data(buf);
7322 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7323 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7324 WMITLV_GET_STRUCT_TLVLEN
7325 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7326 profile_enable_cmd->profile_id = value1;
7327 profile_enable_cmd->enable = value2;
7328 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7329 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7330 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307331 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307332 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307333 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307334 return ret;
7335 }
7336 break;
7337
7338 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307339 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307340 break;
7341 }
7342
7343 return 0;
7344}
7345
7346#ifdef FEATURE_WLAN_RA_FILTERING
7347/**
7348 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
7349 * @wmi_handle: wmi handle
7350 * @vdev_id: vdev id
7351 *
7352 * Return: CDF status
7353 */
Govind Singhb53420c2016-03-09 14:32:57 +05307354QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307355 uint8_t vdev_id, uint8_t default_pattern,
7356 uint16_t rate_limit_interval)
7357{
7358
7359 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7360 wmi_buf_t buf;
7361 uint8_t *buf_ptr;
7362 int32_t len;
7363 int ret;
7364
7365 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7366 WMI_TLV_HDR_SIZE +
7367 0 * sizeof(WOW_BITMAP_PATTERN_T) +
7368 WMI_TLV_HDR_SIZE +
7369 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7370 WMI_TLV_HDR_SIZE +
7371 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7372 WMI_TLV_HDR_SIZE +
7373 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7374 WMI_TLV_HDR_SIZE +
7375 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7376
7377 buf = wmi_buf_alloc(wmi_handle, len);
7378 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307379 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7380 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307381 }
7382
7383 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7384 buf_ptr = (uint8_t *) cmd;
7385
7386 WMITLV_SET_HDR(&cmd->tlv_header,
7387 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7388 WMITLV_GET_STRUCT_TLVLEN
7389 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7390 cmd->vdev_id = vdev_id;
7391 cmd->pattern_id = default_pattern,
7392 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
7393 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7394
7395 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
7396 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7397 buf_ptr += WMI_TLV_HDR_SIZE;
7398
7399 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7400 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7401 buf_ptr += WMI_TLV_HDR_SIZE;
7402
7403 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7404 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7405 buf_ptr += WMI_TLV_HDR_SIZE;
7406
7407 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7408 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7409 buf_ptr += WMI_TLV_HDR_SIZE;
7410
7411 /* Fill TLV for pattern_info_timeout but no data. */
7412 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7413 buf_ptr += WMI_TLV_HDR_SIZE;
7414
7415 /* Fill TLV for ra_ratelimit_interval. */
7416 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
7417 buf_ptr += WMI_TLV_HDR_SIZE;
7418
7419 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
7420
Govind Singhb53420c2016-03-09 14:32:57 +05307421 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05307422 rate_limit_interval, vdev_id);
7423
7424 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7425 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7426 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307427 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307428 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307429 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307430 }
7431
Govind Singhb53420c2016-03-09 14:32:57 +05307432 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307433
7434}
7435#endif /* FEATURE_WLAN_RA_FILTERING */
7436
7437/**
7438 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7439 * @wmi_handle: wmi handle
7440 * @vdev_id: vdev id
7441 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307442 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307443 */
Govind Singhb53420c2016-03-09 14:32:57 +05307444QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307445{
7446 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7447 wmi_buf_t buf;
7448 int32_t len = sizeof(*cmd);
7449
Govind Singhb53420c2016-03-09 14:32:57 +05307450 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307451 buf = wmi_buf_alloc(wmi_handle, len);
7452 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307453 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307454 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307455 }
7456 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7457 wmi_buf_data(buf);
7458 WMITLV_SET_HDR(&cmd->tlv_header,
7459 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7460 WMITLV_GET_STRUCT_TLVLEN
7461 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7462 cmd->vdev_id = vdev_id;
7463 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7464 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7465 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307466 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307467 __func__);
7468 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307469 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307470 }
7471
7472 return 0;
7473}
7474
7475/**
7476 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7477 * @wmi_handle: wmi handle
7478 * @vdev_id: vdev id
7479 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307480 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307481 */
Govind Singhb53420c2016-03-09 14:32:57 +05307482QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307483 uint8_t vdev_id)
7484{
7485 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7486 wmi_buf_t buf;
7487 int32_t len = sizeof(*cmd);
7488
Govind Singhb53420c2016-03-09 14:32:57 +05307489 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307490 buf = wmi_buf_alloc(wmi_handle, len);
7491 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307492 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307493 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307494 }
7495 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7496 WMITLV_SET_HDR(&cmd->tlv_header,
7497 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7498 WMITLV_GET_STRUCT_TLVLEN
7499 (wmi_csa_offload_enable_cmd_fixed_param));
7500 cmd->vdev_id = vdev_id;
7501 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7502 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7503 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307504 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307505 __func__);
7506 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307507 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307508 }
7509
7510 return 0;
7511}
7512
7513/**
7514 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7515 * @wmi_handle: wmi handle
7516 * @startOemDataReq: start request params
7517 *
7518 * Return: CDF status
7519 */
Govind Singhb53420c2016-03-09 14:32:57 +05307520QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007521 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307522 uint8_t *data)
7523{
7524 wmi_buf_t buf;
7525 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307526 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307527
7528 buf = wmi_buf_alloc(wmi_handle,
7529 (data_len + WMI_TLV_HDR_SIZE));
7530 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307531 WMI_LOGE(FL("wmi_buf_alloc failed"));
7532 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307533 }
7534
7535 cmd = (uint8_t *) wmi_buf_data(buf);
7536
7537 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7538 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307539 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307540 data_len);
7541
Govind Singhb53420c2016-03-09 14:32:57 +05307542 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307543 data_len);
7544
7545 ret = wmi_unified_cmd_send(wmi_handle, buf,
7546 (data_len +
7547 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7548
Govind Singh67922e82016-04-01 16:48:57 +05307549 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307550 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307551 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307552 }
7553
Govind Singh67922e82016-04-01 16:48:57 +05307554 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307555}
7556
7557/**
7558 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7559 * @wmi_handle: wmi handle
7560 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7561 *
7562 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7563 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7564 * to firmware based on phyerr filtering
7565 * offload status.
7566 *
7567 * Return: 1 success, 0 failure
7568 */
Govind Singhb53420c2016-03-09 14:32:57 +05307569QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307570send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7571 bool dfs_phyerr_filter_offload)
7572{
7573 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7574 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7575 wmi_buf_t buf;
7576 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307577 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307578
7579
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007580 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307581 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307582 __func__);
7583 len = sizeof(*disable_phyerr_offload_cmd);
7584 buf = wmi_buf_alloc(wmi_handle, len);
7585 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307586 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307587 return 0;
7588 }
7589 disable_phyerr_offload_cmd =
7590 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7591 wmi_buf_data(buf);
7592
7593 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7594 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7595 WMITLV_GET_STRUCT_TLVLEN
7596 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7597
7598 /*
7599 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7600 * to the firmware to disable the phyerror
7601 * filtering offload.
7602 */
7603 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7604 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307605 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307606 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307607 __func__, ret);
7608 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307609 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307610 }
Govind Singhb53420c2016-03-09 14:32:57 +05307611 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307612 __func__);
7613 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307614 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307615 __func__);
7616
7617 len = sizeof(*enable_phyerr_offload_cmd);
7618 buf = wmi_buf_alloc(wmi_handle, len);
7619 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307620 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7621 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307622 }
7623
7624 enable_phyerr_offload_cmd =
7625 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7626 wmi_buf_data(buf);
7627
7628 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7629 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7630 WMITLV_GET_STRUCT_TLVLEN
7631 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7632
7633 /*
7634 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7635 * to the firmware to enable the phyerror
7636 * filtering offload.
7637 */
7638 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7639 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7640
Govind Singh67922e82016-04-01 16:48:57 +05307641 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307642 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307643 __func__, ret);
7644 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307645 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307646 }
Govind Singhb53420c2016-03-09 14:32:57 +05307647 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307648 __func__);
7649 }
7650
Govind Singhb53420c2016-03-09 14:32:57 +05307651 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307652}
7653
7654#if !defined(REMOVE_PKT_LOG)
7655/**
7656 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7657 * @wmi_handle: wmi handle
7658 * @pktlog_event: pktlog event
7659 * @cmd_id: pktlog cmd id
7660 *
7661 * Return: CDF status
7662 */
Govind Singhb53420c2016-03-09 14:32:57 +05307663QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307664 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307665 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307666{
7667 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7668 WMI_CMD_ID CMD_ID;
7669 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7670 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7671 int len = 0;
7672 wmi_buf_t buf;
7673
7674 PKTLOG_EVENT = pktlog_event;
7675 CMD_ID = cmd_id;
7676
7677 switch (CMD_ID) {
7678 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7679 len = sizeof(*cmd);
7680 buf = wmi_buf_alloc(wmi_handle, len);
7681 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307682 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7683 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307684 }
7685 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7686 wmi_buf_data(buf);
7687 WMITLV_SET_HDR(&cmd->tlv_header,
7688 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7689 WMITLV_GET_STRUCT_TLVLEN
7690 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7691 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307692 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7693 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007694 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307695 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7696 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307697 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307698 goto wmi_send_failed;
7699 }
7700 break;
7701 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7702 len = sizeof(*disable_cmd);
7703 buf = wmi_buf_alloc(wmi_handle, len);
7704 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307705 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7706 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307707 }
7708 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7709 wmi_buf_data(buf);
7710 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7711 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7712 WMITLV_GET_STRUCT_TLVLEN
7713 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007714 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307715 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7716 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307717 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307718 goto wmi_send_failed;
7719 }
7720 break;
7721 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307722 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307723 break;
7724 }
7725
Govind Singhb53420c2016-03-09 14:32:57 +05307726 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307727
7728wmi_send_failed:
7729 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307730 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307731}
7732#endif /* REMOVE_PKT_LOG */
7733
7734/**
7735 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
7736 * @wmi_handle: wmi handle
7737 * @vdev_id: vdev id
7738 * @bitmap: Event bitmap
7739 * @enable: enable/disable
7740 *
7741 * Return: CDF status
7742 */
Govind Singhb53420c2016-03-09 14:32:57 +05307743QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307744 uint32_t vdev_id,
7745 uint32_t bitmap,
7746 bool enable)
7747{
7748 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
7749 uint16_t len;
7750 wmi_buf_t buf;
7751 int ret;
7752
7753 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
7754 buf = wmi_buf_alloc(wmi_handle, len);
7755 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307756 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7757 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307758 }
7759 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
7760 WMITLV_SET_HDR(&cmd->tlv_header,
7761 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
7762 WMITLV_GET_STRUCT_TLVLEN
7763 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
7764 cmd->vdev_id = vdev_id;
7765 cmd->is_add = enable;
7766 cmd->event_bitmap = bitmap;
7767
7768 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7769 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
7770 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307771 WMI_LOGE("Failed to config wow wakeup event");
Govind Singh20c5dac2016-03-07 15:33:31 +05307772 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307773 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307774 }
7775
Govind Singhb53420c2016-03-09 14:32:57 +05307776 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
Govind Singh20c5dac2016-03-07 15:33:31 +05307777 enable ? "enabled" : "disabled");
7778
Govind Singhb53420c2016-03-09 14:32:57 +05307779 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307780}
7781
7782/**
7783 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
7784 * @wmi_handle: wmi handle
7785 * @vdev_id: vdev id
7786 * @ptrn_id: pattern id
7787 * @ptrn: pattern
7788 * @ptrn_len: pattern length
7789 * @ptrn_offset: pattern offset
7790 * @mask: mask
7791 * @mask_len: mask length
7792 * @user: true for user configured pattern and false for default pattern
7793 * @default_patterns: default patterns
7794 *
7795 * Return: CDF status
7796 */
Govind Singhb53420c2016-03-09 14:32:57 +05307797QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307798 uint8_t vdev_id, uint8_t ptrn_id,
7799 const uint8_t *ptrn, uint8_t ptrn_len,
7800 uint8_t ptrn_offset, const uint8_t *mask,
7801 uint8_t mask_len, bool user,
7802 uint8_t default_patterns)
7803{
7804 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7805 WOW_BITMAP_PATTERN_T *bitmap_pattern;
7806 wmi_buf_t buf;
7807 uint8_t *buf_ptr;
7808 int32_t len;
7809 int ret;
7810
7811
7812 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7813 WMI_TLV_HDR_SIZE +
7814 1 * sizeof(WOW_BITMAP_PATTERN_T) +
7815 WMI_TLV_HDR_SIZE +
7816 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7817 WMI_TLV_HDR_SIZE +
7818 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7819 WMI_TLV_HDR_SIZE +
7820 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7821 WMI_TLV_HDR_SIZE +
7822 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7823
7824 buf = wmi_buf_alloc(wmi_handle, len);
7825 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307826 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7827 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307828 }
7829
7830 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7831 buf_ptr = (uint8_t *) cmd;
7832
7833 WMITLV_SET_HDR(&cmd->tlv_header,
7834 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7835 WMITLV_GET_STRUCT_TLVLEN
7836 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7837 cmd->vdev_id = vdev_id;
7838 cmd->pattern_id = ptrn_id;
7839
7840 cmd->pattern_type = WOW_BITMAP_PATTERN;
7841 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7842
7843 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7844 sizeof(WOW_BITMAP_PATTERN_T));
7845 buf_ptr += WMI_TLV_HDR_SIZE;
7846 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
7847
7848 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
7849 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
7850 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
7851
Govind Singhb53420c2016-03-09 14:32:57 +05307852 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
7853 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05307854
7855 bitmap_pattern->pattern_offset = ptrn_offset;
7856 bitmap_pattern->pattern_len = ptrn_len;
7857
7858 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
7859 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
7860
7861 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
7862 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
7863
7864 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
7865 bitmap_pattern->pattern_id = ptrn_id;
7866
Govind Singhb53420c2016-03-09 14:32:57 +05307867 WMI_LOGI("vdev id : %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307868 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
7869 bitmap_pattern->pattern_offset, user);
Govind Singh87542482016-06-08 19:40:11 +05307870#ifdef CONFIG_MCL
Govind Singhb53420c2016-03-09 14:32:57 +05307871 WMI_LOGI("Pattern : ");
7872 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307873 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
7874
Govind Singhb53420c2016-03-09 14:32:57 +05307875 WMI_LOGI("Mask : ");
7876 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307877 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
Govind Singh87542482016-06-08 19:40:11 +05307878#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05307879
7880 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
7881
7882 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7883 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7884 buf_ptr += WMI_TLV_HDR_SIZE;
7885
7886 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7887 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7888 buf_ptr += WMI_TLV_HDR_SIZE;
7889
7890 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7891 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7892 buf_ptr += WMI_TLV_HDR_SIZE;
7893
7894 /* Fill TLV for pattern_info_timeout but no data. */
7895 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7896 buf_ptr += WMI_TLV_HDR_SIZE;
7897
7898 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
7899 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
7900 buf_ptr += WMI_TLV_HDR_SIZE;
7901 *(A_UINT32 *) buf_ptr = 0;
7902
7903 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7904 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7905 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307906 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307907 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307908 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307909 }
7910
Govind Singhb53420c2016-03-09 14:32:57 +05307911 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307912}
7913
7914/**
7915 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
7916 * @wmi_handle: wmi handle
7917 * @ptrn_id: pattern id
7918 * @vdev_id: vdev id
7919 *
7920 * Return: CDF status
7921 */
Govind Singhb53420c2016-03-09 14:32:57 +05307922QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle, uint8_t ptrn_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307923 uint8_t vdev_id)
7924{
7925 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
7926 wmi_buf_t buf;
7927 int32_t len;
7928 int ret;
7929
7930 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
7931
7932
7933 buf = wmi_buf_alloc(wmi_handle, len);
7934 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307935 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7936 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307937 }
7938
7939 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7940
7941 WMITLV_SET_HDR(&cmd->tlv_header,
7942 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
7943 WMITLV_GET_STRUCT_TLVLEN(
7944 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
7945 cmd->vdev_id = vdev_id;
7946 cmd->pattern_id = ptrn_id;
7947 cmd->pattern_type = WOW_BITMAP_PATTERN;
7948
Govind Singhb53420c2016-03-09 14:32:57 +05307949 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05307950 cmd->pattern_id, vdev_id);
7951
7952 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7953 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
7954 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307955 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307956 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307957 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307958 }
7959
Govind Singhb53420c2016-03-09 14:32:57 +05307960 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307961}
7962
7963/**
7964 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
7965 * @wmi_handle: wmi handle
7966 *
7967 * Sends host wakeup indication to FW. On receiving this indication,
7968 * FW will come out of WOW.
7969 *
7970 * Return: CDF status
7971 */
Govind Singhb53420c2016-03-09 14:32:57 +05307972QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307973{
7974 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
7975 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05307976 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307977 int32_t len;
7978 int ret;
7979
7980 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
7981
7982 buf = wmi_buf_alloc(wmi_handle, len);
7983 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307984 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7985 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307986 }
7987
7988 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
7989 wmi_buf_data(buf);
7990 WMITLV_SET_HDR(&cmd->tlv_header,
7991 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
7992 WMITLV_GET_STRUCT_TLVLEN
7993 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
7994
7995
7996 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7997 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
7998 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307999 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308000 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308001 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308002 }
8003
Govind Singhb53420c2016-03-09 14:32:57 +05308004 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308005}
8006
8007/**
8008 * send_del_ts_cmd_tlv() - send DELTS request to fw
8009 * @wmi_handle: wmi handle
8010 * @msg: delts params
8011 *
8012 * Return: CDF status
8013 */
Govind Singhb53420c2016-03-09 14:32:57 +05308014QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308015 uint8_t ac)
8016{
8017 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8018 wmi_buf_t buf;
8019 int32_t len = sizeof(*cmd);
8020
8021 buf = wmi_buf_alloc(wmi_handle, len);
8022 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308023 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8024 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308025 }
8026 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8027 WMITLV_SET_HDR(&cmd->tlv_header,
8028 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8029 WMITLV_GET_STRUCT_TLVLEN
8030 (wmi_vdev_wmm_delts_cmd_fixed_param));
8031 cmd->vdev_id = vdev_id;
8032 cmd->ac = ac;
8033
Govind Singhb53420c2016-03-09 14:32:57 +05308034 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308035 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8036 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8037 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308038 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308039 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308040 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308041 }
8042
Govind Singhb53420c2016-03-09 14:32:57 +05308043 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308044}
8045
8046/**
8047 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8048 * @wmi_handle: handle to wmi
8049 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8050 *
Govind Singhb53420c2016-03-09 14:32:57 +05308051 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308052 * ADD_TS requestes to firmware in loop for all the ACs with
8053 * active flow.
8054 *
8055 * Return: CDF status
8056 */
Govind Singhb53420c2016-03-09 14:32:57 +05308057QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308058 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8059{
8060 int i = 0;
8061 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8062 wmi_buf_t buf;
8063 int32_t len = sizeof(*cmd);
8064
8065 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8066 /* if flow in this AC is active */
8067 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8068 /*
8069 * as per implementation of wma_add_ts_req() we
8070 * are not waiting any response from firmware so
8071 * apart from sending ADDTS to firmware just send
8072 * success to upper layers
8073 */
Govind Singhb53420c2016-03-09 14:32:57 +05308074 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308075
8076 buf = wmi_buf_alloc(wmi_handle, len);
8077 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308078 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8079 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308080 }
8081 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8082 wmi_buf_data(buf);
8083 WMITLV_SET_HDR(&cmd->tlv_header,
8084 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8085 WMITLV_GET_STRUCT_TLVLEN
8086 (wmi_vdev_wmm_addts_cmd_fixed_param));
8087 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8088 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308089 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308090 traffic.userPrio);
8091 cmd->medium_time_us =
8092 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8093 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308094 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308095 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8096 cmd->medium_time_us, cmd->downgrade_type);
8097 if (wmi_unified_cmd_send
8098 (wmi_handle, buf, len,
8099 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308100 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308101 __func__);
8102 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308103 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308104 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308105 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308106 }
8107 }
8108 }
8109
Govind Singhb53420c2016-03-09 14:32:57 +05308110 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308111}
8112
8113/**
8114 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8115 * @wmi_handle: wmi handle
8116 * @msg: ADDTS params
8117 *
8118 * Return: CDF status
8119 */
Govind Singhb53420c2016-03-09 14:32:57 +05308120QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308121 struct add_ts_param *msg)
8122{
8123 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8124 wmi_buf_t buf;
8125 int32_t len = sizeof(*cmd);
8126
Govind Singhb53420c2016-03-09 14:32:57 +05308127 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308128
8129 buf = wmi_buf_alloc(wmi_handle, len);
8130 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308131 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8132 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308133 }
8134 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8135 WMITLV_SET_HDR(&cmd->tlv_header,
8136 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8137 WMITLV_GET_STRUCT_TLVLEN
8138 (wmi_vdev_wmm_addts_cmd_fixed_param));
8139 cmd->vdev_id = msg->sme_session_id;
8140 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8141 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8142 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308143 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308144 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8145 cmd->downgrade_type, __func__, __LINE__);
8146 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8147 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308148 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8149 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308150 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308151 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308152 }
8153
Govind Singhb53420c2016-03-09 14:32:57 +05308154 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308155}
8156
8157/**
8158 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
8159 * @wmi_handle: wmi handle
8160 * @vdev_id: vdev id
8161 * @enable: Flag to enable/disable packet filter
8162 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308163 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308164 */
Govind Singhb53420c2016-03-09 14:32:57 +05308165QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308166 uint8_t vdev_id, bool enable)
8167{
8168 int32_t len;
8169 int ret = 0;
8170 wmi_buf_t buf;
8171 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
8172
8173 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
8174
8175 buf = wmi_buf_alloc(wmi_handle, len);
8176 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308177 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308178 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308179 }
8180
8181 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
8182 WMITLV_SET_HDR(&cmd->tlv_header,
8183 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
8184 WMITLV_GET_STRUCT_TLVLEN(
8185 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
8186
8187 cmd->vdev_id = vdev_id;
8188 if (enable)
8189 cmd->enable = PACKET_FILTER_SET_ENABLE;
8190 else
8191 cmd->enable = PACKET_FILTER_SET_DISABLE;
8192
Govind Singhb53420c2016-03-09 14:32:57 +05308193 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308194 __func__, cmd->enable, vdev_id);
8195
8196 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8197 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308198 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308199 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308200 wmi_buf_free(buf);
8201 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308202
8203 return ret;
8204}
8205
8206/**
8207 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
8208 * @wmi_handle: wmi handle
8209 * @vdev_id: vdev id
8210 * @rcv_filter_param: Packet filter parameters
8211 * @filter_id: Filter id
8212 * @enable: Flag to add/delete packet filter configuration
8213 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308214 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308215 */
Govind Singhb53420c2016-03-09 14:32:57 +05308216QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308217 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8218 uint8_t filter_id, bool enable)
8219{
8220 int len, i;
8221 int err = 0;
8222 wmi_buf_t buf;
8223 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8224
8225
8226 /* allocate the memory */
8227 len = sizeof(*cmd);
8228 buf = wmi_buf_alloc(wmi_handle, len);
8229 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308230 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308231 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308232 }
8233
8234 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8235 WMITLV_SET_HDR(&cmd->tlv_header,
8236 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8237 WMITLV_GET_STRUCT_TLVLEN
8238 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8239
8240 cmd->vdev_id = vdev_id;
8241 cmd->filter_id = filter_id;
8242 if (enable)
8243 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8244 else
8245 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8246
8247 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308248 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308249 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8250 rcv_filter_param->numFieldParams);
8251 cmd->filter_type = rcv_filter_param->filterType;
8252 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8253
8254 for (i = 0; i < cmd->num_params; i++) {
8255 cmd->paramsData[i].proto_type =
8256 rcv_filter_param->paramsData[i].protocolLayer;
8257 cmd->paramsData[i].cmp_type =
8258 rcv_filter_param->paramsData[i].cmpFlag;
8259 cmd->paramsData[i].data_length =
8260 rcv_filter_param->paramsData[i].dataLength;
8261 cmd->paramsData[i].data_offset =
8262 rcv_filter_param->paramsData[i].dataOffset;
8263 memcpy(&cmd->paramsData[i].compareData,
8264 rcv_filter_param->paramsData[i].compareData,
8265 sizeof(cmd->paramsData[i].compareData));
8266 memcpy(&cmd->paramsData[i].dataMask,
8267 rcv_filter_param->paramsData[i].dataMask,
8268 sizeof(cmd->paramsData[i].dataMask));
8269 }
8270 }
8271
Govind Singhb53420c2016-03-09 14:32:57 +05308272 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308273 cmd->filter_action, cmd->filter_id, cmd->num_params);
8274 /* send the command along with data */
8275 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8276 WMI_PACKET_FILTER_CONFIG_CMDID);
8277 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308278 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308279 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308280 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308281 }
8282
8283
8284 return 0;
8285}
8286
8287/**
8288 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
8289 * @wmi_handle: wmi handle
8290 * @vdev_id: vdev id
8291 * @multicastAddr: mcast address
8292 * @clearList: clear list flag
8293 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308294 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308295 */
Govind Singhb53420c2016-03-09 14:32:57 +05308296QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308297 uint8_t vdev_id,
Govind Singhb53420c2016-03-09 14:32:57 +05308298 struct qdf_mac_addr multicast_addr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308299 bool clearList)
8300{
8301 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
8302 wmi_buf_t buf;
8303 int err;
8304
8305 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8306 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308307 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308308 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308309 }
8310
8311 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308312 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308313
8314 WMITLV_SET_HDR(&cmd->tlv_header,
8315 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
8316 WMITLV_GET_STRUCT_TLVLEN
8317 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
8318 cmd->action =
8319 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
8320 cmd->vdev_id = vdev_id;
8321 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
8322 err = wmi_unified_cmd_send(wmi_handle, buf,
8323 sizeof(*cmd),
8324 WMI_SET_MCASTBCAST_FILTER_CMDID);
8325 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308326 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308327 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308328 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308329 }
Govind Singhb53420c2016-03-09 14:32:57 +05308330 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308331 cmd->action, vdev_id, clearList);
Govind Singh224a7312016-06-21 14:33:26 +05308332 WMI_LOGD("MCBC MAC Addr: %pM", multicast_addr.bytes);
Govind Singh20c5dac2016-03-07 15:33:31 +05308333
8334 return 0;
8335}
8336
8337/**
8338 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
8339 * @wmi_handle: wmi handle
8340 * @vdev_id: vdev id
8341 * @params: GTK offload parameters
8342 *
8343 * Return: CDF status
8344 */
Govind Singhb53420c2016-03-09 14:32:57 +05308345QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308346 struct gtk_offload_params *params,
8347 bool enable_offload,
8348 uint32_t gtk_offload_opcode)
8349{
8350 int len;
8351 wmi_buf_t buf;
8352 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308353 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308354
Govind Singhb53420c2016-03-09 14:32:57 +05308355 WMI_LOGD("%s Enter", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308356
8357 len = sizeof(*cmd);
8358
8359 /* alloc wmi buffer */
8360 buf = wmi_buf_alloc(wmi_handle, len);
8361 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308362 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8363 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308364 goto out;
8365 }
8366
8367 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8368 WMITLV_SET_HDR(&cmd->tlv_header,
8369 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8370 WMITLV_GET_STRUCT_TLVLEN
8371 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8372
8373 cmd->vdev_id = vdev_id;
8374
8375 /* Request target to enable GTK offload */
Siddarth Poddar9500f2e2016-04-01 17:45:06 +05308376 if (enable_offload == WMI_GTK_OFFLOAD_ENABLE) {
Govind Singh20c5dac2016-03-07 15:33:31 +05308377 cmd->flags = gtk_offload_opcode;
8378
8379 /* Copy the keys and replay counter */
Govind Singhb53420c2016-03-09 14:32:57 +05308380 qdf_mem_copy(cmd->KCK, params->aKCK, WMI_GTK_OFFLOAD_KCK_BYTES);
8381 qdf_mem_copy(cmd->KEK, params->aKEK, WMI_GTK_OFFLOAD_KEK_BYTES);
8382 qdf_mem_copy(cmd->replay_counter, &params->ullKeyReplayCounter,
Govind Singh20c5dac2016-03-07 15:33:31 +05308383 GTK_REPLAY_COUNTER_BYTES);
8384 } else {
8385 cmd->flags = gtk_offload_opcode;
8386 }
8387
8388 /* send the wmi command */
8389 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8390 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308391 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
Govind Singh20c5dac2016-03-07 15:33:31 +05308392 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308393 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308394 }
8395
Govind Singhb53420c2016-03-09 14:32:57 +05308396 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
Govind Singh20c5dac2016-03-07 15:33:31 +05308397out:
Govind Singhb53420c2016-03-09 14:32:57 +05308398 WMI_LOGD("%s Exit", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308399 return status;
8400}
8401
8402/**
8403 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
8404 * @wmi_handle: wmi handle
8405 * @params: GTK offload params
8406 *
8407 * Return: CDF status
8408 */
Govind Singhb53420c2016-03-09 14:32:57 +05308409QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308410 uint8_t vdev_id,
8411 uint64_t offload_req_opcode)
8412{
8413 int len;
8414 wmi_buf_t buf;
8415 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308416 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308417
8418 len = sizeof(*cmd);
8419
8420 /* alloc wmi buffer */
8421 buf = wmi_buf_alloc(wmi_handle, len);
8422 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308423 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8424 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308425 goto out;
8426 }
8427
8428 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8429 WMITLV_SET_HDR(&cmd->tlv_header,
8430 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8431 WMITLV_GET_STRUCT_TLVLEN
8432 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8433
8434 /* Request for GTK offload status */
8435 cmd->flags = offload_req_opcode;
8436 cmd->vdev_id = vdev_id;
8437
8438 /* send the wmi command */
8439 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8440 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308441 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
Govind Singh20c5dac2016-03-07 15:33:31 +05308442 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308443 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308444 }
8445
8446out:
8447 return status;
8448}
8449
8450/**
8451 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8452 * @wmi_handle: wmi handle
8453 * @pAddPeriodicTxPtrnParams: tx ptrn params
8454 *
8455 * Retrun: CDF status
8456 */
Govind Singhb53420c2016-03-09 14:32:57 +05308457QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308458 struct periodic_tx_pattern *
8459 pAddPeriodicTxPtrnParams,
8460 uint8_t vdev_id)
8461{
8462 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8463 wmi_buf_t wmi_buf;
8464 uint32_t len;
8465 uint8_t *buf_ptr;
8466 uint32_t ptrn_len, ptrn_len_aligned;
8467 int j;
8468
8469 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8470 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8471 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8472 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8473
8474 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8475 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308476 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8477 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308478 }
8479
8480 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8481
8482 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8483 WMITLV_SET_HDR(&cmd->tlv_header,
8484 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8485 WMITLV_GET_STRUCT_TLVLEN
8486 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8487
8488 /* Pass the pattern id to delete for the corresponding vdev id */
8489 cmd->vdev_id = vdev_id;
8490 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8491 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8492 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8493
8494 /* Pattern info */
8495 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8496 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8497 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308498 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308499 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308500 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308501
Govind Singhb53420c2016-03-09 14:32:57 +05308502 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308503 __func__, cmd->pattern_id, cmd->vdev_id);
8504
8505 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8506 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308507 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308508 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308509 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308510 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308511 }
Govind Singhb53420c2016-03-09 14:32:57 +05308512 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308513}
8514
8515/**
8516 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8517 * @wmi_handle: wmi handle
8518 * @vdev_id: vdev id
8519 * @pattern_id: pattern id
8520 *
8521 * Retrun: CDF status
8522 */
Govind Singhb53420c2016-03-09 14:32:57 +05308523QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308524 uint8_t vdev_id,
8525 uint8_t pattern_id)
8526{
8527 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8528 wmi_buf_t wmi_buf;
8529 uint32_t len =
8530 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8531
8532 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8533 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308534 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8535 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308536 }
8537
8538 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8539 wmi_buf_data(wmi_buf);
8540 WMITLV_SET_HDR(&cmd->tlv_header,
8541 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8542 WMITLV_GET_STRUCT_TLVLEN
8543 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8544
8545 /* Pass the pattern id to delete for the corresponding vdev id */
8546 cmd->vdev_id = vdev_id;
8547 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308548 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308549 __func__, cmd->pattern_id, cmd->vdev_id);
8550
8551 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8552 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308553 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308554 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308555 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308556 }
Govind Singhb53420c2016-03-09 14:32:57 +05308557 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308558}
8559
8560/**
8561 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8562 * @wmi_handle: wmi handle
8563 * @preq: stats ext params
8564 *
8565 * Return: CDF status
8566 */
Govind Singhb53420c2016-03-09 14:32:57 +05308567QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308568 struct stats_ext_params *preq)
8569{
Govind Singh67922e82016-04-01 16:48:57 +05308570 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308571 wmi_req_stats_ext_cmd_fixed_param *cmd;
8572 wmi_buf_t buf;
8573 uint16_t len;
8574 uint8_t *buf_ptr;
8575
8576 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8577
8578 buf = wmi_buf_alloc(wmi_handle, len);
8579 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308580 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308581 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308582 }
8583
8584 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8585 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8586
8587 WMITLV_SET_HDR(&cmd->tlv_header,
8588 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8589 WMITLV_GET_STRUCT_TLVLEN
8590 (wmi_req_stats_ext_cmd_fixed_param));
8591 cmd->vdev_id = preq->vdev_id;
8592 cmd->data_len = preq->request_data_len;
8593
Govind Singhb53420c2016-03-09 14:32:57 +05308594 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308595 __func__, preq->request_data_len, preq->vdev_id);
8596
8597 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8598 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8599
8600 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308601 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308602
8603 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8604 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308605 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308606 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308607 ret);
8608 wmi_buf_free(buf);
8609 }
8610
8611 return ret;
8612}
8613
8614/**
8615 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8616 * @wmi_handle: wmi handle
8617 * @params: ext wow params
8618 *
8619 * Return:0 for success or error code
8620 */
Govind Singhb53420c2016-03-09 14:32:57 +05308621QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308622 struct ext_wow_params *params)
8623{
8624 wmi_extwow_enable_cmd_fixed_param *cmd;
8625 wmi_buf_t buf;
8626 int32_t len;
8627 int ret;
8628
8629 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8630 buf = wmi_buf_alloc(wmi_handle, len);
8631 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308632 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8633 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308634 }
8635
8636 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8637
8638 WMITLV_SET_HDR(&cmd->tlv_header,
8639 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8640 WMITLV_GET_STRUCT_TLVLEN
8641 (wmi_extwow_enable_cmd_fixed_param));
8642
8643 cmd->vdev_id = params->vdev_id;
8644 cmd->type = params->type;
8645 cmd->wakeup_pin_num = params->wakeup_pin_num;
8646
Govind Singhb53420c2016-03-09 14:32:57 +05308647 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308648 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8649
8650 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8651 WMI_EXTWOW_ENABLE_CMDID);
8652 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308653 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308654 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308655 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308656 }
8657
Govind Singhb53420c2016-03-09 14:32:57 +05308658 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308659
8660}
8661
8662/**
8663 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8664 * @wmi_handle: wmi handle
8665 * @app_type1_params: app type1 params
8666 *
8667 * Return: CDF status
8668 */
Govind Singhb53420c2016-03-09 14:32:57 +05308669QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308670 struct app_type1_params *app_type1_params)
8671{
8672 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8673 wmi_buf_t buf;
8674 int32_t len;
8675 int ret;
8676
8677 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8678 buf = wmi_buf_alloc(wmi_handle, len);
8679 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308680 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8681 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308682 }
8683
8684 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8685 wmi_buf_data(buf);
8686
8687 WMITLV_SET_HDR(&cmd->tlv_header,
8688 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8689 WMITLV_GET_STRUCT_TLVLEN
8690 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8691
8692 cmd->vdev_id = app_type1_params->vdev_id;
8693 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8694 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308695 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308696 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308697 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308698 cmd->passwd_len = app_type1_params->pass_length;
8699
Govind Singhb53420c2016-03-09 14:32:57 +05308700 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308701 "identification_id %.8s id_length %u "
8702 "password %.16s pass_length %u",
8703 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8704 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8705
8706 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8707 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8708 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308709 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308710 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308711 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308712 }
8713
Govind Singhb53420c2016-03-09 14:32:57 +05308714 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308715}
8716
8717/**
8718 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8719 * @wmi_handle: wmi handle
8720 * @appType2Params: app type2 params
8721 *
8722 * Return: CDF status
8723 */
Govind Singhb53420c2016-03-09 14:32:57 +05308724QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308725 struct app_type2_params *appType2Params)
8726{
8727 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8728 wmi_buf_t buf;
8729 int32_t len;
8730 int ret;
8731
8732 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8733 buf = wmi_buf_alloc(wmi_handle, len);
8734 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308735 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8736 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308737 }
8738
8739 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8740 wmi_buf_data(buf);
8741
8742 WMITLV_SET_HDR(&cmd->tlv_header,
8743 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8744 WMITLV_GET_STRUCT_TLVLEN
8745 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8746
8747 cmd->vdev_id = appType2Params->vdev_id;
8748
Govind Singhb53420c2016-03-09 14:32:57 +05308749 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308750 cmd->rc4_key_len = appType2Params->rc4_key_len;
8751
8752 cmd->ip_id = appType2Params->ip_id;
8753 cmd->ip_device_ip = appType2Params->ip_device_ip;
8754 cmd->ip_server_ip = appType2Params->ip_server_ip;
8755
8756 cmd->tcp_src_port = appType2Params->tcp_src_port;
8757 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8758 cmd->tcp_seq = appType2Params->tcp_seq;
8759 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8760
8761 cmd->keepalive_init = appType2Params->keepalive_init;
8762 cmd->keepalive_min = appType2Params->keepalive_min;
8763 cmd->keepalive_max = appType2Params->keepalive_max;
8764 cmd->keepalive_inc = appType2Params->keepalive_inc;
8765
8766 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8767 &cmd->gateway_mac);
8768 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8769 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8770
Govind Singhb53420c2016-03-09 14:32:57 +05308771 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308772 "rc4_key %.16s rc4_key_len %u "
8773 "ip_id %x ip_device_ip %x ip_server_ip %x "
8774 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8775 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8776 "keepalive_max %u keepalive_inc %u "
8777 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8778 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8779 cmd->rc4_key, cmd->rc4_key_len,
8780 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8781 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8782 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8783 cmd->keepalive_max, cmd->keepalive_inc,
8784 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8785
8786 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8787 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8788 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308789 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308790 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308791 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308792 }
8793
Govind Singhb53420c2016-03-09 14:32:57 +05308794 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308795
8796}
8797
8798/**
8799 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8800 * @wmi_handle: wmi handle
8801 * @timer_val: auto shutdown timer value
8802 *
8803 * Return: CDF status
8804 */
Govind Singhb53420c2016-03-09 14:32:57 +05308805QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308806 uint32_t timer_val)
8807{
Govind Singh67922e82016-04-01 16:48:57 +05308808 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308809 wmi_buf_t buf = NULL;
8810 uint8_t *buf_ptr;
8811 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8812 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8813
Govind Singhb53420c2016-03-09 14:32:57 +05308814 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308815 __func__, timer_val);
8816
8817 buf = wmi_buf_alloc(wmi_handle, len);
8818 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308819 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8820 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308821 }
8822
8823 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8824 wmi_auto_sh_cmd =
8825 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8826 wmi_auto_sh_cmd->timer_value = timer_val;
8827
8828 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8829 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8830 WMITLV_GET_STRUCT_TLVLEN
8831 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8832
8833 status = wmi_unified_cmd_send(wmi_handle, buf,
8834 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308835 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308836 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308837 __func__, status);
8838 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308839 }
8840
Govind Singh67922e82016-04-01 16:48:57 +05308841 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308842}
8843
8844/**
8845 * send_nan_req_cmd_tlv() - to send nan request to target
8846 * @wmi_handle: wmi handle
8847 * @nan_req: request data which will be non-null
8848 *
8849 * Return: CDF status
8850 */
Govind Singhb53420c2016-03-09 14:32:57 +05308851QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308852 struct nan_req_params *nan_req)
8853{
Govind Singh67922e82016-04-01 16:48:57 +05308854 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308855 wmi_nan_cmd_param *cmd;
8856 wmi_buf_t buf;
8857 uint16_t len = sizeof(*cmd);
8858 uint16_t nan_data_len, nan_data_len_aligned;
8859 uint8_t *buf_ptr;
8860
8861 /*
8862 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8863 * +------------+----------+-----------------------+--------------+
8864 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8865 * +------------+----------+-----------------------+--------------+
8866 */
8867 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308868 WMI_LOGE("%s:nan req is not valid", __func__);
8869 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308870 }
8871 nan_data_len = nan_req->request_data_len;
8872 nan_data_len_aligned = roundup(nan_req->request_data_len,
8873 sizeof(uint32_t));
8874 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8875 buf = wmi_buf_alloc(wmi_handle, len);
8876 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308877 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8878 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308879 }
8880 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8881 cmd = (wmi_nan_cmd_param *) buf_ptr;
8882 WMITLV_SET_HDR(&cmd->tlv_header,
8883 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8884 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8885 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308886 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308887 __func__, nan_req->request_data_len);
8888 buf_ptr += sizeof(wmi_nan_cmd_param);
8889 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8890 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308891 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308892
8893 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8894 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308895 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308896 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308897 __func__, ret);
8898 wmi_buf_free(buf);
8899 }
8900
8901 return ret;
8902}
8903
8904/**
8905 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8906 * @wmi_handle: wmi handle
8907 * @pDhcpSrvOffloadInfo: DHCP server offload info
8908 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308909 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308910 */
Govind Singhb53420c2016-03-09 14:32:57 +05308911QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308912 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8913{
8914 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8915 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308916 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308917
8918 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8919 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308920 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308921 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308922 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308923 }
8924
8925 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308926 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308927
8928 WMITLV_SET_HDR(&cmd->tlv_header,
8929 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8930 WMITLV_GET_STRUCT_TLVLEN
8931 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8932 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8933 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8934 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8935 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8936 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308937 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308938 sizeof(*cmd),
8939 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308940 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308941 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308942 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308943 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308944 }
Govind Singhb53420c2016-03-09 14:32:57 +05308945 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308946 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308947
8948 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308949}
8950
8951/**
8952 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8953 * @wmi_handle: wmi handle
8954 * @flashing: flashing request
8955 *
8956 * Return: CDF status
8957 */
Govind Singhb53420c2016-03-09 14:32:57 +05308958QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308959 struct flashing_req_params *flashing)
8960{
8961 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308962 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308963 wmi_buf_t buf;
8964 uint8_t *buf_ptr;
8965 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8966
8967 buf = wmi_buf_alloc(wmi_handle, len);
8968 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308969 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308970 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308971 }
8972 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8973 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8974 WMITLV_SET_HDR(&cmd->tlv_header,
8975 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8976 WMITLV_GET_STRUCT_TLVLEN
8977 (wmi_set_led_flashing_cmd_fixed_param));
8978 cmd->pattern_id = flashing->pattern_id;
8979 cmd->led_x0 = flashing->led_x0;
8980 cmd->led_x1 = flashing->led_x1;
8981
8982 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8983 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308984 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308985 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308986 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308987 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308988 }
Govind Singh67922e82016-04-01 16:48:57 +05308989
8990 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308991}
8992
8993/**
8994 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8995 * @wmi_handle: wmi handle
8996 * @ch_avoid_update_req: channel avoid update params
8997 *
8998 * Return: CDF status
8999 */
Govind Singhb53420c2016-03-09 14:32:57 +05309000QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309001{
Govind Singh67922e82016-04-01 16:48:57 +05309002 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309003 wmi_buf_t buf = NULL;
9004 uint8_t *buf_ptr;
9005 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9006 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9007
9008
9009 buf = wmi_buf_alloc(wmi_handle, len);
9010 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309011 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9012 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309013 }
9014
9015 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9016 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9017 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9018 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9019 WMITLV_GET_STRUCT_TLVLEN
9020 (wmi_chan_avoid_update_cmd_param));
9021
9022 status = wmi_unified_cmd_send(wmi_handle, buf,
9023 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309024 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309025 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309026 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9027 " returned Error %d", status);
9028 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309029 }
9030
Govind Singh67922e82016-04-01 16:48:57 +05309031 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309032}
9033
9034/**
9035 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9036 * @wmi_handle: wmi handle
9037 * @reg_dmn: reg domain
9038 * @regdmn2G: 2G reg domain
9039 * @regdmn5G: 5G reg domain
9040 * @ctl2G: 2G test limit
9041 * @ctl5G: 5G test limit
9042 *
9043 * Return: none
9044 */
Govind Singhb53420c2016-03-09 14:32:57 +05309045QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309046 uint32_t reg_dmn, uint16_t regdmn2G,
9047 uint16_t regdmn5G, int8_t ctl2G,
9048 int8_t ctl5G)
9049{
9050 wmi_buf_t buf;
9051 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9052 int32_t len = sizeof(*cmd);
9053
9054
9055 buf = wmi_buf_alloc(wmi_handle, len);
9056 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309057 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9058 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309059 }
9060 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9061 WMITLV_SET_HDR(&cmd->tlv_header,
9062 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9063 WMITLV_GET_STRUCT_TLVLEN
9064 (wmi_pdev_set_regdomain_cmd_fixed_param));
9065 cmd->reg_domain = reg_dmn;
9066 cmd->reg_domain_2G = regdmn2G;
9067 cmd->reg_domain_5G = regdmn5G;
9068 cmd->conformance_test_limit_2G = ctl2G;
9069 cmd->conformance_test_limit_5G = ctl5G;
9070
9071 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9072 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309073 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309074 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309075 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309076 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309077 }
9078
Govind Singhb53420c2016-03-09 14:32:57 +05309079 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309080}
9081
9082
9083/**
9084 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9085 * @wmi_handle: wmi handle
9086 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9087 *
9088 * This function sets tdls off channel mode
9089 *
9090 * Return: 0 on success; Negative errno otherwise
9091 */
Govind Singhb53420c2016-03-09 14:32:57 +05309092QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309093 struct tdls_channel_switch_params *chan_switch_params)
9094{
9095 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9096 wmi_buf_t wmi_buf;
9097 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9098
9099 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9100 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309101 WMI_LOGE(FL("wmi_buf_alloc failed"));
9102 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309103 }
9104 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9105 wmi_buf_data(wmi_buf);
9106 WMITLV_SET_HDR(&cmd->tlv_header,
9107 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9108 WMITLV_GET_STRUCT_TLVLEN(
9109 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9110
9111 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9112 &cmd->peer_macaddr);
9113 cmd->vdev_id = chan_switch_params->vdev_id;
9114 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9115 cmd->is_peer_responder = chan_switch_params->is_responder;
9116 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9117 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9118 cmd->offchan_oper_class = chan_switch_params->oper_class;
9119
Govind Singhb53420c2016-03-09 14:32:57 +05309120 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309121 cmd->peer_macaddr.mac_addr31to0,
9122 cmd->peer_macaddr.mac_addr47to32);
9123
Govind Singhb53420c2016-03-09 14:32:57 +05309124 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309125 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9126 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9127 ),
9128 cmd->vdev_id,
9129 cmd->offchan_mode,
9130 cmd->offchan_num,
9131 cmd->offchan_bw_bitmap,
9132 cmd->is_peer_responder,
9133 cmd->offchan_oper_class);
9134
9135 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9136 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309137 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309138 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309139 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309140 }
9141
9142
Govind Singhb53420c2016-03-09 14:32:57 +05309143 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309144}
9145
9146/**
9147 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9148 * @wmi_handle: wmi handle
9149 * @pwmaTdlsparams: TDLS params
9150 *
9151 * Return: 0 for sucess or error code
9152 */
Govind Singhb53420c2016-03-09 14:32:57 +05309153QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309154 void *tdls_param, uint8_t tdls_state)
9155{
9156 wmi_tdls_set_state_cmd_fixed_param *cmd;
9157 wmi_buf_t wmi_buf;
9158
9159 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9160 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9161
9162 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9163 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309164 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9165 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309166 }
9167 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9168 WMITLV_SET_HDR(&cmd->tlv_header,
9169 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9170 WMITLV_GET_STRUCT_TLVLEN
9171 (wmi_tdls_set_state_cmd_fixed_param));
9172 cmd->vdev_id = wmi_tdls->vdev_id;
9173 cmd->state = tdls_state;
9174 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9175 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9176 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9177 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9178 cmd->rssi_delta = wmi_tdls->rssi_delta;
9179 cmd->tdls_options = wmi_tdls->tdls_options;
9180 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9181 cmd->tdls_peer_traffic_response_timeout_ms =
9182 wmi_tdls->peer_traffic_response_timeout;
9183 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9184 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9185 cmd->tdls_puapsd_rx_frame_threshold =
9186 wmi_tdls->puapsd_rx_frame_threshold;
9187 cmd->teardown_notification_ms =
9188 wmi_tdls->teardown_notification_ms;
9189 cmd->tdls_peer_kickout_threshold =
9190 wmi_tdls->tdls_peer_kickout_threshold;
9191
Govind Singhb53420c2016-03-09 14:32:57 +05309192 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309193 "notification_interval_ms: %d, "
9194 "tx_discovery_threshold: %d, "
9195 "tx_teardown_threshold: %d, "
9196 "rssi_teardown_threshold: %d, "
9197 "rssi_delta: %d, "
9198 "tdls_options: 0x%x, "
9199 "tdls_peer_traffic_ind_window: %d, "
9200 "tdls_peer_traffic_response_timeout: %d, "
9201 "tdls_puapsd_mask: 0x%x, "
9202 "tdls_puapsd_inactivity_time: %d, "
9203 "tdls_puapsd_rx_frame_threshold: %d, "
9204 "teardown_notification_ms: %d, "
9205 "tdls_peer_kickout_threshold: %d",
9206 __func__, tdls_state, cmd->state,
9207 cmd->notification_interval_ms,
9208 cmd->tx_discovery_threshold,
9209 cmd->tx_teardown_threshold,
9210 cmd->rssi_teardown_threshold,
9211 cmd->rssi_delta,
9212 cmd->tdls_options,
9213 cmd->tdls_peer_traffic_ind_window,
9214 cmd->tdls_peer_traffic_response_timeout_ms,
9215 cmd->tdls_puapsd_mask,
9216 cmd->tdls_puapsd_inactivity_time_ms,
9217 cmd->tdls_puapsd_rx_frame_threshold,
9218 cmd->teardown_notification_ms,
9219 cmd->tdls_peer_kickout_threshold);
9220
9221 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9222 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309223 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309224 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309225 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309226 }
Govind Singhb53420c2016-03-09 14:32:57 +05309227 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309228
Govind Singhb53420c2016-03-09 14:32:57 +05309229 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309230}
9231
9232/**
9233 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9234 * @wmi_handle: wmi handle
9235 * @peerStateParams: TDLS peer state params
9236 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309237 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309238 */
Govind Singhb53420c2016-03-09 14:32:57 +05309239QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309240 struct tdls_peer_state_params *peerStateParams,
9241 uint32_t *ch_mhz)
9242{
9243 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9244 wmi_tdls_peer_capabilities *peer_cap;
9245 wmi_channel *chan_info;
9246 wmi_buf_t wmi_buf;
9247 uint8_t *buf_ptr;
9248 uint32_t i;
9249 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9250 sizeof(wmi_tdls_peer_capabilities);
9251
9252
9253 len += WMI_TLV_HDR_SIZE +
9254 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9255
9256 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9257 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309258 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9259 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309260 }
9261
9262 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9263 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9264 WMITLV_SET_HDR(&cmd->tlv_header,
9265 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9266 WMITLV_GET_STRUCT_TLVLEN
9267 (wmi_tdls_peer_update_cmd_fixed_param));
9268
9269 cmd->vdev_id = peerStateParams->vdevId;
9270 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9271 &cmd->peer_macaddr);
9272
9273
9274 cmd->peer_state = peerStateParams->peerState;
9275
Govind Singhb53420c2016-03-09 14:32:57 +05309276 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309277 "peer_macaddr.mac_addr31to0: 0x%x, "
9278 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9279 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9280 cmd->peer_macaddr.mac_addr31to0,
9281 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9282
9283 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9284 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9285 WMITLV_SET_HDR(&peer_cap->tlv_header,
9286 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9287 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9288
9289 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9290 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9291 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9292 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9293 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9294 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9295 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9296 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9297
9298 /* Ack and More Data Ack are sent as 0, so no need to set
9299 * but fill SP
9300 */
9301 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9302 peerStateParams->peerCap.peerMaxSp);
9303
9304 peer_cap->buff_sta_support =
9305 peerStateParams->peerCap.peerBuffStaSupport;
9306 peer_cap->off_chan_support =
9307 peerStateParams->peerCap.peerOffChanSupport;
9308 peer_cap->peer_curr_operclass =
9309 peerStateParams->peerCap.peerCurrOperClass;
9310 /* self curr operclass is not being used and so pass op class for
9311 * preferred off chan in it.
9312 */
9313 peer_cap->self_curr_operclass =
9314 peerStateParams->peerCap.opClassForPrefOffChan;
9315 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9316 peer_cap->peer_operclass_len =
9317 peerStateParams->peerCap.peerOperClassLen;
9318
Govind Singhb53420c2016-03-09 14:32:57 +05309319 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309320 __func__, peer_cap->peer_operclass_len);
9321 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9322 peer_cap->peer_operclass[i] =
9323 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309324 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309325 __func__, i, peer_cap->peer_operclass[i]);
9326 }
9327
9328 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9329 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9330 peer_cap->pref_offchan_bw =
9331 peerStateParams->peerCap.prefOffChanBandwidth;
9332
Govind Singhb53420c2016-03-09 14:32:57 +05309333 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309334 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9335 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9336 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9337 " %d, pref_offchan_bw: %d",
9338 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9339 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9340 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9341 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9342 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9343
9344 /* next fill variable size array of peer chan info */
9345 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9346 WMITLV_SET_HDR(buf_ptr,
9347 WMITLV_TAG_ARRAY_STRUC,
9348 sizeof(wmi_channel) *
9349 peerStateParams->peerCap.peerChanLen);
9350 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9351
9352 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9353 WMITLV_SET_HDR(&chan_info->tlv_header,
9354 WMITLV_TAG_STRUC_wmi_channel,
9355 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9356 chan_info->mhz = ch_mhz[i];
9357 chan_info->band_center_freq1 = chan_info->mhz;
9358 chan_info->band_center_freq2 = 0;
9359
Govind Singhb53420c2016-03-09 14:32:57 +05309360 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309361
9362 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9363 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309364 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309365 peerStateParams->peerCap.peerChan[i].chanId,
9366 peerStateParams->peerCap.peerChan[i].dfsSet);
9367 }
9368
9369 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9370 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9371 else
9372 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9373
9374 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9375 peerStateParams->peerCap.
9376 peerChan[i].pwr);
9377
9378 WMI_SET_CHANNEL_REG_POWER(chan_info,
9379 peerStateParams->peerCap.peerChan[i].
9380 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309381 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309382 peerStateParams->peerCap.peerChan[i].pwr);
9383
9384 chan_info++;
9385 }
9386
9387 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9388 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309389 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309390 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309391 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309392 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309393 }
9394
9395
Govind Singhb53420c2016-03-09 14:32:57 +05309396 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309397}
9398
9399/*
9400 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9401 * firmware
9402 * @wmi_handle: Pointer to wmi handle
9403 * @mem_dump_req: Pointer for mem_dump_req
9404 *
9405 * This function sends memory dump request to firmware
9406 *
Govind Singhb53420c2016-03-09 14:32:57 +05309407 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309408 *
9409 */
Govind Singhb53420c2016-03-09 14:32:57 +05309410QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309411 struct fw_dump_req_param *mem_dump_req)
9412{
9413 wmi_get_fw_mem_dump_fixed_param *cmd;
9414 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309415 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309416 int32_t len;
9417 wmi_buf_t buf;
9418 u_int8_t *buf_ptr;
9419 int ret, loop;
9420
9421 /*
9422 * len = sizeof(fixed param) that includes tlv header +
9423 * tlv header for array of struc +
9424 * sizeof (each struct)
9425 */
9426 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9427 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9428 buf = wmi_buf_alloc(wmi_handle, len);
9429
9430 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309431 WMI_LOGE(FL("Failed allocate wmi buffer"));
9432 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309433 }
9434
9435 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309436 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309437 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9438
9439 WMITLV_SET_HDR(&cmd->tlv_header,
9440 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9441 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9442
9443 cmd->request_id = mem_dump_req->request_id;
9444 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9445
9446 /* TLV indicating array of structures to follow */
9447 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9448 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9449 sizeof(wmi_fw_mem_dump) *
9450 cmd->num_fw_mem_dump_segs);
9451
9452 buf_ptr += WMI_TLV_HDR_SIZE;
9453 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9454
Govind Singhb53420c2016-03-09 14:32:57 +05309455 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309456 mem_dump_req->request_id, mem_dump_req->num_seg);
9457 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309458 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309459 ((uint8_t *)(mem_dump_req->segment) +
9460 loop * sizeof(*seg_req));
9461 WMITLV_SET_HDR(&dump_params->tlv_header,
9462 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9463 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9464 dump_params->seg_id = seg_req->seg_id;
9465 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9466 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9467 dump_params->seg_length = seg_req->seg_length;
9468 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9469 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309470 WMI_LOGI(FL("seg_number:%d"), loop);
9471 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309472 dump_params->seg_id, dump_params->seg_start_addr_lo,
9473 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309474 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309475 dump_params->seg_length, dump_params->dest_addr_lo,
9476 dump_params->dest_addr_hi);
9477 dump_params++;
9478 }
9479
9480 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9481 WMI_GET_FW_MEM_DUMP_CMDID);
9482 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309483 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309484 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309485 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309486 }
9487
Govind Singhb53420c2016-03-09 14:32:57 +05309488 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9489 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309490}
9491
9492/*
9493 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9494 * @wmi_handle: Pointer to WMi handle
9495 * @ie_data: Pointer for ie data
9496 *
9497 * This function sends IE information to firmware
9498 *
Govind Singhb53420c2016-03-09 14:32:57 +05309499 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309500 *
9501 */
Govind Singhb53420c2016-03-09 14:32:57 +05309502QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309503 struct vdev_ie_info_param *ie_info)
9504{
9505 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9506 wmi_buf_t buf;
9507 uint8_t *buf_ptr;
9508 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309509 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309510
9511
9512 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9513 /* Allocate memory for the WMI command */
9514 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9515
9516 buf = wmi_buf_alloc(wmi_handle, len);
9517 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309518 WMI_LOGE(FL("wmi_buf_alloc failed"));
9519 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309520 }
9521
9522 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309523 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309524
9525 /* Populate the WMI command */
9526 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9527
9528 WMITLV_SET_HDR(&cmd->tlv_header,
9529 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9530 WMITLV_GET_STRUCT_TLVLEN(
9531 wmi_vdev_set_ie_cmd_fixed_param));
9532 cmd->vdev_id = ie_info->vdev_id;
9533 cmd->ie_id = ie_info->ie_id;
9534 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009535 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309536
Govind Singhb53420c2016-03-09 14:32:57 +05309537 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309538 ie_info->length, ie_info->vdev_id);
9539
9540 buf_ptr += sizeof(*cmd);
9541 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9542 buf_ptr += WMI_TLV_HDR_SIZE;
9543
Govind Singhb53420c2016-03-09 14:32:57 +05309544 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309545
9546 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9547 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309548 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309549 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309550 wmi_buf_free(buf);
9551 }
9552
9553 return ret;
9554}
9555
Govind Singh9ddd5162016-03-07 16:30:32 +05309556
9557void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05309558 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05309559{
Govind Singhe7f2f342016-05-23 12:12:52 +05309560 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05309561 resource_cfg->num_peers = tgt_res_cfg->num_peers;
9562 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
9563 resource_cfg->num_offload_reorder_buffs =
9564 tgt_res_cfg->num_offload_reorder_buffs;
9565 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
9566 resource_cfg->num_tids = tgt_res_cfg->num_tids;
9567 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
9568 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
9569 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
9570 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
9571 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
9572 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
9573 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
9574 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
9575 resource_cfg->scan_max_pending_req =
9576 tgt_res_cfg->scan_max_pending_req;
9577 resource_cfg->bmiss_offload_max_vdev =
9578 tgt_res_cfg->bmiss_offload_max_vdev;
9579 resource_cfg->roam_offload_max_vdev =
9580 tgt_res_cfg->roam_offload_max_vdev;
9581 resource_cfg->roam_offload_max_ap_profiles =
9582 tgt_res_cfg->roam_offload_max_ap_profiles;
9583 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
9584 resource_cfg->num_mcast_table_elems =
9585 tgt_res_cfg->num_mcast_table_elems;
9586 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
9587 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
9588 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
9589 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
9590 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
9591 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
9592 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
9593 resource_cfg->vow_config = tgt_res_cfg->vow_config;
9594 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
9595 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
9596 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
9597 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
9598 resource_cfg->num_tdls_conn_table_entries =
9599 tgt_res_cfg->num_tdls_conn_table_entries;
9600 resource_cfg->beacon_tx_offload_max_vdev =
9601 tgt_res_cfg->beacon_tx_offload_max_vdev;
9602 resource_cfg->num_multicast_filter_entries =
9603 tgt_res_cfg->num_multicast_filter_entries;
9604 resource_cfg->num_wow_filters =
9605 tgt_res_cfg->num_wow_filters;
9606 resource_cfg->num_keep_alive_pattern =
9607 tgt_res_cfg->num_keep_alive_pattern;
9608 resource_cfg->keep_alive_pattern_size =
9609 tgt_res_cfg->keep_alive_pattern_size;
9610 resource_cfg->max_tdls_concurrent_sleep_sta =
9611 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
9612 resource_cfg->max_tdls_concurrent_buffer_sta =
9613 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
9614 resource_cfg->wmi_send_separate =
9615 tgt_res_cfg->wmi_send_separate;
9616 resource_cfg->num_ocb_vdevs =
9617 tgt_res_cfg->num_ocb_vdevs;
9618 resource_cfg->num_ocb_channels =
9619 tgt_res_cfg->num_ocb_channels;
9620 resource_cfg->num_ocb_schedules =
9621 tgt_res_cfg->num_ocb_schedules;
9622
9623}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309624#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309625/**
9626 * send_init_cmd_tlv() - wmi init command
9627 * @wmi_handle: pointer to wmi handle
9628 * @res_cfg: resource config
9629 * @num_mem_chunks: no of mem chunck
9630 * @mem_chunk: pointer to mem chunck structure
9631 *
9632 * This function sends IE information to firmware
9633 *
Govind Singhb53420c2016-03-09 14:32:57 +05309634 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309635 *
9636 */
Govind Singhb53420c2016-03-09 14:32:57 +05309637QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309638 wmi_resource_config *tgt_res_cfg,
9639 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
9640 bool action)
9641{
9642 wmi_buf_t buf;
9643 wmi_init_cmd_fixed_param *cmd;
9644 wmi_abi_version my_vers;
9645 int num_whitelist;
9646 uint8_t *buf_ptr;
9647 wmi_resource_config *resource_cfg;
9648 wlan_host_memory_chunk *host_mem_chunks;
9649 uint32_t mem_chunk_len = 0;
9650 uint16_t idx;
9651 int len;
9652 int ret;
9653
9654 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
9655 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
9656 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
9657 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309658 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
9659 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309660 }
9661
9662 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9663 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
9664 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
9665
9666 host_mem_chunks = (wlan_host_memory_chunk *)
9667 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
9668 + WMI_TLV_HDR_SIZE);
9669
9670 WMITLV_SET_HDR(&cmd->tlv_header,
9671 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
9672 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
9673
Govind Singhb53420c2016-03-09 14:32:57 +05309674 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +05309675 WMITLV_SET_HDR(&resource_cfg->tlv_header,
9676 WMITLV_TAG_STRUC_wmi_resource_config,
9677 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
9678
9679 for (idx = 0; idx < num_mem_chunks; ++idx) {
9680 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
9681 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
9682 WMITLV_GET_STRUCT_TLVLEN
9683 (wlan_host_memory_chunk));
9684 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
9685 host_mem_chunks[idx].size = mem_chunks[idx].len;
9686 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309687 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +05309688 idx, host_mem_chunks[idx].size,
9689 host_mem_chunks[idx].ptr);
9690 }
9691 cmd->num_host_mem_chunks = num_mem_chunks;
9692 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
9693 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
9694 WMITLV_TAG_ARRAY_STRUC,
9695 (sizeof(wlan_host_memory_chunk) *
9696 num_mem_chunks));
9697
9698 num_whitelist = sizeof(version_whitelist) /
9699 sizeof(wmi_whitelist_version_info);
9700 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
9701 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
9702 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
9703 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
9704 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
9705 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +05309706#ifdef CONFIG_MCL
9707 /* This needs to be enabled for WIN Lithium after removing dependency
9708 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +05309709 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
9710 &my_vers,
9711 &wmi_handle->fw_abi_version,
9712 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +05309713#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309714 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05309715 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
9716 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
9717 cmd->host_abi_vers.abi_version_ns_0,
9718 cmd->host_abi_vers.abi_version_ns_1,
9719 cmd->host_abi_vers.abi_version_ns_2,
9720 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +05309721#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309722 /* Save version sent from host -
9723 * Will be used to check ready event
9724 */
Govind Singhb53420c2016-03-09 14:32:57 +05309725 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309726 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309727#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309728 if (action) {
9729 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9730 WMI_INIT_CMDID);
9731 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309732 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +05309733 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309734 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309735 }
9736 } else {
9737 wmi_handle->saved_wmi_init_cmd.buf = buf;
9738 wmi_handle->saved_wmi_init_cmd.buf_len = len;
9739 }
9740
Govind Singhb53420c2016-03-09 14:32:57 +05309741 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309742
9743}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309744#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309745/**
9746 * send_saved_init_cmd_tlv() - wmi init command
9747 * @wmi_handle: pointer to wmi handle
9748 *
9749 * This function sends IE information to firmware
9750 *
Govind Singhb53420c2016-03-09 14:32:57 +05309751 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309752 *
9753 */
Govind Singhb53420c2016-03-09 14:32:57 +05309754QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +05309755{
9756 int status;
9757
9758 if (!wmi_handle->saved_wmi_init_cmd.buf ||
9759 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05309760 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
9761 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309762 }
9763 status = wmi_unified_cmd_send(wmi_handle,
9764 wmi_handle->saved_wmi_init_cmd.buf,
9765 wmi_handle->saved_wmi_init_cmd.buf_len,
9766 WMI_INIT_CMDID);
9767 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +05309768 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +05309769 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309770 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309771 }
9772 wmi_handle->saved_wmi_init_cmd.buf = NULL;
9773 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
9774
Govind Singhb53420c2016-03-09 14:32:57 +05309775 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309776}
9777
Govind Singhb53420c2016-03-09 14:32:57 +05309778QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05309779{
9780 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
9781 wmi_service_ready_event_fixed_param *ev;
9782
9783
9784 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
9785
9786 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
9787 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05309788 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309789
Govind Singh87542482016-06-08 19:40:11 +05309790#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309791 /*Save fw version from service ready message */
9792 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05309793 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309794 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309795#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309796 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309797}
9798
9799/**
9800 * wmi_unified_save_fw_version_cmd() - save fw version
9801 * @wmi_handle: pointer to wmi handle
9802 * @res_cfg: resource config
9803 * @num_mem_chunks: no of mem chunck
9804 * @mem_chunk: pointer to mem chunck structure
9805 *
9806 * This function sends IE information to firmware
9807 *
Govind Singhb53420c2016-03-09 14:32:57 +05309808 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309809 *
9810 */
Govind Singhb53420c2016-03-09 14:32:57 +05309811QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309812 void *evt_buf)
9813{
9814 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
9815 wmi_ready_event_fixed_param *ev = NULL;
9816
9817 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
9818 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +05309819#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309820 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
9821 &ev->fw_abi_vers)) {
9822 /*
9823 * Error: Our host version and the given firmware version
9824 * are incompatible.
9825 **/
Govind Singhb53420c2016-03-09 14:32:57 +05309826 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +05309827 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
9828 __func__,
9829 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
9830 abi_version_0),
9831 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
9832 abi_version_0),
9833 wmi_handle->final_abi_vers.abi_version_ns_0,
9834 wmi_handle->final_abi_vers.abi_version_ns_1,
9835 wmi_handle->final_abi_vers.abi_version_ns_2,
9836 wmi_handle->final_abi_vers.abi_version_ns_3,
9837 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
9838 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
9839 ev->fw_abi_vers.abi_version_ns_0,
9840 ev->fw_abi_vers.abi_version_ns_1,
9841 ev->fw_abi_vers.abi_version_ns_2,
9842 ev->fw_abi_vers.abi_version_ns_3);
9843
Govind Singhb53420c2016-03-09 14:32:57 +05309844 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309845 }
Govind Singhb53420c2016-03-09 14:32:57 +05309846 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309847 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +05309848 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309849 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309850#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309851
Govind Singhb53420c2016-03-09 14:32:57 +05309852 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309853}
Govind Singha4836fd2016-03-07 16:45:38 +05309854
9855/**
9856 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
9857 * @wmi_handle: wmi handle
9858 * @custom_addr: base mac address
9859 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309860 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +05309861 */
Govind Singhb53420c2016-03-09 14:32:57 +05309862QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309863 uint8_t *custom_addr)
9864{
9865 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
9866 wmi_buf_t buf;
9867 int err;
9868
9869 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9870 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309871 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309872 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309873 }
9874
9875 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309876 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +05309877
9878 WMITLV_SET_HDR(&cmd->tlv_header,
9879 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
9880 WMITLV_GET_STRUCT_TLVLEN
9881 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
9882 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -07009883 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +05309884 err = wmi_unified_cmd_send(wmi_handle, buf,
9885 sizeof(*cmd),
9886 WMI_PDEV_SET_BASE_MACADDR_CMDID);
9887 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05309888 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05309889 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309890 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309891 }
9892
9893 return 0;
9894}
9895
9896/**
9897 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
9898 * @handle: wmi handle
9899 * @event: Event received from FW
9900 * @len: Length of the event
9901 *
9902 * Enables the low frequency events and disables the high frequency
9903 * events. Bit 17 indicates if the event if low/high frequency.
9904 * 1 - high frequency, 0 - low frequency
9905 *
9906 * Return: 0 on successfully enabling/disabling the events
9907 */
Govind Singhb53420c2016-03-09 14:32:57 +05309908QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309909 uint8_t *event,
9910 uint32_t len)
9911{
9912 uint32_t num_of_diag_events_logs;
9913 wmi_diag_event_log_config_fixed_param *cmd;
9914 wmi_buf_t buf;
9915 uint8_t *buf_ptr;
9916 uint32_t *cmd_args, *evt_args;
9917 uint32_t buf_len, i;
9918
9919 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
9920 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
9921
Govind Singhb53420c2016-03-09 14:32:57 +05309922 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +05309923
9924 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
9925 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309926 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +05309927 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309928 }
9929 wmi_event = param_buf->fixed_param;
9930 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
9931 evt_args = param_buf->diag_events_logs_list;
9932 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +05309933 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309934 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +05309935 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309936 }
9937
Govind Singhb53420c2016-03-09 14:32:57 +05309938 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309939 __func__, num_of_diag_events_logs);
9940
9941 /* Free any previous allocation */
9942 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +05309943 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309944
9945 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +05309946 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +05309947 sizeof(uint32_t));
9948 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +05309949 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +05309950 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309951 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309952 }
9953 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
9954
9955 /* Prepare the send buffer */
9956 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
9957 (num_of_diag_events_logs * sizeof(uint32_t));
9958
9959 buf = wmi_buf_alloc(wmi_handle, buf_len);
9960 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309961 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9962 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309963 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05309964 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309965 }
9966
9967 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
9968 buf_ptr = (uint8_t *) cmd;
9969
9970 WMITLV_SET_HDR(&cmd->tlv_header,
9971 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
9972 WMITLV_GET_STRUCT_TLVLEN(
9973 wmi_diag_event_log_config_fixed_param));
9974
9975 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
9976
9977 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
9978
9979 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9980 (num_of_diag_events_logs * sizeof(uint32_t)));
9981
9982 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
9983
9984 /* Populate the events */
9985 for (i = 0; i < num_of_diag_events_logs; i++) {
9986 /* Low freq (0) - Enable (1) the event
9987 * High freq (1) - Disable (0) the event
9988 */
9989 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
9990 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
9991 /* Set the event ID */
9992 WMI_DIAG_ID_SET(cmd_args[i],
9993 WMI_DIAG_ID_GET(evt_args[i]));
9994 /* Set the type */
9995 WMI_DIAG_TYPE_SET(cmd_args[i],
9996 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +05309997 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +05309998 wmi_handle->events_logs_list[i] = evt_args[i];
9999 }
10000
10001 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
10002 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010003 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010004 __func__);
10005 wmi_buf_free(buf);
10006 /* Not clearing events_logs_list, though wmi cmd failed.
10007 * Host can still have this list
10008 */
Govind Singh67922e82016-04-01 16:48:57 +053010009 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010010 }
10011
10012 return 0;
10013}
10014
10015/**
10016 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
10017 * @wmi_handle: wmi handle
10018 * @start_log: Start logging related parameters
10019 *
10020 * Send the command to the FW based on which specific logging of diag
10021 * event/log id can be started/stopped
10022 *
10023 * Return: None
10024 */
Govind Singhb53420c2016-03-09 14:32:57 +053010025QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010026 struct wmi_wifi_start_log *start_log)
10027{
10028 wmi_diag_event_log_config_fixed_param *cmd;
10029 wmi_buf_t buf;
10030 uint8_t *buf_ptr;
10031 uint32_t len, count, log_level, i;
10032 uint32_t *cmd_args;
10033 uint32_t total_len;
10034 count = 0;
10035
10036 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010037 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053010038 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010039 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010040 }
10041 /* total_len stores the number of events where BITS 17 and 18 are set.
10042 * i.e., events of high frequency (17) and for extended debugging (18)
10043 */
10044 total_len = 0;
10045 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10046 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
10047 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
10048 total_len++;
10049 }
10050
10051 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10052 (total_len * sizeof(uint32_t));
10053
10054 buf = wmi_buf_alloc(wmi_handle, len);
10055 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010056 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010057 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010058 }
10059 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10060 buf_ptr = (uint8_t *) cmd;
10061
10062 WMITLV_SET_HDR(&cmd->tlv_header,
10063 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10064 WMITLV_GET_STRUCT_TLVLEN(
10065 wmi_diag_event_log_config_fixed_param));
10066
10067 cmd->num_of_diag_events_logs = total_len;
10068
10069 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10070
10071 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10072 (total_len * sizeof(uint32_t)));
10073
10074 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10075
Govind Singh224a7312016-06-21 14:33:26 +053010076 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053010077 log_level = 1;
10078 else
10079 log_level = 0;
10080
Govind Singhb53420c2016-03-09 14:32:57 +053010081 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053010082 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10083 uint32_t val = wmi_handle->events_logs_list[i];
10084 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
10085 (WMI_DIAG_EXT_FEATURE_GET(val))) {
10086
10087 WMI_DIAG_ID_SET(cmd_args[count],
10088 WMI_DIAG_ID_GET(val));
10089 WMI_DIAG_TYPE_SET(cmd_args[count],
10090 WMI_DIAG_TYPE_GET(val));
10091 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
10092 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053010093 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053010094 count++;
10095 }
10096 }
10097
10098 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10099 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010100 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010101 __func__);
10102 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010103 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010104 }
10105
Govind Singhb53420c2016-03-09 14:32:57 +053010106 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010107}
10108
10109/**
10110 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
10111 * @wmi_handle: WMI handle
10112 *
10113 * This function is used to send the flush command to the FW,
10114 * that will flush the fw logs that are residue in the FW
10115 *
10116 * Return: None
10117 */
Govind Singhb53420c2016-03-09 14:32:57 +053010118QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053010119{
10120 wmi_debug_mesg_flush_fixed_param *cmd;
10121 wmi_buf_t buf;
10122 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053010123 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010124
10125 buf = wmi_buf_alloc(wmi_handle, len);
10126 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010127 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010128 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010129 }
10130
10131 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
10132 WMITLV_SET_HDR(&cmd->tlv_header,
10133 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
10134 WMITLV_GET_STRUCT_TLVLEN(
10135 wmi_debug_mesg_flush_fixed_param));
10136 cmd->reserved0 = 0;
10137
10138 ret = wmi_unified_cmd_send(wmi_handle,
10139 buf,
10140 len,
10141 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010142 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010143 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053010144 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010145 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010146 }
Govind Singhb53420c2016-03-09 14:32:57 +053010147 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053010148
Govind Singh67922e82016-04-01 16:48:57 +053010149 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010150}
10151
10152/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010153 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010154 * @wmi_handle: wmi handle
10155 * @msg: PCL structure containing the PCL and the number of channels
10156 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010157 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053010158 * firmware. The DBS Manager is the consumer of this information in the WLAN
10159 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
10160 * to migrate to a new channel without host driver involvement. An example of
10161 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
10162 * manage the channel selection without firmware involvement.
10163 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010164 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
10165 * channel list. The weights corresponds to the channels sent in
10166 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
10167 * weightage compared to the non PCL channels.
10168 *
Govind Singha4836fd2016-03-07 16:45:38 +053010169 * Return: Success if the cmd is sent successfully to the firmware
10170 */
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010171QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
10172 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053010173{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010174 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010175 wmi_buf_t buf;
10176 uint8_t *buf_ptr;
10177 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010178 uint32_t chan_len;
10179
10180 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053010181
10182 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010183 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053010184
10185 buf = wmi_buf_alloc(wmi_handle, len);
10186 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010187 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10188 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010189 }
10190
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010191 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010192 buf_ptr = (uint8_t *) cmd;
10193 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010194 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
10195 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053010196
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010197 cmd->pdev_id = WMI_PDEV_ID_SOC;
10198 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053010199 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010200
10201 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053010202 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010203 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053010204 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010205 for (i = 0; i < chan_len ; i++) {
10206 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053010207 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010208 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010209 }
10210 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010211 WMI_PDEV_SET_PCL_CMDID)) {
10212 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010213 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010214 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010215 }
Govind Singhb53420c2016-03-09 14:32:57 +053010216 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010217}
10218
10219/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010220 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010221 * @wmi_handle: wmi handle
10222 * @msg: Structure containing the following parameters
10223 *
10224 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
10225 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
10226 *
10227 * Provides notification to the WLAN firmware that host driver is requesting a
10228 * HardWare (HW) Mode change. This command is needed to support iHelium in the
10229 * configurations that include the Dual Band Simultaneous (DBS) feature.
10230 *
10231 * Return: Success if the cmd is sent successfully to the firmware
10232 */
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010233QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010234 uint32_t hw_mode_index)
10235{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010236 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010237 wmi_buf_t buf;
10238 uint32_t len;
10239
10240 len = sizeof(*cmd);
10241
10242 buf = wmi_buf_alloc(wmi_handle, len);
10243 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010244 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10245 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010246 }
10247
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010248 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010249 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010250 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
10251 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
10252
10253 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010254 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053010255 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053010256
10257 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010258 WMI_PDEV_SET_HW_MODE_CMDID)) {
10259 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010260 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010261 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010262 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010263 }
10264
Govind Singhb53420c2016-03-09 14:32:57 +053010265 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010266}
10267
10268/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010269 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010270 * @wmi_handle: wmi handle
10271 * @msg: Dual MAC config parameters
10272 *
10273 * Configures WLAN firmware with the dual MAC features
10274 *
Govind Singhb53420c2016-03-09 14:32:57 +053010275 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053010276 */
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010277QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010278 struct wmi_dual_mac_config *msg)
10279{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010280 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010281 wmi_buf_t buf;
10282 uint32_t len;
10283
10284 len = sizeof(*cmd);
10285
10286 buf = wmi_buf_alloc(wmi_handle, len);
10287 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010288 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10289 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010290 }
10291
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010292 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010293 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010294 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053010295 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010296 wmi_pdev_set_mac_config_cmd_fixed_param));
10297
10298 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010299 cmd->concurrent_scan_config_bits = msg->scan_config;
10300 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053010301 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053010302 __func__, msg->scan_config, msg->fw_mode_config);
10303
10304 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010305 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
10306 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010307 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010308 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010309 }
Govind Singhb53420c2016-03-09 14:32:57 +053010310 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010311}
10312
10313/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010314 * fill_arp_offload_params_tlv() - Fill ARP offload data
10315 * @wmi_handle: wmi handle
10316 * @offload_req: offload request
10317 * @buf_ptr: buffer pointer
10318 *
10319 * To fill ARP offload data to firmware
10320 * when target goes to wow mode.
10321 *
10322 * Return: None
10323 */
10324static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
10325 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10326{
10327
10328 int i;
10329 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
10330 bool enable_or_disable = offload_req->enableOrDisable;
10331
10332 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10333 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
10334 *buf_ptr += WMI_TLV_HDR_SIZE;
10335 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
10336 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
10337 WMITLV_SET_HDR(&arp_tuple->tlv_header,
10338 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
10339 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
10340
10341 /* Fill data for ARP and NS in the first tupple for LA */
10342 if ((enable_or_disable & WMI_OFFLOAD_ENABLE) && (i == 0)) {
10343 /* Copy the target ip addr and flags */
10344 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
10345 qdf_mem_copy(&arp_tuple->target_ipaddr,
10346 offload_req->params.hostIpv4Addr,
10347 WMI_IPV4_ADDR_LEN);
10348 WMI_LOGD("ARPOffload IP4 address: %pI4",
10349 offload_req->params.hostIpv4Addr);
10350 }
10351 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
10352 }
10353}
10354
10355#ifdef WLAN_NS_OFFLOAD
10356/**
10357 * fill_ns_offload_params_tlv() - Fill NS offload data
10358 * @wmi|_handle: wmi handle
10359 * @offload_req: offload request
10360 * @buf_ptr: buffer pointer
10361 *
10362 * To fill NS offload data to firmware
10363 * when target goes to wow mode.
10364 *
10365 * Return: None
10366 */
10367static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10368 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10369{
10370
10371 int i;
10372 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10373 struct ns_offload_req_params ns_req;
10374
10375 ns_req = offload_req->nsOffloadInfo;
10376 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10377 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10378 *buf_ptr += WMI_TLV_HDR_SIZE;
10379 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
10380 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10381 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10382 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10383 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
10384
10385 /*
10386 * Fill data only for NS offload in the first ARP tuple for LA
10387 */
10388 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10389 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10390 /* Copy the target/solicitation/remote ip addr */
10391 if (ns_req.targetIPv6AddrValid[i])
10392 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10393 &ns_req.targetIPv6Addr[i],
10394 sizeof(WMI_IPV6_ADDR));
10395 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10396 &ns_req.selfIPv6Addr[i],
10397 sizeof(WMI_IPV6_ADDR));
10398 if (ns_req.target_ipv6_addr_ac_type[i]) {
10399 ns_tuple->flags |=
10400 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10401 }
10402 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10403 i, &ns_req.selfIPv6Addr[i],
10404 &ns_req.targetIPv6Addr[i]);
10405
10406 /* target MAC is optional, check if it is valid,
10407 * if this is not valid, the target will use the known
10408 * local MAC address rather than the tuple
10409 */
10410 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10411 ns_req.self_macaddr.bytes,
10412 &ns_tuple->target_mac);
10413 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10414 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10415 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10416 }
10417 }
10418 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10419 }
10420}
10421
10422
10423/**
10424 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
10425 * @wmi: wmi handle
10426 * @offload_req: offload request
10427 * @buf_ptr: buffer pointer
10428 *
10429 * To fill extended NS offload extended data to firmware
10430 * when target goes to wow mode.
10431 *
10432 * Return: None
10433 */
10434static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10435 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10436{
10437 int i;
10438 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10439 uint32_t count, num_ns_ext_tuples;
10440 struct ns_offload_req_params ns_req;
10441
10442 ns_req = offload_req->nsOffloadInfo;
10443 count = offload_req->num_ns_offload_count;
10444 num_ns_ext_tuples = offload_req->num_ns_offload_count -
10445 WMI_MAX_NS_OFFLOADS;
10446
10447 /* Populate extended NS offload tuples */
10448 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10449 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10450 *buf_ptr += WMI_TLV_HDR_SIZE;
10451 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
10452 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10453 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10454 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10455 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
10456
10457 /*
10458 * Fill data only for NS offload in the first ARP tuple for LA
10459 */
10460 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10461 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10462 /* Copy the target/solicitation/remote ip addr */
10463 if (ns_req.targetIPv6AddrValid[i])
10464 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10465 &ns_req.targetIPv6Addr[i],
10466 sizeof(WMI_IPV6_ADDR));
10467 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10468 &ns_req.selfIPv6Addr[i],
10469 sizeof(WMI_IPV6_ADDR));
10470 if (ns_req.target_ipv6_addr_ac_type[i]) {
10471 ns_tuple->flags |=
10472 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10473 }
10474 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10475 i, &ns_req.selfIPv6Addr[i],
10476 &ns_req.targetIPv6Addr[i]);
10477
10478 /* target MAC is optional, check if it is valid,
10479 * if this is not valid, the target will use the
10480 * known local MAC address rather than the tuple
10481 */
10482 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10483 ns_req.self_macaddr.bytes,
10484 &ns_tuple->target_mac);
10485 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10486 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10487 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10488 }
10489 }
10490 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10491 }
10492}
10493#else
10494static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10495 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10496{
10497 return;
10498}
10499
10500static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10501 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10502{
10503 return;
10504}
10505#endif
10506
10507/**
Govind Singha4836fd2016-03-07 16:45:38 +053010508 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
10509 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010510 * @arp_offload_req: arp offload request
10511 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053010512 * @arp_only: flag
10513 *
10514 * To configure ARP NS off load data to firmware
10515 * when target goes to wow mode.
10516 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010517 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053010518 */
Govind Singhb53420c2016-03-09 14:32:57 +053010519QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010520 struct host_offload_req_param *arp_offload_req,
10521 struct host_offload_req_param *ns_offload_req,
10522 bool arp_only,
Govind Singha4836fd2016-03-07 16:45:38 +053010523 uint8_t vdev_id)
10524{
Govind Singha4836fd2016-03-07 16:45:38 +053010525 int32_t res;
10526 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010527 A_UINT8 *buf_ptr;
10528 wmi_buf_t buf;
10529 int32_t len;
10530 uint32_t count = 0, num_ns_ext_tuples = 0;
10531
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010532 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053010533
Govind Singha4836fd2016-03-07 16:45:38 +053010534 /*
10535 * TLV place holder size for array of NS tuples
10536 * TLV place holder size for array of ARP tuples
10537 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010538 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
10539 WMI_TLV_HDR_SIZE +
10540 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
10541 WMI_TLV_HDR_SIZE +
10542 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010543
10544 /*
10545 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
10546 * extra length for extended NS offload tuples which follows ARP offload
10547 * tuples. Host needs to fill this structure in following format:
10548 * 2 NS ofload tuples
10549 * 2 ARP offload tuples
10550 * N numbers of extended NS offload tuples if HDD has given more than
10551 * 2 NS offload addresses
10552 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010553 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053010554 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010555 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
10556 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010557 }
10558
10559 buf = wmi_buf_alloc(wmi_handle, len);
10560 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010561 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053010562 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010563 }
10564
10565 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
10566 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
10567 WMITLV_SET_HDR(&cmd->tlv_header,
10568 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
10569 WMITLV_GET_STRUCT_TLVLEN
10570 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
10571 cmd->flags = 0;
10572 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010573 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053010574
Govind Singhb53420c2016-03-09 14:32:57 +053010575 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053010576
Govind Singha4836fd2016-03-07 16:45:38 +053010577 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010578 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
10579 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
10580 if (num_ns_ext_tuples)
10581 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053010582
10583 res = wmi_unified_cmd_send(wmi_handle, buf, len,
10584 WMI_SET_ARP_NS_OFFLOAD_CMDID);
10585 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053010586 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053010587 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010588 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010589 }
10590
Govind Singhb53420c2016-03-09 14:32:57 +053010591 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010592}
10593
10594/**
10595 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
10596 * @wmi_handle: wmi handle
10597 * @request: SSID hotlist set request
10598 *
Govind Singhb53420c2016-03-09 14:32:57 +053010599 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053010600 */
Govind Singhb53420c2016-03-09 14:32:57 +053010601QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053010602send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
10603 struct ssid_hotlist_request_params *request)
10604{
10605 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
10606 wmi_buf_t wmi_buf;
10607 uint32_t len;
10608 uint32_t array_size;
10609 uint8_t *buf_ptr;
10610
10611 /* length of fixed portion */
10612 len = sizeof(*cmd);
10613
10614 /* length of variable portion */
10615 array_size =
10616 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
10617 len += WMI_TLV_HDR_SIZE + array_size;
10618
10619 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10620 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010621 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10622 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010623 }
10624
10625 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10626 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
10627 buf_ptr;
10628 WMITLV_SET_HDR
10629 (&cmd->tlv_header,
10630 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
10631 WMITLV_GET_STRUCT_TLVLEN
10632 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
10633
10634 cmd->request_id = request->request_id;
10635 cmd->requestor_id = 0;
10636 cmd->vdev_id = request->session_id;
10637 cmd->table_id = 0;
10638 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
10639 cmd->total_entries = request->ssid_count;
10640 cmd->num_entries_in_page = request->ssid_count;
10641 cmd->first_entry_index = 0;
10642
10643 buf_ptr += sizeof(*cmd);
10644 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
10645
10646 if (request->ssid_count) {
10647 wmi_extscan_hotlist_ssid_entry *entry;
10648 int i;
10649
10650 buf_ptr += WMI_TLV_HDR_SIZE;
10651 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
10652 for (i = 0; i < request->ssid_count; i++) {
10653 WMITLV_SET_HDR
10654 (entry,
10655 WMITLV_TAG_ARRAY_STRUC,
10656 WMITLV_GET_STRUCT_TLVLEN
10657 (wmi_extscan_hotlist_ssid_entry));
10658 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053010659 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053010660 request->ssids[i].ssid.mac_ssid,
10661 request->ssids[i].ssid.length);
10662 entry->band = request->ssids[i].band;
10663 entry->min_rssi = request->ssids[i].rssi_low;
10664 entry->max_rssi = request->ssids[i].rssi_high;
10665 entry++;
10666 }
10667 cmd->mode = WMI_EXTSCAN_MODE_START;
10668 } else {
10669 cmd->mode = WMI_EXTSCAN_MODE_STOP;
10670 }
10671
10672 if (wmi_unified_cmd_send
10673 (wmi_handle, wmi_buf, len,
10674 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010675 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053010676 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010677 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010678 }
10679
Govind Singhb53420c2016-03-09 14:32:57 +053010680 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010681}
10682
10683/**
10684 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
10685 * @wmi_handle: wmi handle
10686 * @vdev_id: vdev id
10687 *
10688 * This function sends roam synch complete event to fw.
10689 *
10690 * Return: CDF STATUS
10691 */
Govind Singhb53420c2016-03-09 14:32:57 +053010692QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010693 uint8_t vdev_id)
10694{
10695 wmi_roam_synch_complete_fixed_param *cmd;
10696 wmi_buf_t wmi_buf;
10697 uint8_t *buf_ptr;
10698 uint16_t len;
10699 len = sizeof(wmi_roam_synch_complete_fixed_param);
10700
10701 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10702 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010703 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10704 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010705 }
10706 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
10707 buf_ptr = (uint8_t *) cmd;
10708 WMITLV_SET_HDR(&cmd->tlv_header,
10709 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
10710 WMITLV_GET_STRUCT_TLVLEN
10711 (wmi_roam_synch_complete_fixed_param));
10712 cmd->vdev_id = vdev_id;
10713 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10714 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010715 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053010716 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010717 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010718 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010719 }
10720
Govind Singhb53420c2016-03-09 14:32:57 +053010721 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010722}
10723
10724/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053010725 * send_fw_test_cmd_tlv() - send fw test command to fw.
10726 * @wmi_handle: wmi handle
10727 * @wmi_fwtest: fw test command
10728 *
10729 * This function sends fw test command to fw.
10730 *
10731 * Return: CDF STATUS
10732 */
10733QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
10734 struct set_fwtest_params *wmi_fwtest)
10735{
10736 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10737 wmi_buf_t wmi_buf;
10738 uint16_t len;
10739
10740 len = sizeof(*cmd);
10741
10742 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10743 if (!wmi_buf) {
10744 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10745 return QDF_STATUS_E_NOMEM;
10746 }
10747
10748 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10749 WMITLV_SET_HDR(&cmd->tlv_header,
10750 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10751 WMITLV_GET_STRUCT_TLVLEN(
10752 wmi_fwtest_set_param_cmd_fixed_param));
10753 cmd->param_id = wmi_fwtest->arg;
10754 cmd->param_value = wmi_fwtest->value;
10755
10756 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10757 WMI_FWTEST_CMDID)) {
10758 WMI_LOGP("%s: failed to send fw test command", __func__);
10759 qdf_nbuf_free(wmi_buf);
10760 return QDF_STATUS_E_FAILURE;
10761 }
10762
10763 return QDF_STATUS_SUCCESS;
10764}
10765
10766/**
Govind Singha4836fd2016-03-07 16:45:38 +053010767 * send_unit_test_cmd_tlv() - send unit test command to fw.
10768 * @wmi_handle: wmi handle
10769 * @wmi_utest: unit test command
10770 *
10771 * This function send unit test command to fw.
10772 *
10773 * Return: CDF STATUS
10774 */
Govind Singhb53420c2016-03-09 14:32:57 +053010775QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010776 struct wmi_unit_test_cmd *wmi_utest)
10777{
10778 wmi_unit_test_cmd_fixed_param *cmd;
10779 wmi_buf_t wmi_buf;
10780 uint8_t *buf_ptr;
10781 int i;
10782 uint16_t len, args_tlv_len;
10783 A_UINT32 *unit_test_cmd_args;
10784
10785 args_tlv_len =
10786 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
10787 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
10788
10789 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10790 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010791 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10792 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010793 }
10794
10795 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10796 buf_ptr = (uint8_t *) cmd;
10797 WMITLV_SET_HDR(&cmd->tlv_header,
10798 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
10799 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
10800 cmd->vdev_id = wmi_utest->vdev_id;
10801 cmd->module_id = wmi_utest->module_id;
10802 cmd->num_args = wmi_utest->num_args;
10803 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
10804 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10805 (wmi_utest->num_args * sizeof(uint32_t)));
10806 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053010807 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053010808 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
10809 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010810 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010811 }
10812 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10813 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010814 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010815 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010816 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010817 }
10818
Govind Singhb53420c2016-03-09 14:32:57 +053010819 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010820}
10821
10822/**
10823 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
10824 * @wmi_handle: wma handle
10825 * @roaminvoke: roam invoke command
10826 *
10827 * Send roam invoke command to fw for fastreassoc.
10828 *
10829 * Return: CDF STATUS
10830 */
Govind Singhb53420c2016-03-09 14:32:57 +053010831QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010832 struct wmi_roam_invoke_cmd *roaminvoke,
10833 uint32_t ch_hz)
10834{
10835 wmi_roam_invoke_cmd_fixed_param *cmd;
10836 wmi_buf_t wmi_buf;
10837 u_int8_t *buf_ptr;
10838 u_int16_t len, args_tlv_len;
10839 A_UINT32 *channel_list;
10840 wmi_mac_addr *bssid_list;
10841
10842 /* Host sends only one channel and one bssid */
10843 args_tlv_len = 2 * WMI_TLV_HDR_SIZE + sizeof(A_UINT32) +
10844 sizeof(wmi_mac_addr);
10845 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
10846 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10847 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010848 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10849 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010850 }
10851
10852 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
10853 buf_ptr = (u_int8_t *) cmd;
10854 WMITLV_SET_HDR(&cmd->tlv_header,
10855 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
10856 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
10857 cmd->vdev_id = roaminvoke->vdev_id;
10858 cmd->flags = 0;
10859 cmd->roam_scan_mode = 0;
10860 cmd->roam_ap_sel_mode = 0;
10861 cmd->roam_delay = 0;
10862 cmd->num_chan = 1;
10863 cmd->num_bssid = 1;
10864 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
10865 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10866 (sizeof(u_int32_t)));
10867 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
10868 *channel_list = ch_hz;
10869 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
10870 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
10871 (sizeof(wmi_mac_addr)));
10872 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
10873 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
10874 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10875 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010876 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053010877 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010878 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010879 }
10880
Govind Singhb53420c2016-03-09 14:32:57 +053010881 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010882}
10883
10884/**
10885 * send_roam_scan_offload_cmd_tlv() - set roam offload command
10886 * @wmi_handle: wmi handle
10887 * @command: command
10888 * @vdev_id: vdev id
10889 *
10890 * This function set roam offload command to fw.
10891 *
10892 * Return: CDF status
10893 */
Govind Singhb53420c2016-03-09 14:32:57 +053010894QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010895 uint32_t command, uint32_t vdev_id)
10896{
Govind Singh67922e82016-04-01 16:48:57 +053010897 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010898 wmi_roam_scan_cmd_fixed_param *cmd_fp;
10899 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053010900 int len;
10901 uint8_t *buf_ptr;
10902
10903 len = sizeof(wmi_roam_scan_cmd_fixed_param);
10904 buf = wmi_buf_alloc(wmi_handle, len);
10905 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010906 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10907 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010908 }
10909
10910 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10911
10912 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
10913 WMITLV_SET_HDR(&cmd_fp->tlv_header,
10914 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
10915 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
10916 cmd_fp->vdev_id = vdev_id;
10917 cmd_fp->command_arg = command;
10918
10919 status = wmi_unified_cmd_send(wmi_handle, buf,
10920 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053010921 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010922 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010923 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010924 goto error;
10925 }
10926
Govind Singhb53420c2016-03-09 14:32:57 +053010927 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
10928 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010929
10930error:
10931 wmi_buf_free(buf);
10932
Govind Singh67922e82016-04-01 16:48:57 +053010933 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010934}
10935
10936/**
10937 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
10938 * @wmi_handle: wmi handle
10939 * @ap_profile_p: ap profile
10940 * @vdev_id: vdev id
10941 *
10942 * Send WMI_ROAM_AP_PROFILE to firmware
10943 *
10944 * Return: CDF status
10945 */
Govind Singhb53420c2016-03-09 14:32:57 +053010946QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010947 wmi_ap_profile *ap_profile_p,
10948 uint32_t vdev_id)
10949{
Govind Singha4836fd2016-03-07 16:45:38 +053010950 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010951 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010952 int len;
10953 uint8_t *buf_ptr;
10954 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
10955
10956 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
10957
10958 buf = wmi_buf_alloc(wmi_handle, len);
10959 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010960 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10961 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010962 }
10963
10964 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10965 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
10966 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
10967 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
10968 WMITLV_GET_STRUCT_TLVLEN
10969 (wmi_roam_ap_profile_fixed_param));
10970 /* fill in threshold values */
10971 roam_ap_profile_fp->vdev_id = vdev_id;
10972 roam_ap_profile_fp->id = 0;
10973 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
10974
Govind Singhb53420c2016-03-09 14:32:57 +053010975 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053010976 WMITLV_SET_HDR(buf_ptr,
10977 WMITLV_TAG_STRUC_wmi_ap_profile,
10978 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
10979 status = wmi_unified_cmd_send(wmi_handle, buf,
10980 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053010981 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010982 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010983 status);
Govind Singh67922e82016-04-01 16:48:57 +053010984 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010985 }
10986
Govind Singhb53420c2016-03-09 14:32:57 +053010987 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053010988
Govind Singh67922e82016-04-01 16:48:57 +053010989 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010990}
10991
10992/**
10993 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
10994 * @wmi_handle: wmi handle
10995 * @scan_period: scan period
10996 * @scan_age: scan age
10997 * @vdev_id: vdev id
10998 *
10999 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
11000 *
11001 * Return: CDF status
11002 */
Govind Singhb53420c2016-03-09 14:32:57 +053011003QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011004 uint32_t scan_period,
11005 uint32_t scan_age,
11006 uint32_t vdev_id)
11007{
Govind Singh67922e82016-04-01 16:48:57 +053011008 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011009 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053011010 int len;
11011 uint8_t *buf_ptr;
11012 wmi_roam_scan_period_fixed_param *scan_period_fp;
11013
11014 /* Send scan period values */
11015 len = sizeof(wmi_roam_scan_period_fixed_param);
11016 buf = wmi_buf_alloc(wmi_handle, len);
11017 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011018 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11019 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011020 }
11021
11022 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11023 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
11024 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
11025 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
11026 WMITLV_GET_STRUCT_TLVLEN
11027 (wmi_roam_scan_period_fixed_param));
11028 /* fill in scan period values */
11029 scan_period_fp->vdev_id = vdev_id;
11030 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
11031 scan_period_fp->roam_scan_age = scan_age;
11032
11033 status = wmi_unified_cmd_send(wmi_handle, buf,
11034 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053011035 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011036 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011037 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011038 goto error;
11039 }
11040
Govind Singhb53420c2016-03-09 14:32:57 +053011041 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011042 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053011043 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011044error:
11045 wmi_buf_free(buf);
11046
Govind Singh67922e82016-04-01 16:48:57 +053011047 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011048}
11049
11050/**
11051 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
11052 * @wmi_handle: wmi handle
11053 * @chan_count: channel count
11054 * @chan_list: channel list
11055 * @list_type: list type
11056 * @vdev_id: vdev id
11057 *
11058 * Set roam offload channel list.
11059 *
11060 * Return: CDF status
11061 */
Govind Singhb53420c2016-03-09 14:32:57 +053011062QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011063 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070011064 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053011065 uint8_t list_type, uint32_t vdev_id)
11066{
Govind Singha4836fd2016-03-07 16:45:38 +053011067 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011068 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011069 int len, list_tlv_len;
11070 int i;
11071 uint8_t *buf_ptr;
11072 wmi_roam_chan_list_fixed_param *chan_list_fp;
11073 A_UINT32 *roam_chan_list_array;
11074
11075 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053011076 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053011077 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053011078 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053011079 }
11080 /* Channel list is a table of 2 TLV's */
11081 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
11082 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
11083 buf = wmi_buf_alloc(wmi_handle, len);
11084 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011085 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11086 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011087 }
11088
11089 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11090 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
11091 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
11092 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
11093 WMITLV_GET_STRUCT_TLVLEN
11094 (wmi_roam_chan_list_fixed_param));
11095 chan_list_fp->vdev_id = vdev_id;
11096 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053011097 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053011098 /* external app is controlling channel list */
11099 chan_list_fp->chan_list_type =
11100 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
11101 } else {
11102 /* umac supplied occupied channel list in LFR */
11103 chan_list_fp->chan_list_type =
11104 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
11105 }
11106
11107 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
11108 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11109 (chan_list_fp->num_chan * sizeof(uint32_t)));
11110 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053011111 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053011112 for (i = 0; ((i < chan_list_fp->num_chan) &&
11113 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
11114 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053011115 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011116 }
11117
11118 status = wmi_unified_cmd_send(wmi_handle, buf,
11119 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053011120 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011121 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011122 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011123 goto error;
11124 }
11125
Govind Singhb53420c2016-03-09 14:32:57 +053011126 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
11127 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011128error:
11129 wmi_buf_free(buf);
11130
Govind Singh67922e82016-04-01 16:48:57 +053011131 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011132}
11133
11134/**
11135 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
11136 * @wmi_handle: wmi handle
11137 * @rssi_change_thresh: RSSI Change threshold
11138 * @bcn_rssi_weight: beacon RSSI weight
11139 * @vdev_id: vdev id
11140 *
11141 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
11142 *
11143 * Return: CDF status
11144 */
Govind Singhb53420c2016-03-09 14:32:57 +053011145QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011146 uint32_t vdev_id,
11147 int32_t rssi_change_thresh,
11148 uint32_t bcn_rssi_weight,
11149 uint32_t hirssi_delay_btw_scans)
11150{
Govind Singha4836fd2016-03-07 16:45:38 +053011151 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011152 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011153 int len;
11154 uint8_t *buf_ptr;
11155 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
11156
11157 /* Send rssi change parameters */
11158 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
11159 buf = wmi_buf_alloc(wmi_handle, len);
11160 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011161 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11162 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011163 }
11164
11165 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11166 rssi_change_fp =
11167 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
11168 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
11169 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
11170 WMITLV_GET_STRUCT_TLVLEN
11171 (wmi_roam_scan_rssi_change_threshold_fixed_param));
11172 /* fill in rssi change threshold (hysteresis) values */
11173 rssi_change_fp->vdev_id = vdev_id;
11174 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
11175 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
11176 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
11177
11178 status = wmi_unified_cmd_send(wmi_handle, buf,
11179 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053011180 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011181 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011182 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011183 goto error;
11184 }
11185
Govind Singhb53420c2016-03-09 14:32:57 +053011186 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053011187 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053011188 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
11189 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011190error:
11191 wmi_buf_free(buf);
11192
Govind Singh67922e82016-04-01 16:48:57 +053011193 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011194}
11195
11196/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
11197 * @wmi_handle: wmi handle.
11198 * @cmd: size of command structure.
11199 * @per_entry_size: per entry size.
11200 *
11201 * This utility function calculates how many hotlist entries can
11202 * fit in one page.
11203 *
11204 * Return: number of entries
11205 */
11206static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
11207 size_t cmd_size,
11208 size_t per_entry_size)
11209{
11210 uint32_t avail_space = 0;
11211 int num_entries = 0;
11212 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
11213
11214 /* Calculate number of hotlist entries that can
11215 * be passed in wma message request.
11216 */
11217 avail_space = max_msg_len - cmd_size;
11218 num_entries = avail_space / per_entry_size;
11219 return num_entries;
11220}
11221
11222/**
11223 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
11224 * @wmi_handle: wmi handle
11225 * @photlist: hotlist command params
11226 * @buf_len: buffer length
11227 *
11228 * This function fills individual elements for hotlist request and
11229 * TLV for bssid entries
11230 *
11231 * Return: CDF Status.
11232 */
Govind Singhb53420c2016-03-09 14:32:57 +053011233QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011234 struct ext_scan_setbssi_hotlist_params *
11235 photlist, int *buf_len)
11236{
11237 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
11238 wmi_extscan_hotlist_entry *dest_hotlist;
11239 struct ap_threshold_params *src_ap = photlist->ap;
11240 wmi_buf_t buf;
11241 uint8_t *buf_ptr;
11242
11243 int j, index = 0;
11244 int cmd_len = 0;
11245 int num_entries;
11246 int min_entries = 0;
11247 int numap = photlist->numAp;
11248 int len = sizeof(*cmd);
11249
11250 len += WMI_TLV_HDR_SIZE;
11251 cmd_len = len;
11252
11253 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
11254 cmd_len,
11255 sizeof(*dest_hotlist));
11256 /* setbssid hotlist expects the bssid list
11257 * to be non zero value
11258 */
11259 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011260 WMI_LOGE("%s: Invalid number of bssid's", __func__);
11261 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011262 }
11263
11264 /* Split the hot list entry pages and send multiple command
11265 * requests if the buffer reaches the maximum request size
11266 */
11267 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011268 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053011269 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
11270 buf = wmi_buf_alloc(wmi_handle, len);
11271 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011272 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
11273 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011274 }
11275 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11276 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
11277 buf_ptr;
11278 WMITLV_SET_HDR(&cmd->tlv_header,
11279 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
11280 WMITLV_GET_STRUCT_TLVLEN
11281 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
11282
11283 /* Multiple requests are sent until the num_entries_in_page
11284 * matches the total_entries
11285 */
11286 cmd->request_id = photlist->requestId;
11287 cmd->vdev_id = photlist->sessionId;
11288 cmd->total_entries = numap;
11289 cmd->mode = 1;
11290 cmd->num_entries_in_page = min_entries;
11291 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
11292 cmd->first_entry_index = index;
11293
Govind Singhb53420c2016-03-09 14:32:57 +053011294 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011295 __func__, cmd->vdev_id, cmd->total_entries,
11296 cmd->num_entries_in_page,
11297 cmd->lost_ap_scan_count);
11298
11299 buf_ptr += sizeof(*cmd);
11300 WMITLV_SET_HDR(buf_ptr,
11301 WMITLV_TAG_ARRAY_STRUC,
11302 min_entries * sizeof(wmi_extscan_hotlist_entry));
11303 dest_hotlist = (wmi_extscan_hotlist_entry *)
11304 (buf_ptr + WMI_TLV_HDR_SIZE);
11305
11306 /* Populate bssid, channel info and rssi
11307 * for the bssid's that are sent as hotlists.
11308 */
11309 for (j = 0; j < min_entries; j++) {
11310 WMITLV_SET_HDR(dest_hotlist,
11311 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
11312 WMITLV_GET_STRUCT_TLVLEN
11313 (wmi_extscan_hotlist_entry));
11314
11315 dest_hotlist->min_rssi = src_ap->low;
11316 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
11317 &dest_hotlist->bssid);
11318
Govind Singhb53420c2016-03-09 14:32:57 +053011319 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011320 __func__, dest_hotlist->channel,
11321 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053011322 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053011323 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
11324 __func__, dest_hotlist->bssid.mac_addr31to0,
11325 dest_hotlist->bssid.mac_addr47to32);
11326 dest_hotlist++;
11327 src_ap++;
11328 }
11329 buf_ptr += WMI_TLV_HDR_SIZE +
11330 (min_entries * sizeof(wmi_extscan_hotlist_entry));
11331
11332 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11333 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011334 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011335 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011336 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011337 }
11338 index = index + min_entries;
11339 num_entries = numap - min_entries;
11340 len = cmd_len;
11341 }
Govind Singhb53420c2016-03-09 14:32:57 +053011342 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011343}
11344
Govind Singhbca3b1b2016-05-02 17:59:24 +053011345/**
11346 * send_power_dbg_cmd_tlv() - send power debug commands
11347 * @wmi_handle: wmi handle
11348 * @param: wmi power debug parameter
11349 *
11350 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
11351 *
11352 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
11353 */
11354QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
11355 struct wmi_power_dbg_params *param)
11356{
11357 wmi_buf_t buf = NULL;
11358 QDF_STATUS status;
11359 int len, args_tlv_len;
11360 uint8_t *buf_ptr;
11361 uint8_t i;
11362 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
11363 uint32_t *cmd_args;
11364
11365 /* Prepare and send power debug cmd parameters */
11366 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
11367 len = sizeof(*cmd) + args_tlv_len;
11368 buf = wmi_buf_alloc(wmi_handle, len);
11369 if (!buf) {
11370 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11371 return QDF_STATUS_E_NOMEM;
11372 }
11373
11374 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11375 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
11376 WMITLV_SET_HDR(&cmd->tlv_header,
11377 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
11378 WMITLV_GET_STRUCT_TLVLEN
11379 (wmi_pdev_wal_power_debug_cmd_fixed_param));
11380
11381 cmd->pdev_id = param->pdev_id;
11382 cmd->module_id = param->module_id;
11383 cmd->num_args = param->num_args;
11384 buf_ptr += sizeof(*cmd);
11385 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11386 (param->num_args * sizeof(uint32_t)));
11387 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11388 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
11389 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
11390 cmd_args[i] = param->args[i];
11391 WMI_LOGI("%d,", param->args[i]);
11392 }
11393
11394 status = wmi_unified_cmd_send(wmi_handle, buf,
11395 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
11396 if (QDF_IS_STATUS_ERROR(status)) {
11397 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
11398 status);
11399 goto error;
11400 }
11401
11402 return QDF_STATUS_SUCCESS;
11403error:
11404 wmi_buf_free(buf);
11405
11406 return status;
11407}
11408
Govind Singhe7f2f342016-05-23 12:12:52 +053011409/**
11410 * init_cmd_send_tlv() - send initialization cmd to fw
11411 * @wmi_handle: wmi handle
11412 * @param tgt_res_cfg: pointer to target resource configuration
11413 * @param num_mem_chunks: Number of memory chunks
11414 * @param mem_chunks: pointer to target memory chunks
11415 *
11416 * Return: QDF_STATUS_SUCCESS for success or error code
11417 */
11418static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
11419 target_resource_config *tgt_res_cfg, uint8_t num_mem_chunks,
11420 struct wmi_host_mem_chunk *mem_chunks)
11421{
11422 wmi_buf_t buf;
11423 wmi_init_cmd_fixed_param *cmd;
11424 wmi_abi_version my_vers;
11425 int num_whitelist;
11426 uint8_t *buf_ptr;
11427 wmi_resource_config *resource_cfg;
11428 wlan_host_memory_chunk *host_mem_chunks;
11429 uint32_t mem_chunk_len = 0;
11430 uint16_t idx;
11431 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053011432 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053011433
11434 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11435 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11436 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11437 if (!buf) {
11438 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11439 return QDF_STATUS_E_FAILURE;
11440 }
11441
11442 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11443 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11444 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11445
11446 host_mem_chunks = (wlan_host_memory_chunk *)
11447 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11448 + WMI_TLV_HDR_SIZE);
11449
11450 WMITLV_SET_HDR(&cmd->tlv_header,
11451 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11452 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11453
11454 wmi_copy_resource_config(resource_cfg, tgt_res_cfg);
11455 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11456 WMITLV_TAG_STRUC_wmi_resource_config,
11457 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11458
11459 for (idx = 0; idx < num_mem_chunks; ++idx) {
11460 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11461 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11462 WMITLV_GET_STRUCT_TLVLEN
11463 (wlan_host_memory_chunk));
11464 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11465 host_mem_chunks[idx].size = mem_chunks[idx].len;
11466 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
11467 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
11468 idx, host_mem_chunks[idx].size,
11469 host_mem_chunks[idx].ptr);
11470 }
11471 cmd->num_host_mem_chunks = num_mem_chunks;
11472 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11473 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11474 WMITLV_TAG_ARRAY_STRUC,
11475 (sizeof(wlan_host_memory_chunk) *
11476 num_mem_chunks));
11477
11478 num_whitelist = sizeof(version_whitelist) /
11479 sizeof(wmi_whitelist_version_info);
11480 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11481 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11482 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11483 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11484 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11485 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
11486
Govind Singh87542482016-06-08 19:40:11 +053011487#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011488 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11489 &my_vers,
11490 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
11491 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011492#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011493 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
11494 __func__,
11495 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11496 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11497 cmd->host_abi_vers.abi_version_ns_0,
11498 cmd->host_abi_vers.abi_version_ns_1,
11499 cmd->host_abi_vers.abi_version_ns_2,
11500 cmd->host_abi_vers.abi_version_ns_3);
11501
11502 /* Save version sent from host -
11503 * Will be used to check ready event
11504 */
Govind Singh87542482016-06-08 19:40:11 +053011505#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011506 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
11507 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011508#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053011509 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
11510 if (QDF_IS_STATUS_ERROR(ret)) {
11511 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
11512 ret);
11513 wmi_buf_free(buf);
11514 }
11515 return ret;
11516
Govind Singhe7f2f342016-05-23 12:12:52 +053011517}
11518
11519/**
11520 * save_service_bitmap_tlv() - save service bitmap
11521 * @wmi_handle: wmi handle
11522 * @param evt_buf: pointer to event buffer
11523 *
11524 * Return: None
11525 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011526#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011527void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11528{
11529 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11530 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11531
11532 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
11533 param_buf->wmi_service_bitmap,
11534 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
11535}
11536#else
11537void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11538{
11539 return;
11540}
11541
11542#endif
11543
11544/**
11545 * is_service_enabled_tlv() - Check if service enabled
11546 * @param wmi_handle: wmi handle
11547 * @param service_id: service identifier
11548 *
11549 * Return: 1 enabled, 0 disabled
11550 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011551#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011552static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11553 uint32_t service_id)
11554{
11555 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
11556 service_id);
11557}
11558#else
11559static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11560 uint32_t service_id)
11561{
11562 return false;
11563}
11564#endif
11565
11566/**
11567 * extract_service_ready_tlv() - extract service ready event
11568 * @wmi_handle: wmi handle
11569 * @param evt_buf: pointer to received event buffer
11570 * @param cap: pointer to hold target capability information extracted from even
11571 *
11572 * Return: QDF_STATUS_SUCCESS for success or error code
11573 */
11574static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
11575 void *evt_buf, target_capability_info *cap)
11576{
11577 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11578 wmi_service_ready_event_fixed_param *ev;
11579
11580
11581 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11582
11583 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11584 if (!ev) {
11585 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11586 return QDF_STATUS_E_FAILURE;
11587 }
11588
11589 cap->phy_capability = ev->phy_capability;
11590 cap->max_frag_entry = ev->max_frag_entry;
11591 cap->num_rf_chains = ev->num_rf_chains;
11592 cap->ht_cap_info = ev->ht_cap_info;
11593 cap->vht_cap_info = ev->vht_cap_info;
11594 cap->vht_supp_mcs = ev->vht_supp_mcs;
11595 cap->hw_min_tx_power = ev->hw_min_tx_power;
11596 cap->hw_max_tx_power = ev->hw_max_tx_power;
11597 cap->sys_cap_info = ev->sys_cap_info;
11598 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
11599 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
11600 cap->max_num_scan_channels = ev->max_num_scan_channels;
11601 cap->max_supported_macs = ev->max_supported_macs;
11602 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
11603 cap->txrx_chainmask = ev->txrx_chainmask;
11604 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
11605 cap->num_msdu_desc = ev->num_msdu_desc;
11606
11607 return QDF_STATUS_SUCCESS;
11608}
11609
11610/**
11611 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
11612 * @wmi_handle: wmi handle
11613 * @param evt_buf: Pointer to event buffer
11614 * @param cap: pointer to hold HAL reg capabilities
11615 *
11616 * Return: QDF_STATUS_SUCCESS for success or error code
11617 */
11618static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
11619 void *evt_buf, TARGET_HAL_REG_CAPABILITIES *cap)
11620{
11621 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11622
11623 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11624
11625 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
11626 sizeof(uint32_t)),
11627 sizeof(TARGET_HAL_REG_CAPABILITIES));
11628
11629 return QDF_STATUS_SUCCESS;
11630}
11631
11632/**
11633 * extract_host_mem_req_tlv() - Extract host memory request event
11634 * @wmi_handle: wmi handle
11635 * @param evt_buf: pointer to event buffer
11636 * @param num_entries: pointer to hold number of entries requested
11637 *
11638 * Return: Number of entries requested
11639 */
11640static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
11641 void *evt_buf, uint8_t *num_entries)
11642{
11643 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11644 wmi_service_ready_event_fixed_param *ev;
11645
11646 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11647
11648 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11649 if (!ev) {
11650 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11651 return NULL;
11652 }
11653
11654 *num_entries = ev->num_mem_reqs;
11655
11656 return (host_mem_req *)param_buf->mem_reqs;
11657}
11658
11659/**
11660 * save_fw_version_in_service_ready_tlv() - Save fw version in service
11661 * ready function
11662 * @wmi_handle: wmi handle
11663 * @param evt_buf: pointer to event buffer
11664 *
11665 * Return: QDF_STATUS_SUCCESS for success or error code
11666 */
11667static QDF_STATUS
11668save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11669{
11670 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11671 wmi_service_ready_event_fixed_param *ev;
11672
11673
11674 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11675
11676 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11677 if (!ev) {
11678 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11679 return QDF_STATUS_E_FAILURE;
11680 }
11681
Govind Singh87542482016-06-08 19:40:11 +053011682#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011683 /*Save fw version from service ready message */
11684 /*This will be used while sending INIT message */
11685 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
11686 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011687#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011688 return QDF_STATUS_SUCCESS;
11689}
11690
11691/**
11692 * ready_extract_init_status_tlv() - Extract init status from ready event
11693 * @wmi_handle: wmi handle
11694 * @param evt_buf: Pointer to event buffer
11695 *
11696 * Return: ready status
11697 */
11698static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
11699 void *evt_buf)
11700{
11701 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11702 wmi_ready_event_fixed_param *ev = NULL;
11703
11704
11705 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11706 ev = param_buf->fixed_param;
11707
11708 qdf_print("%s:%d\n", __func__, ev->status);
11709
11710 return ev->status;
11711}
11712
11713/**
11714 * ready_extract_mac_addr_tlv() - extract mac address from ready event
11715 * @wmi_handle: wmi handle
11716 * @param evt_buf: pointer to event buffer
11717 * @param macaddr: Pointer to hold MAC address
11718 *
11719 * Return: QDF_STATUS_SUCCESS for success or error code
11720 */
11721static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
11722 void *evt_buf, uint8_t *macaddr)
11723{
11724 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11725 wmi_ready_event_fixed_param *ev = NULL;
11726
11727
11728 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11729 ev = param_buf->fixed_param;
11730
11731 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
11732
11733 return QDF_STATUS_SUCCESS;
11734}
11735
11736/**
11737 * extract_dbglog_data_len_tlv() - extract debuglog data length
11738 * @wmi_handle: wmi handle
11739 * @param evt_buf: pointer to event buffer
11740 *
11741 * Return: length
11742 */
11743static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
11744 void *evt_buf, uint16_t *len)
11745{
11746 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
11747
11748 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
11749
11750 *len = param_buf->num_bufp;
11751
11752 return param_buf->bufp;
11753}
11754
11755/**
11756 * extract_vdev_start_resp_tlv() - extract vdev start response
11757 * @wmi_handle: wmi handle
11758 * @param evt_buf: pointer to event buffer
11759 * @param vdev_rsp: Pointer to hold vdev response
11760 *
11761 * Return: QDF_STATUS_SUCCESS for success or error code
11762 */
11763static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
11764 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
11765{
11766 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
11767 wmi_vdev_start_response_event_fixed_param *ev;
11768
11769 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
11770 if (!param_buf) {
11771 qdf_print("Invalid start response event buffer\n");
11772 return QDF_STATUS_E_INVAL;
11773 }
11774
11775 ev = param_buf->fixed_param;
11776 if (!ev) {
11777 qdf_print("Invalid start response event buffer\n");
11778 return QDF_STATUS_E_INVAL;
11779 }
11780
11781 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
11782
11783 vdev_rsp->vdev_id = ev->vdev_id;
11784 vdev_rsp->requestor_id = ev->requestor_id;
11785 vdev_rsp->resp_type = ev->resp_type;
11786 vdev_rsp->status = ev->status;
11787 vdev_rsp->chain_mask = ev->chain_mask;
11788 vdev_rsp->smps_mode = ev->smps_mode;
11789 vdev_rsp->mac_id = ev->mac_id;
11790 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
11791 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
11792
11793 return QDF_STATUS_SUCCESS;
11794}
11795
11796/**
11797 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
11798 * @wmi_handle: wmi handle
11799 * @param evt_buf: pointer to event buffer
11800 * @param vdev_map: Pointer to hold vdev map
11801 * @param tbttoffset_list: Pointer to tbtt offset list
11802 *
11803 * Return: QDF_STATUS_SUCCESS for success or error code
11804 */
11805static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
11806 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
11807{
11808 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
11809 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
11810
11811 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
11812 if (!param_buf) {
11813 qdf_print("Invalid tbtt update event buffer\n");
11814 return QDF_STATUS_E_INVAL;
11815 }
11816 tbtt_offset_event = param_buf->fixed_param;
11817
11818 *vdev_map = tbtt_offset_event->vdev_map;
11819 *tbttoffset_list = param_buf->tbttoffset_list;
11820
11821 return QDF_STATUS_SUCCESS;
11822}
11823
11824/**
11825 * extract_mgmt_rx_params_tlv() - extract management rx params from event
11826 * @wmi_handle: wmi handle
11827 * @param evt_buf: pointer to event buffer
11828 * @param hdr: Pointer to hold header
11829 * @param bufp: Pointer to hold pointer to rx param buffer
11830 *
11831 * Return: QDF_STATUS_SUCCESS for success or error code
11832 */
11833static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
11834 void *evt_buf, wmi_host_mgmt_rx_hdr *hdr, uint8_t **bufp)
11835{
11836 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
11837 wmi_mgmt_rx_hdr *ev_hdr = NULL;
11838
11839 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
11840 if (!param_tlvs) {
11841 WMI_LOGE("Get NULL point message from FW");
11842 return QDF_STATUS_E_INVAL;
11843 }
11844
11845 ev_hdr = param_tlvs->hdr;
11846 if (!hdr) {
11847 WMI_LOGE("Rx event is NULL");
11848 return QDF_STATUS_E_INVAL;
11849 }
11850
11851
11852 hdr->channel = ev_hdr->channel;
11853 hdr->snr = ev_hdr->snr;
11854 hdr->rate = ev_hdr->rate;
11855 hdr->phy_mode = ev_hdr->phy_mode;
11856 hdr->buf_len = ev_hdr->buf_len;
11857 hdr->status = ev_hdr->status;
11858 hdr->flags = ev_hdr->flags;
11859 hdr->rssi = ev_hdr->rssi;
11860 hdr->tsf_delta = ev_hdr->tsf_delta;
11861 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
11862
11863 *bufp = param_tlvs->bufp;
11864
11865 return QDF_STATUS_SUCCESS;
11866}
11867
11868/**
11869 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
11870 * @wmi_handle: wmi handle
11871 * @param evt_buf: pointer to event buffer
11872 * @param vdev_id: Pointer to hold vdev identifier
11873 *
11874 * Return: QDF_STATUS_SUCCESS for success or error code
11875 */
11876static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
11877 void *evt_buf, uint32_t *vdev_id)
11878{
11879 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
11880 wmi_vdev_stopped_event_fixed_param *resp_event;
11881
11882 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
11883 if (!param_buf) {
11884 WMI_LOGE("Invalid event buffer");
11885 return QDF_STATUS_E_INVAL;
11886 }
11887 resp_event = param_buf->fixed_param;
11888 *vdev_id = resp_event->vdev_id;
11889
11890 return QDF_STATUS_SUCCESS;
11891}
11892
11893/**
11894 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
11895 * @wmi_handle: wmi handle
11896 * @param evt_buf: pointer to event buffer
11897 * @param param: Pointer to hold roam param
11898 *
11899 * Return: QDF_STATUS_SUCCESS for success or error code
11900 */
11901static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
11902 void *evt_buf, wmi_host_roam_event *param)
11903{
11904 WMI_ROAM_EVENTID_param_tlvs *param_buf;
11905 wmi_roam_event_fixed_param *evt;
11906
11907 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
11908 if (!param_buf) {
11909 WMI_LOGE("Invalid roam event buffer");
11910 return QDF_STATUS_E_INVAL;
11911 }
11912
11913 evt = param_buf->fixed_param;
11914 qdf_mem_zero(param, sizeof(*param));
11915
11916 param->vdev_id = evt->vdev_id;
11917 param->reason = evt->reason;
11918 param->rssi = evt->rssi;
11919
11920 return QDF_STATUS_SUCCESS;
11921}
11922
11923/**
11924 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
11925 * @wmi_handle: wmi handle
11926 * @param evt_buf: pointer to event buffer
11927 * @param param: Pointer to hold vdev scan param
11928 *
11929 * Return: QDF_STATUS_SUCCESS for success or error code
11930 */
11931static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
11932 void *evt_buf, wmi_host_scan_event *param)
11933{
11934 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
11935 wmi_scan_event_fixed_param *evt = NULL;
11936
11937 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
11938 evt = param_buf->fixed_param;
11939
11940 qdf_mem_zero(param, sizeof(*param));
11941 switch (evt->event) {
11942 case WMI_SCAN_EVENT_STARTED:
11943 param->event = WMI_HOST_SCAN_EVENT_STARTED;
11944 break;
11945 case WMI_SCAN_EVENT_COMPLETED:
11946 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
11947 break;
11948 case WMI_SCAN_EVENT_BSS_CHANNEL:
11949 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
11950 break;
11951 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
11952 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
11953 break;
11954 case WMI_SCAN_EVENT_DEQUEUED:
11955 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
11956 break;
11957 case WMI_SCAN_EVENT_PREEMPTED:
11958 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
11959 break;
11960 case WMI_SCAN_EVENT_START_FAILED:
11961 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
11962 break;
11963 case WMI_SCAN_EVENT_RESTARTED:
11964 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
11965 break;
11966 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
11967 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
11968 break;
11969 case WMI_SCAN_EVENT_MAX:
11970 default:
11971 param->event = WMI_HOST_SCAN_EVENT_MAX;
11972 break;
11973 };
11974
11975 switch (evt->reason) {
11976 case WMI_SCAN_REASON_NONE:
11977 param->reason = WMI_HOST_SCAN_REASON_NONE;
11978 break;
11979 case WMI_SCAN_REASON_COMPLETED:
11980 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
11981 break;
11982 case WMI_SCAN_REASON_CANCELLED:
11983 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
11984 break;
11985 case WMI_SCAN_REASON_PREEMPTED:
11986 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
11987 break;
11988 case WMI_SCAN_REASON_TIMEDOUT:
11989 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
11990 break;
11991 case WMI_SCAN_REASON_INTERNAL_FAILURE:
11992 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
11993 break;
11994 case WMI_SCAN_REASON_MAX:
11995 default:
11996 param->reason = WMI_HOST_SCAN_REASON_MAX;
11997 break;
11998 };
11999
12000 param->channel_freq = evt->channel_freq;
12001 param->requestor = evt->requestor;
12002 param->scan_id = evt->scan_id;
12003 param->vdev_id = evt->vdev_id;
12004
12005 return QDF_STATUS_SUCCESS;
12006}
12007
12008/**
12009 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
12010 * @wmi_handle: wmi handle
12011 * @param evt_buf: pointer to event buffer
12012 * @param param: Pointer to hold MGMT TX completion params
12013 *
12014 * Return: QDF_STATUS_SUCCESS for success or error code
12015 */
12016static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
12017 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
12018{
12019 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
12020 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
12021
12022 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
12023 evt_buf;
12024 if (!param_buf) {
12025 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
12026 return QDF_STATUS_E_INVAL;
12027 }
12028 cmpl_params = param_buf->fixed_param;
12029
12030 param->desc_id = cmpl_params->desc_id;
12031 param->status = cmpl_params->status;
12032
12033 return QDF_STATUS_SUCCESS;
12034}
12035
12036/**
12037 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
12038 * @wmi_handle: wmi handle
12039 * @param evt_buf: pointer to event buffer
12040 * @param vdev_map: Pointer to hold vdev map
12041 *
12042 * Return: QDF_STATUS_SUCCESS for success or error code
12043 */
12044static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
12045 void *evt_buf, uint32_t *vdev_map)
12046{
12047 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12048 wmi_host_swba_event_fixed_param *swba_event;
12049
12050 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12051 if (!param_buf) {
12052 WMI_LOGE("Invalid swba event buffer");
12053 return QDF_STATUS_E_INVAL;
12054 }
12055 swba_event = param_buf->fixed_param;
12056 *vdev_map = swba_event->vdev_map;
12057
12058 return QDF_STATUS_SUCCESS;
12059}
12060
12061/**
12062 * extract_swba_tim_info_tlv() - extract swba tim info from event
12063 * @wmi_handle: wmi handle
12064 * @param evt_buf: pointer to event buffer
12065 * @param idx: Index to bcn info
12066 * @param tim_info: Pointer to hold tim info
12067 *
12068 * Return: QDF_STATUS_SUCCESS for success or error code
12069 */
12070static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
12071 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
12072{
12073 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12074 wmi_tim_info *tim_info_ev;
12075
12076 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12077 if (!param_buf) {
12078 WMI_LOGE("Invalid swba event buffer");
12079 return QDF_STATUS_E_INVAL;
12080 }
12081
12082 tim_info_ev = &param_buf->tim_info[idx];
12083
12084 tim_info->tim_len = tim_info_ev->tim_len;
12085 tim_info->tim_mcast = tim_info_ev->tim_mcast;
12086 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
12087 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
12088 tim_info->tim_changed = tim_info_ev->tim_changed;
12089 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
12090
12091 return QDF_STATUS_SUCCESS;
12092}
12093
12094/**
12095 * extract_swba_noa_info_tlv() - extract swba NoA information from event
12096 * @wmi_handle: wmi handle
12097 * @param evt_buf: pointer to event buffer
12098 * @param idx: Index to bcn info
12099 * @param p2p_desc: Pointer to hold p2p NoA info
12100 *
12101 * Return: QDF_STATUS_SUCCESS for success or error code
12102 */
12103static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
12104 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
12105{
12106 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12107 wmi_p2p_noa_info *p2p_noa_info;
12108 uint8_t i = 0;
12109
12110 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12111 if (!param_buf) {
12112 WMI_LOGE("Invalid swba event buffer");
12113 return QDF_STATUS_E_INVAL;
12114 }
12115
12116 p2p_noa_info = &param_buf->p2p_noa_info[idx];
12117
12118 p2p_desc->modified = false;
12119 p2p_desc->num_descriptors = 0;
12120 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
12121 p2p_desc->modified = true;
12122 p2p_desc->index =
12123 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
12124 p2p_desc->oppPS =
12125 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
12126 p2p_desc->ctwindow =
12127 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
12128 p2p_desc->num_descriptors =
12129 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
12130 (p2p_noa_info);
12131 for (i = 0; i < p2p_desc->num_descriptors; i++) {
12132 p2p_desc->noa_descriptors[i].type_count =
12133 (uint8_t) p2p_noa_info->noa_descriptors[i].
12134 type_count;
12135 p2p_desc->noa_descriptors[i].duration =
12136 p2p_noa_info->noa_descriptors[i].duration;
12137 p2p_desc->noa_descriptors[i].interval =
12138 p2p_noa_info->noa_descriptors[i].interval;
12139 p2p_desc->noa_descriptors[i].start_time =
12140 p2p_noa_info->noa_descriptors[i].start_time;
12141 }
12142 }
12143
12144 return QDF_STATUS_SUCCESS;
12145}
12146
12147/**
12148 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
12149 * @wmi_handle: wmi handle
12150 * @param evt_buf: pointer to event buffer
12151 * @param ev: Pointer to hold peer param
12152 *
12153 * Return: QDF_STATUS_SUCCESS for success or error code
12154 */
12155static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
12156 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
12157{
12158 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
12159 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
12160
12161 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
12162 kickout_event = param_buf->fixed_param;
12163
12164 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
12165 ev->peer_macaddr);
12166
12167 ev->reason = kickout_event->reason;
12168 ev->rssi = kickout_event->rssi;
12169
12170 return QDF_STATUS_SUCCESS;
12171}
12172
12173/**
12174 * extract_all_stats_counts_tlv() - extract all stats count from event
12175 * @wmi_handle: wmi handle
12176 * @param evt_buf: pointer to event buffer
12177 * @param stats_param: Pointer to hold stats count
12178 *
12179 * Return: QDF_STATUS_SUCCESS for success or error code
12180 */
12181static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
12182 void *evt_buf, wmi_host_stats_event *stats_param)
12183{
12184 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12185 wmi_stats_event_fixed_param *ev;
12186
12187 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12188
12189 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12190 if (!ev) {
12191 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
12192 return QDF_STATUS_E_FAILURE;
12193 }
12194
12195 switch (ev->stats_id) {
12196 case WMI_REQUEST_PEER_STAT:
12197 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
12198 break;
12199
12200 case WMI_REQUEST_AP_STAT:
12201 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
12202 break;
12203
12204 case WMI_REQUEST_PDEV_STAT:
12205 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
12206 break;
12207
12208 case WMI_REQUEST_VDEV_STAT:
12209 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
12210 break;
12211
12212 case WMI_REQUEST_BCNFLT_STAT:
12213 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
12214 break;
12215
12216 case WMI_REQUEST_VDEV_RATE_STAT:
12217 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
12218 break;
12219
12220 default:
12221 stats_param->stats_id = 0;
12222 break;
12223
12224 }
12225
12226 stats_param->num_pdev_stats = ev->num_pdev_stats;
12227 stats_param->num_pdev_ext_stats = 0;
12228 stats_param->num_vdev_stats = ev->num_vdev_stats;
12229 stats_param->num_peer_stats = ev->num_peer_stats;
12230 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
12231 stats_param->num_chan_stats = ev->num_chan_stats;
12232
12233 return QDF_STATUS_SUCCESS;
12234}
12235
12236/**
12237 * extract_pdev_stats_tlv() - extract pdev stats from event
12238 * @wmi_handle: wmi handle
12239 * @param evt_buf: pointer to event buffer
12240 * @param index: Index into pdev stats
12241 * @param pdev_stats: Pointer to hold pdev stats
12242 *
12243 * Return: QDF_STATUS_SUCCESS for success or error code
12244 */
12245static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
12246 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
12247{
12248 return QDF_STATUS_SUCCESS;
12249}
12250
12251/**
12252 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
12253 * @wmi_handle: wmi handle
12254 * @param evt_buf: pointer to event buffer
12255 * @param index: Index into extended pdev stats
12256 * @param pdev_ext_stats: Pointer to hold extended pdev stats
12257 *
12258 * Return: QDF_STATUS_SUCCESS for success or error code
12259 */
12260static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
12261 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
12262{
12263 return QDF_STATUS_SUCCESS;
12264}
12265
12266/**
12267 * extract_vdev_stats_tlv() - extract vdev stats from event
12268 * @wmi_handle: wmi handle
12269 * @param evt_buf: pointer to event buffer
12270 * @param index: Index into vdev stats
12271 * @param vdev_stats: Pointer to hold vdev stats
12272 *
12273 * Return: QDF_STATUS_SUCCESS for success or error code
12274 */
12275static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
12276 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
12277{
12278 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12279 wmi_stats_event_fixed_param *ev_param;
12280 uint8_t *data;
12281
12282 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12283 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12284 data = (uint8_t *) param_buf->data;
12285
12286 if (index < ev_param->num_vdev_stats) {
12287 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
12288 ((ev_param->num_pdev_stats) *
12289 sizeof(wmi_pdev_stats)) +
12290 (index * sizeof(wmi_vdev_stats)));
12291
12292 vdev_stats->vdev_id = ev->vdev_id;
12293 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
12294 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
12295
12296 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
12297 sizeof(ev->tx_frm_cnt));
12298 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
12299 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
12300 ev->multiple_retry_cnt,
12301 sizeof(ev->multiple_retry_cnt));
12302 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
12303 sizeof(ev->fail_cnt));
12304 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
12305 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
12306 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
12307 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
12308 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
12309 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
12310 sizeof(ev->tx_rate_history));
12311 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
12312 sizeof(ev->bcn_rssi_history));
12313
12314 }
12315
12316 return QDF_STATUS_SUCCESS;
12317}
12318
12319/**
12320 * extract_peer_stats_tlv() - extract peer stats from event
12321 * @wmi_handle: wmi handle
12322 * @param evt_buf: pointer to event buffer
12323 * @param index: Index into peer stats
12324 * @param peer_stats: Pointer to hold peer stats
12325 *
12326 * Return: QDF_STATUS_SUCCESS for success or error code
12327 */
12328static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
12329 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
12330{
12331 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12332 wmi_stats_event_fixed_param *ev_param;
12333 uint8_t *data;
12334
12335 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12336 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12337 data = (uint8_t *) param_buf->data;
12338
12339 if (index < ev_param->num_peer_stats) {
12340 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
12341 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12342 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12343 (index * sizeof(wmi_peer_stats)));
12344
12345 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
12346
12347 OS_MEMCPY(&(peer_stats->peer_macaddr),
12348 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
12349
12350 peer_stats->peer_rssi = ev->peer_rssi;
12351 peer_stats->peer_tx_rate = ev->peer_tx_rate;
12352 peer_stats->peer_rx_rate = ev->peer_rx_rate;
12353 }
12354
12355 return QDF_STATUS_SUCCESS;
12356}
12357
12358/**
12359 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
12360 * @wmi_handle: wmi handle
12361 * @param evt_buf: pointer to event buffer
12362 * @param index: Index into bcn fault stats
12363 * @param bcnflt_stats: Pointer to hold bcn fault stats
12364 *
12365 * Return: QDF_STATUS_SUCCESS for success or error code
12366 */
12367static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
12368 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
12369{
12370 return QDF_STATUS_SUCCESS;
12371}
12372
12373/**
12374 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
12375 * @wmi_handle: wmi handle
12376 * @param evt_buf: pointer to event buffer
12377 * @param index: Index into extended peer stats
12378 * @param peer_extd_stats: Pointer to hold extended peer stats
12379 *
12380 * Return: QDF_STATUS_SUCCESS for success or error code
12381 */
12382static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
12383 void *evt_buf, uint32_t index,
12384 wmi_host_peer_extd_stats *peer_extd_stats)
12385{
12386 return QDF_STATUS_SUCCESS;
12387}
12388
12389/**
12390 * extract_chan_stats_tlv() - extract chan stats from event
12391 * @wmi_handle: wmi handle
12392 * @param evt_buf: pointer to event buffer
12393 * @param index: Index into chan stats
12394 * @param vdev_extd_stats: Pointer to hold chan stats
12395 *
12396 * Return: QDF_STATUS_SUCCESS for success or error code
12397 */
12398static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
12399 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
12400{
12401 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12402 wmi_stats_event_fixed_param *ev_param;
12403 uint8_t *data;
12404
12405 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12406 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12407 data = (uint8_t *) param_buf->data;
12408
12409 if (index < ev_param->num_chan_stats) {
12410 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
12411 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12412 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12413 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
12414 (index * sizeof(wmi_chan_stats)));
12415
12416
12417 /* Non-TLV doesnt have num_chan_stats */
12418 chan_stats->chan_mhz = ev->chan_mhz;
12419 chan_stats->sampling_period_us = ev->sampling_period_us;
12420 chan_stats->rx_clear_count = ev->rx_clear_count;
12421 chan_stats->tx_duration_us = ev->tx_duration_us;
12422 chan_stats->rx_duration_us = ev->rx_duration_us;
12423 }
12424
12425 return QDF_STATUS_SUCCESS;
12426}
12427
12428/**
12429 * extract_profile_ctx_tlv() - extract profile context from event
12430 * @wmi_handle: wmi handle
12431 * @param evt_buf: pointer to event buffer
12432 * @idx: profile stats index to extract
12433 * @param profile_ctx: Pointer to hold profile context
12434 *
12435 * Return: QDF_STATUS_SUCCESS for success or error code
12436 */
12437static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
12438 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
12439{
12440 return QDF_STATUS_SUCCESS;
12441}
12442
12443/**
12444 * extract_profile_data_tlv() - extract profile data from event
12445 * @wmi_handle: wmi handle
12446 * @param evt_buf: pointer to event buffer
12447 * @param profile_data: Pointer to hold profile data
12448 *
12449 * Return: QDF_STATUS_SUCCESS for success or error code
12450 */
12451static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
12452 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
12453{
12454
12455 return QDF_STATUS_SUCCESS;
12456}
12457
12458/**
12459 * extract_chan_info_event_tlv() - extract chan information from event
12460 * @wmi_handle: wmi handle
12461 * @param evt_buf: pointer to event buffer
12462 * @param chan_info: Pointer to hold chan information
12463 *
12464 * Return: QDF_STATUS_SUCCESS for success or error code
12465 */
12466static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
12467 void *evt_buf, wmi_host_chan_info_event *chan_info)
12468{
12469 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
12470 wmi_chan_info_event_fixed_param *ev;
12471
12472 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
12473
12474 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
12475 if (!ev) {
12476 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
12477 return QDF_STATUS_E_FAILURE;
12478 }
12479
12480 chan_info->err_code = ev->err_code;
12481 chan_info->freq = ev->freq;
12482 chan_info->cmd_flags = ev->cmd_flags;
12483 chan_info->noise_floor = ev->noise_floor;
12484 chan_info->rx_clear_count = ev->rx_clear_count;
12485 chan_info->cycle_count = ev->cycle_count;
12486
12487 return QDF_STATUS_SUCCESS;
12488}
12489
12490/**
12491 * extract_channel_hopping_event_tlv() - extract channel hopping param
12492 * from event
12493 * @wmi_handle: wmi handle
12494 * @param evt_buf: pointer to event buffer
12495 * @param ch_hopping: Pointer to hold channel hopping param
12496 *
12497 * Return: QDF_STATUS_SUCCESS for success or error code
12498 */
12499static QDF_STATUS extract_channel_hopping_event_tlv(wmi_unified_t wmi_handle,
12500 void *evt_buf, wmi_host_pdev_channel_hopping_event *chan_info)
12501{
12502 return QDF_STATUS_SUCCESS;
12503}
12504
Govind Singh06c18392016-06-10 10:33:19 +053012505#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhecf03cd2016-05-12 12:45:51 +053012506static bool is_management_record_tlv(uint32_t cmd_id)
12507{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053012508 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053012509 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053012510
Govind Singhecf03cd2016-05-12 12:45:51 +053012511 return false;
12512}
Govind Singh06c18392016-06-10 10:33:19 +053012513#endif
Govind Singhecf03cd2016-05-12 12:45:51 +053012514
Govind Singh5eb51532016-03-09 11:34:12 +053012515struct wmi_ops tlv_ops = {
12516 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
12517 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
12518 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053012519 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
12520 .send_hidden_ssid_vdev_restart_cmd =
12521 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012522 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
12523 .send_peer_param_cmd = send_peer_param_cmd_tlv,
12524 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012525 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012526 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012527 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070012528 .send_peer_rx_reorder_queue_setup_cmd =
12529 send_peer_rx_reorder_queue_setup_cmd_tlv,
12530 .send_peer_rx_reorder_queue_remove_cmd =
12531 send_peer_rx_reorder_queue_remove_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012532 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
12533 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
12534 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
12535 .send_suspend_cmd = send_suspend_cmd_tlv,
12536 .send_resume_cmd = send_resume_cmd_tlv,
12537 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
12538 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
12539 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
12540 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
12541 .send_dbglog_cmd = send_dbglog_cmd_tlv,
12542 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
12543 .send_stats_request_cmd = send_stats_request_cmd_tlv,
12544 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
12545 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012546#ifndef CONFIG_MCL
12547 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
12548#endif
Govind Singh5eb51532016-03-09 11:34:12 +053012549 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
12550 .send_scan_start_cmd = send_scan_start_cmd_tlv,
12551 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
12552 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012553 .send_mgmt_cmd = send_mgmt_cmd_tlv,
12554 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
12555 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012556 .send_set_sta_uapsd_auto_trig_cmd =
12557 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053012558 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
12559 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
12560 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
12561 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
12562 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053012563 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
12564 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
12565 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
12566 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
12567 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
12568 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
12569 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012570 .send_ocb_start_timing_advert_cmd =
12571 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053012572 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
12573 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
12574 .send_set_mcc_channel_time_latency_cmd =
12575 send_set_mcc_channel_time_latency_cmd_tlv,
12576 .send_set_mcc_channel_time_quota_cmd =
12577 send_set_mcc_channel_time_quota_cmd_tlv,
12578 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
12579 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053012580 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012581 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
12582 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
12583 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012584 .send_probe_rsp_tmpl_send_cmd =
12585 send_probe_rsp_tmpl_send_cmd_tlv,
12586 .send_p2p_go_set_beacon_ie_cmd =
12587 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053012588 .send_setup_install_key_cmd =
12589 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012590 .send_set_gateway_params_cmd =
12591 send_set_gateway_params_cmd_tlv,
12592 .send_set_rssi_monitoring_cmd =
12593 send_set_rssi_monitoring_cmd_tlv,
12594 .send_scan_probe_setoui_cmd =
12595 send_scan_probe_setoui_cmd_tlv,
12596 .send_reset_passpoint_network_list_cmd =
12597 send_reset_passpoint_network_list_cmd_tlv,
12598 .send_set_passpoint_network_list_cmd =
12599 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053012600 .send_roam_scan_offload_rssi_thresh_cmd =
12601 send_roam_scan_offload_rssi_thresh_cmd_tlv,
12602 .send_roam_scan_filter_cmd =
12603 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053012604 .send_set_epno_network_list_cmd =
12605 send_set_epno_network_list_cmd_tlv,
12606 .send_ipa_offload_control_cmd =
12607 send_ipa_offload_control_cmd_tlv,
12608 .send_extscan_get_capabilities_cmd =
12609 send_extscan_get_capabilities_cmd_tlv,
12610 .send_extscan_get_cached_results_cmd =
12611 send_extscan_get_cached_results_cmd_tlv,
12612 .send_extscan_stop_change_monitor_cmd =
12613 send_extscan_stop_change_monitor_cmd_tlv,
12614 .send_extscan_start_change_monitor_cmd =
12615 send_extscan_start_change_monitor_cmd_tlv,
12616 .send_extscan_stop_hotlist_monitor_cmd =
12617 send_extscan_stop_hotlist_monitor_cmd_tlv,
12618 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
12619 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
12620 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
12621 .send_plm_start_cmd = send_plm_start_cmd_tlv,
12622 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012623#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053012624 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012625#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053012626 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
12627 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
12628 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
12629 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
12630 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053012631 .send_snr_request_cmd = send_snr_request_cmd_tlv,
12632 .send_snr_cmd = send_snr_cmd_tlv,
12633 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012634#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053012635 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
12636 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
12637 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
12638 .send_lphb_config_udp_pkt_filter_cmd =
12639 send_lphb_config_udp_pkt_filter_cmd_tlv,
12640 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
12641 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
12642 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012643 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
12644 .send_process_update_edca_param_cmd =
12645 send_process_update_edca_param_cmd_tlv,
12646 .send_roam_scan_offload_mode_cmd =
12647 send_roam_scan_offload_mode_cmd_tlv,
12648 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
12649 .send_roam_scan_offload_ap_profile_cmd =
12650 send_roam_scan_offload_ap_profile_cmd_tlv,
12651#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053012652 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
12653 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012654#ifdef FEATURE_WLAN_RA_FILTERING
Govind Singh20c5dac2016-03-07 15:33:31 +053012655 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053012656#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053012657 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
12658 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
12659 .send_dfs_phyerr_filter_offload_en_cmd =
12660 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053012661 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
12662 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
12663 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
12664 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
12665 .send_del_ts_cmd = send_del_ts_cmd_tlv,
12666 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
12667 .send_add_ts_cmd = send_add_ts_cmd_tlv,
12668 .send_enable_disable_packet_filter_cmd =
12669 send_enable_disable_packet_filter_cmd_tlv,
12670 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
12671 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
12672 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
12673 .send_process_gtk_offload_getinfo_cmd =
12674 send_process_gtk_offload_getinfo_cmd_tlv,
12675 .send_process_add_periodic_tx_ptrn_cmd =
12676 send_process_add_periodic_tx_ptrn_cmd_tlv,
12677 .send_process_del_periodic_tx_ptrn_cmd =
12678 send_process_del_periodic_tx_ptrn_cmd_tlv,
12679 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
12680 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
12681 .send_set_app_type2_params_in_fw_cmd =
12682 send_set_app_type2_params_in_fw_cmd_tlv,
12683 .send_set_auto_shutdown_timer_cmd =
12684 send_set_auto_shutdown_timer_cmd_tlv,
12685 .send_nan_req_cmd = send_nan_req_cmd_tlv,
12686 .send_process_dhcpserver_offload_cmd =
12687 send_process_dhcpserver_offload_cmd_tlv,
12688 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
12689 .send_process_ch_avoid_update_cmd =
12690 send_process_ch_avoid_update_cmd_tlv,
12691 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
12692 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
12693 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
12694 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
12695 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
12696 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012697#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012698 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012699#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012700 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053012701 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053012702 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053012703 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012704 .send_set_base_macaddr_indicate_cmd =
12705 send_set_base_macaddr_indicate_cmd_tlv,
12706 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
12707 .send_enable_specific_fw_logs_cmd =
12708 send_enable_specific_fw_logs_cmd_tlv,
12709 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012710 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012711 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012712 .send_pdev_set_dual_mac_config_cmd =
12713 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012714 .send_enable_arp_ns_offload_cmd =
12715 send_enable_arp_ns_offload_cmd_tlv,
12716 .send_app_type1_params_in_fw_cmd =
12717 send_app_type1_params_in_fw_cmd_tlv,
12718 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
12719 .send_process_roam_synch_complete_cmd =
12720 send_process_roam_synch_complete_cmd_tlv,
12721 .send_unit_test_cmd = send_unit_test_cmd_tlv,
12722 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
12723 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053012724 .send_roam_scan_offload_scan_period_cmd =
12725 send_roam_scan_offload_scan_period_cmd_tlv,
12726 .send_roam_scan_offload_chan_list_cmd =
12727 send_roam_scan_offload_chan_list_cmd_tlv,
12728 .send_roam_scan_offload_rssi_change_cmd =
12729 send_roam_scan_offload_rssi_change_cmd_tlv,
12730 .send_get_buf_extscan_hotlist_cmd =
12731 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053012732 .send_adapt_dwelltime_params_cmd =
12733 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053012734 .init_cmd_send = init_cmd_send_tlv,
12735 .get_target_cap_from_service_ready = extract_service_ready_tlv,
12736 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
12737 .extract_host_mem_req = extract_host_mem_req_tlv,
12738 .save_service_bitmap = save_service_bitmap_tlv,
12739 .is_service_enabled = is_service_enabled_tlv,
12740 .save_fw_version = save_fw_version_in_service_ready_tlv,
12741 .ready_extract_init_status = ready_extract_init_status_tlv,
12742 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
12743 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
12744 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
12745 .extract_tbttoffset_update_params =
12746 extract_tbttoffset_update_params_tlv,
12747 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
12748 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
12749 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
12750 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
12751 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
12752 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
12753 .extract_swba_tim_info = extract_swba_tim_info_tlv,
12754 .extract_swba_noa_info = extract_swba_noa_info_tlv,
12755 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
12756 .extract_all_stats_count = extract_all_stats_counts_tlv,
12757 .extract_pdev_stats = extract_pdev_stats_tlv,
12758 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
12759 .extract_vdev_stats = extract_vdev_stats_tlv,
12760 .extract_peer_stats = extract_peer_stats_tlv,
12761 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
12762 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
12763 .extract_chan_stats = extract_chan_stats_tlv,
12764 .extract_profile_ctx = extract_profile_ctx_tlv,
12765 .extract_profile_data = extract_profile_data_tlv,
12766 .extract_chan_info_event = extract_chan_info_event_tlv,
12767 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053012768 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053012769 .send_encrypt_decrypt_send_cmd =
12770 send_encrypt_decrypt_send_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053012771 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053012772};
12773
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053012774#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053012775/**
12776 * populate_tlv_service() - populates wmi services
12777 *
12778 * @param wmi_service: Pointer to hold wmi_service
12779 * Return: None
12780 */
12781static void populate_tlv_service(uint32_t *wmi_service)
12782{
12783 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
12784 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
12785 wmi_service[wmi_service_roam_scan_offload] =
12786 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
12787 wmi_service[wmi_service_bcn_miss_offload] =
12788 WMI_SERVICE_BCN_MISS_OFFLOAD;
12789 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
12790 wmi_service[wmi_service_sta_advanced_pwrsave] =
12791 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
12792 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
12793 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
12794 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
12795 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
12796 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
12797 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
12798 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
12799 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
12800 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
12801 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
12802 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
12803 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
12804 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
12805 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
12806 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
12807 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
12808 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
12809 wmi_service[wmi_service_packet_power_save] =
12810 WMI_SERVICE_PACKET_POWER_SAVE;
12811 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
12812 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
12813 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
12814 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
12815 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
12816 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
12817 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
12818 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
12819 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
12820 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
12821 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
12822 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
12823 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
12824 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
12825 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
12826 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
12827 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
12828 wmi_service[wmi_service_mcc_bcn_interval_change] =
12829 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
12830 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
12831 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
12832 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
12833 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
12834 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
12835 wmi_service[wmi_service_lte_ant_share_support] =
12836 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
12837 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
12838 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
12839 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
12840 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
12841 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
12842 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
12843 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
12844 wmi_service[wmi_service_bcn_txrate_override] =
12845 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
12846 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
12847 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
12848 wmi_service[wmi_service_estimate_linkspeed] =
12849 WMI_SERVICE_ESTIMATE_LINKSPEED;
12850 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
12851 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
12852 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
12853 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
12854 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
12855 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
12856 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
12857 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
12858 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
12859 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
12860 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
12861 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
12862 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
12863 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
12864 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
12865 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
12866 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
12867 wmi_service[wmi_service_sap_auth_offload] =
12868 WMI_SERVICE_SAP_AUTH_OFFLOAD;
12869 wmi_service[wmi_service_dual_band_simultaneous_support] =
12870 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
12871 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
12872 wmi_service[wmi_service_ap_arpns_offload] =
12873 WMI_SERVICE_AP_ARPNS_OFFLOAD;
12874 wmi_service[wmi_service_per_band_chainmask_support] =
12875 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
12876 wmi_service[wmi_service_packet_filter_offload] =
12877 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
12878 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
12879 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
12880 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
12881 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
12882
12883 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
12884 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
12885 wmi_service[wmi_service_smart_antenna_sw_support] =
12886 WMI_SERVICE_UNAVAILABLE;
12887 wmi_service[wmi_service_smart_antenna_hw_support] =
12888 WMI_SERVICE_UNAVAILABLE;
12889 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
12890 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
12891 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
12892 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
12893 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
12894 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
12895 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
12896 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
12897 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
12898 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
12899 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
12900
12901 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
12902 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
12903 wmi_service[wmi_service_periodic_chan_stat_support] =
12904 WMI_SERVICE_UNAVAILABLE;
12905 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
12906 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
12907 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
12908}
12909
12910/**
12911 * populate_tlv_event_id() - populates wmi event ids
12912 *
12913 * @param event_ids: Pointer to hold event ids
12914 * Return: None
12915 */
12916static void populate_tlv_events_id(uint32_t *event_ids)
12917{
12918 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
12919 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
12920 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
12921 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
12922 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
12923 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
12924 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
12925 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
12926 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
12927 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
12928 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
12929 event_ids[wmi_service_ready_ext_event_id] =
12930 WMI_SERVICE_READY_EXT_EVENTID;
12931 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
12932 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
12933 event_ids[wmi_vdev_install_key_complete_event_id] =
12934 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
12935 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
12936 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
12937
12938 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
12939 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
12940 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
12941 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
12942 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
12943 event_ids[wmi_peer_estimated_linkspeed_event_id] =
12944 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
12945 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
12946 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
12947 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
12948 event_ids[wmi_tbttoffset_update_event_id] =
12949 WMI_TBTTOFFSET_UPDATE_EVENTID;
12950 event_ids[wmi_offload_bcn_tx_status_event_id] =
12951 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
12952 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
12953 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
12954 event_ids[wmi_mgmt_tx_completion_event_id] =
12955 WMI_MGMT_TX_COMPLETION_EVENTID;
12956
12957 event_ids[wmi_tx_delba_complete_event_id] =
12958 WMI_TX_DELBA_COMPLETE_EVENTID;
12959 event_ids[wmi_tx_addba_complete_event_id] =
12960 WMI_TX_ADDBA_COMPLETE_EVENTID;
12961 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
12962
12963 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
12964
12965 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
12966 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
12967
12968 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
12969
12970 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
12971
12972 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
12973
12974 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
12975 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
12976 event_ids[wmi_do_wow_disable_ack_event_id] =
12977 WMI_D0_WOW_DISABLE_ACK_EVENTID;
12978 event_ids[wmi_wow_initial_wakeup_event_id] =
12979 WMI_WOW_INITIAL_WAKEUP_EVENTID;
12980
12981 event_ids[wmi_rtt_meas_report_event_id] =
12982 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
12983 event_ids[wmi_tsf_meas_report_event_id] =
12984 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
12985 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
12986 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
12987 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
12988 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
12989 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
12990 event_ids[wmi_update_fw_mem_dump_event_id] =
12991 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
12992 event_ids[wmi_diag_event_id_log_supported_event_id] =
12993 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
12994 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
12995 event_ids[wmi_nlo_scan_complete_event_id] =
12996 WMI_NLO_SCAN_COMPLETE_EVENTID;
12997 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
12998 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
12999
13000 event_ids[wmi_gtk_offload_status_event_id] =
13001 WMI_GTK_OFFLOAD_STATUS_EVENTID;
13002 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
13003 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
13004 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
13005
13006 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
13007
13008 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
13009
13010 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
13011 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
13012 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
13013 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
13014 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
13015 event_ids[wmi_wlan_profile_data_event_id] =
13016 WMI_WLAN_PROFILE_DATA_EVENTID;
13017 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
13018 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
13019 event_ids[wmi_vdev_get_keepalive_event_id] =
13020 WMI_VDEV_GET_KEEPALIVE_EVENTID;
13021 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
13022
13023 event_ids[wmi_diag_container_event_id] =
13024 WMI_DIAG_DATA_CONTAINER_EVENTID;
13025
13026 event_ids[wmi_host_auto_shutdown_event_id] =
13027 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
13028
13029 event_ids[wmi_update_whal_mib_stats_event_id] =
13030 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
13031
13032 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
13033 event_ids[wmi_update_vdev_rate_stats_event_id] =
13034 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
13035
13036 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
13037
13038 /** Set OCB Sched Response, deprecated */
13039 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
13040
13041 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
13042 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
13043 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
13044
13045 /* GPIO Event */
13046 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
13047 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
13048
13049 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
13050 event_ids[wmi_rfkill_state_change_event_id] =
13051 WMI_RFKILL_STATE_CHANGE_EVENTID;
13052
13053 /* TDLS Event */
13054 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
13055
13056 event_ids[wmi_batch_scan_enabled_event_id] =
13057 WMI_BATCH_SCAN_ENABLED_EVENTID;
13058 event_ids[wmi_batch_scan_result_event_id] =
13059 WMI_BATCH_SCAN_RESULT_EVENTID;
13060 /* OEM Event */
13061 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
13062 event_ids[wmi_oem_meas_report_event_id] =
13063 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
13064 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
13065
13066 /* NAN Event */
13067 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
13068
13069 /* LPI Event */
13070 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
13071 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
13072 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
13073
13074 /* ExtScan events */
13075 event_ids[wmi_extscan_start_stop_event_id] =
13076 WMI_EXTSCAN_START_STOP_EVENTID;
13077 event_ids[wmi_extscan_operation_event_id] =
13078 WMI_EXTSCAN_OPERATION_EVENTID;
13079 event_ids[wmi_extscan_table_usage_event_id] =
13080 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
13081 event_ids[wmi_extscan_cached_results_event_id] =
13082 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
13083 event_ids[wmi_extscan_wlan_change_results_event_id] =
13084 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
13085 event_ids[wmi_extscan_hotlist_match_event_id] =
13086 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
13087 event_ids[wmi_extscan_capabilities_event_id] =
13088 WMI_EXTSCAN_CAPABILITIES_EVENTID;
13089 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
13090 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
13091
13092 /* mDNS offload events */
13093 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
13094
13095 /* SAP Authentication offload events */
13096 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
13097 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
13098
13099 /** Out-of-context-of-bss (OCB) events */
13100 event_ids[wmi_ocb_set_config_resp_event_id] =
13101 WMI_OCB_SET_CONFIG_RESP_EVENTID;
13102 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
13103 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
13104 event_ids[wmi_dcc_get_stats_resp_event_id] =
13105 WMI_DCC_GET_STATS_RESP_EVENTID;
13106 event_ids[wmi_dcc_update_ndl_resp_event_id] =
13107 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
13108 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
13109 /* System-On-Chip events */
13110 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
13111 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
13112 event_ids[wmi_soc_hw_mode_transition_event_id] =
13113 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
13114 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
13115 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
13116}
13117
13118/**
13119 * populate_pdev_param_tlv() - populates pdev params
13120 *
13121 * @param pdev_param: Pointer to hold pdev params
13122 * Return: None
13123 */
13124static void populate_pdev_param_tlv(uint32_t *pdev_param)
13125{
13126 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
13127 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
13128 pdev_param[wmi_pdev_param_txpower_limit2g] =
13129 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
13130 pdev_param[wmi_pdev_param_txpower_limit5g] =
13131 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
13132 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
13133 pdev_param[wmi_pdev_param_beacon_gen_mode] =
13134 WMI_PDEV_PARAM_BEACON_GEN_MODE;
13135 pdev_param[wmi_pdev_param_beacon_tx_mode] =
13136 WMI_PDEV_PARAM_BEACON_TX_MODE;
13137 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
13138 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
13139 pdev_param[wmi_pdev_param_protection_mode] =
13140 WMI_PDEV_PARAM_PROTECTION_MODE;
13141 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
13142 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
13143 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
13144 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
13145 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
13146 pdev_param[wmi_pdev_param_sta_kickout_th] =
13147 WMI_PDEV_PARAM_STA_KICKOUT_TH;
13148 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
13149 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
13150 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
13151 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
13152 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
13153 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
13154 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
13155 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
13156 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
13157 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
13158 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
13159 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
13160 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
13161 pdev_param[wmi_pdev_param_ltr_sleep_override] =
13162 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
13163 pdev_param[wmi_pdev_param_ltr_rx_override] =
13164 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
13165 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
13166 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
13167 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
13168 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
13169 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
13170 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
13171 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
13172 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
13173 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
13174 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
13175 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
13176 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
13177 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
13178 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
13179 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
13180 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
13181 pdev_param[wmi_pdev_param_peer_stats_update_period] =
13182 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
13183 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
13184 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
13185 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
13186 pdev_param[wmi_pdev_param_arp_ac_override] =
13187 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
13188 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
13189 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
13190 pdev_param[wmi_pdev_param_ani_poll_period] =
13191 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
13192 pdev_param[wmi_pdev_param_ani_listen_period] =
13193 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
13194 pdev_param[wmi_pdev_param_ani_ofdm_level] =
13195 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
13196 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
13197 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
13198 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
13199 pdev_param[wmi_pdev_param_idle_ps_config] =
13200 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
13201 pdev_param[wmi_pdev_param_power_gating_sleep] =
13202 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
13203 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
13204 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
13205 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
13206 pdev_param[wmi_pdev_param_hw_rfkill_config] =
13207 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
13208 pdev_param[wmi_pdev_param_low_power_rf_enable] =
13209 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
13210 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
13211 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
13212 pdev_param[wmi_pdev_param_power_collapse_enable] =
13213 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
13214 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
13215 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
13216 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
13217 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
13218 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
13219 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
13220 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
13221 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
13222 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
13223 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
13224 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
13225 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
13226 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
13227 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
13228 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
13229 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
13230 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
13231 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
13232 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
13233 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
13234 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
13235 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
13236 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
13237 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
13238 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
13239 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
13240 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
13241 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
13242 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
13243 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
13244 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
13245 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
13246 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
13247 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
13248 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
13249 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
13250 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
13251 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
13252 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
13253 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
13254 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
13255 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
13256 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
13257 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
13258 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
13259 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
13260 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
13261 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
13262 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
13263 WMI_UNAVAILABLE_PARAM;
13264 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
13265 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
13266 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
13267 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
13268 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
13269 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
13270 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
13271 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
13272 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
13273 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
13274 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
13275 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
13276 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
13277 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
13278 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
13279 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
13280 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
13281 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
13282 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
13283 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
13284 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
13285 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
13286 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
13287 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
13288 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
13289 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
13290 WMI_UNAVAILABLE_PARAM;
13291 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
13292 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
13293 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
13294 WMI_UNAVAILABLE_PARAM;
13295 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
13296 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
13297 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
13298 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
13299 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
13300 WMI_UNAVAILABLE_PARAM;
13301 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
13302 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
13303 WMI_UNAVAILABLE_PARAM;
13304 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] = WMI_UNAVAILABLE_PARAM;
13305 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
13306}
13307
13308/**
13309 * populate_vdev_param_tlv() - populates vdev params
13310 *
13311 * @param vdev_param: Pointer to hold vdev params
13312 * Return: None
13313 */
13314static void populate_vdev_param_tlv(uint32_t *vdev_param)
13315{
13316 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
13317 vdev_param[wmi_vdev_param_fragmentation_threshold] =
13318 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
13319 vdev_param[wmi_vdev_param_beacon_interval] =
13320 WMI_VDEV_PARAM_BEACON_INTERVAL;
13321 vdev_param[wmi_vdev_param_listen_interval] =
13322 WMI_VDEV_PARAM_LISTEN_INTERVAL;
13323 vdev_param[wmi_vdev_param_multicast_rate] =
13324 WMI_VDEV_PARAM_MULTICAST_RATE;
13325 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
13326 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
13327 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
13328 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
13329 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
13330 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
13331 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
13332 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
13333 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
13334 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
13335 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
13336 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
13337 vdev_param[wmi_vdev_param_bmiss_count_max] =
13338 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
13339 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
13340 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
13341 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
13342 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
13343 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
13344 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
13345 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
13346 vdev_param[wmi_vdev_param_disable_htprotection] =
13347 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
13348 vdev_param[wmi_vdev_param_sta_quickkickout] =
13349 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
13350 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
13351 vdev_param[wmi_vdev_param_protection_mode] =
13352 WMI_VDEV_PARAM_PROTECTION_MODE;
13353 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
13354 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
13355 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
13356 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
13357 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
13358 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
13359 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
13360 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
13361 vdev_param[wmi_vdev_param_bcast_data_rate] =
13362 WMI_VDEV_PARAM_BCAST_DATA_RATE;
13363 vdev_param[wmi_vdev_param_mcast_data_rate] =
13364 WMI_VDEV_PARAM_MCAST_DATA_RATE;
13365 vdev_param[wmi_vdev_param_mcast_indicate] =
13366 WMI_VDEV_PARAM_MCAST_INDICATE;
13367 vdev_param[wmi_vdev_param_dhcp_indicate] =
13368 WMI_VDEV_PARAM_DHCP_INDICATE;
13369 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
13370 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
13371 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
13372 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
13373 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
13374 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
13375 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
13376 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
13377 vdev_param[wmi_vdev_param_ap_enable_nawds] =
13378 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
13379 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
13380 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
13381 vdev_param[wmi_vdev_param_packet_powersave] =
13382 WMI_VDEV_PARAM_PACKET_POWERSAVE;
13383 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
13384 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
13385 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
13386 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
13387 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
13388 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
13389 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
13390 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
13391 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
13392 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
13393 vdev_param[wmi_vdev_param_early_rx_slop_step] =
13394 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
13395 vdev_param[wmi_vdev_param_early_rx_init_slop] =
13396 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
13397 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
13398 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
13399 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
13400 vdev_param[wmi_vdev_param_snr_num_for_cal] =
13401 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
13402 vdev_param[wmi_vdev_param_roam_fw_offload] =
13403 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
13404 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
13405 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
13406 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
13407 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
13408 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
13409 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
13410 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
13411 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
13412 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
13413 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
13414 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
13415 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
13416 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
13417 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
13418 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
13419 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
13420 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
13421 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
13422 vdev_param[wmi_vdev_param_inactivity_cnt] =
13423 WMI_VDEV_PARAM_INACTIVITY_CNT;
13424 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
13425 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
13426 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
13427 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
13428 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
13429 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
13430 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
13431 vdev_param[wmi_vdev_param_rx_leak_window] =
13432 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
13433 vdev_param[wmi_vdev_param_stats_avg_factor] =
13434 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
13435 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
13436 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
13437 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
13438 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
13439 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
13440 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
13441}
13442#endif
13443
Govind Singh5eb51532016-03-09 11:34:12 +053013444/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013445 * wmi_tlv_attach() - Attach TLV APIs
Govind Singh5eb51532016-03-09 11:34:12 +053013446 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013447 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053013448 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013449#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013450void wmi_tlv_attach(wmi_unified_t wmi_handle)
13451{
13452 wmi_handle->ops = &tlv_ops;
13453#ifdef WMI_INTERFACE_EVENT_LOGGING
13454 wmi_handle->log_info.buf_offset_command = 2;
13455 wmi_handle->log_info.buf_offset_event = 4;
13456 wmi_handle->log_info.is_management_record =
13457 is_management_record_tlv;
13458#endif
13459 populate_tlv_service(wmi_handle->services);
13460 populate_tlv_events_id(wmi_handle->wmi_events);
13461 populate_pdev_param_tlv(wmi_handle->pdev_param);
13462 populate_vdev_param_tlv(wmi_handle->vdev_param);
13463}
13464#else
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013465void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053013466{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053013467 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053013468#ifdef WMI_INTERFACE_EVENT_LOGGING
13469 wmi_handle->log_info.buf_offset_command = 2;
13470 wmi_handle->log_info.buf_offset_event = 4;
13471 wmi_handle->log_info.is_management_record =
13472 is_management_record_tlv;
13473#endif
Govind Singh5eb51532016-03-09 11:34:12 +053013474}
Govind Singhe7f2f342016-05-23 12:12:52 +053013475#endif