blob: 3aee76e849abfbaadfb33a2d9143ce779e0fdee2 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Paul Zhangd19abd82017-01-04 16:45:42 +08002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
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) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530258 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530259 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
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800502 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530503 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530504 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530505 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530506 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530507 }
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;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530589 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
590 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
591 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530592 default:
593 return QDF_STATUS_E_NOSUPPORT;
594 }
595
596 return QDF_STATUS_SUCCESS;
597}
598#endif
599/**
Govind Singh5eb51532016-03-09 11:34:12 +0530600 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530601 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530602 * @peer_addr: peer mac address
603 * @param : pointer to hold peer set parameter
604 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530605 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530606 */
Govind Singhb53420c2016-03-09 14:32:57 +0530607QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530608 uint8_t peer_addr[IEEE80211_ADDR_LEN],
609 struct peer_set_params *param)
610{
611 wmi_peer_set_param_cmd_fixed_param *cmd;
612 wmi_buf_t buf;
613 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530614 uint32_t param_id;
615
616 if (convert_host_peer_id_to_target_id_tlv(&param_id,
617 param->param_id) != QDF_STATUS_SUCCESS)
618 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530619
620 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
621 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530622 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530623 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530624 }
625 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
626 WMITLV_SET_HDR(&cmd->tlv_header,
627 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
628 WMITLV_GET_STRUCT_TLVLEN
629 (wmi_peer_set_param_cmd_fixed_param));
630 cmd->vdev_id = param->vdev_id;
631 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530632 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530633 cmd->param_value = param->param_value;
634 err = wmi_unified_cmd_send(wmi, buf,
635 sizeof(wmi_peer_set_param_cmd_fixed_param),
636 WMI_PEER_SET_PARAM_CMDID);
637 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530638 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530639 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530640 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530641 }
642
643 return 0;
644}
645
646/**
647 * send_vdev_up_cmd_tlv() - send vdev up command in fw
648 * @wmi: wmi handle
649 * @bssid: bssid
650 * @vdev_up_params: pointer to hold vdev up parameter
651 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530652 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530653 */
Govind Singhb53420c2016-03-09 14:32:57 +0530654QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530655 uint8_t bssid[IEEE80211_ADDR_LEN],
656 struct vdev_up_params *params)
657{
658 wmi_vdev_up_cmd_fixed_param *cmd;
659 wmi_buf_t buf;
660 int32_t len = sizeof(*cmd);
661
Govind Singhb53420c2016-03-09 14:32:57 +0530662 WMI_LOGD("%s: VDEV_UP", __func__);
663 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530664 params->vdev_id, params->assoc_id, bssid);
665 buf = wmi_buf_alloc(wmi, len);
666 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530667 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530668 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530669 }
670 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
671 WMITLV_SET_HDR(&cmd->tlv_header,
672 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
673 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
674 cmd->vdev_id = params->vdev_id;
675 cmd->vdev_assoc_id = params->assoc_id;
676 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
677 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530678 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530679 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530680 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530681 }
682
683 return 0;
684}
685
686/**
687 * send_peer_create_cmd_tlv() - send peer create command to fw
688 * @wmi: wmi handle
689 * @peer_addr: peer mac address
690 * @peer_type: peer type
691 * @vdev_id: vdev id
692 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530693 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530694 */
Govind Singhb53420c2016-03-09 14:32:57 +0530695QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530696 struct peer_create_params *param)
697{
698 wmi_peer_create_cmd_fixed_param *cmd;
699 wmi_buf_t buf;
700 int32_t len = sizeof(*cmd);
701
702 buf = wmi_buf_alloc(wmi, len);
703 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530704 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530705 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530706 }
707 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
708 WMITLV_SET_HDR(&cmd->tlv_header,
709 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
710 WMITLV_GET_STRUCT_TLVLEN
711 (wmi_peer_create_cmd_fixed_param));
712 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
713 cmd->peer_type = param->peer_type;
714 cmd->vdev_id = param->vdev_id;
715
716 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530717 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530718 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530719 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530720 }
Govind Singhb53420c2016-03-09 14:32:57 +0530721 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530722 param->vdev_id);
723
724 return 0;
725}
726
727/**
Leo Changeee40872016-09-28 13:43:36 -0700728 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
729 * command to fw
730 * @wmi: wmi handle
731 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
732 *
733 * Return: 0 for success or error code
734 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700735static
Leo Changeee40872016-09-28 13:43:36 -0700736QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
737 struct rx_reorder_queue_setup_params *param)
738{
739 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
740 wmi_buf_t buf;
741 int32_t len = sizeof(*cmd);
742
743 buf = wmi_buf_alloc(wmi, len);
744 if (!buf) {
745 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
746 return QDF_STATUS_E_NOMEM;
747 }
748 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
749 WMITLV_SET_HDR(&cmd->tlv_header,
750 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
751 WMITLV_GET_STRUCT_TLVLEN
752 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
753 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
754 cmd->vdev_id = param->vdev_id;
755 cmd->tid = param->tid;
756 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
757 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
758 cmd->queue_no = param->queue_no;
759
760 if (wmi_unified_cmd_send(wmi, buf, len,
761 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
762 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
763 __func__);
764 qdf_nbuf_free(buf);
765 return QDF_STATUS_E_FAILURE;
766 }
767 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
768 param->peer_macaddr, param->vdev_id, param->tid);
769
770 return QDF_STATUS_SUCCESS;
771}
772
773/**
774 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
775 * command to fw
776 * @wmi: wmi handle
777 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
778 *
779 * Return: 0 for success or error code
780 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700781static
Leo Changeee40872016-09-28 13:43:36 -0700782QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
783 struct rx_reorder_queue_remove_params *param)
784{
785 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
786 wmi_buf_t buf;
787 int32_t len = sizeof(*cmd);
788
789 buf = wmi_buf_alloc(wmi, len);
790 if (!buf) {
791 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
792 return QDF_STATUS_E_NOMEM;
793 }
794 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
795 wmi_buf_data(buf);
796 WMITLV_SET_HDR(&cmd->tlv_header,
797 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
798 WMITLV_GET_STRUCT_TLVLEN
799 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
800 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
801 cmd->vdev_id = param->vdev_id;
802 cmd->tid_mask = param->peer_tid_bitmap;
803
804 if (wmi_unified_cmd_send(wmi, buf, len,
805 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
806 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
807 __func__);
808 qdf_nbuf_free(buf);
809 return QDF_STATUS_E_FAILURE;
810 }
811 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
812 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
813
814 return QDF_STATUS_SUCCESS;
815}
816
817/**
Govind Singh5eb51532016-03-09 11:34:12 +0530818 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
819 * @wmi_handle: wmi handle
820 * @value: value
821 * @mac_id: mac id to have radio context
822 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530823 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530824 */
Govind Singhb53420c2016-03-09 14:32:57 +0530825QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530826 uint32_t value, uint8_t mac_id)
827{
828 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
829 wmi_buf_t buf;
830 int32_t len = sizeof(*cmd);
831
Govind Singhb53420c2016-03-09 14:32:57 +0530832 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530833
834 buf = wmi_buf_alloc(wmi_handle, len);
835 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530836 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530837 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530838 }
839
840 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
841 WMITLV_SET_HDR(&cmd->tlv_header,
842 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
843 WMITLV_GET_STRUCT_TLVLEN
844 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530845 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530846 cmd->enable = value;
847
848 if (wmi_unified_cmd_send(wmi_handle, buf, len,
849 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530850 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530851 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530852 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530853 }
854
855 return 0;
856}
857
858/**
859 * send_pdev_utf_cmd_tlv() - send utf command to fw
860 * @wmi_handle: wmi handle
861 * @param: pointer to pdev_utf_params
862 * @mac_id: mac id to have radio context
863 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530864 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530865 */
Govind Singhb53420c2016-03-09 14:32:57 +0530866QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530867send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
868 struct pdev_utf_params *param,
869 uint8_t mac_id)
870{
871 wmi_buf_t buf;
872 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -0700873 /* if param->len is 0 no data is sent, return error */
874 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +0530875 static uint8_t msgref = 1;
876 uint8_t segNumber = 0, segInfo, numSegments;
877 uint16_t chunk_len, total_bytes;
878 uint8_t *bufpos;
879 struct seg_hdr_info segHdrInfo;
880
881 bufpos = param->utf_payload;
882 total_bytes = param->len;
883 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
884 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
885 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
886
887 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
888 numSegments++;
889
890 while (param->len) {
891 if (param->len > MAX_WMI_UTF_LEN)
892 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
893 else
894 chunk_len = param->len;
895
896 buf = wmi_buf_alloc(wmi_handle,
897 (chunk_len + sizeof(segHdrInfo) +
898 WMI_TLV_HDR_SIZE));
899 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530900 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530901 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530902 }
903
904 cmd = (uint8_t *) wmi_buf_data(buf);
905
906 segHdrInfo.len = total_bytes;
907 segHdrInfo.msgref = msgref;
908 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
909 segHdrInfo.segmentInfo = segInfo;
910 segHdrInfo.pad = 0;
911
Govind Singhb53420c2016-03-09 14:32:57 +0530912 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +0530913 " segHdrInfo.segmentInfo = %d",
914 __func__, segHdrInfo.len, segHdrInfo.msgref,
915 segHdrInfo.segmentInfo);
916
Govind Singhb53420c2016-03-09 14:32:57 +0530917 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +0530918 "chunk len %d", __func__, total_bytes, segNumber,
919 numSegments, chunk_len);
920
921 segNumber++;
922
923 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
924 (chunk_len + sizeof(segHdrInfo)));
925 cmd += WMI_TLV_HDR_SIZE;
926 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
927 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
928
929 ret = wmi_unified_cmd_send(wmi_handle, buf,
930 (chunk_len + sizeof(segHdrInfo) +
931 WMI_TLV_HDR_SIZE),
932 WMI_PDEV_UTF_CMDID);
933
Govind Singh67922e82016-04-01 16:48:57 +0530934 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530935 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530936 wmi_buf_free(buf);
937 break;
938 }
939
940 param->len -= chunk_len;
941 bufpos += chunk_len;
942 }
943
944 msgref++;
945
946 return ret;
947}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530948#ifdef CONFIG_MCL
949static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
950 uint32_t host_param)
951{
952 return host_param;
953}
954#else
955static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
956 uint32_t host_param)
957{
958 if (host_param < wmi_pdev_param_max)
959 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +0530960
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530961 return WMI_UNAVAILABLE_PARAM;
962}
963#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530964/**
965 * send_pdev_param_cmd_tlv() - set pdev parameters
966 * @wmi_handle: wmi handle
967 * @param: pointer to pdev parameter
968 * @mac_id: radio context
969 *
970 * Return: 0 on success, errno on failure
971 */
Govind Singhb53420c2016-03-09 14:32:57 +0530972QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530973send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
974 struct pdev_params *param,
975 uint8_t mac_id)
976{
Govind Singh67922e82016-04-01 16:48:57 +0530977 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530978 wmi_pdev_set_param_cmd_fixed_param *cmd;
979 wmi_buf_t buf;
980 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530981 uint32_t pdev_param;
982
983 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
984 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
985 WMI_LOGW("%s: Unavailable param %d\n",
986 __func__, param->param_id);
987 return QDF_STATUS_E_INVAL;
988 }
Govind Singh5eb51532016-03-09 11:34:12 +0530989
990 buf = wmi_buf_alloc(wmi_handle, len);
991 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530992 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530993 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530994 }
995 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
996 WMITLV_SET_HDR(&cmd->tlv_header,
997 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
998 WMITLV_GET_STRUCT_TLVLEN
999 (wmi_pdev_set_param_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +05301000 cmd->pdev_id = 0;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301001 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301002 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301003 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301004 param->param_value);
1005 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1006 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301007 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301008 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301009 wmi_buf_free(buf);
1010 }
1011 return ret;
1012}
1013
1014/**
1015 * send_suspend_cmd_tlv() - WMI suspend function
1016 * @param wmi_handle : handle to WMI.
1017 * @param param : pointer to hold suspend parameter
1018 * @mac_id: radio context
1019 *
1020 * Return 0 on success and -ve on failure.
1021 */
Govind Singhb53420c2016-03-09 14:32:57 +05301022QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301023 struct suspend_params *param,
1024 uint8_t mac_id)
1025{
1026 wmi_pdev_suspend_cmd_fixed_param *cmd;
1027 wmi_buf_t wmibuf;
1028 uint32_t len = sizeof(*cmd);
1029 int32_t ret;
1030
1031 /*
1032 * send the comand to Target to ignore the
1033 * PCIE reset so as to ensure that Host and target
1034 * states are in sync
1035 */
1036 wmibuf = wmi_buf_alloc(wmi_handle, len);
1037 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301038 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301039
1040 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1041 WMITLV_SET_HDR(&cmd->tlv_header,
1042 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1043 WMITLV_GET_STRUCT_TLVLEN
1044 (wmi_pdev_suspend_cmd_fixed_param));
1045 if (param->disable_target_intr)
1046 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1047 else
1048 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1049 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1050 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301051 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301052 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301053 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301054 }
1055
1056 return ret;
1057}
1058
1059/**
1060 * send_resume_cmd_tlv() - WMI resume function
1061 * @param wmi_handle : handle to WMI.
1062 * @mac_id: radio context
1063 *
1064 * Return: 0 on success and -ve on failure.
1065 */
Govind Singhb53420c2016-03-09 14:32:57 +05301066QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301067 uint8_t mac_id)
1068{
1069 wmi_buf_t wmibuf;
1070 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301071 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301072
1073 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1074 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301075 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301076 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1077 WMITLV_SET_HDR(&cmd->tlv_header,
1078 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1079 WMITLV_GET_STRUCT_TLVLEN
1080 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07001081 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +05301082 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1083 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301084 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301085 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301086 wmi_buf_free(wmibuf);
1087 }
1088
1089 return ret;
1090}
1091
1092/**
1093 * send_wow_enable_cmd_tlv() - WMI wow enable function
1094 * @param wmi_handle : handle to WMI.
1095 * @param param : pointer to hold wow enable parameter
1096 * @mac_id: radio context
1097 *
1098 * Return: 0 on success and -ve on failure.
1099 */
Govind Singhb53420c2016-03-09 14:32:57 +05301100QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301101 struct wow_cmd_params *param,
1102 uint8_t mac_id)
1103{
1104 wmi_wow_enable_cmd_fixed_param *cmd;
1105 wmi_buf_t buf;
1106 int32_t len;
1107 int32_t ret;
1108
1109 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1110
1111 buf = wmi_buf_alloc(wmi_handle, len);
1112 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301113 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1114 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301115 }
1116 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1117 WMITLV_SET_HDR(&cmd->tlv_header,
1118 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1119 WMITLV_GET_STRUCT_TLVLEN
1120 (wmi_wow_enable_cmd_fixed_param));
1121 cmd->enable = param->enable;
1122 if (param->can_suspend_link)
1123 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1124 else
1125 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001126 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301127
Govind Singhb53420c2016-03-09 14:32:57 +05301128 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301129 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1130 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1131
1132 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1133 WMI_WOW_ENABLE_CMDID);
1134 if (ret)
1135 wmi_buf_free(buf);
1136
1137 return ret;
1138}
1139
1140/**
1141 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301142 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301143 * @peer_addr: peer mac address
1144 * @param: pointer to ap_ps parameter structure
1145 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301146 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301147 */
Govind Singhb53420c2016-03-09 14:32:57 +05301148QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301149 uint8_t *peer_addr,
1150 struct ap_ps_params *param)
1151{
1152 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1153 wmi_buf_t buf;
1154 int32_t err;
1155
1156 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1157 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301158 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301159 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301160 }
1161 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1162 WMITLV_SET_HDR(&cmd->tlv_header,
1163 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1164 WMITLV_GET_STRUCT_TLVLEN
1165 (wmi_ap_ps_peer_cmd_fixed_param));
1166 cmd->vdev_id = param->vdev_id;
1167 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1168 cmd->param = param->param;
1169 cmd->value = param->value;
1170 err = wmi_unified_cmd_send(wmi_handle, buf,
1171 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1172 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301173 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301174 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301175 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301176 }
1177
1178 return 0;
1179}
1180
1181/**
1182 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301183 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301184 * @peer_addr: peer mac address
1185 * @param: pointer to sta_ps parameter structure
1186 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301187 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301188 */
Govind Singhb53420c2016-03-09 14:32:57 +05301189QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301190 struct sta_ps_params *param)
1191{
1192 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1193 wmi_buf_t buf;
1194 int32_t len = sizeof(*cmd);
1195
1196 buf = wmi_buf_alloc(wmi_handle, len);
1197 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301198 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301199 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301200 }
1201
1202 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1203 WMITLV_SET_HDR(&cmd->tlv_header,
1204 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1205 WMITLV_GET_STRUCT_TLVLEN
1206 (wmi_sta_powersave_param_cmd_fixed_param));
1207 cmd->vdev_id = param->vdev_id;
1208 cmd->param = param->param;
1209 cmd->value = param->value;
1210
1211 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1212 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301213 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301214 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301215 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301216 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301217 }
1218
1219 return 0;
1220}
1221
1222/**
1223 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301224 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301225 * @param: ponirt to crash inject paramter structure
1226 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301227 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301228 */
Govind Singhb53420c2016-03-09 14:32:57 +05301229QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301230 struct crash_inject *param)
1231{
1232 int32_t ret = 0;
1233 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1234 uint16_t len = sizeof(*cmd);
1235 wmi_buf_t buf;
1236
1237 buf = wmi_buf_alloc(wmi_handle, len);
1238 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301239 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301240 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301241 }
1242
1243 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1244 WMITLV_SET_HDR(&cmd->tlv_header,
1245 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1246 WMITLV_GET_STRUCT_TLVLEN
1247 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1248 cmd->type = param->type;
1249 cmd->delay_time_ms = param->delay_time_ms;
1250
1251 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1252 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301253 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301254 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301255 __func__, ret);
1256 wmi_buf_free(buf);
1257 }
1258
1259 return ret;
1260}
1261
1262/**
1263 * send_dbglog_cmd_tlv() - set debug log level
1264 * @param wmi_handle : handle to WMI.
1265 * @param param : pointer to hold dbglog level parameter
1266 *
1267 * Return: 0 on success and -ve on failure.
1268 */
Govind Singhb53420c2016-03-09 14:32:57 +05301269QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301270send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1271 struct dbglog_params *dbglog_param)
1272{
1273 wmi_buf_t buf;
1274 wmi_debug_log_config_cmd_fixed_param *configmsg;
1275 A_STATUS status = A_OK;
1276 int32_t i;
1277 int32_t len;
1278 int8_t *buf_ptr;
1279 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1280
1281 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1282
1283 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1284 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1285 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1286 buf = wmi_buf_alloc(wmi_handle, len);
1287 if (buf == NULL)
1288 return A_NO_MEMORY;
1289
1290 configmsg =
1291 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1292 buf_ptr = (int8_t *) configmsg;
1293 WMITLV_SET_HDR(&configmsg->tlv_header,
1294 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1295 WMITLV_GET_STRUCT_TLVLEN
1296 (wmi_debug_log_config_cmd_fixed_param));
1297 configmsg->dbg_log_param = dbglog_param->param;
1298 configmsg->value = dbglog_param->val;
1299 /* Filling in the data part of second tlv -- should
1300 * follow first tlv _ WMI_TLV_HDR_SIZE */
1301 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1302 sizeof
1303 (wmi_debug_log_config_cmd_fixed_param)
1304 + WMI_TLV_HDR_SIZE);
1305 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1306 WMITLV_TAG_ARRAY_UINT32,
1307 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1308 if (dbglog_param->module_id_bitmap) {
1309 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1310 module_id_bitmap_array[i] =
1311 dbglog_param->module_id_bitmap[i];
1312 }
1313 }
1314
1315 status = wmi_unified_cmd_send(wmi_handle, buf,
1316 len, WMI_DBGLOG_CFG_CMDID);
1317
1318 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301319 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301320
1321 return status;
1322}
1323
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301324#ifdef CONFIG_MCL
1325static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1326 uint32_t host_param)
1327{
1328 return host_param;
1329}
1330#else
1331static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1332 uint32_t host_param)
1333{
1334 if (host_param < wmi_vdev_param_max)
1335 return wmi_handle->vdev_param[host_param];
1336
1337 return WMI_UNAVAILABLE_PARAM;
1338}
1339#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301340/**
1341 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1342 * @param wmi_handle : handle to WMI.
1343 * @param macaddr : MAC address
1344 * @param param : pointer to hold vdev set parameter
1345 *
1346 * Return: 0 on success and -ve on failure.
1347 */
Govind Singhb53420c2016-03-09 14:32:57 +05301348QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301349 struct vdev_set_params *param)
1350{
Govind Singh67922e82016-04-01 16:48:57 +05301351 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301352 wmi_vdev_set_param_cmd_fixed_param *cmd;
1353 wmi_buf_t buf;
1354 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301355 uint32_t vdev_param;
1356
1357 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1358 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1359 WMI_LOGW("%s:Vdev param %d not available", __func__,
1360 param->param_id);
1361 return QDF_STATUS_E_INVAL;
1362
1363 }
Govind Singh5eb51532016-03-09 11:34:12 +05301364
1365 buf = wmi_buf_alloc(wmi_handle, len);
1366 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301367 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301368 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301369 }
1370 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1371 WMITLV_SET_HDR(&cmd->tlv_header,
1372 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1373 WMITLV_GET_STRUCT_TLVLEN
1374 (wmi_vdev_set_param_cmd_fixed_param));
1375 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301376 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301377 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301378 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301379 param->if_id, param->param_id, param->param_value);
1380 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1381 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301382 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301383 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301384 wmi_buf_free(buf);
1385 }
1386
1387 return ret;
1388}
1389
1390/**
1391 * send_stats_request_cmd_tlv() - WMI request stats function
1392 * @param wmi_handle : handle to WMI.
1393 * @param macaddr : MAC address
1394 * @param param : pointer to hold stats request parameter
1395 *
1396 * Return: 0 on success and -ve on failure.
1397 */
Govind Singhb53420c2016-03-09 14:32:57 +05301398QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301399 uint8_t macaddr[IEEE80211_ADDR_LEN],
1400 struct stats_request_params *param)
1401{
Govind Singhd3156eb2016-02-26 17:50:39 +05301402 int32_t ret;
1403 wmi_request_stats_cmd_fixed_param *cmd;
1404 wmi_buf_t buf;
1405 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1406
1407 buf = wmi_buf_alloc(wmi_handle, len);
1408 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301409 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1410 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301411 }
1412
1413 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1414 WMITLV_SET_HDR(&cmd->tlv_header,
1415 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1416 WMITLV_GET_STRUCT_TLVLEN
1417 (wmi_request_stats_cmd_fixed_param));
1418 cmd->stats_id = param->stats_id;
1419 cmd->vdev_id = param->vdev_id;
1420 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1421 WMI_REQUEST_STATS_CMDID);
1422 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301423 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301424 wmi_buf_free(buf);
1425 }
1426
1427 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301428}
1429
Govind Singh87542482016-06-08 19:40:11 +05301430#ifdef CONFIG_WIN
1431/**
1432 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1433 * @param wmi_handle : handle to WMI.
1434 * @param macaddr : MAC address
1435 * @param param : pointer to hold stats request parameter
1436 *
1437 * Return: 0 on success and -ve on failure.
1438 */
1439QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
1440 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1441{
1442 return 0;
1443}
1444#else
Govind Singh5eb51532016-03-09 11:34:12 +05301445/**
1446 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1447 * @param wmi_handle : handle to WMI.
1448 * @param macaddr : MAC address
1449 * @param param : pointer to hold stats request parameter
1450 *
1451 * Return: 0 on success and -ve on failure.
1452 */
Govind Singhb53420c2016-03-09 14:32:57 +05301453QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301454 uint8_t macaddr[IEEE80211_ADDR_LEN],
1455 struct packet_enable_params *param)
1456{
1457 return 0;
1458}
Govind Singh87542482016-06-08 19:40:11 +05301459#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301460
Govind Singh87542482016-06-08 19:40:11 +05301461#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301462/**
1463 * send_beacon_send_cmd_tlv() - WMI beacon send function
1464 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301465 * @param param : pointer to hold beacon send cmd parameter
1466 *
1467 * Return: 0 on success and -ve on failure.
1468 */
Govind Singhb53420c2016-03-09 14:32:57 +05301469QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301470 struct beacon_params *param)
1471{
Govind Singhd3156eb2016-02-26 17:50:39 +05301472 int32_t ret;
1473 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1474 wmi_bcn_prb_info *bcn_prb_info;
1475 wmi_buf_t wmi_buf;
1476 uint8_t *buf_ptr;
1477 uint32_t wmi_buf_len;
1478
1479 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1480 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1481 param->tmpl_len_aligned;
1482 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1483 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301484 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301485 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301486 }
1487 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1488 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1489 WMITLV_SET_HDR(&cmd->tlv_header,
1490 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1491 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1492 cmd->vdev_id = param->vdev_id;
1493 cmd->tim_ie_offset = param->tim_ie_offset;
1494 cmd->buf_len = param->tmpl_len;
1495 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1496
1497 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1498 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1499 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1500 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1501 bcn_prb_info->caps = 0;
1502 bcn_prb_info->erp = 0;
1503 buf_ptr += sizeof(wmi_bcn_prb_info);
1504
1505 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1506 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301507 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301508
1509 ret = wmi_unified_cmd_send(wmi_handle,
1510 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1511 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301512 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301513 wmi_buf_free(wmi_buf);
1514 }
Govind Singh5eb51532016-03-09 11:34:12 +05301515 return 0;
1516}
Govind Singh87542482016-06-08 19:40:11 +05301517#else
1518QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
1519 struct beacon_params *param)
1520{
1521 return 0;
1522}
1523
1524/**
1525 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1526 * @param wmi_handle : handle to WMI.
1527 * @param param : pointer to hold beacon send cmd parameter
1528 *
1529 * Return: 0 on success and -ve on failure.
1530 */
1531QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
1532 struct beacon_tmpl_params *param)
1533{
1534 int32_t ret;
1535 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1536 wmi_bcn_prb_info *bcn_prb_info;
1537 wmi_buf_t wmi_buf;
1538 uint8_t *buf_ptr;
1539 uint32_t wmi_buf_len;
1540
1541 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1542 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1543 param->tmpl_len_aligned;
1544 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1545 if (!wmi_buf) {
1546 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1547 return QDF_STATUS_E_NOMEM;
1548 }
1549 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1550 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1551 WMITLV_SET_HDR(&cmd->tlv_header,
1552 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1553 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1554 cmd->vdev_id = param->vdev_id;
1555 cmd->tim_ie_offset = param->tim_ie_offset;
1556 cmd->buf_len = param->tmpl_len;
1557 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1558
1559 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1560 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1561 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1562 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1563 bcn_prb_info->caps = 0;
1564 bcn_prb_info->erp = 0;
1565 buf_ptr += sizeof(wmi_bcn_prb_info);
1566
1567 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1568 buf_ptr += WMI_TLV_HDR_SIZE;
1569 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1570
1571 ret = wmi_unified_cmd_send(wmi_handle,
1572 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1573 if (ret) {
1574 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1575 wmi_buf_free(wmi_buf);
1576 }
1577 return 0;
1578}
1579#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301580
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301581#ifdef CONFIG_MCL
1582static inline void copy_peer_flags_tlv(
1583 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1584 struct peer_assoc_params *param)
1585{
1586 cmd->peer_flags = param->peer_flags;
1587}
1588#else
1589static inline void copy_peer_flags_tlv(
1590 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1591 struct peer_assoc_params *param)
1592{
1593 /*
1594 * The target only needs a subset of the flags maintained in the host.
1595 * Just populate those flags and send it down
1596 */
1597 cmd->peer_flags = 0;
1598
1599 /*
1600 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1601 */
1602 if (param->is_wme_set) {
1603
1604 if (param->qos_flag)
1605 cmd->peer_flags |= WMI_PEER_QOS;
1606 if (param->apsd_flag)
1607 cmd->peer_flags |= WMI_PEER_APSD;
1608 if (param->ht_flag)
1609 cmd->peer_flags |= WMI_PEER_HT;
1610 if (param->bw_40)
1611 cmd->peer_flags |= WMI_PEER_40MHZ;
1612 if (param->bw_80)
1613 cmd->peer_flags |= WMI_PEER_80MHZ;
1614 if (param->bw_160)
1615 cmd->peer_flags |= WMI_PEER_160MHZ;
1616
1617 /* Typically if STBC is enabled for VHT it should be enabled
1618 * for HT as well
1619 **/
1620 if (param->stbc_flag)
1621 cmd->peer_flags |= WMI_PEER_STBC;
1622
1623 /* Typically if LDPC is enabled for VHT it should be enabled
1624 * for HT as well
1625 **/
1626 if (param->ldpc_flag)
1627 cmd->peer_flags |= WMI_PEER_LDPC;
1628
1629 if (param->static_mimops_flag)
1630 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1631 if (param->dynamic_mimops_flag)
1632 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1633 if (param->spatial_mux_flag)
1634 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1635 if (param->vht_flag)
1636 cmd->peer_flags |= WMI_PEER_VHT;
1637 }
1638 /*
1639 * Suppress authorization for all AUTH modes that need 4-way handshake
1640 * (during re-association).
1641 * Authorization will be done for these modes on key installation.
1642 */
1643 if (param->auth_flag)
1644 cmd->peer_flags |= WMI_PEER_AUTH;
1645 if (param->need_ptk_4_way)
1646 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1647 else
1648 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1649 if (param->need_gtk_2_way)
1650 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1651 /* safe mode bypass the 4-way handshake */
1652 if (param->safe_mode_enabled)
1653 cmd->peer_flags &=
1654 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1655 /* Disable AMSDU for station transmit, if user configures it */
1656 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1657 * it
1658 * if (param->amsdu_disable) Add after FW support
1659 **/
1660
1661 /* Target asserts if node is marked HT and all MCS is set to 0.
1662 * Mark the node as non-HT if all the mcs rates are disabled through
1663 * iwpriv
1664 **/
1665 if (param->peer_ht_rates.num_rates == 0)
1666 cmd->peer_flags &= ~WMI_PEER_HT;
1667}
1668#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301669
1670#ifdef CONFIG_MCL
1671static inline void copy_peer_mac_addr_tlv(
1672 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1673 struct peer_assoc_params *param)
1674{
1675 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1676 sizeof(param->peer_macaddr));
1677}
1678#else
1679static inline void copy_peer_mac_addr_tlv(
1680 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1681 struct peer_assoc_params *param)
1682{
1683 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1684}
1685#endif
1686
Govind Singh5eb51532016-03-09 11:34:12 +05301687/**
1688 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1689 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301690 * @param param : pointer to peer assoc parameter
1691 *
1692 * Return: 0 on success and -ve on failure.
1693 */
Govind Singhb53420c2016-03-09 14:32:57 +05301694QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301695 struct peer_assoc_params *param)
1696{
Govind Singhd3156eb2016-02-26 17:50:39 +05301697 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1698 wmi_vht_rate_set *mcs;
1699 wmi_buf_t buf;
1700 int32_t len;
1701 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301702 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301703 uint32_t peer_legacy_rates_align;
1704 uint32_t peer_ht_rates_align;
1705
1706
1707 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1708 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301709
1710 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301711 (peer_legacy_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301712 WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301713 (peer_ht_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301714 sizeof(wmi_vht_rate_set);
1715
1716 buf = wmi_buf_alloc(wmi_handle, len);
1717 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301718 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301719 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301720 }
1721
1722 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1723 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1724 WMITLV_SET_HDR(&cmd->tlv_header,
1725 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1726 WMITLV_GET_STRUCT_TLVLEN
1727 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301728
Govind Singhd3156eb2016-02-26 17:50:39 +05301729 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301730
Govind Singhd3156eb2016-02-26 17:50:39 +05301731 cmd->peer_new_assoc = param->peer_new_assoc;
1732 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301733
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301734 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301735 copy_peer_mac_addr_tlv(cmd, param);
1736
Govind Singhd3156eb2016-02-26 17:50:39 +05301737 cmd->peer_rate_caps = param->peer_rate_caps;
1738 cmd->peer_caps = param->peer_caps;
1739 cmd->peer_listen_intval = param->peer_listen_intval;
1740 cmd->peer_ht_caps = param->peer_ht_caps;
1741 cmd->peer_max_mpdu = param->peer_max_mpdu;
1742 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301743 cmd->peer_vht_caps = param->peer_vht_caps;
1744 cmd->peer_phymode = param->peer_phymode;
1745
1746 /* Update peer legacy rate information */
1747 buf_ptr += sizeof(*cmd);
1748 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301749 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301750 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301751 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301752 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301753 param->peer_legacy_rates.num_rates);
1754
1755 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001756 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301757 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301758 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301759 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301760 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301761 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301762 param->peer_ht_rates.num_rates);
1763
1764 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001765 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301766 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1767 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1768
1769 cmd->peer_nss = param->peer_nss;
1770 mcs = (wmi_vht_rate_set *) buf_ptr;
1771 if (param->vht_capable) {
1772 mcs->rx_max_rate = param->rx_max_rate;
1773 mcs->rx_mcs_set = param->rx_mcs_set;
1774 mcs->tx_max_rate = param->tx_max_rate;
1775 mcs->tx_mcs_set = param->tx_mcs_set;
1776 }
1777
Govind Singhb53420c2016-03-09 14:32:57 +05301778 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301779 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1780 "nss %d phymode %d peer_mpdu_density %d "
1781 "cmd->peer_vht_caps %x", __func__,
1782 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1783 cmd->peer_rate_caps, cmd->peer_caps,
1784 cmd->peer_listen_intval, cmd->peer_ht_caps,
1785 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1786 cmd->peer_mpdu_density,
1787 cmd->peer_vht_caps);
1788
1789 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1790 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301791 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301792 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301793 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301794 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301795 }
1796
1797 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301798}
1799
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301800/* copy_scan_notify_events() - Helper routine to copy scan notify events
1801 */
1802#ifdef CONFIG_MCL
1803static inline void copy_scan_notify_ev_flags(
1804 wmi_start_scan_cmd_fixed_param * cmd,
1805 struct scan_start_params *params)
1806{
1807 cmd->notify_scan_events = params->notify_scan_events;
1808 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1809}
1810#else
1811static inline void copy_scan_notify_ev_flags(
1812 wmi_start_scan_cmd_fixed_param * cmd,
1813 struct scan_start_params *params)
1814{
1815 cmd->notify_scan_events = WMI_SCAN_EVENT_STARTED |
1816 WMI_SCAN_EVENT_COMPLETED |
1817 WMI_SCAN_EVENT_BSS_CHANNEL |
1818 WMI_SCAN_EVENT_FOREIGN_CHANNEL |
1819 WMI_SCAN_EVENT_DEQUEUED
1820 ;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301821
1822 cmd->scan_ctrl_flags = (params->passive_flag) ?
1823 WMI_SCAN_FLAG_PASSIVE : 0;
1824
1825 if (params->is_strict_pscan_en)
1826 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301827
1828 if (params->is_phy_error)
1829 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301830
1831 if (params->half_rate)
1832 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
1833
1834 if (params->quarter_rate)
1835 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
1836
1837 if (params->is_phy_error)
1838 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
1839
1840 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
1841 /* add cck rates if required */
1842 if (params->add_cck_rates)
1843 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
1844 /** It enables the Channel stat event indication to host */
1845 if (params->chan_stat_enable)
1846 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
1847 if (params->add_bcast_probe_reqd)
1848 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
1849 /* off channel TX control */
1850 if (params->offchan_tx_mgmt)
1851 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
1852 if (params->offchan_tx_data)
1853 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301854}
1855#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301856/**
1857 * send_scan_start_cmd_tlv() - WMI scan start function
1858 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301859 * @param param : pointer to hold scan start cmd parameter
1860 *
1861 * Return: 0 on success and -ve on failure.
1862 */
Govind Singhb53420c2016-03-09 14:32:57 +05301863QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301864 struct scan_start_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05301865{
Govind Singhd3156eb2016-02-26 17:50:39 +05301866 int32_t ret = 0;
1867 int32_t i;
1868 wmi_buf_t wmi_buf;
1869 wmi_start_scan_cmd_fixed_param *cmd;
1870 uint8_t *buf_ptr;
1871 uint32_t *tmp_ptr;
1872 wmi_ssid *ssid = NULL;
1873 wmi_mac_addr *bssid;
1874 int len = sizeof(*cmd);
1875
1876 /* Length TLV placeholder for array of uint32_t */
1877 len += WMI_TLV_HDR_SIZE;
1878 /* calculate the length of buffer required */
1879 if (params->num_chan)
1880 len += params->num_chan * sizeof(uint32_t);
1881
1882 /* Length TLV placeholder for array of wmi_ssid structures */
1883 len += WMI_TLV_HDR_SIZE;
1884 if (params->num_ssids)
1885 len += params->num_ssids * sizeof(wmi_ssid);
1886
1887 /* Length TLV placeholder for array of wmi_mac_addr structures */
1888 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301889 if (params->num_bssid)
1890 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05301891
1892 /* Length TLV placeholder for array of bytes */
1893 len += WMI_TLV_HDR_SIZE;
1894 if (params->ie_len)
1895 len += roundup(params->ie_len, sizeof(uint32_t));
1896
1897 /* Allocate the memory */
1898 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1899 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301900 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301901 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05301902 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05301903 }
1904 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1905 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
1906 WMITLV_SET_HDR(&cmd->tlv_header,
1907 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
1908 WMITLV_GET_STRUCT_TLVLEN
1909 (wmi_start_scan_cmd_fixed_param));
1910
1911 cmd->scan_id = params->scan_id;
1912 cmd->scan_req_id = params->scan_req_id;
1913 cmd->vdev_id = params->vdev_id;
1914 cmd->scan_priority = params->scan_priority;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301915 copy_scan_notify_ev_flags(cmd, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05301916 cmd->dwell_time_active = params->dwell_time_active;
1917 cmd->dwell_time_passive = params->dwell_time_passive;
1918 cmd->min_rest_time = params->min_rest_time;
1919 cmd->max_rest_time = params->max_rest_time;
1920 cmd->repeat_probe_time = params->repeat_probe_time;
1921 cmd->probe_spacing_time = params->probe_spacing_time;
1922 cmd->idle_time = params->idle_time;
1923 cmd->max_scan_time = params->max_scan_time;
1924 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05301925 cmd->burst_duration = params->burst_duration;
1926 cmd->num_chan = params->num_chan;
1927 cmd->num_bssid = params->num_bssid;
1928 cmd->num_ssids = params->num_ssids;
1929 cmd->ie_len = params->ie_len;
1930 cmd->n_probes = params->n_probes;
1931 buf_ptr += sizeof(*cmd);
1932 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
1933 for (i = 0; i < params->num_chan; ++i)
1934 tmp_ptr[i] = params->chan_list[i];
1935
1936 WMITLV_SET_HDR(buf_ptr,
1937 WMITLV_TAG_ARRAY_UINT32,
1938 (params->num_chan * sizeof(uint32_t)));
1939 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05301940 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05301941 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05301942 goto error;
1943 }
1944
1945 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1946 (params->num_ssids * sizeof(wmi_ssid)));
1947
1948 if (params->num_ssids) {
1949 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
1950 for (i = 0; i < params->num_ssids; ++i) {
1951 ssid->ssid_len = params->ssid[i].length;
Govind Singhb53420c2016-03-09 14:32:57 +05301952 qdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05301953 params->ssid[i].length);
1954 ssid++;
1955 }
1956 }
1957 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
1958
1959 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1960 (params->num_bssid * sizeof(wmi_mac_addr)));
1961 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301962#if CONFIG_MCL
Govind Singhd3156eb2016-02-26 17:50:39 +05301963 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301964#else
1965 if (params->num_bssid) {
1966 for (i = 0; i < params->num_bssid; ++i) {
1967 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->bssid_list[i],
1968 bssid);
1969 bssid++;
1970 }
1971 }
1972#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05301973 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
1974
1975 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, params->ie_len_with_pad);
1976 if (params->ie_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05301977 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singhd3156eb2016-02-26 17:50:39 +05301978 (uint8_t *) params->ie_base +
1979 (params->uie_fieldOffset), params->ie_len);
1980 }
1981 buf_ptr += WMI_TLV_HDR_SIZE + params->ie_len_with_pad;
1982
1983 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1984 len, WMI_START_SCAN_CMDID);
1985 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301986 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301987 wmi_buf_free(wmi_buf);
1988 }
1989 return ret;
1990error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05301991 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05301992 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301993}
1994
1995/**
1996 * send_scan_stop_cmd_tlv() - WMI scan start function
1997 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301998 * @param param : pointer to hold scan start cmd parameter
1999 *
2000 * Return: 0 on success and -ve on failure.
2001 */
Govind Singhb53420c2016-03-09 14:32:57 +05302002QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302003 struct scan_stop_params *param)
2004{
Govind Singhd3156eb2016-02-26 17:50:39 +05302005 wmi_stop_scan_cmd_fixed_param *cmd;
2006 int ret;
2007 int len = sizeof(*cmd);
2008 wmi_buf_t wmi_buf;
2009
2010 /* Allocate the memory */
2011 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2012 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302013 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302014 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302015 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302016 goto error;
2017 }
2018
2019 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2020 WMITLV_SET_HDR(&cmd->tlv_header,
2021 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2022 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2023 cmd->vdev_id = param->vdev_id;
2024 cmd->requestor = param->requestor;
2025 cmd->scan_id = param->scan_id;
2026 /* stop the scan with the corresponding scan_id */
2027 cmd->req_type = param->req_type;
2028 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
2029 len, WMI_STOP_SCAN_CMDID);
2030 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302031 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302032 wmi_buf_free(wmi_buf);
2033 }
2034
2035error:
2036 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302037}
2038
Govind Singh87542482016-06-08 19:40:11 +05302039#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302040/**
2041 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2042 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302043 * @param param : pointer to hold scan channel list parameter
2044 *
2045 * Return: 0 on success and -ve on failure.
2046 */
Govind Singhb53420c2016-03-09 14:32:57 +05302047QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302048 struct scan_chan_list_params *chan_list)
2049{
2050 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302051 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302052 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302053 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302054 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302055 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302056 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2057
2058 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2059 buf = wmi_buf_alloc(wmi_handle, len);
2060 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302061 WMI_LOGE("Failed to allocate memory");
2062 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302063 goto end;
2064 }
2065
2066 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2067 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2068 WMITLV_SET_HDR(&cmd->tlv_header,
2069 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2070 WMITLV_GET_STRUCT_TLVLEN
2071 (wmi_scan_chan_list_cmd_fixed_param));
2072
Govind Singhb53420c2016-03-09 14:32:57 +05302073 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302074
2075 cmd->num_scan_chans = chan_list->num_scan_chans;
2076 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2077 WMITLV_TAG_ARRAY_STRUC,
2078 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302079 chan_info = (wmi_channel_param *)
2080 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302081 tchan_info = chan_list->chan_info;
2082
2083 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2084 WMITLV_SET_HDR(&chan_info->tlv_header,
2085 WMITLV_TAG_STRUC_wmi_channel,
2086 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2087 chan_info->mhz = tchan_info->mhz;
2088 chan_info->band_center_freq1 =
2089 tchan_info->band_center_freq1;
2090 chan_info->band_center_freq2 =
2091 tchan_info->band_center_freq2;
2092 chan_info->info = tchan_info->info;
2093 chan_info->reg_info_1 = tchan_info->reg_info_1;
2094 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302095 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302096
2097 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2098 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2099 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2100 tchan_info++;
2101 chan_info++;
2102 }
2103
Govind Singh67922e82016-04-01 16:48:57 +05302104 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singhd3156eb2016-02-26 17:50:39 +05302105 WMI_SCAN_CHAN_LIST_CMDID);
2106
Govind Singh67922e82016-04-01 16:48:57 +05302107 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302108 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302109 wmi_buf_free(buf);
2110 }
Govind Singh67922e82016-04-01 16:48:57 +05302111
Govind Singhd3156eb2016-02-26 17:50:39 +05302112end:
Govind Singhb53420c2016-03-09 14:32:57 +05302113 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302114}
Govind Singh87542482016-06-08 19:40:11 +05302115#else
2116QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
2117 struct scan_chan_list_params *chan_list)
2118{
2119 wmi_buf_t buf;
2120 QDF_STATUS qdf_status;
2121 wmi_scan_chan_list_cmd_fixed_param *cmd;
2122 int i;
2123 uint8_t *buf_ptr;
2124 wmi_channel *chan_info;
2125 struct channel_param *tchan_info;
2126 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302127
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302128 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302129 buf = wmi_buf_alloc(wmi_handle, len);
2130 if (!buf) {
2131 WMI_LOGE("Failed to allocate memory");
2132 qdf_status = QDF_STATUS_E_NOMEM;
2133 goto end;
2134 }
2135
2136 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2137 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2138 WMITLV_SET_HDR(&cmd->tlv_header,
2139 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2140 WMITLV_GET_STRUCT_TLVLEN
2141 (wmi_scan_chan_list_cmd_fixed_param));
2142
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302143 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302144
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302145 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302146 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2147 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302148 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302149 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2150 tchan_info = &(chan_list->ch_param[0]);
2151
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302152 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302153 WMITLV_SET_HDR(&chan_info->tlv_header,
2154 WMITLV_TAG_STRUC_wmi_channel,
2155 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2156 chan_info->mhz = tchan_info->mhz;
2157 chan_info->band_center_freq1 =
2158 tchan_info->cfreq1;
2159 chan_info->band_center_freq2 =
2160 tchan_info->cfreq2;
2161
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302162 if (tchan_info->is_chan_passive)
2163 WMI_SET_CHANNEL_FLAG(chan_info,
2164 WMI_CHAN_FLAG_PASSIVE);
2165
2166 if (tchan_info->allow_vht)
2167 WMI_SET_CHANNEL_FLAG(chan_info,
2168 WMI_CHAN_FLAG_ALLOW_VHT);
2169 else if (tchan_info->allow_ht)
2170 WMI_SET_CHANNEL_FLAG(chan_info,
2171 WMI_CHAN_FLAG_ALLOW_HT);
2172 WMI_SET_CHANNEL_MODE(chan_info,
2173 tchan_info->phy_mode);
2174
2175 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2176 * after FW support
2177 */
2178
2179 /* also fill in power information */
2180 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2181 tchan_info->minpower);
2182 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2183 tchan_info->maxpower);
2184 WMI_SET_CHANNEL_REG_POWER(chan_info,
2185 tchan_info->maxregpower);
2186 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2187 tchan_info->antennamax);
2188 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2189 tchan_info->reg_class_id);
2190
Govind Singh87542482016-06-08 19:40:11 +05302191 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2192
Govind Singh87542482016-06-08 19:40:11 +05302193 tchan_info++;
2194 chan_info++;
2195 }
2196
2197 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
2198 WMI_SCAN_CHAN_LIST_CMDID);
2199
2200 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2201 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2202 wmi_buf_free(buf);
2203 }
2204
2205end:
2206 return qdf_status;
2207}
2208#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302209/**
2210 * send_mgmt_cmd_tlv() - WMI scan start function
2211 * @wmi_handle : handle to WMI.
2212 * @param : pointer to hold mgmt cmd parameter
2213 *
2214 * Return: 0 on success and -ve on failure.
2215 */
Govind Singhb53420c2016-03-09 14:32:57 +05302216QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302217 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302218{
Govind Singh427ee5a2016-02-26 18:09:36 +05302219 wmi_buf_t buf;
2220 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2221 int32_t cmd_len;
2222 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302223 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302224 uint8_t *bufp;
2225 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2226 mgmt_tx_dl_frm_len;
2227
2228 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2229 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2230
2231 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2232 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302233 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2234 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302235 }
2236
2237 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2238 bufp = (uint8_t *) cmd;
2239 WMITLV_SET_HDR(&cmd->tlv_header,
2240 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2241 WMITLV_GET_STRUCT_TLVLEN
2242 (wmi_mgmt_tx_send_cmd_fixed_param));
2243
2244 cmd->vdev_id = param->vdev_id;
2245
Govind Singh224a7312016-06-21 14:33:26 +05302246 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302247 cmd->chanfreq = param->chanfreq;
2248 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2249 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2250 sizeof(uint32_t)));
2251 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302252 qdf_mem_copy(bufp, param->pdata, bufp_len);
2253 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2254 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302255 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2256#if defined(HELIUMPLUS_PADDR64)
2257 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2258#endif
2259 cmd->frame_len = param->frm_len;
2260 cmd->buf_len = bufp_len;
2261
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002262 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002263 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002264
Govind Singh427ee5a2016-02-26 18:09:36 +05302265 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2266 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302267 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302268 goto err1;
2269 }
Govind Singhb53420c2016-03-09 14:32:57 +05302270 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302271
2272err1:
2273 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302274 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302275}
2276
2277/**
2278 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2279 * @wmi_handle: wmi handle
2280 * @param_value: parameter value
2281 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302282 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302283 */
Govind Singhb53420c2016-03-09 14:32:57 +05302284QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302285 uint32_t param_value)
2286{
Govind Singh67922e82016-04-01 16:48:57 +05302287 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302288 wmi_modem_power_state_cmd_param *cmd;
2289 wmi_buf_t buf;
2290 uint16_t len = sizeof(*cmd);
2291
2292 buf = wmi_buf_alloc(wmi_handle, len);
2293 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302294 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302295 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302296 }
2297 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2298 WMITLV_SET_HDR(&cmd->tlv_header,
2299 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2300 WMITLV_GET_STRUCT_TLVLEN
2301 (wmi_modem_power_state_cmd_param));
2302 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302303 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302304 param_value);
2305 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2306 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302307 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302308 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302309 wmi_buf_free(buf);
2310 }
Govind Singh67922e82016-04-01 16:48:57 +05302311
Govind Singh427ee5a2016-02-26 18:09:36 +05302312 return ret;
2313}
2314
2315/**
2316 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2317 * @wmi_handle: wmi handle
2318 * @vdev_id: vdev id
2319 * @val: value
2320 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302321 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302322 */
Govind Singhb53420c2016-03-09 14:32:57 +05302323QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302324 uint32_t vdev_id, uint8_t val)
2325{
2326 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2327 wmi_buf_t buf;
2328 int32_t len = sizeof(*cmd);
2329
Govind Singhb53420c2016-03-09 14:32:57 +05302330 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302331
2332 buf = wmi_buf_alloc(wmi_handle, len);
2333 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302334 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302335 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302336 }
2337 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2338 WMITLV_SET_HDR(&cmd->tlv_header,
2339 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2340 WMITLV_GET_STRUCT_TLVLEN
2341 (wmi_sta_powersave_mode_cmd_fixed_param));
2342 cmd->vdev_id = vdev_id;
2343 if (val)
2344 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2345 else
2346 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2347
2348 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2349 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302350 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302351 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302352 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302353 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302354 }
Govind Singh5eb51532016-03-09 11:34:12 +05302355 return 0;
2356}
2357
Govind Singh427ee5a2016-02-26 18:09:36 +05302358/**
2359 * send_set_mimops_cmd_tlv() - set MIMO powersave
2360 * @wmi_handle: wmi handle
2361 * @vdev_id: vdev id
2362 * @value: value
2363 *
Govind Singhb53420c2016-03-09 14:32:57 +05302364 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302365 */
Govind Singhb53420c2016-03-09 14:32:57 +05302366QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302367 uint8_t vdev_id, int value)
2368{
Govind Singh67922e82016-04-01 16:48:57 +05302369 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302370 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2371 wmi_buf_t buf;
2372 uint16_t len = sizeof(*cmd);
2373
2374 buf = wmi_buf_alloc(wmi_handle, len);
2375 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302376 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302377 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302378 }
2379 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2380 WMITLV_SET_HDR(&cmd->tlv_header,
2381 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2382 WMITLV_GET_STRUCT_TLVLEN
2383 (wmi_sta_smps_force_mode_cmd_fixed_param));
2384
2385 cmd->vdev_id = vdev_id;
2386
Houston Hoffmanb5168052016-04-14 02:18:01 -07002387 /* WMI_SMPS_FORCED_MODE values do not directly map
2388 * to SM power save values defined in the specification.
2389 * Make sure to send the right mapping.
2390 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302391 switch (value) {
2392 case 0:
2393 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2394 break;
2395 case 1:
2396 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2397 break;
2398 case 2:
2399 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2400 break;
2401 case 3:
2402 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2403 break;
2404 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302405 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2406 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302407 }
2408
Govind Singhb53420c2016-03-09 14:32:57 +05302409 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302410
2411 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2412 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302413 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302414 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302415 wmi_buf_free(buf);
2416 }
2417
2418 return ret;
2419}
2420
2421/**
2422 * send_set_smps_params_cmd_tlv() - set smps params
2423 * @wmi_handle: wmi handle
2424 * @vdev_id: vdev id
2425 * @value: value
2426 *
Govind Singhb53420c2016-03-09 14:32:57 +05302427 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302428 */
Govind Singhb53420c2016-03-09 14:32:57 +05302429QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302430 int value)
2431{
Govind Singh67922e82016-04-01 16:48:57 +05302432 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302433 wmi_sta_smps_param_cmd_fixed_param *cmd;
2434 wmi_buf_t buf;
2435 uint16_t len = sizeof(*cmd);
2436
2437 buf = wmi_buf_alloc(wmi_handle, len);
2438 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302439 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302440 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302441 }
2442 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2443 WMITLV_SET_HDR(&cmd->tlv_header,
2444 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2445 WMITLV_GET_STRUCT_TLVLEN
2446 (wmi_sta_smps_param_cmd_fixed_param));
2447
2448 cmd->vdev_id = vdev_id;
2449 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2450 cmd->param =
2451 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2452
Govind Singhb53420c2016-03-09 14:32:57 +05302453 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302454 cmd->param);
2455
2456 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2457 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302458 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302459 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302460 wmi_buf_free(buf);
2461 }
2462
2463 return ret;
2464}
2465
2466/**
2467 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2468 * @wmi_handle: wmi handle
2469 * @noa: p2p power save parameters
2470 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302471 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302472 */
Govind Singhb53420c2016-03-09 14:32:57 +05302473QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302474 struct p2p_ps_params *noa)
2475{
2476 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2477 wmi_p2p_noa_descriptor *noa_discriptor;
2478 wmi_buf_t buf;
2479 uint8_t *buf_ptr;
2480 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302481 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302482 uint32_t duration;
2483
Govind Singhb53420c2016-03-09 14:32:57 +05302484 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302485 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2486 buf = wmi_buf_alloc(wmi_handle, len);
2487 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302488 WMI_LOGE("Failed to allocate memory");
2489 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302490 goto end;
2491 }
2492
2493 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2494 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2495 WMITLV_SET_HDR(&cmd->tlv_header,
2496 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2497 WMITLV_GET_STRUCT_TLVLEN
2498 (wmi_p2p_set_noa_cmd_fixed_param));
2499 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2500 cmd->vdev_id = noa->session_id;
2501 cmd->enable = (duration) ? true : false;
2502 cmd->num_noa = 1;
2503
2504 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2505 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2506 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2507 sizeof
2508 (wmi_p2p_set_noa_cmd_fixed_param)
2509 + WMI_TLV_HDR_SIZE);
2510 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2511 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2512 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2513 noa_discriptor->type_count = noa->count;
2514 noa_discriptor->duration = duration;
2515 noa_discriptor->interval = noa->interval;
2516 noa_discriptor->start_time = 0;
2517
Govind Singhb53420c2016-03-09 14:32:57 +05302518 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302519 cmd->vdev_id, noa->count, noa_discriptor->duration,
2520 noa->interval);
2521 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2522 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302523 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302524 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302525 wmi_buf_free(buf);
2526 }
2527
2528end:
Govind Singhb53420c2016-03-09 14:32:57 +05302529 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302530 return status;
2531}
2532
2533
2534/**
2535 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2536 * @wmi_handle: wmi handle
2537 * @noa: p2p opp power save parameters
2538 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302539 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302540 */
Govind Singhb53420c2016-03-09 14:32:57 +05302541QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302542 struct p2p_ps_params *oppps)
2543{
2544 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2545 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302546 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302547
Govind Singhb53420c2016-03-09 14:32:57 +05302548 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302549 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2550 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302551 WMI_LOGE("Failed to allocate memory");
2552 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302553 goto end;
2554 }
2555
2556 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2557 WMITLV_SET_HDR(&cmd->tlv_header,
2558 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2559 WMITLV_GET_STRUCT_TLVLEN
2560 (wmi_p2p_set_oppps_cmd_fixed_param));
2561 cmd->vdev_id = oppps->session_id;
2562 if (oppps->ctwindow)
2563 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2564
2565 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302566 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302567 cmd->vdev_id, oppps->ctwindow);
2568 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2569 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302570 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302571 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302572 wmi_buf_free(buf);
2573 }
2574
2575end:
Govind Singhb53420c2016-03-09 14:32:57 +05302576 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302577 return status;
2578}
2579
2580/**
2581 * send_get_temperature_cmd_tlv() - get pdev temperature req
2582 * @wmi_handle: wmi handle
2583 *
Govind Singhb53420c2016-03-09 14:32:57 +05302584 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302585 */
Govind Singhb53420c2016-03-09 14:32:57 +05302586QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05302587{
2588 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
2589 wmi_buf_t wmi_buf;
2590 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
2591 uint8_t *buf_ptr;
2592
2593 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05302594 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
2595 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05302596 }
2597
2598 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2599 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302600 WMI_LOGE(FL("wmi_buf_alloc failed"));
2601 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302602 }
2603
2604 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2605
2606 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
2607 WMITLV_SET_HDR(&cmd->tlv_header,
2608 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
2609 WMITLV_GET_STRUCT_TLVLEN
2610 (wmi_pdev_get_temperature_cmd_fixed_param));
2611
2612 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
2613 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302614 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05302615 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302616 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302617 }
Govind Singh2edc80f2016-03-01 15:30:53 +05302618
Govind Singhb53420c2016-03-09 14:32:57 +05302619 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302620}
2621
2622/**
2623 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
2624 * @wmi_handle: wmi handle
2625 * @vdevid: vdev id
2626 * @peer_addr: peer mac address
2627 * @auto_triggerparam: auto trigger parameters
2628 * @num_ac: number of access category
2629 *
2630 * This function sets the trigger
2631 * uapsd params such as service interval, delay interval
2632 * and suspend interval which will be used by the firmware
2633 * to send trigger frames periodically when there is no
2634 * traffic on the transmit side.
2635 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302636 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302637 */
Govind Singhb53420c2016-03-09 14:32:57 +05302638QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302639 struct sta_uapsd_trig_params *param)
2640{
2641 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302642 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302643 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
2644 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
2645 uint32_t i;
2646 wmi_buf_t buf;
2647 uint8_t *buf_ptr;
2648
2649 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2650 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302651 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302652 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302653 }
2654
2655 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2656 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
2657 WMITLV_SET_HDR(&cmd->tlv_header,
2658 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
2659 WMITLV_GET_STRUCT_TLVLEN
2660 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
2661 cmd->vdev_id = param->vdevid;
2662 cmd->num_ac = param->num_ac;
2663 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
2664
2665 /* TLV indicating array of structures to follow */
2666 buf_ptr += sizeof(*cmd);
2667 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
2668
2669 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302670 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302671
2672 /*
2673 * Update tag and length for uapsd auto trigger params (this will take
2674 * care of updating tag and length if it is not pre-filled by caller).
2675 */
2676 for (i = 0; i < param->num_ac; i++) {
2677 WMITLV_SET_HDR((buf_ptr +
2678 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
2679 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
2680 WMITLV_GET_STRUCT_TLVLEN
2681 (wmi_sta_uapsd_auto_trig_param));
2682 }
2683
2684 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2685 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302686 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302687 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302688 wmi_buf_free(buf);
2689 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05302690
Govind Singh427ee5a2016-02-26 18:09:36 +05302691 return ret;
2692}
2693
Govind Singh2edc80f2016-03-01 15:30:53 +05302694/**
2695 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
2696 * @wmi_handle: pointer to the wmi handle
2697 * @utc: pointer to the UTC time struct
2698 *
2699 * Return: 0 on succes
2700 */
Govind Singhb53420c2016-03-09 14:32:57 +05302701QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302702 struct ocb_utc_param *utc)
2703{
Govind Singh67922e82016-04-01 16:48:57 +05302704 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302705 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
2706 uint8_t *buf_ptr;
2707 uint32_t len, i;
2708 wmi_buf_t buf;
2709
2710 len = sizeof(*cmd);
2711 buf = wmi_buf_alloc(wmi_handle, len);
2712 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302713 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302714 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302715 }
2716
2717 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2718 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
2719 WMITLV_SET_HDR(&cmd->tlv_header,
2720 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
2721 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
2722 cmd->vdev_id = utc->vdev_id;
2723
2724 for (i = 0; i < SIZE_UTC_TIME; i++)
2725 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
2726
2727 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
2728 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
2729
2730 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2731 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302732 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302733 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302734 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302735 }
2736
Govind Singh67922e82016-04-01 16:48:57 +05302737 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302738}
2739
2740/**
2741 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
2742 * frames on a channel
2743 * @wmi_handle: pointer to the wmi handle
2744 * @timing_advert: pointer to the timing advertisement struct
2745 *
2746 * Return: 0 on succes
2747 */
Govind Singhb53420c2016-03-09 14:32:57 +05302748QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302749 struct ocb_timing_advert_param *timing_advert)
2750{
Govind Singh67922e82016-04-01 16:48:57 +05302751 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302752 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
2753 uint8_t *buf_ptr;
2754 uint32_t len, len_template;
2755 wmi_buf_t buf;
2756
2757 len = sizeof(*cmd) +
2758 WMI_TLV_HDR_SIZE;
2759
2760 len_template = timing_advert->template_length;
2761 /* Add padding to the template if needed */
2762 if (len_template % 4 != 0)
2763 len_template += 4 - (len_template % 4);
2764 len += len_template;
2765
2766 buf = wmi_buf_alloc(wmi_handle, len);
2767 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302768 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302769 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302770 }
2771
2772 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2773 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
2774 WMITLV_SET_HDR(&cmd->tlv_header,
2775 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
2776 WMITLV_GET_STRUCT_TLVLEN(
2777 wmi_ocb_start_timing_advert_cmd_fixed_param));
2778 cmd->vdev_id = timing_advert->vdev_id;
2779 cmd->repeat_rate = timing_advert->repeat_rate;
2780 cmd->channel_freq = timing_advert->chan_freq;
2781 cmd->timestamp_offset = timing_advert->timestamp_offset;
2782 cmd->time_value_offset = timing_advert->time_value_offset;
2783 cmd->timing_advert_template_length = timing_advert->template_length;
2784 buf_ptr += sizeof(*cmd);
2785
2786 /* Add the timing advert template */
2787 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2788 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05302789 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05302790 (uint8_t *)timing_advert->template_value,
2791 timing_advert->template_length);
2792
2793 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2794 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302795 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302796 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302797 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302798 }
2799
Govind Singh67922e82016-04-01 16:48:57 +05302800 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302801}
2802
2803/**
2804 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
2805 * on a channel
2806 * @wmi_handle: pointer to the wmi handle
2807 * @timing_advert: pointer to the timing advertisement struct
2808 *
2809 * Return: 0 on succes
2810 */
Govind Singhb53420c2016-03-09 14:32:57 +05302811QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302812 struct ocb_timing_advert_param *timing_advert)
2813{
Govind Singh67922e82016-04-01 16:48:57 +05302814 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302815 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
2816 uint8_t *buf_ptr;
2817 uint32_t len;
2818 wmi_buf_t buf;
2819
2820 len = sizeof(*cmd);
2821 buf = wmi_buf_alloc(wmi_handle, len);
2822 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302823 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302824 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302825 }
2826
2827 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2828 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
2829 WMITLV_SET_HDR(&cmd->tlv_header,
2830 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
2831 WMITLV_GET_STRUCT_TLVLEN(
2832 wmi_ocb_stop_timing_advert_cmd_fixed_param));
2833 cmd->vdev_id = timing_advert->vdev_id;
2834 cmd->channel_freq = timing_advert->chan_freq;
2835
2836 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2837 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302838 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302839 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302840 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302841 }
2842
Govind Singh67922e82016-04-01 16:48:57 +05302843 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302844}
2845
2846/**
2847 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
2848 * @wmi_handle: pointer to the wmi handle
2849 * @request: pointer to the request
2850 *
2851 * Return: 0 on succes
2852 */
Govind Singhb53420c2016-03-09 14:32:57 +05302853QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302854 uint8_t vdev_id)
2855{
Govind Singhb53420c2016-03-09 14:32:57 +05302856 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302857 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
2858 uint8_t *buf_ptr;
2859 wmi_buf_t buf;
2860 int32_t len;
2861
2862 len = sizeof(*cmd);
2863 buf = wmi_buf_alloc(wmi_handle, len);
2864 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302865 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302866 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302867 }
2868 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2869
2870 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302871 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302872 WMITLV_SET_HDR(&cmd->tlv_header,
2873 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
2874 WMITLV_GET_STRUCT_TLVLEN(
2875 wmi_ocb_get_tsf_timer_cmd_fixed_param));
2876 cmd->vdev_id = vdev_id;
2877
2878 /* Send the WMI command */
2879 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2880 WMI_OCB_GET_TSF_TIMER_CMDID);
2881 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05302882 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302883 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302884 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302885 }
2886
Govind Singh67922e82016-04-01 16:48:57 +05302887 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302888}
2889
2890/**
2891 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
2892 * @wmi_handle: pointer to the wmi handle
2893 * @get_stats_param: pointer to the dcc stats
2894 *
2895 * Return: 0 on succes
2896 */
Govind Singhb53420c2016-03-09 14:32:57 +05302897QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302898 struct dcc_get_stats_param *get_stats_param)
2899{
Govind Singh67922e82016-04-01 16:48:57 +05302900 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302901 wmi_dcc_get_stats_cmd_fixed_param *cmd;
2902 wmi_dcc_channel_stats_request *channel_stats_array;
2903 wmi_buf_t buf;
2904 uint8_t *buf_ptr;
2905 uint32_t len;
2906 uint32_t i;
2907
2908 /* Validate the input */
2909 if (get_stats_param->request_array_len !=
2910 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302911 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05302912 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302913 }
2914
2915 /* Allocate memory for the WMI command */
2916 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
2917 get_stats_param->request_array_len;
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"));
2922 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_get_stats_cmd_fixed_param *)buf_ptr;
2930 buf_ptr += sizeof(*cmd);
2931
2932 WMITLV_SET_HDR(&cmd->tlv_header,
2933 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
2934 WMITLV_GET_STRUCT_TLVLEN(
2935 wmi_dcc_get_stats_cmd_fixed_param));
2936 cmd->vdev_id = get_stats_param->vdev_id;
2937 cmd->num_channels = get_stats_param->channel_count;
2938
2939 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2940 get_stats_param->request_array_len);
2941 buf_ptr += WMI_TLV_HDR_SIZE;
2942
2943 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302944 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05302945 get_stats_param->request_array_len);
2946 for (i = 0; i < cmd->num_channels; i++)
2947 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
2948 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
2949 WMITLV_GET_STRUCT_TLVLEN(
2950 wmi_dcc_channel_stats_request));
2951
2952 /* Send the WMI command */
2953 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2954 WMI_DCC_GET_STATS_CMDID);
2955
Govind Singh67922e82016-04-01 16:48:57 +05302956 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302957 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302958 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302959 }
2960
Govind Singh67922e82016-04-01 16:48:57 +05302961 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302962}
2963
2964/**
2965 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
2966 * @wmi_handle: pointer to the wmi handle
2967 * @vdev_id: vdev id
2968 * @dcc_stats_bitmap: dcc status bitmap
2969 *
2970 * Return: 0 on succes
2971 */
Govind Singhb53420c2016-03-09 14:32:57 +05302972QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302973 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
2974{
Govind Singh67922e82016-04-01 16:48:57 +05302975 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302976 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
2977 wmi_buf_t buf;
2978 uint8_t *buf_ptr;
2979 uint32_t len;
2980
2981 /* Allocate memory for the WMI command */
2982 len = sizeof(*cmd);
2983
2984 buf = wmi_buf_alloc(wmi_handle, len);
2985 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302986 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302987 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302988 }
2989
2990 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302991 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302992
2993 /* Populate the WMI command */
2994 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
2995
2996 WMITLV_SET_HDR(&cmd->tlv_header,
2997 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
2998 WMITLV_GET_STRUCT_TLVLEN(
2999 wmi_dcc_clear_stats_cmd_fixed_param));
3000 cmd->vdev_id = vdev_id;
3001 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3002
3003 /* Send the WMI command */
3004 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3005 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303006 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303007 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303008 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303009 }
3010
Govind Singh67922e82016-04-01 16:48:57 +05303011 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303012}
3013
3014/**
3015 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3016 * @wmi_handle: pointer to the wmi handle
3017 * @update_ndl_param: pointer to the request parameters
3018 *
3019 * Return: 0 on success
3020 */
Govind Singhb53420c2016-03-09 14:32:57 +05303021QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303022 struct dcc_update_ndl_param *update_ndl_param)
3023{
Govind Singhb53420c2016-03-09 14:32:57 +05303024 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303025 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3026 wmi_dcc_ndl_chan *ndl_chan_array;
3027 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3028 uint32_t active_state_count;
3029 wmi_buf_t buf;
3030 uint8_t *buf_ptr;
3031 uint32_t len;
3032 uint32_t i;
3033
3034 /* validate the input */
3035 if (update_ndl_param->dcc_ndl_chan_list_len !=
3036 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303037 WMI_LOGE(FL("Invalid parameter"));
3038 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303039 }
3040 active_state_count = 0;
3041 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3042 for (i = 0; i < update_ndl_param->channel_count; i++)
3043 active_state_count +=
3044 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3045 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3046 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303047 WMI_LOGE(FL("Invalid parameter"));
3048 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303049 }
3050
3051 /* Allocate memory for the WMI command */
3052 len = sizeof(*cmd) +
3053 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3054 WMI_TLV_HDR_SIZE +
3055 update_ndl_param->dcc_ndl_active_state_list_len;
3056
3057 buf = wmi_buf_alloc(wmi_handle, len);
3058 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303059 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303060 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303061 }
3062
3063 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303064 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303065
3066 /* Populate the WMI command */
3067 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3068 buf_ptr += sizeof(*cmd);
3069
3070 WMITLV_SET_HDR(&cmd->tlv_header,
3071 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3072 WMITLV_GET_STRUCT_TLVLEN(
3073 wmi_dcc_update_ndl_cmd_fixed_param));
3074 cmd->vdev_id = update_ndl_param->vdev_id;
3075 cmd->num_channel = update_ndl_param->channel_count;
3076
3077 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3078 update_ndl_param->dcc_ndl_chan_list_len);
3079 buf_ptr += WMI_TLV_HDR_SIZE;
3080
3081 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303082 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303083 update_ndl_param->dcc_ndl_chan_list_len);
3084 for (i = 0; i < cmd->num_channel; i++)
3085 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3086 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3087 WMITLV_GET_STRUCT_TLVLEN(
3088 wmi_dcc_ndl_chan));
3089 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3090
3091 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3092 update_ndl_param->dcc_ndl_active_state_list_len);
3093 buf_ptr += WMI_TLV_HDR_SIZE;
3094
3095 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303096 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303097 update_ndl_param->dcc_ndl_active_state_list,
3098 update_ndl_param->dcc_ndl_active_state_list_len);
3099 for (i = 0; i < active_state_count; i++) {
3100 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3101 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3102 WMITLV_GET_STRUCT_TLVLEN(
3103 wmi_dcc_ndl_active_state_config));
3104 }
3105 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3106
3107 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303108 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303109 WMI_DCC_UPDATE_NDL_CMDID);
3110 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303111 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303112 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303113 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303114 }
3115
Govind Singh67922e82016-04-01 16:48:57 +05303116 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303117}
3118
3119/**
3120 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3121 * @wmi_handle: pointer to the wmi handle
3122 * @config: the OCB configuration
3123 *
3124 * Return: 0 on success
3125 */
Govind Singhb53420c2016-03-09 14:32:57 +05303126QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303127 struct ocb_config_param *config, uint32_t *ch_mhz)
3128{
Govind Singh67922e82016-04-01 16:48:57 +05303129 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303130 wmi_ocb_set_config_cmd_fixed_param *cmd;
3131 wmi_channel *chan;
3132 wmi_ocb_channel *ocb_chan;
3133 wmi_qos_parameter *qos_param;
3134 wmi_dcc_ndl_chan *ndl_chan;
3135 wmi_dcc_ndl_active_state_config *ndl_active_config;
3136 wmi_ocb_schedule_element *sched_elem;
3137 uint8_t *buf_ptr;
3138 wmi_buf_t buf;
3139 int32_t len;
3140 int32_t i, j, active_state_count;
3141
3142 /*
3143 * Validate the dcc_ndl_chan_list_len and count the number of active
3144 * states. Validate dcc_ndl_active_state_list_len.
3145 */
3146 active_state_count = 0;
3147 if (config->dcc_ndl_chan_list_len) {
3148 if (!config->dcc_ndl_chan_list ||
3149 config->dcc_ndl_chan_list_len !=
3150 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303151 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303152 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303153 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303154 }
3155
3156 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3157 i < config->channel_count; ++i, ++ndl_chan)
3158 active_state_count +=
3159 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3160
3161 if (active_state_count) {
3162 if (!config->dcc_ndl_active_state_list ||
3163 config->dcc_ndl_active_state_list_len !=
3164 active_state_count *
3165 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303166 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303167 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303168 }
3169 }
3170 }
3171
3172 len = sizeof(*cmd) +
3173 WMI_TLV_HDR_SIZE + config->channel_count *
3174 sizeof(wmi_channel) +
3175 WMI_TLV_HDR_SIZE + config->channel_count *
3176 sizeof(wmi_ocb_channel) +
3177 WMI_TLV_HDR_SIZE + config->channel_count *
3178 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3179 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3180 WMI_TLV_HDR_SIZE + active_state_count *
3181 sizeof(wmi_dcc_ndl_active_state_config) +
3182 WMI_TLV_HDR_SIZE + config->schedule_size *
3183 sizeof(wmi_ocb_schedule_element);
3184 buf = wmi_buf_alloc(wmi_handle, len);
3185 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303186 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303187 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303188 }
3189
3190 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3191 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3192 WMITLV_SET_HDR(&cmd->tlv_header,
3193 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3194 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3195 cmd->vdev_id = config->session_id;
3196 cmd->channel_count = config->channel_count;
3197 cmd->schedule_size = config->schedule_size;
3198 cmd->flags = config->flags;
3199 buf_ptr += sizeof(*cmd);
3200
3201 /* Add the wmi_channel info */
3202 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3203 config->channel_count*sizeof(wmi_channel));
3204 buf_ptr += WMI_TLV_HDR_SIZE;
3205 for (i = 0; i < config->channel_count; i++) {
3206 chan = (wmi_channel *)buf_ptr;
3207 WMITLV_SET_HDR(&chan->tlv_header,
3208 WMITLV_TAG_STRUC_wmi_channel,
3209 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3210 chan->mhz = config->channels[i].chan_freq;
3211 chan->band_center_freq1 = config->channels[i].chan_freq;
3212 chan->band_center_freq2 = 0;
3213 chan->info = 0;
3214
3215 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3216 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3217 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3218 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3219 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3220 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3221 config->channels[i].antenna_max);
3222
3223 if (config->channels[i].bandwidth < 10)
3224 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3225 else if (config->channels[i].bandwidth < 20)
3226 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3227 buf_ptr += sizeof(*chan);
3228 }
3229
3230 /* Add the wmi_ocb_channel info */
3231 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3232 config->channel_count*sizeof(wmi_ocb_channel));
3233 buf_ptr += WMI_TLV_HDR_SIZE;
3234 for (i = 0; i < config->channel_count; i++) {
3235 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3236 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3237 WMITLV_TAG_STRUC_wmi_ocb_channel,
3238 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3239 ocb_chan->bandwidth = config->channels[i].bandwidth;
3240 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3241 config->channels[i].mac_address.bytes,
3242 &ocb_chan->mac_address);
3243 buf_ptr += sizeof(*ocb_chan);
3244 }
3245
3246 /* Add the wmi_qos_parameter info */
3247 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3248 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3249 buf_ptr += WMI_TLV_HDR_SIZE;
3250 /* WMI_MAX_NUM_AC parameters for each channel */
3251 for (i = 0; i < config->channel_count; i++) {
3252 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3253 qos_param = (wmi_qos_parameter *)buf_ptr;
3254 WMITLV_SET_HDR(&qos_param->tlv_header,
3255 WMITLV_TAG_STRUC_wmi_qos_parameter,
3256 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3257 qos_param->aifsn =
3258 config->channels[i].qos_params[j].aifsn;
3259 qos_param->cwmin =
3260 config->channels[i].qos_params[j].cwmin;
3261 qos_param->cwmax =
3262 config->channels[i].qos_params[j].cwmax;
3263 buf_ptr += sizeof(*qos_param);
3264 }
3265 }
3266
3267 /* Add the wmi_dcc_ndl_chan (per channel) */
3268 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3269 config->dcc_ndl_chan_list_len);
3270 buf_ptr += WMI_TLV_HDR_SIZE;
3271 if (config->dcc_ndl_chan_list_len) {
3272 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303273 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303274 config->dcc_ndl_chan_list_len);
3275 for (i = 0; i < config->channel_count; i++)
3276 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3277 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3278 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3279 buf_ptr += config->dcc_ndl_chan_list_len;
3280 }
3281
3282 /* Add the wmi_dcc_ndl_active_state_config */
3283 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3284 sizeof(wmi_dcc_ndl_active_state_config));
3285 buf_ptr += WMI_TLV_HDR_SIZE;
3286 if (active_state_count) {
3287 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303288 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303289 config->dcc_ndl_active_state_list,
3290 active_state_count * sizeof(*ndl_active_config));
3291 for (i = 0; i < active_state_count; ++i)
3292 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3293 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3294 WMITLV_GET_STRUCT_TLVLEN(
3295 wmi_dcc_ndl_active_state_config));
3296 buf_ptr += active_state_count *
3297 sizeof(*ndl_active_config);
3298 }
3299
3300 /* Add the wmi_ocb_schedule_element info */
3301 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3302 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3303 buf_ptr += WMI_TLV_HDR_SIZE;
3304 for (i = 0; i < config->schedule_size; i++) {
3305 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3306 WMITLV_SET_HDR(&sched_elem->tlv_header,
3307 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3308 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3309 sched_elem->channel_freq = config->schedule[i].chan_freq;
3310 sched_elem->total_duration = config->schedule[i].total_duration;
3311 sched_elem->guard_interval = config->schedule[i].guard_interval;
3312 buf_ptr += sizeof(*sched_elem);
3313 }
3314
3315
3316 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3317 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303318 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303319 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303320 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303321 }
3322
Govind Singh67922e82016-04-01 16:48:57 +05303323 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303324}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303325
3326/**
3327 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3328 * @wmi_handle: wmi handle
3329 * @mcc_adaptive_scheduler: enable/disable
3330 *
3331 * This function enable/disable mcc adaptive scheduler in fw.
3332 *
Govind Singhb53420c2016-03-09 14:32:57 +05303333 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303334 */
Govind Singhb53420c2016-03-09 14:32:57 +05303335QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003336 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3337 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303338{
Govind Singh67922e82016-04-01 16:48:57 +05303339 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303340 wmi_buf_t buf = 0;
3341 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3342 uint16_t len =
3343 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3344
3345 buf = wmi_buf_alloc(wmi_handle, len);
3346 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303347 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3348 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303349 }
3350 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3351 wmi_buf_data(buf);
3352
3353 WMITLV_SET_HDR(&cmd->tlv_header,
3354 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3355 WMITLV_GET_STRUCT_TLVLEN
3356 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3357 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003358 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303359
3360 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3361 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303362 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303363 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303364 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303365 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303366 }
Govind Singh67922e82016-04-01 16:48:57 +05303367
3368 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303369}
3370
3371/**
3372 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3373 * @wmi: wmi handle
3374 * @mcc_channel: mcc channel
3375 * @mcc_channel_time_latency: MCC channel time latency.
3376 *
3377 * Currently used to set time latency for an MCC vdev/adapter using operating
3378 * channel of it and channel number. The info is provided run time using
3379 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3380 *
3381 * Return: CDF status
3382 */
Govind Singhb53420c2016-03-09 14:32:57 +05303383QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303384 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3385{
Govind Singh67922e82016-04-01 16:48:57 +05303386 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303387 wmi_buf_t buf = 0;
3388 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3389 uint16_t len = 0;
3390 uint8_t *buf_ptr = NULL;
3391 wmi_resmgr_chan_latency chan_latency;
3392 /* Note: we only support MCC time latency for a single channel */
3393 uint32_t num_channels = 1;
3394 uint32_t chan1_freq = mcc_channel_freq;
3395 uint32_t latency_chan1 = mcc_channel_time_latency;
3396
3397
3398 /* If 0ms latency is provided, then FW will set to a default.
3399 * Otherwise, latency must be at least 30ms.
3400 */
3401 if ((latency_chan1 > 0) &&
3402 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303403 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303404 "Minimum is 30ms (or 0 to use default value by "
3405 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303406 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303407 }
3408
3409 /* Set WMI CMD for channel time latency here */
3410 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3411 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3412 num_channels * sizeof(wmi_resmgr_chan_latency);
3413 buf = wmi_buf_alloc(wmi_handle, len);
3414 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303415 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3416 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303417 }
3418 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3419 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3420 wmi_buf_data(buf);
3421 WMITLV_SET_HDR(&cmdTL->tlv_header,
3422 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3423 WMITLV_GET_STRUCT_TLVLEN
3424 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3425 cmdTL->num_chans = num_channels;
3426 /* Update channel time latency information for home channel(s) */
3427 buf_ptr += sizeof(*cmdTL);
3428 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3429 num_channels * sizeof(wmi_resmgr_chan_latency));
3430 buf_ptr += WMI_TLV_HDR_SIZE;
3431 chan_latency.chan_mhz = chan1_freq;
3432 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303433 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303434 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3435 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303436 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303437 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303438 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303439 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303440 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303441 }
Govind Singh67922e82016-04-01 16:48:57 +05303442
3443 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303444}
3445
3446/**
3447 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3448 * @wmi: wmi handle
3449 * @adapter_1_chan_number: adapter 1 channel number
3450 * @adapter_1_quota: adapter 1 quota
3451 * @adapter_2_chan_number: adapter 2 channel number
3452 *
3453 * Return: CDF status
3454 */
Govind Singhb53420c2016-03-09 14:32:57 +05303455QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303456 uint32_t adapter_1_chan_freq,
3457 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3458{
Govind Singh67922e82016-04-01 16:48:57 +05303459 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303460 wmi_buf_t buf = 0;
3461 uint16_t len = 0;
3462 uint8_t *buf_ptr = NULL;
3463 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3464 wmi_resmgr_chan_time_quota chan_quota;
3465 uint32_t quota_chan1 = adapter_1_quota;
3466 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3467 uint32_t quota_chan2 = 100 - quota_chan1;
3468 /* Note: setting time quota for MCC requires info for 2 channels */
3469 uint32_t num_channels = 2;
3470 uint32_t chan1_freq = adapter_1_chan_freq;
3471 uint32_t chan2_freq = adapter_2_chan_freq;
3472
Govind Singhb53420c2016-03-09 14:32:57 +05303473 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303474 "freq2:%dMHz, Quota2:%dms", __func__,
3475 chan1_freq, quota_chan1, chan2_freq,
3476 quota_chan2);
3477
3478 /*
3479 * Perform sanity check on time quota values provided.
3480 */
3481 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3482 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303483 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303484 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303485 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303486 }
3487 /* Set WMI CMD for channel time quota here */
3488 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3489 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3490 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3491 buf = wmi_buf_alloc(wmi_handle, len);
3492 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303493 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3494 QDF_ASSERT(0);
3495 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303496 }
3497 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3498 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3499 wmi_buf_data(buf);
3500 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3501 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3502 WMITLV_GET_STRUCT_TLVLEN
3503 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3504 cmdTQ->num_chans = num_channels;
3505
3506 /* Update channel time quota information for home channel(s) */
3507 buf_ptr += sizeof(*cmdTQ);
3508 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3509 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3510 buf_ptr += WMI_TLV_HDR_SIZE;
3511 chan_quota.chan_mhz = chan1_freq;
3512 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303513 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303514 /* Construct channel and quota record for the 2nd MCC mode. */
3515 buf_ptr += sizeof(chan_quota);
3516 chan_quota.chan_mhz = chan2_freq;
3517 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05303518 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303519
3520 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3521 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303522 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303523 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303524 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303525 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303526 }
Govind Singh67922e82016-04-01 16:48:57 +05303527
3528 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303529}
3530
3531/**
3532 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3533 * @wmi_handle: Pointer to wmi handle
3534 * @thermal_info: Thermal command information
3535 *
3536 * This function sends the thermal management command
3537 * to the firmware
3538 *
Govind Singhb53420c2016-03-09 14:32:57 +05303539 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303540 */
Govind Singhb53420c2016-03-09 14:32:57 +05303541QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303542 struct thermal_cmd_params *thermal_info)
3543{
3544 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3545 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303546 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303547 uint32_t len = 0;
3548
3549 len = sizeof(*cmd);
3550
3551 buf = wmi_buf_alloc(wmi_handle, len);
3552 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303553 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3554 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303555 }
3556
3557 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3558
3559 WMITLV_SET_HDR(&cmd->tlv_header,
3560 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3561 WMITLV_GET_STRUCT_TLVLEN
3562 (wmi_thermal_mgmt_cmd_fixed_param));
3563
3564 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3565 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3566 cmd->enable = thermal_info->thermal_enable;
3567
Govind Singhb53420c2016-03-09 14:32:57 +05303568 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303569 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3570
3571 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3572 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303573 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303574 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303575 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303576 }
3577
Govind Singh67922e82016-04-01 16:48:57 +05303578 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303579}
3580
3581
3582/**
3583 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303584 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303585 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3586 *
3587 * This function sends down the LRO configuration parameters to
3588 * the firmware to enable LRO, sets the TCP flags and sets the
3589 * seed values for the toeplitz hash generation
3590 *
Govind Singhb53420c2016-03-09 14:32:57 +05303591 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303592 */
Govind Singhb53420c2016-03-09 14:32:57 +05303593QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303594 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3595{
3596 wmi_lro_info_cmd_fixed_param *cmd;
3597 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303598 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303599
3600
3601 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3602 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303603 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3604 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303605 }
3606
3607 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3608
3609 WMITLV_SET_HDR(&cmd->tlv_header,
3610 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3611 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3612
3613 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3614 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3615 wmi_lro_cmd->tcp_flag);
3616 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3617 wmi_lro_cmd->tcp_flag_mask);
3618 cmd->toeplitz_hash_ipv4_0_3 =
3619 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3620 cmd->toeplitz_hash_ipv4_4_7 =
3621 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3622 cmd->toeplitz_hash_ipv4_8_11 =
3623 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3624 cmd->toeplitz_hash_ipv4_12_15 =
3625 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3626 cmd->toeplitz_hash_ipv4_16 =
3627 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3628
3629 cmd->toeplitz_hash_ipv6_0_3 =
3630 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3631 cmd->toeplitz_hash_ipv6_4_7 =
3632 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3633 cmd->toeplitz_hash_ipv6_8_11 =
3634 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3635 cmd->toeplitz_hash_ipv6_12_15 =
3636 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3637 cmd->toeplitz_hash_ipv6_16_19 =
3638 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3639 cmd->toeplitz_hash_ipv6_20_23 =
3640 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3641 cmd->toeplitz_hash_ipv6_24_27 =
3642 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3643 cmd->toeplitz_hash_ipv6_28_31 =
3644 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3645 cmd->toeplitz_hash_ipv6_32_35 =
3646 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3647 cmd->toeplitz_hash_ipv6_36_39 =
3648 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3649 cmd->toeplitz_hash_ipv6_40 =
3650 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3651
Govind Singhb53420c2016-03-09 14:32:57 +05303652 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303653 cmd->lro_enable, cmd->tcp_flag_u32);
3654
3655 status = wmi_unified_cmd_send(wmi_handle, buf,
3656 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303657 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303658 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303659 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303660 }
3661
Govind Singh67922e82016-04-01 16:48:57 +05303662 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303663}
3664
Govind Singh4eacd2b2016-03-07 14:24:22 +05303665/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303666 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3667 * @wmi_handle: Pointer to wmi handle
3668 * @rate_report_params: Pointer to peer rate report parameters
3669 *
3670 *
3671 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3672 */
3673QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
3674 struct wmi_peer_rate_report_params *rate_report_params)
3675{
3676 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3677 wmi_buf_t buf = NULL;
3678 QDF_STATUS status = 0;
3679 uint32_t len = 0;
3680 uint32_t i, j;
3681
3682 len = sizeof(*cmd);
3683
3684 buf = wmi_buf_alloc(wmi_handle, len);
3685 if (!buf) {
3686 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
3687 return QDF_STATUS_E_FAILURE;
3688 }
3689
3690 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3691 wmi_buf_data(buf);
3692
3693 WMITLV_SET_HDR(
3694 &cmd->tlv_header,
3695 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3696 WMITLV_GET_STRUCT_TLVLEN(
3697 wmi_peer_set_rate_report_condition_fixed_param));
3698
3699 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3700 cmd->report_backoff_time = rate_report_params->backoff_time;
3701 cmd->report_timer_period = rate_report_params->timer_period;
3702 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
3703 cmd->cond_per_phy[i].val_cond_flags =
3704 rate_report_params->report_per_phy[i].cond_flags;
3705 cmd->cond_per_phy[i].rate_delta.min_delta =
3706 rate_report_params->report_per_phy[i].delta.delta_min;
3707 cmd->cond_per_phy[i].rate_delta.percentage =
3708 rate_report_params->report_per_phy[i].delta.percent;
3709 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3710 cmd->cond_per_phy[i].rate_threshold[j] =
3711 rate_report_params->report_per_phy[i].
3712 report_rate_threshold[j];
3713 }
3714 }
3715
3716 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
3717 cmd->enable_rate_report,
3718 cmd->report_backoff_time, cmd->report_timer_period);
3719
3720 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3721 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3722 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303723 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303724 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3725 __func__);
3726 }
3727 return status;
3728}
3729
3730/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303731 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3732 * @wmi_handle: wmi handle
3733 * @param: bcn ll cmd parameter
3734 *
Govind Singhb53420c2016-03-09 14:32:57 +05303735 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303736 */
Govind Singhb53420c2016-03-09 14:32:57 +05303737QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303738 wmi_bcn_send_from_host_cmd_fixed_param *param)
3739{
3740 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3741 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303742 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303743
3744 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3745 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303746 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3747 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303748 }
3749
3750 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3751 WMITLV_SET_HDR(&cmd->tlv_header,
3752 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3753 WMITLV_GET_STRUCT_TLVLEN
3754 (wmi_bcn_send_from_host_cmd_fixed_param));
3755 cmd->vdev_id = param->vdev_id;
3756 cmd->data_len = param->data_len;
3757 cmd->frame_ctrl = param->frame_ctrl;
3758 cmd->frag_ptr = param->frag_ptr;
3759 cmd->dtim_flag = param->dtim_flag;
3760
3761 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3762 WMI_PDEV_SEND_BCN_CMDID);
3763
Govind Singh67922e82016-04-01 16:48:57 +05303764 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303765 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303766 wmi_buf_free(wmi_buf);
3767 }
3768
3769 return ret;
3770}
3771
3772/**
3773 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
3774 * @wmi_handle: wmi handle
3775 * @vdev_id: vdev id
3776 * @max_retries: max retries
3777 * @retry_interval: retry interval
3778 * This function sets sta query related parameters in fw.
3779 *
Govind Singhb53420c2016-03-09 14:32:57 +05303780 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303781 */
3782
Govind Singhb53420c2016-03-09 14:32:57 +05303783QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303784 uint8_t vdev_id, uint32_t max_retries,
3785 uint32_t retry_interval)
3786{
3787 wmi_buf_t buf;
3788 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
3789 int len;
3790
3791 len = sizeof(*cmd);
3792 buf = wmi_buf_alloc(wmi_handle, len);
3793 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303794 WMI_LOGE(FL("wmi_buf_alloc failed"));
3795 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303796 }
3797
3798 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
3799 WMITLV_SET_HDR(&cmd->tlv_header,
3800 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
3801 WMITLV_GET_STRUCT_TLVLEN
3802 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
3803
3804
3805 cmd->vdev_id = vdev_id;
3806 cmd->sa_query_max_retry_count = max_retries;
3807 cmd->sa_query_retry_interval = retry_interval;
3808
Govind Singhb53420c2016-03-09 14:32:57 +05303809 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303810 vdev_id, retry_interval, max_retries);
3811
3812 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3813 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303814 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05303815 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303816 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303817 }
3818
Govind Singhb53420c2016-03-09 14:32:57 +05303819 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303820 return 0;
3821}
3822
3823/**
3824 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
3825 * @wmi_handle: wmi handle
3826 * @params: sta keep alive parameter
3827 *
3828 * This function sets keep alive related parameters in fw.
3829 *
3830 * Return: CDF status
3831 */
Govind Singhb53420c2016-03-09 14:32:57 +05303832QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303833 struct sta_params *params)
3834{
3835 wmi_buf_t buf;
3836 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
3837 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
3838 uint8_t *buf_ptr;
3839 int len;
Govind Singh67922e82016-04-01 16:48:57 +05303840 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303841
Govind Singhb53420c2016-03-09 14:32:57 +05303842 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303843
Govind Singh4eacd2b2016-03-07 14:24:22 +05303844 len = sizeof(*cmd) + sizeof(*arp_rsp);
3845 buf = wmi_buf_alloc(wmi_handle, len);
3846 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303847 WMI_LOGE("wmi_buf_alloc failed");
3848 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303849 }
3850
3851 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
3852 buf_ptr = (uint8_t *) cmd;
3853 WMITLV_SET_HDR(&cmd->tlv_header,
3854 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
3855 WMITLV_GET_STRUCT_TLVLEN
3856 (WMI_STA_KEEPALIVE_CMD_fixed_param));
3857 cmd->interval = params->timeperiod;
3858 cmd->enable = (params->timeperiod) ? 1 : 0;
3859 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05303860 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303861 params->timeperiod, params->method);
3862 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
3863 WMITLV_SET_HDR(&arp_rsp->tlv_header,
3864 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
3865 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
3866
3867 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
3868 if ((NULL == params->hostv4addr) ||
3869 (NULL == params->destv4addr) ||
3870 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303871 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05303872 "destv4addr:%p destmac:%p ", __func__,
3873 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303874 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303875 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303876 }
3877 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05303878 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303879 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05303880 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303881 WMI_IPV4_ADDR_LEN);
3882 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
3883 } else {
3884 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
3885 }
3886
Govind Singh67922e82016-04-01 16:48:57 +05303887 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3888 WMI_STA_KEEPALIVE_CMDID);
3889 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303890 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303891 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303892 }
3893
Govind Singhb53420c2016-03-09 14:32:57 +05303894 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303895 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303896}
3897
3898/**
3899 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
3900 * @wmi_handle: wmi handle
3901 * @if_id: vdev id
3902 * @gtx_info: GTX config params
3903 *
3904 * This function set GTX related params in firmware.
3905 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303906 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303907 */
Govind Singhb53420c2016-03-09 14:32:57 +05303908QDF_STATUS send_vdev_set_gtx_cfg_cmd_tlv(wmi_unified_t wmi_handle, uint32_t if_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303909 struct wmi_gtx_config *gtx_info)
3910{
3911 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
3912 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05303913 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303914 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303915
Govind Singh4eacd2b2016-03-07 14:24:22 +05303916 buf = wmi_buf_alloc(wmi_handle, len);
3917 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303918 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303919 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303920 }
3921 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
3922 WMITLV_SET_HDR(&cmd->tlv_header,
3923 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
3924 WMITLV_GET_STRUCT_TLVLEN
3925 (wmi_vdev_set_gtx_params_cmd_fixed_param));
3926 cmd->vdev_id = if_id;
3927
3928 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
3929 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
3930 cmd->userGtxMask = gtx_info->gtx_usrcfg;
3931 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
3932 cmd->gtxPERMargin = gtx_info->gtx_margin;
3933 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
3934 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
3935 cmd->gtxBWMask = gtx_info->gtx_bwmask;
3936
Govind Singhb53420c2016-03-09 14:32:57 +05303937 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05303938 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
3939 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
3940 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
3941 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
3942
Abhishek Singh716c46c2016-05-04 16:24:07 +05303943 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303944 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303945 if (QDF_IS_STATUS_ERROR(ret)) {
3946 WMI_LOGE("Failed to set GTX PARAMS");
3947 wmi_buf_free(buf);
3948 }
3949 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303950}
3951
3952/**
3953 * send_process_update_edca_param_cmd_tlv() - update EDCA params
3954 * @wmi_handle: wmi handle
3955 * @edca_params: edca parameters
3956 *
3957 * This function updates EDCA parameters to the target
3958 *
3959 * Return: CDF Status
3960 */
Govind Singhb53420c2016-03-09 14:32:57 +05303961QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303962 uint8_t vdev_id,
3963 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
3964{
3965 uint8_t *buf_ptr;
3966 wmi_buf_t buf;
3967 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
3968 wmi_wmm_vparams *wmm_param, *twmm_param;
3969 int len = sizeof(*cmd);
3970 int ac;
3971
3972 buf = wmi_buf_alloc(wmi_handle, len);
3973
3974 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303975 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3976 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303977 }
3978
3979 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3980 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
3981 WMITLV_SET_HDR(&cmd->tlv_header,
3982 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3983 WMITLV_GET_STRUCT_TLVLEN
3984 (wmi_vdev_set_wmm_params_cmd_fixed_param));
3985 cmd->vdev_id = vdev_id;
3986
3987 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
3988 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
3989 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
3990 WMITLV_SET_HDR(&wmm_param->tlv_header,
3991 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3992 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
3993 wmm_param->cwmin = twmm_param->cwmin;
3994 wmm_param->cwmax = twmm_param->cwmax;
3995 wmm_param->aifs = twmm_param->aifs;
3996 wmm_param->txoplimit = twmm_param->txoplimit;
3997 wmm_param->acm = twmm_param->acm;
3998 wmm_param->no_ack = twmm_param->no_ack;
3999 }
4000
4001 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4002 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4003 goto fail;
4004
Govind Singhb53420c2016-03-09 14:32:57 +05304005 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304006
4007fail:
4008 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304009 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4010 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304011}
4012
4013/**
4014 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4015 * @wmi_handle: wmi handle
4016 * @vdev_id: vdev id
4017 * @probe_rsp_info: probe response info
4018 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304019 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304020 */
Govind Singhb53420c2016-03-09 14:32:57 +05304021QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304022 uint8_t vdev_id,
4023 struct wmi_probe_resp_params *probe_rsp_info,
4024 uint8_t *frm)
4025{
4026 wmi_prb_tmpl_cmd_fixed_param *cmd;
4027 wmi_bcn_prb_info *bcn_prb_info;
4028 wmi_buf_t wmi_buf;
4029 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4030 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304031 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304032
Govind Singhb53420c2016-03-09 14:32:57 +05304033 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304034
4035 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4036 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4037
4038 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4039 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4040 tmpl_len_aligned;
4041
4042 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304043 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304044 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304045 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304046 }
4047
4048 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4049 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304050 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304051 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304052 }
4053
4054 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4055
4056 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4057 WMITLV_SET_HDR(&cmd->tlv_header,
4058 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4059 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4060 cmd->vdev_id = vdev_id;
4061 cmd->buf_len = tmpl_len;
4062 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4063
4064 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4065 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4066 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4067 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4068 bcn_prb_info->caps = 0;
4069 bcn_prb_info->erp = 0;
4070 buf_ptr += sizeof(wmi_bcn_prb_info);
4071
4072 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4073 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304074 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304075
4076 ret = wmi_unified_cmd_send(wmi_handle,
4077 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304078 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304079 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304080 wmi_buf_free(wmi_buf);
4081 }
4082
4083 return ret;
4084}
4085
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304086#ifdef FEATURE_WLAN_WAPI
4087#define WPI_IV_LEN 16
4088
4089/**
4090 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4091 *
4092 * @dest_tx: destination address of tsc key counter
4093 * @src_tx: source address of tsc key counter
4094 * @dest_rx: destination address of rsc key counter
4095 * @src_rx: source address of rsc key counter
4096 *
4097 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4098 *
4099 * Return: None
4100 *
4101 */
4102static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4103 uint8_t *dest_rx, uint8_t *src_rx)
4104{
4105 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4106 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4107}
4108#else
4109static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4110 uint8_t *dest_rx, uint8_t *src_rx)
4111{
4112 return;
4113}
4114#endif
4115
4116/**
4117 * send_setup_install_key_cmd_tlv() - set key parameters
4118 * @wmi_handle: wmi handle
4119 * @key_params: key parameters
4120 *
4121 * This function fills structure from information
4122 * passed in key_params.
4123 *
4124 * Return: QDF_STATUS_SUCCESS - success
4125 * QDF_STATUS_E_FAILURE - failure
4126 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4127 */
4128QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
4129 struct set_key_params *key_params)
4130{
4131 wmi_vdev_install_key_cmd_fixed_param *cmd;
4132 wmi_buf_t buf;
4133 uint8_t *buf_ptr;
4134 uint32_t len;
4135 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304136 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304137
4138 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4139 WMI_TLV_HDR_SIZE;
4140
4141 buf = wmi_buf_alloc(wmi_handle, len);
4142 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304143 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304144 return QDF_STATUS_E_NOMEM;
4145 }
4146
4147 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4148 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4149 WMITLV_SET_HDR(&cmd->tlv_header,
4150 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4151 WMITLV_GET_STRUCT_TLVLEN
4152 (wmi_vdev_install_key_cmd_fixed_param));
4153 cmd->vdev_id = key_params->vdev_id;
4154 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304155
4156 if (key_params->key_idx >= (IEEE80211_WEP_NKID + 1))
4157 cmd->key_ix = 0;
4158
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304159 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4160 cmd->key_flags |= key_params->key_flags;
4161 cmd->key_cipher = key_params->key_cipher;
4162 if ((key_params->key_txmic_len) &&
4163 (key_params->key_rxmic_len)) {
4164 cmd->key_txmic_len = key_params->key_txmic_len;
4165 cmd->key_rxmic_len = key_params->key_rxmic_len;
4166 }
Govind Singh87542482016-06-08 19:40:11 +05304167#ifdef FEATURE_WLAN_WAPI
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304168 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4169 key_params->tx_iv,
4170 cmd->wpi_key_rsc_counter,
4171 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304172#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304173 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4174 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4175 roundup(key_params->key_len, sizeof(uint32_t)));
4176 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4177 qdf_mem_copy((void *)key_data,
4178 (const void *)key_params->key_data, key_params->key_len);
4179 cmd->key_len = key_params->key_len;
4180
4181 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4182 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304183 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304184 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304185
Govind Singh67922e82016-04-01 16:48:57 +05304186 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304187}
4188
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304189/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004190 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4191 * @wmi_handle: wmi handle
4192 * @params: sar limit params
4193 *
4194 * Return: QDF_STATUS_SUCCESS for success or error code
4195 */
4196static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4197 struct sar_limit_cmd_params *sar_limit_params)
4198{
4199 wmi_buf_t buf;
4200 QDF_STATUS qdf_status;
4201 wmi_sar_limits_cmd_fixed_param *cmd;
4202 int i;
4203 uint8_t *buf_ptr;
4204 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4205 struct sar_limit_cmd_row *sar_rows_list;
4206 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4207
4208 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4209 buf = wmi_buf_alloc(wmi_handle, len);
4210 if (!buf) {
4211 WMI_LOGE("Failed to allocate memory");
4212 qdf_status = QDF_STATUS_E_NOMEM;
4213 goto end;
4214 }
4215
4216 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4217 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4218 WMITLV_SET_HDR(&cmd->tlv_header,
4219 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4220 WMITLV_GET_STRUCT_TLVLEN
4221 (wmi_sar_limits_cmd_fixed_param));
4222 cmd->sar_enable = sar_limit_params->sar_enable;
4223 cmd->commit_limits = sar_limit_params->commit_limits;
4224 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4225
4226 WMI_LOGD("no of sar rows = %d, len = %d",
4227 sar_limit_params->num_limit_rows, len);
4228 buf_ptr += sizeof(*cmd);
4229 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4230 sizeof(wmi_sar_limit_cmd_row) *
4231 sar_limit_params->num_limit_rows);
4232 if (cmd->num_limit_rows == 0)
4233 goto send_sar_limits;
4234
4235 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4236 (buf_ptr + WMI_TLV_HDR_SIZE);
4237 sar_rows_list = sar_limit_params->sar_limit_row_list;
4238
4239 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4240 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4241 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4242 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4243 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4244 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4245 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4246 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4247 wmi_sar_rows_list->validity_bitmap =
4248 sar_rows_list->validity_bitmap;
4249 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4250 i, wmi_sar_rows_list->band_id,
4251 wmi_sar_rows_list->chain_id,
4252 wmi_sar_rows_list->mod_id,
4253 wmi_sar_rows_list->limit_value,
4254 wmi_sar_rows_list->validity_bitmap);
4255 sar_rows_list++;
4256 wmi_sar_rows_list++;
4257 }
4258send_sar_limits:
4259 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4260 WMI_SAR_LIMITS_CMDID);
4261
4262 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4263 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4264 wmi_buf_free(buf);
4265 }
4266
4267end:
4268 return qdf_status;
4269}
4270
4271/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304272 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4273 * @wmi_handle: wmi handle
4274 * @params: encrypt/decrypt params
4275 *
4276 * Return: QDF_STATUS_SUCCESS for success or error code
4277 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004278static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304279QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4280 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4281{
4282 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4283 wmi_buf_t wmi_buf;
4284 uint8_t *buf_ptr;
4285 QDF_STATUS ret;
4286 uint32_t len;
4287
4288 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4289
4290 len = sizeof(*cmd) +
4291 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4292 WMI_TLV_HDR_SIZE;
4293 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4294 if (!wmi_buf) {
4295 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4296 __func__);
4297 return QDF_STATUS_E_NOMEM;
4298 }
4299
4300 buf_ptr = wmi_buf_data(wmi_buf);
4301 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4302
4303 WMITLV_SET_HDR(&cmd->tlv_header,
4304 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4305 WMITLV_GET_STRUCT_TLVLEN(
4306 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4307
4308 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4309 cmd->key_flag = encrypt_decrypt_params->key_flag;
4310 cmd->key_idx = encrypt_decrypt_params->key_idx;
4311 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4312 cmd->key_len = encrypt_decrypt_params->key_len;
4313 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4314 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4315
4316 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4317 encrypt_decrypt_params->key_len);
4318
4319 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4320 MAX_MAC_HEADER_LEN);
4321
4322 cmd->data_len = encrypt_decrypt_params->data_len;
4323
4324 if (cmd->data_len) {
4325 buf_ptr += sizeof(*cmd);
4326 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4327 roundup(encrypt_decrypt_params->data_len,
4328 sizeof(A_UINT32)));
4329 buf_ptr += WMI_TLV_HDR_SIZE;
4330 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4331 encrypt_decrypt_params->data_len);
4332 }
4333
4334 /* This conversion is to facilitate data to FW in little endian */
4335 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4336 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4337 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4338 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4339 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4340 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4341
4342 ret = wmi_unified_cmd_send(wmi_handle,
4343 wmi_buf, len,
4344 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4345 if (QDF_IS_STATUS_ERROR(ret)) {
4346 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4347 wmi_buf_free(wmi_buf);
4348 }
4349
4350 return ret;
4351}
4352
4353
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304354
Govind Singh4eacd2b2016-03-07 14:24:22 +05304355/**
4356 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4357 * @wmi_handle: wmi handle
4358 * @vdev_id: vdev id
4359 * @p2p_ie: p2p IE
4360 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304361 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304362 */
Govind Singhb53420c2016-03-09 14:32:57 +05304363QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304364 A_UINT32 vdev_id, uint8_t *p2p_ie)
4365{
Govind Singh67922e82016-04-01 16:48:57 +05304366 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304367 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4368 wmi_buf_t wmi_buf;
4369 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4370 uint8_t *buf_ptr;
4371
4372 ie_len = (uint32_t) (p2p_ie[1] + 2);
4373
4374 /* More than one P2P IE may be included in a single frame.
4375 If multiple P2P IEs are present, the complete P2P attribute
4376 data consists of the concatenation of the P2P Attribute
4377 fields of the P2P IEs. The P2P Attributes field of each
4378 P2P IE may be any length up to the maximum (251 octets).
4379 In this case host sends one P2P IE to firmware so the length
4380 should not exceed more than 251 bytes
4381 */
4382 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304383 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304384 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304385 }
4386
4387 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4388
4389 wmi_buf_len =
4390 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4391 WMI_TLV_HDR_SIZE;
4392
4393 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4394 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304395 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304396 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304397 }
4398
4399 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4400
4401 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4402 WMITLV_SET_HDR(&cmd->tlv_header,
4403 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4404 WMITLV_GET_STRUCT_TLVLEN
4405 (wmi_p2p_go_set_beacon_ie_fixed_param));
4406 cmd->vdev_id = vdev_id;
4407 cmd->ie_buf_len = ie_len;
4408
4409 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4410 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4411 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304412 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304413
Govind Singhb53420c2016-03-09 14:32:57 +05304414 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304415
4416 ret = wmi_unified_cmd_send(wmi_handle,
4417 wmi_buf, wmi_buf_len,
4418 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304419 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304420 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304421 wmi_buf_free(wmi_buf);
4422 }
4423
Govind Singhb53420c2016-03-09 14:32:57 +05304424 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304425 return ret;
4426}
4427
4428/**
4429 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4430 * @wmi_handle: wmi handle
4431 * @req: gateway parameter update request structure
4432 *
4433 * This function reads the incoming @req and fill in the destination
4434 * WMI structure and sends down the gateway configs down to the firmware
4435 *
Govind Singhb53420c2016-03-09 14:32:57 +05304436 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304437 */
Govind Singhb53420c2016-03-09 14:32:57 +05304438QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304439 struct gateway_update_req_param *req)
4440{
4441 wmi_roam_subnet_change_config_fixed_param *cmd;
4442 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304443 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304444 int len = sizeof(*cmd);
4445
4446 buf = wmi_buf_alloc(wmi_handle, len);
4447 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304448 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4449 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304450 }
4451
4452 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4453 WMITLV_SET_HDR(&cmd->tlv_header,
4454 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4455 WMITLV_GET_STRUCT_TLVLEN(
4456 wmi_roam_subnet_change_config_fixed_param));
4457
4458 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304459 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4460 QDF_IPV4_ADDR_SIZE);
4461 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4462 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304463 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4464 &cmd->inet_gw_mac_addr);
4465 cmd->max_retries = req->max_retries;
4466 cmd->timeout = req->timeout;
4467 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4468 cmd->flag = 0;
4469 if (req->ipv4_addr_type)
4470 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4471
4472 if (req->ipv6_addr_type)
4473 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4474
4475 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4476 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304477 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304478 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304479 ret);
4480 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304481 }
4482
Govind Singh67922e82016-04-01 16:48:57 +05304483 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304484}
4485
4486/**
4487 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4488 * @wmi_handle: wmi handle
4489 * @req: rssi monitoring request structure
4490 *
4491 * This function reads the incoming @req and fill in the destination
4492 * WMI structure and send down the rssi monitoring configs down to the firmware
4493 *
4494 * Return: 0 on success; error number otherwise
4495 */
Govind Singhb53420c2016-03-09 14:32:57 +05304496QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304497 struct rssi_monitor_param *req)
4498{
4499 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4500 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304501 QDF_STATUS ret;
4502 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304503
4504 buf = wmi_buf_alloc(wmi_handle, len);
4505 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304506 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4507 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304508 }
4509
4510 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4511 WMITLV_SET_HDR(&cmd->tlv_header,
4512 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4513 WMITLV_GET_STRUCT_TLVLEN(
4514 wmi_rssi_breach_monitor_config_fixed_param));
4515
4516 cmd->vdev_id = req->session_id;
4517 cmd->request_id = req->request_id;
4518 cmd->lo_rssi_reenable_hysteresis = 0;
4519 cmd->hi_rssi_reenable_histeresis = 0;
4520 cmd->min_report_interval = 0;
4521 cmd->max_num_report = 1;
4522 if (req->control) {
4523 /* enable one threshold for each min/max */
4524 cmd->enabled_bitmap = 0x09;
4525 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4526 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4527 } else {
4528 cmd->enabled_bitmap = 0;
4529 cmd->low_rssi_breach_threshold[0] = 0;
4530 cmd->hi_rssi_breach_threshold[0] = 0;
4531 }
4532
4533 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4534 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304535 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304536 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304537 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304538 }
4539
Govind Singhb53420c2016-03-09 14:32:57 +05304540 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304541 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304542}
4543
4544/**
4545 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4546 * @wmi_handle: wmi handle
4547 * @psetoui: OUI parameters
4548 *
4549 * set scan probe OUI parameters in firmware
4550 *
4551 * Return: CDF status
4552 */
Govind Singhb53420c2016-03-09 14:32:57 +05304553QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304554 struct scan_mac_oui *psetoui)
4555{
4556 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4557 wmi_buf_t wmi_buf;
4558 uint32_t len;
4559 uint8_t *buf_ptr;
4560 uint32_t *oui_buf;
4561
4562 len = sizeof(*cmd);
4563 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4564 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304565 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4566 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304567 }
4568 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4569 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4570 WMITLV_SET_HDR(&cmd->tlv_header,
4571 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4572 WMITLV_GET_STRUCT_TLVLEN
4573 (wmi_scan_prob_req_oui_cmd_fixed_param));
4574
4575 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304576 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304577 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4578 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304579 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304580 cmd->prob_req_oui);
4581
4582 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4583 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304584 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304585 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304586 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304587 }
Govind Singhb53420c2016-03-09 14:32:57 +05304588 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304589}
4590
4591/**
4592 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
4593 * @wmi_handle: wmi handle
4594 * @req: passpoint network request structure
4595 *
4596 * This function sends down WMI command with network id set to wildcard id.
4597 * firmware shall clear all the config entries
4598 *
Govind Singhb53420c2016-03-09 14:32:57 +05304599 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304600 */
Govind Singhb53420c2016-03-09 14:32:57 +05304601QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304602 struct wifi_passpoint_req_param *req)
4603{
4604 wmi_passpoint_config_cmd_fixed_param *cmd;
4605 wmi_buf_t buf;
4606 uint32_t len;
4607 int ret;
4608
4609 len = sizeof(*cmd);
4610 buf = wmi_buf_alloc(wmi_handle, len);
4611 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304612 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4613 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304614 }
4615
4616 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
4617
4618 WMITLV_SET_HDR(&cmd->tlv_header,
4619 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4620 WMITLV_GET_STRUCT_TLVLEN(
4621 wmi_passpoint_config_cmd_fixed_param));
4622 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
4623
4624 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4625 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4626 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304627 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304628 __func__);
4629 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304630 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304631 }
4632
Govind Singhb53420c2016-03-09 14:32:57 +05304633 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304634}
4635
4636/**
4637 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
4638 * @wmi_handle: wmi handle
4639 * @req: passpoint network request structure
4640 *
4641 * This function reads the incoming @req and fill in the destination
4642 * WMI structure and send down the passpoint configs down to the firmware
4643 *
Govind Singhb53420c2016-03-09 14:32:57 +05304644 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304645 */
Govind Singhb53420c2016-03-09 14:32:57 +05304646QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304647 struct wifi_passpoint_req_param *req)
4648{
4649 wmi_passpoint_config_cmd_fixed_param *cmd;
4650 u_int8_t i, j, *bytes;
4651 wmi_buf_t buf;
4652 uint32_t len;
4653 int ret;
4654
4655 len = sizeof(*cmd);
4656 for (i = 0; i < req->num_networks; i++) {
4657 buf = wmi_buf_alloc(wmi_handle, len);
4658 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304659 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4660 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304661 }
4662
4663 cmd = (wmi_passpoint_config_cmd_fixed_param *)
4664 wmi_buf_data(buf);
4665
4666 WMITLV_SET_HDR(&cmd->tlv_header,
4667 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4668 WMITLV_GET_STRUCT_TLVLEN(
4669 wmi_passpoint_config_cmd_fixed_param));
4670 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05304671 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
4672 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304673 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05304674 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304675 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
4676 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05304677 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304678 j, bytes[0], bytes[1], bytes[2], bytes[3],
4679 bytes[4], bytes[5], bytes[6], bytes[7]);
4680
Govind Singhb53420c2016-03-09 14:32:57 +05304681 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05304682 &req->networks[i].roaming_consortium_ids[j],
4683 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
4684 }
Govind Singhb53420c2016-03-09 14:32:57 +05304685 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304686 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304687 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304688 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
4689
4690 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4691 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4692 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304693 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304694 __func__);
4695 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304696 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304697 }
4698 }
4699
Govind Singhb53420c2016-03-09 14:32:57 +05304700 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304701}
4702
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304703/**
4704 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
4705 * @wmi_handle: wmi handle
4706 * @scan_cmd_fp: start scan command ptr
4707 * @roam_req: roam request param
4708 *
4709 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
4710 * of WMI_ROAM_SCAN_MODE.
4711 *
4712 * Return: QDF status
4713 */
4714QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
4715 wmi_start_scan_cmd_fixed_param *
4716 scan_cmd_fp,
4717 struct roam_offload_scan_params *roam_req)
4718{
4719 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304720 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304721 int len;
4722 uint8_t *buf_ptr;
4723 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05304724
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304725#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4726 int auth_mode = roam_req->auth_mode;
4727 wmi_roam_offload_tlv_param *roam_offload_params;
4728 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
4729 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
4730 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304731 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304732#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4733 /* Need to create a buf with roam_scan command at
4734 * front and piggyback with scan command */
4735 len = sizeof(wmi_roam_scan_mode_fixed_param) +
4736#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4737 (2 * WMI_TLV_HDR_SIZE) +
4738#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4739 sizeof(wmi_start_scan_cmd_fixed_param);
4740#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4741 if (roam_req->is_roam_req_valid &&
4742 roam_req->roam_offload_enabled) {
4743 len += sizeof(wmi_roam_offload_tlv_param);
4744 len += WMI_TLV_HDR_SIZE;
4745 if ((auth_mode != WMI_AUTH_NONE) &&
4746 ((auth_mode != WMI_AUTH_OPEN) ||
4747 (auth_mode == WMI_AUTH_OPEN &&
4748 roam_req->mdid.mdie_present) ||
4749 roam_req->is_ese_assoc)) {
4750 len += WMI_TLV_HDR_SIZE;
4751 if (roam_req->is_ese_assoc)
4752 len +=
4753 sizeof(wmi_roam_ese_offload_tlv_param);
4754 else if (auth_mode == WMI_AUTH_FT_RSNA ||
4755 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
4756 (auth_mode == WMI_AUTH_OPEN &&
4757 roam_req->mdid.mdie_present))
4758 len +=
4759 sizeof(wmi_roam_11r_offload_tlv_param);
4760 else
4761 len +=
4762 sizeof(wmi_roam_11i_offload_tlv_param);
4763 } else {
4764 len += WMI_TLV_HDR_SIZE;
4765 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304766
4767 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
4768 + roundup(roam_req->assoc_ie_length,
4769 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304770 } else {
4771 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05304772 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304773 __func__, roam_req->roam_offload_enabled);
4774 else
Govind Singhe7f2f342016-05-23 12:12:52 +05304775 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304776 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304777 }
4778 if (roam_req->is_roam_req_valid &&
4779 roam_req->roam_offload_enabled) {
4780 roam_req->mode = roam_req->mode |
4781 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
4782 }
4783#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4784
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304785 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4786 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4787 len = sizeof(wmi_roam_scan_mode_fixed_param);
4788
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304789 buf = wmi_buf_alloc(wmi_handle, len);
4790 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304791 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304792 return QDF_STATUS_E_NOMEM;
4793 }
4794
4795 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304796
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304797 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
4798 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
4799 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
4800 WMITLV_GET_STRUCT_TLVLEN
4801 (wmi_roam_scan_mode_fixed_param));
4802
4803 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
4804 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304805 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4806 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4807 goto send_roam_scan_mode_cmd;
4808
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304809 /* Fill in scan parameters suitable for roaming scan */
4810 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304811
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304812 qdf_mem_copy(buf_ptr, scan_cmd_fp,
4813 sizeof(wmi_start_scan_cmd_fixed_param));
4814 /* Ensure there is no additional IEs */
4815 scan_cmd_fp->ie_len = 0;
4816 WMITLV_SET_HDR(buf_ptr,
4817 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
4818 WMITLV_GET_STRUCT_TLVLEN
4819 (wmi_start_scan_cmd_fixed_param));
4820#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4821 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
4822 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
4823 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4824 sizeof(wmi_roam_offload_tlv_param));
4825 buf_ptr += WMI_TLV_HDR_SIZE;
4826 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
4827 WMITLV_SET_HDR(buf_ptr,
4828 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
4829 WMITLV_GET_STRUCT_TLVLEN
4830 (wmi_roam_offload_tlv_param));
4831 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
4832 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
4833 roam_offload_params->select_5g_margin =
4834 roam_req->select_5ghz_margin;
4835 roam_offload_params->reassoc_failure_timeout =
4836 roam_req->reassoc_failure_timeout;
4837
4838 /* Fill the capabilities */
4839 roam_offload_params->capability =
4840 roam_req->roam_offload_params.capability;
4841 roam_offload_params->ht_caps_info =
4842 roam_req->roam_offload_params.ht_caps_info;
4843 roam_offload_params->ampdu_param =
4844 roam_req->roam_offload_params.ampdu_param;
4845 roam_offload_params->ht_ext_cap =
4846 roam_req->roam_offload_params.ht_ext_cap;
4847 roam_offload_params->ht_txbf =
4848 roam_req->roam_offload_params.ht_txbf;
4849 roam_offload_params->asel_cap =
4850 roam_req->roam_offload_params.asel_cap;
4851 roam_offload_params->qos_caps =
4852 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08004853 roam_offload_params->qos_enabled =
4854 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304855 roam_offload_params->wmm_caps =
4856 roam_req->roam_offload_params.wmm_caps;
4857 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
4858 (uint8_t *)roam_req->roam_offload_params.mcsset,
4859 ROAM_OFFLOAD_NUM_MCS_SET);
4860
4861 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
4862 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
4863 * they are filled in the same order.Depending on the
4864 * authentication type, the other mode TLV's are nullified
4865 * and only headers are filled.*/
4866 if ((auth_mode != WMI_AUTH_NONE) &&
4867 ((auth_mode != WMI_AUTH_OPEN) ||
4868 (auth_mode == WMI_AUTH_OPEN
4869 && roam_req->mdid.mdie_present) ||
4870 roam_req->is_ese_assoc)) {
4871 if (roam_req->is_ese_assoc) {
4872 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4873 WMITLV_GET_STRUCT_TLVLEN(0));
4874 buf_ptr += WMI_TLV_HDR_SIZE;
4875 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4876 WMITLV_GET_STRUCT_TLVLEN(0));
4877 buf_ptr += WMI_TLV_HDR_SIZE;
4878 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4879 sizeof(wmi_roam_ese_offload_tlv_param));
4880 buf_ptr += WMI_TLV_HDR_SIZE;
4881 roam_offload_ese =
4882 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
4883 qdf_mem_copy(roam_offload_ese->krk,
4884 roam_req->krk,
4885 sizeof(roam_req->krk));
4886 qdf_mem_copy(roam_offload_ese->btk,
4887 roam_req->btk,
4888 sizeof(roam_req->btk));
4889 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
4890 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
4891 WMITLV_GET_STRUCT_TLVLEN
4892 (wmi_roam_ese_offload_tlv_param));
4893 buf_ptr +=
4894 sizeof(wmi_roam_ese_offload_tlv_param);
4895 } else if (auth_mode == WMI_AUTH_FT_RSNA
4896 || auth_mode == WMI_AUTH_FT_RSNA_PSK
4897 || (auth_mode == WMI_AUTH_OPEN
4898 && roam_req->mdid.mdie_present)) {
4899 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4900 0);
4901 buf_ptr += WMI_TLV_HDR_SIZE;
4902 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4903 sizeof(wmi_roam_11r_offload_tlv_param));
4904 buf_ptr += WMI_TLV_HDR_SIZE;
4905 roam_offload_11r =
4906 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
4907 roam_offload_11r->r0kh_id_len =
4908 roam_req->rokh_id_length;
4909 qdf_mem_copy(roam_offload_11r->r0kh_id,
4910 roam_req->rokh_id,
4911 roam_offload_11r->r0kh_id_len);
4912 qdf_mem_copy(roam_offload_11r->psk_msk,
4913 roam_req->psk_pmk,
4914 sizeof(roam_req->psk_pmk));
4915 roam_offload_11r->psk_msk_len =
4916 roam_req->pmk_len;
4917 roam_offload_11r->mdie_present =
4918 roam_req->mdid.mdie_present;
4919 roam_offload_11r->mdid =
4920 roam_req->mdid.mobility_domain;
4921 if (auth_mode == WMI_AUTH_OPEN) {
4922 /* If FT-Open ensure pmk length
4923 and r0khid len are zero */
4924 roam_offload_11r->r0kh_id_len = 0;
4925 roam_offload_11r->psk_msk_len = 0;
4926 }
4927 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
4928 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
4929 WMITLV_GET_STRUCT_TLVLEN
4930 (wmi_roam_11r_offload_tlv_param));
4931 buf_ptr +=
4932 sizeof(wmi_roam_11r_offload_tlv_param);
4933 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4934 WMITLV_GET_STRUCT_TLVLEN(0));
4935 buf_ptr += WMI_TLV_HDR_SIZE;
4936 } else {
4937 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4938 sizeof(wmi_roam_11i_offload_tlv_param));
4939 buf_ptr += WMI_TLV_HDR_SIZE;
4940 roam_offload_11i =
4941 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07004942 if (roam_req->roam_key_mgmt_offload_enabled &&
4943 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304944 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
4945 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304946 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304947 } else {
4948 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
4949 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304950 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304951 }
4952
4953 qdf_mem_copy(roam_offload_11i->pmk,
4954 roam_req->psk_pmk,
4955 sizeof(roam_req->psk_pmk));
4956 roam_offload_11i->pmk_len = roam_req->pmk_len;
4957 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
4958 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
4959 WMITLV_GET_STRUCT_TLVLEN
4960 (wmi_roam_11i_offload_tlv_param));
4961 buf_ptr +=
4962 sizeof(wmi_roam_11i_offload_tlv_param);
4963 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4964 0);
4965 buf_ptr += WMI_TLV_HDR_SIZE;
4966 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4967 0);
4968 buf_ptr += WMI_TLV_HDR_SIZE;
4969 }
4970 } else {
4971 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4972 WMITLV_GET_STRUCT_TLVLEN(0));
4973 buf_ptr += WMI_TLV_HDR_SIZE;
4974 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4975 WMITLV_GET_STRUCT_TLVLEN(0));
4976 buf_ptr += WMI_TLV_HDR_SIZE;
4977 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4978 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304979 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304980 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304981
4982 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4983 sizeof(*assoc_ies));
4984 buf_ptr += WMI_TLV_HDR_SIZE;
4985
4986 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
4987 WMITLV_SET_HDR(&assoc_ies->tlv_header,
4988 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
4989 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
4990 assoc_ies->buf_len = roam_req->assoc_ie_length;
4991
4992 buf_ptr += sizeof(*assoc_ies);
4993
4994 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4995 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
4996 buf_ptr += WMI_TLV_HDR_SIZE;
4997
4998 if (assoc_ies->buf_len != 0) {
4999 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5000 assoc_ies->buf_len);
5001 }
5002
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305003 } else {
5004 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5005 WMITLV_GET_STRUCT_TLVLEN(0));
5006 buf_ptr += WMI_TLV_HDR_SIZE;
5007 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5008 WMITLV_GET_STRUCT_TLVLEN(0));
5009 buf_ptr += WMI_TLV_HDR_SIZE;
5010 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5011 WMITLV_GET_STRUCT_TLVLEN(0));
5012 buf_ptr += WMI_TLV_HDR_SIZE;
5013 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5014 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305015 buf_ptr += WMI_TLV_HDR_SIZE;
5016 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5017 WMITLV_GET_STRUCT_TLVLEN(0));
5018 buf_ptr += WMI_TLV_HDR_SIZE;
5019 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5020 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305021 }
5022#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305023
5024send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305025 status = wmi_unified_cmd_send(wmi_handle, buf,
5026 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305027 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305028 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305029 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5030 status);
5031 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305032 }
5033
Govind Singh67922e82016-04-01 16:48:57 +05305034 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305035}
5036
5037
5038/**
5039 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5040 * rssi threashold
5041 * @wmi_handle: wmi handle
5042 * @roam_req: Roaming request buffer
5043 *
5044 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5045 *
5046 * Return: QDF status
5047 */
5048QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
5049 struct roam_offload_scan_rssi_params *roam_req)
5050{
5051 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305052 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305053 int len;
5054 uint8_t *buf_ptr;
5055 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5056 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5057 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305058 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305059
5060 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5061 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5062 len += sizeof(wmi_roam_scan_extended_threshold_param);
5063 len += WMI_TLV_HDR_SIZE;
5064 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305065 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5066 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305067 buf = wmi_buf_alloc(wmi_handle, len);
5068 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305069 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305070 return QDF_STATUS_E_NOMEM;
5071 }
5072
5073 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5074 rssi_threshold_fp =
5075 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5076 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5077 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5078 WMITLV_GET_STRUCT_TLVLEN
5079 (wmi_roam_scan_rssi_threshold_fixed_param));
5080 /* fill in threshold values */
5081 rssi_threshold_fp->vdev_id = roam_req->session_id;
5082 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5083 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5084 rssi_threshold_fp->hirssi_scan_max_count =
5085 roam_req->hi_rssi_scan_max_count;
5086 rssi_threshold_fp->hirssi_scan_delta =
5087 roam_req->hi_rssi_scan_rssi_delta;
5088 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5089
5090 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5091 WMITLV_SET_HDR(buf_ptr,
5092 WMITLV_TAG_ARRAY_STRUC,
5093 sizeof(wmi_roam_scan_extended_threshold_param));
5094 buf_ptr += WMI_TLV_HDR_SIZE;
5095 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5096
5097 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5098 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5099 ext_thresholds->boost_threshold_5g =
5100 roam_req->boost_threshold_5g;
5101
5102 ext_thresholds->boost_algorithm_5g =
5103 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5104 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5105 ext_thresholds->penalty_algorithm_5g =
5106 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5107 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5108 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5109 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5110 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5111
5112 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5113 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5114 WMITLV_GET_STRUCT_TLVLEN
5115 (wmi_roam_scan_extended_threshold_param));
5116 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5117 WMITLV_SET_HDR(buf_ptr,
5118 WMITLV_TAG_ARRAY_STRUC,
5119 sizeof(wmi_roam_earlystop_rssi_thres_param));
5120 buf_ptr += WMI_TLV_HDR_SIZE;
5121 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5122 early_stop_thresholds->roam_earlystop_thres_min =
5123 roam_req->roam_earlystop_thres_min;
5124 early_stop_thresholds->roam_earlystop_thres_max =
5125 roam_req->roam_earlystop_thres_max;
5126 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5127 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5128 WMITLV_GET_STRUCT_TLVLEN
5129 (wmi_roam_earlystop_rssi_thres_param));
5130
Gupta, Kapil7e652922016-04-12 15:02:00 +05305131 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5132 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5133 sizeof(wmi_roam_dense_thres_param));
5134 buf_ptr += WMI_TLV_HDR_SIZE;
5135 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5136 dense_thresholds->roam_dense_rssi_thres_offset =
5137 roam_req->dense_rssi_thresh_offset;
5138 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5139 dense_thresholds->roam_dense_traffic_thres =
5140 roam_req->traffic_threshold;
5141 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5142 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5143 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5144 WMITLV_GET_STRUCT_TLVLEN
5145 (wmi_roam_dense_thres_param));
5146
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305147 status = wmi_unified_cmd_send(wmi_handle, buf,
5148 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305149 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305150 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305151 status);
5152 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305153 }
5154
Govind Singh67922e82016-04-01 16:48:57 +05305155 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305156}
5157
5158/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305159 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5160 * configuration params
5161 * @wma_handle: wma handler
5162 * @dwelltime_params: pointer to dwelltime_params
5163 *
5164 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5165 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005166static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305167QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5168 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5169{
5170 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5171 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5172 wmi_buf_t buf;
5173 uint8_t *buf_ptr;
5174 int32_t err;
5175 int len;
5176
5177 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5178 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5179 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5180 buf = wmi_buf_alloc(wmi_handle, len);
5181 if (!buf) {
5182 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5183 __func__);
5184 return QDF_STATUS_E_NOMEM;
5185 }
5186 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5187 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5188 WMITLV_SET_HDR(&dwell_param->tlv_header,
5189 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5190 WMITLV_GET_STRUCT_TLVLEN
5191 (wmi_scan_adaptive_dwell_config_fixed_param));
5192
5193 dwell_param->enable = dwelltime_params->is_enabled;
5194 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5195 WMITLV_SET_HDR(buf_ptr,
5196 WMITLV_TAG_ARRAY_STRUC,
5197 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5198 buf_ptr += WMI_TLV_HDR_SIZE;
5199
5200 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5201 WMITLV_SET_HDR(&cmd->tlv_header,
5202 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5203 WMITLV_GET_STRUCT_TLVLEN(
5204 wmi_scan_adaptive_dwell_parameters_tlv));
5205
5206 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5207 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5208 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5209 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5210 err = wmi_unified_cmd_send(wmi_handle, buf,
5211 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5212 if (err) {
5213 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5214 wmi_buf_free(buf);
5215 return QDF_STATUS_E_FAILURE;
5216 }
5217
5218 return QDF_STATUS_SUCCESS;
5219}
5220
5221
5222/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305223 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5224 * @wmi_handle: wmi handle
5225 * @roam_req: Request which contains the filters
5226 *
5227 * There are filters such as whitelist, blacklist and preferred
5228 * list that need to be applied to the scan results to form the
5229 * probable candidates for roaming.
5230 *
5231 * Return: Return success upon succesfully passing the
5232 * parameters to the firmware, otherwise failure.
5233 */
5234QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
5235 struct roam_scan_filter_params *roam_req)
5236{
5237 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305238 QDF_STATUS status;
5239 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305240 uint32_t len;
5241 uint8_t *buf_ptr;
5242 wmi_roam_filter_fixed_param *roam_filter;
5243 uint8_t *bssid_src_ptr = NULL;
5244 wmi_mac_addr *bssid_dst_ptr = NULL;
5245 wmi_ssid *ssid_ptr = NULL;
5246 uint32_t *bssid_preferred_factor_ptr = NULL;
5247
5248 len = sizeof(wmi_roam_filter_fixed_param);
5249 len += WMI_TLV_HDR_SIZE;
5250 len += roam_req->len;
5251
5252 buf = wmi_buf_alloc(wmi_handle, len);
5253 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305254 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305255 return QDF_STATUS_E_NOMEM;
5256 }
5257
5258 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5259 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5260 WMITLV_SET_HDR(&roam_filter->tlv_header,
5261 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5262 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5263 /* fill in fixed values */
5264 roam_filter->vdev_id = roam_req->session_id;
5265 roam_filter->flags = 0;
5266 roam_filter->op_bitmap = roam_req->op_bitmap;
5267 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5268 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5269 roam_filter->num_bssid_preferred_list =
5270 roam_req->num_bssid_preferred_list;
5271 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5272
5273 WMITLV_SET_HDR((buf_ptr),
5274 WMITLV_TAG_ARRAY_FIXED_STRUC,
5275 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5276 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5277 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5278 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5279 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5280 bssid_src_ptr += ATH_MAC_LEN;
5281 bssid_dst_ptr++;
5282 }
5283 buf_ptr += WMI_TLV_HDR_SIZE +
5284 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5285 WMITLV_SET_HDR((buf_ptr),
5286 WMITLV_TAG_ARRAY_FIXED_STRUC,
5287 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5288 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5289 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5290 qdf_mem_copy(&ssid_ptr->ssid,
5291 &roam_req->ssid_allowed_list[i].mac_ssid,
5292 roam_req->ssid_allowed_list[i].length);
5293 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5294 ssid_ptr++;
5295 }
5296 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5297 sizeof(wmi_ssid));
5298 WMITLV_SET_HDR((buf_ptr),
5299 WMITLV_TAG_ARRAY_FIXED_STRUC,
5300 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5301 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5302 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5303 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5304 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5305 (wmi_mac_addr *)bssid_dst_ptr);
5306 bssid_src_ptr += ATH_MAC_LEN;
5307 bssid_dst_ptr++;
5308 }
5309 buf_ptr += WMI_TLV_HDR_SIZE +
5310 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5311 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5312 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5313 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5314 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5315 *bssid_preferred_factor_ptr =
5316 roam_req->bssid_favored_factor[i];
5317 bssid_preferred_factor_ptr++;
5318 }
5319 buf_ptr += WMI_TLV_HDR_SIZE +
5320 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5321
5322 status = wmi_unified_cmd_send(wmi_handle, buf,
5323 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305324 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305325 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305326 status);
5327 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305328 }
Govind Singh67922e82016-04-01 16:48:57 +05305329
5330 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305331}
5332
Govind Singh4eacd2b2016-03-07 14:24:22 +05305333/** send_set_epno_network_list_cmd_tlv() - set epno network list
5334 * @wmi_handle: wmi handle
5335 * @req: epno config params request structure
5336 *
5337 * This function reads the incoming epno config request structure
5338 * and constructs the WMI message to the firmware.
5339 *
5340 * Returns: 0 on success, error number otherwise
5341 */
Govind Singhb53420c2016-03-09 14:32:57 +05305342QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305343 struct wifi_enhanched_pno_params *req)
5344{
5345 wmi_nlo_config_cmd_fixed_param *cmd;
5346 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305347 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305348 u_int8_t i, *buf_ptr;
5349 wmi_buf_t buf;
5350 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305351 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305352
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305353 /* Fixed Params */
5354 len = sizeof(*cmd);
5355 if (req->num_networks) {
5356 /* TLV place holder for array of structures
5357 * then each nlo_configured_parameters(nlo_list) TLV.
5358 */
5359 len += WMI_TLV_HDR_SIZE;
5360 len += (sizeof(nlo_configured_parameters)
5361 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5362 /* TLV for array of uint32 channel_list */
5363 len += WMI_TLV_HDR_SIZE;
5364 /* TLV for nlo_channel_prediction_cfg */
5365 len += WMI_TLV_HDR_SIZE;
5366 /* TLV for candidate score params */
5367 len += sizeof(enlo_candidate_score_params);
5368 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305369
5370 buf = wmi_buf_alloc(wmi_handle, len);
5371 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305372 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5373 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305374 }
5375
5376 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5377
5378 buf_ptr = (u_int8_t *) cmd;
5379 WMITLV_SET_HDR(&cmd->tlv_header,
5380 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5381 WMITLV_GET_STRUCT_TLVLEN(
5382 wmi_nlo_config_cmd_fixed_param));
5383 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305384
5385 /* set flag to reset if num of networks are 0 */
5386 cmd->flags = (req->num_networks == 0 ?
5387 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305388
5389 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5390
Govind Singhb53420c2016-03-09 14:32:57 +05305391 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305392 WMI_LOGD("SSID count: %d flags: %d",
5393 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305394
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305395 /* Fill nlo_config only when num_networks are non zero */
5396 if (cmd->no_of_ssids) {
5397 /* Fill networks */
5398 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5399 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5400 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305401
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305402 nlo_list = (nlo_configured_parameters *) buf_ptr;
5403 for (i = 0; i < cmd->no_of_ssids; i++) {
5404 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5405 WMITLV_TAG_ARRAY_BYTE,
5406 WMITLV_GET_STRUCT_TLVLEN(
5407 nlo_configured_parameters));
5408 /* Copy ssid and it's length */
5409 nlo_list[i].ssid.valid = true;
5410 nlo_list[i].ssid.ssid.ssid_len =
5411 req->networks[i].ssid.length;
5412 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5413 req->networks[i].ssid.mac_ssid,
5414 nlo_list[i].ssid.ssid.ssid_len);
5415 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5416 nlo_list[i].ssid.ssid.ssid_len,
5417 (char *) nlo_list[i].ssid.ssid.ssid,
5418 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305419
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305420 /* Copy pno flags */
5421 nlo_list[i].bcast_nw_type.valid = true;
5422 nlo_list[i].bcast_nw_type.bcast_nw_type =
5423 req->networks[i].flags;
5424 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305425 nlo_list[i].bcast_nw_type.bcast_nw_type);
5426
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305427 /* Copy auth bit field */
5428 nlo_list[i].auth_type.valid = true;
5429 nlo_list[i].auth_type.auth_type =
5430 req->networks[i].auth_bit_field;
5431 WMI_LOGD("Auth bit field (%u)",
5432 nlo_list[i].auth_type.auth_type);
5433 }
5434
5435 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5436 /* Fill the channel list */
5437 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5438 buf_ptr += WMI_TLV_HDR_SIZE;
5439
5440 /* Fill prediction_param */
5441 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5442 buf_ptr += WMI_TLV_HDR_SIZE;
5443
5444 /* Fill epno candidate score params */
5445 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5446 WMITLV_SET_HDR(buf_ptr,
5447 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5448 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5449 cand_score_params->min5GHz_rssi =
5450 req->min_5ghz_rssi;
5451 cand_score_params->min24GHz_rssi =
5452 req->min_24ghz_rssi;
5453 cand_score_params->initial_score_max =
5454 req->initial_score_max;
5455 cand_score_params->current_connection_bonus =
5456 req->current_connection_bonus;
5457 cand_score_params->same_network_bonus =
5458 req->same_network_bonus;
5459 cand_score_params->secure_bonus =
5460 req->secure_bonus;
5461 cand_score_params->band5GHz_bonus =
5462 req->band_5ghz_bonus;
5463 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305464 }
5465
Govind Singh4eacd2b2016-03-07 14:24:22 +05305466 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305467 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305468 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305469 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305470 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305471 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305472 }
5473
Govind Singhb53420c2016-03-09 14:32:57 +05305474 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305475 req->session_id);
5476
Govind Singh67922e82016-04-01 16:48:57 +05305477 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305478}
5479
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305480
Govind Singh4eacd2b2016-03-07 14:24:22 +05305481/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5482 * @wmi_handle: wmi handle
5483 * @ipa_offload: ipa offload control parameter
5484 *
5485 * Returns: 0 on success, error number otherwise
5486 */
Govind Singhb53420c2016-03-09 14:32:57 +05305487QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305488 struct ipa_offload_control_params *ipa_offload)
5489{
5490 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5491 wmi_buf_t wmi_buf;
5492 uint32_t len;
5493 u_int8_t *buf_ptr;
5494
5495 len = sizeof(*cmd);
5496 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5497 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305498 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5499 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305500 }
5501
Govind Singhb53420c2016-03-09 14:32:57 +05305502 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305503 ipa_offload->offload_type, ipa_offload->enable);
5504
5505 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5506
5507 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5508 WMITLV_SET_HDR(&cmd->tlv_header,
5509 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5510 WMITLV_GET_STRUCT_TLVLEN(
5511 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5512
5513 cmd->offload_type = ipa_offload->offload_type;
5514 cmd->vdev_id = ipa_offload->vdev_id;
5515 cmd->enable = ipa_offload->enable;
5516
5517 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5518 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305519 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305520 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305521 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305522 }
5523
Govind Singhb53420c2016-03-09 14:32:57 +05305524 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305525}
5526
5527/**
5528 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5529 * @wmi_handle: wmi handle
5530 * @pgetcapab: get capabilities params
5531 *
5532 * This function send request to fw to get extscan capabilities.
5533 *
5534 * Return: CDF status
5535 */
Govind Singhb53420c2016-03-09 14:32:57 +05305536QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305537 struct extscan_capabilities_params *pgetcapab)
5538{
5539 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5540 wmi_buf_t wmi_buf;
5541 uint32_t len;
5542 uint8_t *buf_ptr;
5543
5544 len = sizeof(*cmd);
5545 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5546 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305547 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5548 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305549 }
5550 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5551
5552 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5553 WMITLV_SET_HDR(&cmd->tlv_header,
5554 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5555 WMITLV_GET_STRUCT_TLVLEN
5556 (wmi_extscan_get_capabilities_cmd_fixed_param));
5557
5558 cmd->request_id = pgetcapab->request_id;
5559
5560 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5561 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305562 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305563 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305564 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305565 }
Govind Singhb53420c2016-03-09 14:32:57 +05305566 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305567}
5568
5569/**
5570 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5571 * @wmi_handle: wmi handle
5572 * @pcached_results: cached results parameters
5573 *
5574 * This function send request to fw to get cached results.
5575 *
5576 * Return: CDF status
5577 */
Govind Singhb53420c2016-03-09 14:32:57 +05305578QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305579 struct extscan_cached_result_params *pcached_results)
5580{
5581 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5582 wmi_buf_t wmi_buf;
5583 uint32_t len;
5584 uint8_t *buf_ptr;
5585
5586 len = sizeof(*cmd);
5587 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5588 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305589 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5590 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305591 }
5592 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5593
5594 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
5595 WMITLV_SET_HDR(&cmd->tlv_header,
5596 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
5597 WMITLV_GET_STRUCT_TLVLEN
5598 (wmi_extscan_get_cached_results_cmd_fixed_param));
5599
5600 cmd->request_id = pcached_results->request_id;
5601 cmd->vdev_id = pcached_results->session_id;
5602 cmd->control_flags = pcached_results->flush;
5603
5604 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5605 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305606 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305607 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305608 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305609 }
Govind Singhb53420c2016-03-09 14:32:57 +05305610 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305611}
5612
5613/**
5614 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
5615 * @wmi_handle: wmi handle
5616 * @reset_req: Reset change request params
5617 *
5618 * This function sends stop change monitor request to fw.
5619 *
5620 * Return: CDF status
5621 */
Govind Singhb53420c2016-03-09 14:32:57 +05305622QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305623 struct extscan_capabilities_reset_params *reset_req)
5624{
5625 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5626 wmi_buf_t wmi_buf;
5627 uint32_t len;
5628 uint8_t *buf_ptr;
5629 int change_list = 0;
5630
5631 len = sizeof(*cmd);
5632
5633 /* reset significant change tlv is set to 0 */
5634 len += WMI_TLV_HDR_SIZE;
5635 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
5636 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5637 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305638 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5639 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305640 }
5641 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5642
5643 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5644 buf_ptr;
5645 WMITLV_SET_HDR(&cmd->tlv_header,
5646 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5647 WMITLV_GET_STRUCT_TLVLEN
5648 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5649
5650 cmd->request_id = reset_req->request_id;
5651 cmd->vdev_id = reset_req->session_id;
5652 cmd->mode = 0;
5653
5654 buf_ptr += sizeof(*cmd);
5655 WMITLV_SET_HDR(buf_ptr,
5656 WMITLV_TAG_ARRAY_STRUC,
5657 change_list *
5658 sizeof(wmi_extscan_wlan_change_bssid_param));
5659 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
5660 sizeof
5661 (wmi_extscan_wlan_change_bssid_param));
5662
5663 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5664 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305665 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305666 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305667 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305668 }
Govind Singhb53420c2016-03-09 14:32:57 +05305669 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305670}
5671
5672/**
5673 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
5674 * @wmi_handle: wmi handle
5675 * @psigchange: change monitor request params
5676 * @buf: wmi buffer
5677 * @buf_len: buffer length
5678 *
5679 * This function fills elements of change monitor request buffer.
5680 *
5681 * Return: CDF status
5682 */
Govind Singhb53420c2016-03-09 14:32:57 +05305683static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305684 struct extscan_set_sig_changereq_params
5685 *psigchange, wmi_buf_t *buf, int *buf_len)
5686{
5687 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5688 wmi_extscan_wlan_change_bssid_param *dest_chglist;
5689 uint8_t *buf_ptr;
5690 int j;
5691 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08005692 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305693 struct ap_threshold_params *src_ap = psigchange->ap;
5694
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08005695 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305696 WMI_LOGE("%s: Invalid number of bssid's", __func__);
5697 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305698 }
5699 len += WMI_TLV_HDR_SIZE;
5700 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
5701
5702 *buf = wmi_buf_alloc(wmi_handle, len);
5703 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305704 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305705 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305706 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305707 }
5708 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5709 cmd =
5710 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5711 buf_ptr;
5712 WMITLV_SET_HDR(&cmd->tlv_header,
5713 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5714 WMITLV_GET_STRUCT_TLVLEN
5715 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5716
5717 cmd->request_id = psigchange->request_id;
5718 cmd->vdev_id = psigchange->session_id;
5719 cmd->total_entries = numap;
5720 cmd->mode = 1;
5721 cmd->num_entries_in_page = numap;
5722 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
5723 cmd->max_rssi_samples = psigchange->rssi_sample_size;
5724 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
5725 cmd->max_out_of_range_count = psigchange->min_breaching;
5726
5727 buf_ptr += sizeof(*cmd);
5728 WMITLV_SET_HDR(buf_ptr,
5729 WMITLV_TAG_ARRAY_STRUC,
5730 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5731 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
5732 (buf_ptr + WMI_TLV_HDR_SIZE);
5733
5734 for (j = 0; j < numap; j++) {
5735 WMITLV_SET_HDR(dest_chglist,
5736 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5737 WMITLV_GET_STRUCT_TLVLEN
5738 (wmi_extscan_wlan_change_bssid_param));
5739
5740 dest_chglist->lower_rssi_limit = src_ap->low;
5741 dest_chglist->upper_rssi_limit = src_ap->high;
5742 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
5743 &dest_chglist->bssid);
5744
Govind Singhb53420c2016-03-09 14:32:57 +05305745 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305746 dest_chglist->lower_rssi_limit);
5747 dest_chglist++;
5748 src_ap++;
5749 }
5750 buf_ptr += WMI_TLV_HDR_SIZE +
5751 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5752 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305753 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305754}
5755
5756/**
5757 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
5758 * @wmi_handle: wmi handle
5759 * @psigchange: change monitor request params
5760 *
5761 * This function sends start change monitor request to fw.
5762 *
5763 * Return: CDF status
5764 */
Govind Singhb53420c2016-03-09 14:32:57 +05305765QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305766 struct extscan_set_sig_changereq_params *
5767 psigchange)
5768{
Govind Singhb53420c2016-03-09 14:32:57 +05305769 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305770 wmi_buf_t buf;
5771 int len;
5772
5773
Govind Singhb53420c2016-03-09 14:32:57 +05305774 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305775 psigchange, &buf,
5776 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305777 if (qdf_status != QDF_STATUS_SUCCESS) {
5778 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305779 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305780 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305781 }
5782 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305783 WMI_LOGE("%s: Failed to get buffer", __func__);
5784 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305785 }
5786 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5787 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305788 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305789 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305790 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305791 }
Govind Singhb53420c2016-03-09 14:32:57 +05305792 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305793}
5794
5795/**
5796 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
5797 * @wmi_handle: wmi handle
5798 * @photlist_reset: hotlist reset params
5799 *
5800 * This function configures hotlist monitor to stop in fw.
5801 *
5802 * Return: CDF status
5803 */
Govind Singhb53420c2016-03-09 14:32:57 +05305804QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305805 struct extscan_bssid_hotlist_reset_params *photlist_reset)
5806{
5807 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
5808 wmi_buf_t wmi_buf;
5809 uint32_t len;
5810 uint8_t *buf_ptr;
5811 int hotlist_entries = 0;
5812
5813 len = sizeof(*cmd);
5814
5815 /* reset bssid hotlist with tlv set to 0 */
5816 len += WMI_TLV_HDR_SIZE;
5817 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
5818
5819 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5820 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305821 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5822 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305823 }
5824
5825 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5826 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
5827 buf_ptr;
5828 WMITLV_SET_HDR(&cmd->tlv_header,
5829 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
5830 WMITLV_GET_STRUCT_TLVLEN
5831 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
5832
5833 cmd->request_id = photlist_reset->request_id;
5834 cmd->vdev_id = photlist_reset->session_id;
5835 cmd->mode = 0;
5836
5837 buf_ptr += sizeof(*cmd);
5838 WMITLV_SET_HDR(buf_ptr,
5839 WMITLV_TAG_ARRAY_STRUC,
5840 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5841 buf_ptr += WMI_TLV_HDR_SIZE +
5842 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5843
5844 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5845 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305846 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305847 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305848 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305849 }
Govind Singhb53420c2016-03-09 14:32:57 +05305850 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305851}
5852
5853/**
5854 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
5855 * @wmi_handle: wmi handle
5856 * @pstopcmd: stop scan command request params
5857 *
5858 * This function sends stop extscan request to fw.
5859 *
5860 * Return: CDF Status.
5861 */
Govind Singhb53420c2016-03-09 14:32:57 +05305862QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305863 struct extscan_stop_req_params *pstopcmd)
5864{
5865 wmi_extscan_stop_cmd_fixed_param *cmd;
5866 wmi_buf_t wmi_buf;
5867 uint32_t len;
5868 uint8_t *buf_ptr;
5869
5870 len = sizeof(*cmd);
5871 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5872 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305873 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5874 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305875 }
5876 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5877 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
5878 WMITLV_SET_HDR(&cmd->tlv_header,
5879 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
5880 WMITLV_GET_STRUCT_TLVLEN
5881 (wmi_extscan_stop_cmd_fixed_param));
5882
5883 cmd->request_id = pstopcmd->request_id;
5884 cmd->vdev_id = pstopcmd->session_id;
5885
5886 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5887 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305888 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305889 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305890 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305891 }
5892
Govind Singhb53420c2016-03-09 14:32:57 +05305893 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305894}
5895
5896/**
5897 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
5898 * @wmi_handle: wmi handle
5899 * @pstart: scan command request params
5900 * @buf: event buffer
5901 * @buf_len: length of buffer
5902 *
5903 * This function fills individual elements of extscan request and
5904 * TLV for buckets, channel list.
5905 *
5906 * Return: CDF Status.
5907 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005908static
Govind Singhb53420c2016-03-09 14:32:57 +05305909QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305910 struct wifi_scan_cmd_req_params *pstart,
5911 wmi_buf_t *buf, int *buf_len)
5912{
5913 wmi_extscan_start_cmd_fixed_param *cmd;
5914 wmi_extscan_bucket *dest_blist;
5915 wmi_extscan_bucket_channel *dest_clist;
5916 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
5917 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
5918 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
5919
5920 uint8_t *buf_ptr;
5921 int i, k, count = 0;
5922 int len = sizeof(*cmd);
5923 int nbuckets = pstart->numBuckets;
5924 int nchannels = 0;
5925
5926 /* These TLV's are are NULL by default */
5927 uint32_t ie_len_with_pad = 0;
5928 int num_ssid = 0;
5929 int num_bssid = 0;
5930 int ie_len = 0;
5931
5932 uint32_t base_period = pstart->basePeriod;
5933
5934 /* TLV placeholder for ssid_list (NULL) */
5935 len += WMI_TLV_HDR_SIZE;
5936 len += num_ssid * sizeof(wmi_ssid);
5937
5938 /* TLV placeholder for bssid_list (NULL) */
5939 len += WMI_TLV_HDR_SIZE;
5940 len += num_bssid * sizeof(wmi_mac_addr);
5941
5942 /* TLV placeholder for ie_data (NULL) */
5943 len += WMI_TLV_HDR_SIZE;
5944 len += ie_len * sizeof(uint32_t);
5945
5946 /* TLV placeholder for bucket */
5947 len += WMI_TLV_HDR_SIZE;
5948 len += nbuckets * sizeof(wmi_extscan_bucket);
5949
5950 /* TLV channel placeholder */
5951 len += WMI_TLV_HDR_SIZE;
5952 for (i = 0; i < nbuckets; i++) {
5953 nchannels += src_bucket->numChannels;
5954 src_bucket++;
5955 }
5956
Govind Singhb53420c2016-03-09 14:32:57 +05305957 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305958 __func__, nbuckets, nchannels);
5959 len += nchannels * sizeof(wmi_extscan_bucket_channel);
5960 /* Allocate the memory */
5961 *buf = wmi_buf_alloc(wmi_handle, len);
5962 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305963 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05305964 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305965 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305966 }
5967 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5968 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
5969 WMITLV_SET_HDR(&cmd->tlv_header,
5970 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
5971 WMITLV_GET_STRUCT_TLVLEN
5972 (wmi_extscan_start_cmd_fixed_param));
5973
5974 cmd->request_id = pstart->requestId;
5975 cmd->vdev_id = pstart->sessionId;
5976 cmd->base_period = pstart->basePeriod;
5977 cmd->num_buckets = nbuckets;
5978 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05305979 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305980 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05305981 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305982 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05305983#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05305984 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
5985 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05305986 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
5987 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
5988#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05305989 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5990
5991 /* The max dwell time is retrieved from the first channel
5992 * of the first bucket and kept common for all channels.
5993 */
5994 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
5995 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
5996 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
5997 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
5998 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5999 cmd->max_table_usage = pstart->report_threshold_percent;
6000 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6001
6002 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306003 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306004 cmd->probe_delay = 0;
6005 cmd->probe_spacing_time = 0;
6006 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306007 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6008 WMI_SCAN_ADD_CCK_RATES |
6009 WMI_SCAN_ADD_OFDM_RATES |
6010 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6011 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306012 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6013 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306014 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306015 cmd->num_ssids = 0;
6016 cmd->num_bssid = 0;
6017 cmd->ie_len = 0;
6018 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6019 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6020
6021 buf_ptr += sizeof(*cmd);
6022 WMITLV_SET_HDR(buf_ptr,
6023 WMITLV_TAG_ARRAY_FIXED_STRUC,
6024 num_ssid * sizeof(wmi_ssid));
6025 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6026
6027 WMITLV_SET_HDR(buf_ptr,
6028 WMITLV_TAG_ARRAY_FIXED_STRUC,
6029 num_bssid * sizeof(wmi_mac_addr));
6030 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6031
6032 ie_len_with_pad = 0;
6033 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6034 ie_len_with_pad);
6035 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6036
6037 WMITLV_SET_HDR(buf_ptr,
6038 WMITLV_TAG_ARRAY_STRUC,
6039 nbuckets * sizeof(wmi_extscan_bucket));
6040 dest_blist = (wmi_extscan_bucket *)
6041 (buf_ptr + WMI_TLV_HDR_SIZE);
6042 src_bucket = pstart->buckets;
6043
6044 /* Retrieve scanning information from each bucket and
6045 * channels and send it to the target
6046 */
6047 for (i = 0; i < nbuckets; i++) {
6048 WMITLV_SET_HDR(dest_blist,
6049 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6050 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6051
6052 dest_blist->bucket_id = src_bucket->bucket;
6053 dest_blist->base_period_multiplier =
6054 src_bucket->period / base_period;
6055 dest_blist->min_period = src_bucket->period;
6056 dest_blist->max_period = src_bucket->max_period;
6057 dest_blist->exp_backoff = src_bucket->exponent;
6058 dest_blist->exp_max_step_count = src_bucket->step_count;
6059 dest_blist->channel_band = src_bucket->band;
6060 dest_blist->num_channels = src_bucket->numChannels;
6061 dest_blist->notify_extscan_events = 0;
6062
6063 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6064 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006065 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6066 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306067
6068 if (src_bucket->reportEvents &
6069 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6070 dest_blist->forwarding_flags =
6071 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6072 dest_blist->notify_extscan_events |=
6073 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6074 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6075 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6076 } else {
6077 dest_blist->forwarding_flags =
6078 WMI_EXTSCAN_NO_FORWARDING;
6079 }
6080
6081 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6082 dest_blist->configuration_flags = 0;
6083 else
6084 dest_blist->configuration_flags =
6085 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6086
Govind Singhb53420c2016-03-09 14:32:57 +05306087 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306088 __func__, dest_blist->notify_extscan_events,
6089 dest_blist->configuration_flags,
6090 dest_blist->forwarding_flags);
6091
6092 dest_blist->min_dwell_time_active =
6093 src_bucket->min_dwell_time_active;
6094 dest_blist->max_dwell_time_active =
6095 src_bucket->max_dwell_time_active;
6096 dest_blist->min_dwell_time_passive =
6097 src_bucket->min_dwell_time_passive;
6098 dest_blist->max_dwell_time_passive =
6099 src_bucket->max_dwell_time_passive;
6100 src_channel = src_bucket->channels;
6101
6102 /* save the channel info to later populate
6103 * the channel TLV
6104 */
6105 for (k = 0; k < src_bucket->numChannels; k++) {
6106 save_channel[count++].channel = src_channel->channel;
6107 src_channel++;
6108 }
6109 dest_blist++;
6110 src_bucket++;
6111 }
6112 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6113 WMITLV_SET_HDR(buf_ptr,
6114 WMITLV_TAG_ARRAY_STRUC,
6115 nchannels * sizeof(wmi_extscan_bucket_channel));
6116 dest_clist = (wmi_extscan_bucket_channel *)
6117 (buf_ptr + WMI_TLV_HDR_SIZE);
6118
6119 /* Active or passive scan is based on the bucket dwell time
6120 * and channel specific active,passive scans are not
6121 * supported yet
6122 */
6123 for (i = 0; i < nchannels; i++) {
6124 WMITLV_SET_HDR(dest_clist,
6125 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6126 WMITLV_GET_STRUCT_TLVLEN
6127 (wmi_extscan_bucket_channel));
6128 dest_clist->channel = save_channel[i].channel;
6129 dest_clist++;
6130 }
6131 buf_ptr += WMI_TLV_HDR_SIZE +
6132 (nchannels * sizeof(wmi_extscan_bucket_channel));
6133 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306134 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306135}
6136
6137/**
6138 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6139 * @wmi_handle: wmi handle
6140 * @pstart: scan command request params
6141 *
6142 * This function sends start extscan request to fw.
6143 *
6144 * Return: CDF Status.
6145 */
Govind Singhb53420c2016-03-09 14:32:57 +05306146QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306147 struct wifi_scan_cmd_req_params *pstart)
6148{
Govind Singhb53420c2016-03-09 14:32:57 +05306149 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306150 wmi_buf_t buf;
6151 int len;
6152
6153 /* Fill individual elements of extscan request and
6154 * TLV for buckets, channel list.
6155 */
Govind Singhb53420c2016-03-09 14:32:57 +05306156 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306157 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306158 if (qdf_status != QDF_STATUS_SUCCESS) {
6159 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6160 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306161 }
6162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306163 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306164 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306165 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306166 }
6167 if (wmi_unified_cmd_send(wmi_handle, buf,
6168 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306169 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306170 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306171 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306172 }
6173
Govind Singhb53420c2016-03-09 14:32:57 +05306174 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306175}
6176
6177/**
6178 * send_plm_stop_cmd_tlv() - plm stop request
6179 * @wmi_handle: wmi handle
6180 * @plm: plm request parameters
6181 *
6182 * This function request FW to stop PLM.
6183 *
6184 * Return: CDF status
6185 */
Govind Singhb53420c2016-03-09 14:32:57 +05306186QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306187 const struct plm_req_params *plm)
6188{
6189 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6190 int32_t len;
6191 wmi_buf_t buf;
6192 uint8_t *buf_ptr;
6193 int ret;
6194
6195 len = sizeof(*cmd);
6196 buf = wmi_buf_alloc(wmi_handle, len);
6197 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306198 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6199 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306200 }
6201
6202 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6203
6204 buf_ptr = (uint8_t *) cmd;
6205
6206 WMITLV_SET_HDR(&cmd->tlv_header,
6207 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6208 WMITLV_GET_STRUCT_TLVLEN
6209 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6210
6211 cmd->vdev_id = plm->session_id;
6212
6213 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306214 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306215
6216 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6217 WMI_VDEV_PLMREQ_STOP_CMDID);
6218 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306219 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306220 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306221 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306222 }
6223
Govind Singhb53420c2016-03-09 14:32:57 +05306224 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306225}
6226
6227/**
6228 * send_plm_start_cmd_tlv() - plm start request
6229 * @wmi_handle: wmi handle
6230 * @plm: plm request parameters
6231 *
6232 * This function request FW to start PLM.
6233 *
6234 * Return: CDF status
6235 */
Govind Singhb53420c2016-03-09 14:32:57 +05306236QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306237 const struct plm_req_params *plm,
6238 uint32_t *gchannel_list)
6239{
6240 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6241 uint32_t *channel_list;
6242 int32_t len;
6243 wmi_buf_t buf;
6244 uint8_t *buf_ptr;
6245 uint8_t count;
6246 int ret;
6247
6248 /* TLV place holder for channel_list */
6249 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6250 len += sizeof(uint32_t) * plm->plm_num_ch;
6251
6252 buf = wmi_buf_alloc(wmi_handle, len);
6253 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306254 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6255 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306256 }
6257 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6258
6259 buf_ptr = (uint8_t *) cmd;
6260
6261 WMITLV_SET_HDR(&cmd->tlv_header,
6262 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6263 WMITLV_GET_STRUCT_TLVLEN
6264 (wmi_vdev_plmreq_start_cmd_fixed_param));
6265
6266 cmd->vdev_id = plm->session_id;
6267
6268 cmd->meas_token = plm->meas_token;
6269 cmd->dialog_token = plm->diag_token;
6270 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306271 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306272 cmd->off_duration = plm->meas_duration;
6273 cmd->burst_cycle = plm->burst_len;
6274 cmd->tx_power = plm->desired_tx_pwr;
6275 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6276 cmd->num_chans = plm->plm_num_ch;
6277
6278 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6279
Govind Singhb53420c2016-03-09 14:32:57 +05306280 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6281 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6282 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6283 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6284 WMI_LOGD("off_duration: %d", cmd->off_duration);
6285 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6286 WMI_LOGD("tx_power: %d", cmd->tx_power);
6287 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306288
6289 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6290 (cmd->num_chans * sizeof(uint32_t)));
6291
6292 buf_ptr += WMI_TLV_HDR_SIZE;
6293 if (cmd->num_chans) {
6294 channel_list = (uint32_t *) buf_ptr;
6295 for (count = 0; count < cmd->num_chans; count++) {
6296 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306297 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306298 channel_list[count] =
6299 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306300 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306301 }
6302 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6303 }
6304
6305 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6306 WMI_VDEV_PLMREQ_START_CMDID);
6307 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306308 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306309 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306310 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306311 }
6312
Govind Singhb53420c2016-03-09 14:32:57 +05306313 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306314}
6315
6316/**
6317 * send_pno_stop_cmd_tlv() - PNO stop request
6318 * @wmi_handle: wmi handle
6319 * @vdev_id: vdev id
6320 *
6321 * This function request FW to stop ongoing PNO operation.
6322 *
6323 * Return: CDF status
6324 */
Govind Singhb53420c2016-03-09 14:32:57 +05306325QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306326{
6327 wmi_nlo_config_cmd_fixed_param *cmd;
6328 int32_t len = sizeof(*cmd);
6329 wmi_buf_t buf;
6330 uint8_t *buf_ptr;
6331 int ret;
6332
6333 /*
6334 * TLV place holder for array of structures nlo_configured_parameters
6335 * TLV place holder for array of uint32_t channel_list
6336 * TLV place holder for chnl prediction cfg
6337 */
6338 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6339 buf = wmi_buf_alloc(wmi_handle, len);
6340 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306341 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6342 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306343 }
6344
6345 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6346 buf_ptr = (uint8_t *) cmd;
6347
6348 WMITLV_SET_HDR(&cmd->tlv_header,
6349 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6350 WMITLV_GET_STRUCT_TLVLEN
6351 (wmi_nlo_config_cmd_fixed_param));
6352
6353 cmd->vdev_id = vdev_id;
6354 cmd->flags = WMI_NLO_CONFIG_STOP;
6355 buf_ptr += sizeof(*cmd);
6356
6357 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6358 buf_ptr += WMI_TLV_HDR_SIZE;
6359
6360 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6361 buf_ptr += WMI_TLV_HDR_SIZE;
6362
6363 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6364 buf_ptr += WMI_TLV_HDR_SIZE;
6365
6366
6367 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6368 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6369 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306370 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306371 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306372 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306373 }
6374
Govind Singhb53420c2016-03-09 14:32:57 +05306375 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306376}
6377
6378/**
Govind Singhccb0c272016-04-01 16:30:08 +05306379 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6380 * @buf_ptr: Buffer passed by upper layers
6381 * @pno: Buffer to be sent to the firmware
6382 *
6383 * Copy the PNO Channel prediction configuration parameters
6384 * passed by the upper layers to a WMI format TLV and send it
6385 * down to the firmware.
6386 *
6387 * Return: None
6388 */
6389static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6390 struct pno_scan_req_params *pno)
6391{
6392 nlo_channel_prediction_cfg *channel_prediction_cfg =
6393 (nlo_channel_prediction_cfg *) buf_ptr;
6394 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6395 WMITLV_TAG_ARRAY_BYTE,
6396 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306397#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306398 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6399 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6400 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6401 channel_prediction_cfg->full_scan_period_ms =
6402 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306403#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306404 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6405 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6406 channel_prediction_cfg->enable,
6407 channel_prediction_cfg->top_k_num,
6408 channel_prediction_cfg->stationary_threshold,
6409 channel_prediction_cfg->full_scan_period_ms);
6410}
6411
6412/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306413 * send_pno_start_cmd_tlv() - PNO start request
6414 * @wmi_handle: wmi handle
6415 * @pno: PNO request
6416 *
6417 * This function request FW to start PNO request.
6418 * Request: CDF status
6419 */
Govind Singhb53420c2016-03-09 14:32:57 +05306420QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306421 struct pno_scan_req_params *pno,
6422 uint32_t *gchannel_freq_list)
6423{
6424 wmi_nlo_config_cmd_fixed_param *cmd;
6425 nlo_configured_parameters *nlo_list;
6426 uint32_t *channel_list;
6427 int32_t len;
6428 wmi_buf_t buf;
6429 uint8_t *buf_ptr;
6430 uint8_t i;
6431 int ret;
6432
6433 /*
6434 * TLV place holder for array nlo_configured_parameters(nlo_list)
6435 * TLV place holder for array of uint32_t channel_list
6436 * TLV place holder for chnnl prediction cfg
6437 */
6438 len = sizeof(*cmd) +
6439 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6440
Govind Singhb53420c2016-03-09 14:32:57 +05306441 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306442 WMI_NLO_MAX_CHAN);
6443 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306444 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306445 len += sizeof(nlo_channel_prediction_cfg);
6446
6447 buf = wmi_buf_alloc(wmi_handle, len);
6448 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306449 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6450 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306451 }
6452
6453 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6454
6455 buf_ptr = (uint8_t *) cmd;
6456 WMITLV_SET_HDR(&cmd->tlv_header,
6457 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6458 WMITLV_GET_STRUCT_TLVLEN
6459 (wmi_nlo_config_cmd_fixed_param));
6460 cmd->vdev_id = pno->sessionId;
6461 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6462
Govind Singh87542482016-06-08 19:40:11 +05306463#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306464 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6465 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306466#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306467 /* Current FW does not support min-max range for dwell time */
6468 cmd->active_dwell_time = pno->active_max_time;
6469 cmd->passive_dwell_time = pno->passive_max_time;
6470
6471 /* Copy scan interval */
6472 cmd->fast_scan_period = pno->fast_scan_period;
6473 cmd->slow_scan_period = pno->slow_scan_period;
6474 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306475 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306476 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306477 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306478
6479 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6480
Govind Singhb53420c2016-03-09 14:32:57 +05306481 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6482 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306483 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6484 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6485 buf_ptr += WMI_TLV_HDR_SIZE;
6486
6487 nlo_list = (nlo_configured_parameters *) buf_ptr;
6488 for (i = 0; i < cmd->no_of_ssids; i++) {
6489 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6490 WMITLV_TAG_ARRAY_BYTE,
6491 WMITLV_GET_STRUCT_TLVLEN
6492 (nlo_configured_parameters));
6493 /* Copy ssid and it's length */
6494 nlo_list[i].ssid.valid = true;
6495 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306496 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306497 pno->aNetworks[i].ssid.mac_ssid,
6498 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306499 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306500 nlo_list[i].ssid.ssid.ssid_len,
6501 (char *)nlo_list[i].ssid.ssid.ssid,
6502 nlo_list[i].ssid.ssid.ssid_len);
6503
6504 /* Copy rssi threshold */
6505 if (pno->aNetworks[i].rssiThreshold &&
6506 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6507 nlo_list[i].rssi_cond.valid = true;
6508 nlo_list[i].rssi_cond.rssi =
6509 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306510 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306511 nlo_list[i].rssi_cond.rssi);
6512 }
6513 nlo_list[i].bcast_nw_type.valid = true;
6514 nlo_list[i].bcast_nw_type.bcast_nw_type =
6515 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306516 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306517 nlo_list[i].bcast_nw_type.bcast_nw_type);
6518 }
6519 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6520
6521 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306522 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306523 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306524 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306525 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6526 (cmd->num_of_channels * sizeof(uint32_t)));
6527 buf_ptr += WMI_TLV_HDR_SIZE;
6528
6529 channel_list = (uint32_t *) buf_ptr;
6530 for (i = 0; i < cmd->num_of_channels; i++) {
6531 channel_list[i] = pno->aNetworks[0].aChannels[i];
6532
6533 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6534 channel_list[i] = gchannel_freq_list[i];
6535
Govind Singhb53420c2016-03-09 14:32:57 +05306536 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306537 }
6538 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6539 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6540 sizeof(nlo_channel_prediction_cfg));
6541 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306542 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306543 buf_ptr += WMI_TLV_HDR_SIZE;
6544 /** TODO: Discrete firmware doesn't have command/option to configure
6545 * App IE which comes from wpa_supplicant as of part PNO start request.
6546 */
6547 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6548 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6549 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306550 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306551 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306552 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306553 }
6554
Govind Singhb53420c2016-03-09 14:32:57 +05306555 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306556}
6557
6558/* send_set_ric_req_cmd_tlv() - set ric request element
6559 * @wmi_handle: wmi handle
6560 * @msg: message
6561 * @is_add_ts: is addts required
6562 *
6563 * This function sets ric request element for 11r roaming.
6564 *
6565 * Return: CDF status
6566 */
Govind Singhb53420c2016-03-09 14:32:57 +05306567QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306568 void *msg, uint8_t is_add_ts)
6569{
6570 wmi_ric_request_fixed_param *cmd;
6571 wmi_ric_tspec *tspec_param;
6572 wmi_buf_t buf;
6573 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306574 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306575 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6576 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6577
6578 buf = wmi_buf_alloc(wmi_handle, len);
6579 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306580 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6581 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306582 }
6583
6584 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6585
6586 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6587 WMITLV_SET_HDR(&cmd->tlv_header,
6588 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6589 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6590 if (is_add_ts)
6591 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
6592 else
6593 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
6594 cmd->num_ric_request = 1;
6595 cmd->is_add_ric = is_add_ts;
6596
6597 buf_ptr += sizeof(wmi_ric_request_fixed_param);
6598 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
6599
6600 buf_ptr += WMI_TLV_HDR_SIZE;
6601 tspec_param = (wmi_ric_tspec *) buf_ptr;
6602 WMITLV_SET_HDR(&tspec_param->tlv_header,
6603 WMITLV_TAG_STRUC_wmi_ric_tspec,
6604 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
6605
6606 if (is_add_ts)
6607 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05306608#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05306609 else
6610 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05306611#endif
6612 if (ptspecIE) {
6613 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05306614#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05306615 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
6616 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306617#else
Govind Singh87542482016-06-08 19:40:11 +05306618 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
6619 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306620#endif /* ANI_LITTLE_BIT_ENDIAN */
6621
Govind Singh87542482016-06-08 19:40:11 +05306622 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
6623 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
6624 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
6625 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
6626 tspec_param->inactivity_interval = ptspecIE->inactInterval;
6627 tspec_param->suspension_interval = ptspecIE->suspendInterval;
6628 tspec_param->svc_start_time = ptspecIE->svcStartTime;
6629 tspec_param->min_data_rate = ptspecIE->minDataRate;
6630 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
6631 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
6632 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
6633 tspec_param->delay_bound = ptspecIE->delayBound;
6634 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
6635 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
6636 tspec_param->medium_time = 0;
6637 }
Govind Singhb53420c2016-03-09 14:32:57 +05306638 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306639
6640 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6641 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306642 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306643 __func__);
6644 if (is_add_ts)
6645 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05306646 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05306647 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306648 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306649 }
6650
Govind Singhb53420c2016-03-09 14:32:57 +05306651 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306652}
6653
6654/**
6655 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
6656 * @wmi_handle: wmi handle
6657 * @clear_req: ll stats clear request command params
6658 *
Govind Singhb53420c2016-03-09 14:32:57 +05306659 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306660 */
Govind Singhb53420c2016-03-09 14:32:57 +05306661QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306662 const struct ll_stats_clear_params *clear_req,
6663 uint8_t addr[IEEE80211_ADDR_LEN])
6664{
6665 wmi_clear_link_stats_cmd_fixed_param *cmd;
6666 int32_t len;
6667 wmi_buf_t buf;
6668 uint8_t *buf_ptr;
6669 int ret;
6670
6671 len = sizeof(*cmd);
6672 buf = wmi_buf_alloc(wmi_handle, len);
6673
6674 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306675 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6676 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306677 }
6678
6679 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306680 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306681 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
6682
6683 WMITLV_SET_HDR(&cmd->tlv_header,
6684 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
6685 WMITLV_GET_STRUCT_TLVLEN
6686 (wmi_clear_link_stats_cmd_fixed_param));
6687
6688 cmd->stop_stats_collection_req = clear_req->stop_req;
6689 cmd->vdev_id = clear_req->sta_id;
6690 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
6691
6692 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6693 &cmd->peer_macaddr);
6694
Govind Singhb53420c2016-03-09 14:32:57 +05306695 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
6696 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
6697 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
6698 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
6699 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306700 cmd->peer_macaddr); */
6701
6702 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6703 WMI_CLEAR_LINK_STATS_CMDID);
6704 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306705 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306706 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306707 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306708 }
6709
Govind Singhb53420c2016-03-09 14:32:57 +05306710 WMI_LOGD("Clear Link Layer Stats request sent successfully");
6711 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306712}
6713
6714/**
6715 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
6716 * @wmi_handle: wmi handle
6717 * @setReq: ll stats set request command params
6718 *
Govind Singhb53420c2016-03-09 14:32:57 +05306719 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306720 */
Govind Singhb53420c2016-03-09 14:32:57 +05306721QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306722 const struct ll_stats_set_params *set_req)
6723{
6724 wmi_start_link_stats_cmd_fixed_param *cmd;
6725 int32_t len;
6726 wmi_buf_t buf;
6727 uint8_t *buf_ptr;
6728 int ret;
6729
6730 len = sizeof(*cmd);
6731 buf = wmi_buf_alloc(wmi_handle, len);
6732
6733 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306734 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6735 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306736 }
6737
6738 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306739 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306740 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
6741
6742 WMITLV_SET_HDR(&cmd->tlv_header,
6743 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
6744 WMITLV_GET_STRUCT_TLVLEN
6745 (wmi_start_link_stats_cmd_fixed_param));
6746
6747 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
6748 cmd->aggressive_statistics_gathering =
6749 set_req->aggressive_statistics_gathering;
6750
Govind Singhb53420c2016-03-09 14:32:57 +05306751 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
6752 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
6753 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306754
6755 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6756 WMI_START_LINK_STATS_CMDID);
6757 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306758 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306759 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306760 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306761 }
6762
Govind Singhb53420c2016-03-09 14:32:57 +05306763 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306764}
6765
6766/**
6767 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
6768 * @wmi_handle:wmi handle
6769 * @get_req:ll stats get request command params
6770 * @addr: mac address
6771 *
Govind Singhb53420c2016-03-09 14:32:57 +05306772 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306773 */
Govind Singhb53420c2016-03-09 14:32:57 +05306774QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306775 const struct ll_stats_get_params *get_req,
6776 uint8_t addr[IEEE80211_ADDR_LEN])
6777{
6778 wmi_request_link_stats_cmd_fixed_param *cmd;
6779 int32_t len;
6780 wmi_buf_t buf;
6781 uint8_t *buf_ptr;
6782 int ret;
6783
6784 len = sizeof(*cmd);
6785 buf = wmi_buf_alloc(wmi_handle, len);
6786
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05306787 if (!buf) {
6788 WMI_LOGE("%s: buf allocation failed", __func__);
6789 return QDF_STATUS_E_NOMEM;
6790 }
6791
Govind Singh4eacd2b2016-03-07 14:24:22 +05306792 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306793 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306794 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
6795
6796 WMITLV_SET_HDR(&cmd->tlv_header,
6797 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
6798 WMITLV_GET_STRUCT_TLVLEN
6799 (wmi_request_link_stats_cmd_fixed_param));
6800
6801 cmd->request_id = get_req->req_id;
6802 cmd->stats_type = get_req->param_id_mask;
6803 cmd->vdev_id = get_req->sta_id;
6804
6805 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6806 &cmd->peer_macaddr);
6807
Govind Singhb53420c2016-03-09 14:32:57 +05306808 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
6809 WMI_LOGD("Request ID : %d", cmd->request_id);
6810 WMI_LOGD("Stats Type : %d", cmd->stats_type);
6811 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
6812 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306813
6814 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6815 WMI_REQUEST_LINK_STATS_CMDID);
6816 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306817 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306818 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306819 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306820 }
6821
Govind Singhb53420c2016-03-09 14:32:57 +05306822 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306823}
6824
6825/**
6826 * send_get_stats_cmd_tlv() - get stats request
6827 * @wmi_handle: wmi handle
6828 * @get_stats_param: stats params
6829 * @addr: mac address
6830 *
6831 * Return: CDF status
6832 */
Govind Singhb53420c2016-03-09 14:32:57 +05306833QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306834 struct pe_stats_req *get_stats_param,
6835 uint8_t addr[IEEE80211_ADDR_LEN])
6836{
6837 wmi_buf_t buf;
6838 wmi_request_stats_cmd_fixed_param *cmd;
6839 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6840
6841 buf = wmi_buf_alloc(wmi_handle, len);
6842 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306843 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
6844 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306845 }
6846
6847
6848 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6849 WMITLV_SET_HDR(&cmd->tlv_header,
6850 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6851 WMITLV_GET_STRUCT_TLVLEN
6852 (wmi_request_stats_cmd_fixed_param));
6853 cmd->stats_id =
6854 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05306855 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306856 cmd->vdev_id = get_stats_param->session_id;
6857 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05306858 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306859 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6860 WMI_REQUEST_STATS_CMDID)) {
6861
Govind Singhb53420c2016-03-09 14:32:57 +05306862 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306863 __func__);
6864 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306865 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306866 }
6867
Govind Singhb53420c2016-03-09 14:32:57 +05306868 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306869
6870}
6871
Govind Singh20c5dac2016-03-07 15:33:31 +05306872/**
6873 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
6874 * @wmi_handle: wmi handle
6875 * @rssi_req: get RSSI request
6876 *
6877 * Return: CDF status
6878 */
Govind Singhb53420c2016-03-09 14:32:57 +05306879QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05306880{
6881 wmi_buf_t buf;
6882 wmi_request_stats_cmd_fixed_param *cmd;
6883 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6884
6885 buf = wmi_buf_alloc(wmi_handle, len);
6886 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306887 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6888 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306889 }
6890
6891 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6892 WMITLV_SET_HDR(&cmd->tlv_header,
6893 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6894 WMITLV_GET_STRUCT_TLVLEN
6895 (wmi_request_stats_cmd_fixed_param));
6896 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6897 if (wmi_unified_cmd_send
6898 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306899 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306900 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306901 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306902 }
6903
Govind Singhb53420c2016-03-09 14:32:57 +05306904 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306905}
6906
6907/**
6908 * send_snr_cmd_tlv() - get RSSI from fw
6909 * @wmi_handle: wmi handle
6910 * @vdev_id: vdev id
6911 *
6912 * Return: CDF status
6913 */
Govind Singhb53420c2016-03-09 14:32:57 +05306914QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05306915{
6916 wmi_buf_t buf;
6917 wmi_request_stats_cmd_fixed_param *cmd;
6918 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6919
6920 buf = wmi_buf_alloc(wmi_handle, len);
6921 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306922 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6923 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306924 }
6925
6926 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6927 cmd->vdev_id = vdev_id;
6928
6929 WMITLV_SET_HDR(&cmd->tlv_header,
6930 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6931 WMITLV_GET_STRUCT_TLVLEN
6932 (wmi_request_stats_cmd_fixed_param));
6933 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6934 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6935 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306936 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306937 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306938 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306939 }
6940
Govind Singhb53420c2016-03-09 14:32:57 +05306941 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306942}
6943
6944/**
6945 * send_link_status_req_cmd_tlv() - process link status request from UMAC
6946 * @wmi_handle: wmi handle
6947 * @link_status: get link params
6948 *
6949 * Return: CDF status
6950 */
Govind Singhb53420c2016-03-09 14:32:57 +05306951QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306952 struct link_status_params *link_status)
6953{
6954 wmi_buf_t buf;
6955 wmi_request_stats_cmd_fixed_param *cmd;
6956 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6957
6958 buf = wmi_buf_alloc(wmi_handle, len);
6959 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306960 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6961 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306962 }
6963
6964 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6965 WMITLV_SET_HDR(&cmd->tlv_header,
6966 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6967 WMITLV_GET_STRUCT_TLVLEN
6968 (wmi_request_stats_cmd_fixed_param));
6969 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
6970 cmd->vdev_id = link_status->session_id;
6971 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6972 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306973 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306974 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306975 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306976 }
6977
Govind Singhb53420c2016-03-09 14:32:57 +05306978 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306979}
6980
6981#ifdef FEATURE_WLAN_LPHB
6982
6983/**
6984 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
6985 * @wmi_handle: wmi handle
6986 * @lphb_conf_req: configuration info
6987 *
6988 * Return: CDF status
6989 */
Govind Singhb53420c2016-03-09 14:32:57 +05306990QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306991 wmi_hb_set_enable_cmd_fixed_param *params)
6992{
Govind Singh67922e82016-04-01 16:48:57 +05306993 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306994 wmi_buf_t buf = NULL;
6995 uint8_t *buf_ptr;
6996 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
6997 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
6998
6999
7000 buf = wmi_buf_alloc(wmi_handle, len);
7001 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307002 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7003 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307004 }
7005
7006 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7007 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
7008 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
7009 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
7010 WMITLV_GET_STRUCT_TLVLEN
7011 (wmi_hb_set_enable_cmd_fixed_param));
7012
7013 /* fill in values */
7014 hb_enable_fp->vdev_id = params->session;
7015 hb_enable_fp->enable = params->enable;
7016 hb_enable_fp->item = params->item;
7017 hb_enable_fp->session = params->session;
7018
7019 status = wmi_unified_cmd_send(wmi_handle, buf,
7020 len, WMI_HB_SET_ENABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307021 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307022 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_ENABLE returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307023 status);
Govind Singh67922e82016-04-01 16:48:57 +05307024 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307025 }
7026
Govind Singh67922e82016-04-01 16:48:57 +05307027 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307028}
7029
7030/**
7031 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
7032 * @wmi_handle: wmi handle
7033 * @lphb_conf_req: lphb config request
7034 *
7035 * Return: CDF status
7036 */
Govind Singhb53420c2016-03-09 14:32:57 +05307037QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307038 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
7039{
Govind Singh67922e82016-04-01 16:48:57 +05307040 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307041 wmi_buf_t buf = NULL;
7042 uint8_t *buf_ptr;
7043 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
7044 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
7045
7046 buf = wmi_buf_alloc(wmi_handle, len);
7047 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307048 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7049 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307050 }
7051
7052 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7053 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
7054 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
7055 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
7056 WMITLV_GET_STRUCT_TLVLEN
7057 (wmi_hb_set_tcp_params_cmd_fixed_param));
7058
7059 /* fill in values */
7060 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
7061 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
7062 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
7063 hb_tcp_params_fp->seq = lphb_conf_req->seq;
7064 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
7065 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
7066 hb_tcp_params_fp->interval = lphb_conf_req->interval;
7067 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
7068 hb_tcp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05307069 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05307070 &lphb_conf_req->gateway_mac,
7071 sizeof(hb_tcp_params_fp->gateway_mac));
7072
7073 status = wmi_unified_cmd_send(wmi_handle, buf,
7074 len, WMI_HB_SET_TCP_PARAMS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307075 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307076 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307077 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307078 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307079 }
7080
Govind Singh67922e82016-04-01 16:48:57 +05307081 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307082}
7083
7084/**
7085 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
7086 * @wmi_handle: wmi handle
7087 * @lphb_conf_req: lphb config request
7088 *
7089 * Return: CDF status
7090 */
Govind Singhb53420c2016-03-09 14:32:57 +05307091QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307092 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
7093{
Govind Singh67922e82016-04-01 16:48:57 +05307094 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307095 wmi_buf_t buf = NULL;
7096 uint8_t *buf_ptr;
7097 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
7098 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
7099
7100 buf = wmi_buf_alloc(wmi_handle, len);
7101 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307102 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7103 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307104 }
7105
7106 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7107 hb_tcp_filter_fp =
7108 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
7109 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
7110 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
7111 WMITLV_GET_STRUCT_TLVLEN
7112 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
7113
7114 /* fill in values */
7115 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
7116 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
7117 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
7118 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
7119 memcpy((void *)&hb_tcp_filter_fp->filter,
7120 (void *)&g_hb_tcp_filter_fp->filter,
7121 WMI_WLAN_HB_MAX_FILTER_SIZE);
7122
7123 status = wmi_unified_cmd_send(wmi_handle, buf,
7124 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307125 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307126 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307127 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307128 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307129 }
7130
Govind Singh67922e82016-04-01 16:48:57 +05307131 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307132}
7133
7134/**
7135 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
7136 * @wmi_handle: wmi handle
7137 * @lphb_conf_req: lphb config request
7138 *
7139 * Return: CDF status
7140 */
Govind Singhb53420c2016-03-09 14:32:57 +05307141QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307142 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
7143{
Govind Singh67922e82016-04-01 16:48:57 +05307144 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307145 wmi_buf_t buf = NULL;
7146 uint8_t *buf_ptr;
7147 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
7148 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
7149
7150 buf = wmi_buf_alloc(wmi_handle, len);
7151 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307152 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7153 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307154 }
7155
7156 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7157 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
7158 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
7159 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
7160 WMITLV_GET_STRUCT_TLVLEN
7161 (wmi_hb_set_udp_params_cmd_fixed_param));
7162
7163 /* fill in values */
7164 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
7165 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
7166 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
7167 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
7168 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
7169 hb_udp_params_fp->interval = lphb_conf_req->interval;
7170 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
7171 hb_udp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05307172 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05307173 &lphb_conf_req->gateway_mac,
7174 sizeof(lphb_conf_req->gateway_mac));
7175
7176 status = wmi_unified_cmd_send(wmi_handle, buf,
7177 len, WMI_HB_SET_UDP_PARAMS_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307178 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307179 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307180 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307181 wmi_buf_free(buf);
7182 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307183
Govind Singh67922e82016-04-01 16:48:57 +05307184 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307185}
7186
7187/**
7188 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
7189 * @wmi_handle: wmi handle
7190 * @lphb_conf_req: lphb config request
7191 *
7192 * Return: CDF status
7193 */
Govind Singhb53420c2016-03-09 14:32:57 +05307194QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307195 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
7196{
Govind Singh67922e82016-04-01 16:48:57 +05307197 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307198 wmi_buf_t buf = NULL;
7199 uint8_t *buf_ptr;
7200 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
7201 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
7202
7203 buf = wmi_buf_alloc(wmi_handle, len);
7204 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307205 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7206 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307207 }
7208
7209 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7210 hb_udp_filter_fp =
7211 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
7212 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
7213 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
7214 WMITLV_GET_STRUCT_TLVLEN
7215 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
7216
7217 /* fill in values */
7218 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
7219 hb_udp_filter_fp->length = lphb_conf_req->length;
7220 hb_udp_filter_fp->offset = lphb_conf_req->offset;
7221 hb_udp_filter_fp->session = lphb_conf_req->session;
7222 memcpy((void *)&hb_udp_filter_fp->filter,
7223 (void *)&lphb_conf_req->filter,
7224 WMI_WLAN_HB_MAX_FILTER_SIZE);
7225
7226 status = wmi_unified_cmd_send(wmi_handle, buf,
7227 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307228 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307229 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307230 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307231 wmi_buf_free(buf);
7232 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307233
Govind Singh67922e82016-04-01 16:48:57 +05307234 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307235}
7236#endif /* FEATURE_WLAN_LPHB */
7237
7238/**
7239 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7240 * @wmi_handle: wmi handle
7241 * @ta_dhcp_ind: DHCP indication parameter
7242 *
7243 * Return: CDF Status
7244 */
Govind Singhb53420c2016-03-09 14:32:57 +05307245QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307246 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7247{
Govind Singh67922e82016-04-01 16:48:57 +05307248 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307249 wmi_buf_t buf = NULL;
7250 uint8_t *buf_ptr;
7251 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7252 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7253
7254
7255 buf = wmi_buf_alloc(wmi_handle, len);
7256 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307257 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7258 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307259 }
7260
7261 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7262 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7263 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7264 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7265 WMITLV_GET_STRUCT_TLVLEN
7266 (wmi_peer_set_param_cmd_fixed_param));
7267
7268 /* fill in values */
7269 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7270 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7271 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307272 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307273 &ta_dhcp_ind->peer_macaddr,
7274 sizeof(ta_dhcp_ind->peer_macaddr));
7275
7276 status = wmi_unified_cmd_send(wmi_handle, buf,
7277 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307278 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307279 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307280 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307281 wmi_buf_free(buf);
7282 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307283
Govind Singh67922e82016-04-01 16:48:57 +05307284 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307285}
7286
7287/**
7288 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7289 * @wmi_handle: wmi handle
7290 * @pLinkSpeed: link speed info
7291 *
7292 * Return: CDF status
7293 */
Govind Singhb53420c2016-03-09 14:32:57 +05307294QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307295 wmi_mac_addr peer_macaddr)
7296{
7297 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7298 wmi_buf_t wmi_buf;
7299 uint32_t len;
7300 uint8_t *buf_ptr;
7301
7302 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7303 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7304 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307305 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7306 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307307 }
7308 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7309
7310 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7311 WMITLV_SET_HDR(&cmd->tlv_header,
7312 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7313 WMITLV_GET_STRUCT_TLVLEN
7314 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7315
7316 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307317 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307318 &peer_macaddr,
7319 sizeof(peer_macaddr));
7320
7321
7322 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7323 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307324 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307325 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307326 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307327 }
Govind Singhb53420c2016-03-09 14:32:57 +05307328 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307329}
7330
7331/**
7332 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7333 * @wmi_handle: wmi handler
7334 * @egap_params: pointer to egap_params
7335 *
7336 * Return: 0 for success, otherwise appropriate error code
7337 */
Govind Singhb53420c2016-03-09 14:32:57 +05307338QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307339 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7340{
7341 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7342 wmi_buf_t buf;
7343 int32_t err;
7344
7345 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7346 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307347 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7348 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307349 }
7350 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7351 WMITLV_SET_HDR(&cmd->tlv_header,
7352 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7353 WMITLV_GET_STRUCT_TLVLEN(
7354 wmi_ap_ps_egap_param_cmd_fixed_param));
7355
7356 cmd->enable = egap_params->enable;
7357 cmd->inactivity_time = egap_params->inactivity_time;
7358 cmd->wait_time = egap_params->wait_time;
7359 cmd->flags = egap_params->flags;
7360 err = wmi_unified_cmd_send(wmi_handle, buf,
7361 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7362 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307363 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307364 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307365 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307366 }
7367
Govind Singhb53420c2016-03-09 14:32:57 +05307368 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307369}
7370
7371/**
Paul Zhangd19abd82017-01-04 16:45:42 +08007372 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
7373 * @wmi_handle: wmi handler
7374 * @action_params: pointer to action_params
7375 *
7376 * Return: 0 for success, otherwise appropriate error code
7377 */
7378QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
7379 struct action_wakeup_set_param *action_params)
7380{
7381 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
7382 wmi_buf_t buf;
7383 int i;
7384 int32_t err;
7385
7386 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7387 if (!buf) {
7388 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
7389 return QDF_STATUS_E_NOMEM;
7390 }
7391 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
7392 WMITLV_SET_HDR(&cmd->tlv_header,
7393 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
7394 WMITLV_GET_STRUCT_TLVLEN(
7395 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
7396
7397 cmd->vdev_id = action_params->vdev_id;
7398 cmd->operation = action_params->operation;
7399
7400 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
7401 cmd->action_category_map[i] =
7402 action_params->action_category_map[i];
7403
7404 err = wmi_unified_cmd_send(wmi_handle, buf,
7405 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
7406 if (err) {
7407 WMI_LOGE("Failed to send ap_ps_egap cmd");
7408 wmi_buf_free(buf);
7409 return QDF_STATUS_E_FAILURE;
7410 }
7411
7412 return QDF_STATUS_SUCCESS;
7413}
7414
7415/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307416 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7417 * @wmi_handl: wmi handle
7418 * @cmd: Profiling command index
7419 * @value1: parameter1 value
7420 * @value2: parameter2 value
7421 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307422 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307423 */
Govind Singhb53420c2016-03-09 14:32:57 +05307424QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307425 uint32_t cmd, uint32_t value1, uint32_t value2)
7426{
7427 wmi_buf_t buf;
7428 int32_t len = 0;
7429 int ret;
7430 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7431 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7432 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7433 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7434
7435 switch (cmd) {
7436 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7437 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7438 buf = wmi_buf_alloc(wmi_handle, len);
7439 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307440 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307441 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307442 }
7443 prof_trig_cmd =
7444 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7445 wmi_buf_data(buf);
7446 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7447 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7448 WMITLV_GET_STRUCT_TLVLEN
7449 (wmi_wlan_profile_trigger_cmd_fixed_param));
7450 prof_trig_cmd->enable = value1;
7451 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7452 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7453 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307454 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307455 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307456 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307457 return ret;
7458 }
7459 break;
7460
7461 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7462 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7463 buf = wmi_buf_alloc(wmi_handle, len);
7464 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307465 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307466 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307467 }
7468 profile_getdata_cmd =
7469 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7470 wmi_buf_data(buf);
7471 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7472 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7473 WMITLV_GET_STRUCT_TLVLEN
7474 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7475 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7476 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7477 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307478 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307479 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307480 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307481 return ret;
7482 }
7483 break;
7484
7485 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7486 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7487 buf = wmi_buf_alloc(wmi_handle, len);
7488 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307489 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307490 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307491 }
7492 hist_intvl_cmd =
7493 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7494 wmi_buf_data(buf);
7495 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7496 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7497 WMITLV_GET_STRUCT_TLVLEN
7498 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7499 hist_intvl_cmd->profile_id = value1;
7500 hist_intvl_cmd->value = value2;
7501 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7502 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7503 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307504 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307505 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307506 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307507 return ret;
7508 }
7509 break;
7510
7511 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7512 len =
7513 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7514 buf = wmi_buf_alloc(wmi_handle, len);
7515 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307516 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307517 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307518 }
7519 profile_enable_cmd =
7520 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7521 wmi_buf_data(buf);
7522 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7523 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7524 WMITLV_GET_STRUCT_TLVLEN
7525 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7526 profile_enable_cmd->profile_id = value1;
7527 profile_enable_cmd->enable = value2;
7528 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7529 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7530 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307531 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307532 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307533 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307534 return ret;
7535 }
7536 break;
7537
7538 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307539 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307540 break;
7541 }
7542
7543 return 0;
7544}
7545
7546#ifdef FEATURE_WLAN_RA_FILTERING
7547/**
7548 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
7549 * @wmi_handle: wmi handle
7550 * @vdev_id: vdev id
7551 *
7552 * Return: CDF status
7553 */
Govind Singhb53420c2016-03-09 14:32:57 +05307554QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307555 uint8_t vdev_id, uint8_t default_pattern,
7556 uint16_t rate_limit_interval)
7557{
7558
7559 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7560 wmi_buf_t buf;
7561 uint8_t *buf_ptr;
7562 int32_t len;
7563 int ret;
7564
7565 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7566 WMI_TLV_HDR_SIZE +
7567 0 * sizeof(WOW_BITMAP_PATTERN_T) +
7568 WMI_TLV_HDR_SIZE +
7569 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7570 WMI_TLV_HDR_SIZE +
7571 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7572 WMI_TLV_HDR_SIZE +
7573 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7574 WMI_TLV_HDR_SIZE +
7575 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7576
7577 buf = wmi_buf_alloc(wmi_handle, len);
7578 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307579 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7580 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307581 }
7582
7583 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7584 buf_ptr = (uint8_t *) cmd;
7585
7586 WMITLV_SET_HDR(&cmd->tlv_header,
7587 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7588 WMITLV_GET_STRUCT_TLVLEN
7589 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7590 cmd->vdev_id = vdev_id;
7591 cmd->pattern_id = default_pattern,
7592 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
7593 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7594
7595 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
7596 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7597 buf_ptr += WMI_TLV_HDR_SIZE;
7598
7599 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7600 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7601 buf_ptr += WMI_TLV_HDR_SIZE;
7602
7603 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7604 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7605 buf_ptr += WMI_TLV_HDR_SIZE;
7606
7607 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7608 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7609 buf_ptr += WMI_TLV_HDR_SIZE;
7610
7611 /* Fill TLV for pattern_info_timeout but no data. */
7612 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7613 buf_ptr += WMI_TLV_HDR_SIZE;
7614
7615 /* Fill TLV for ra_ratelimit_interval. */
7616 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
7617 buf_ptr += WMI_TLV_HDR_SIZE;
7618
7619 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
7620
Govind Singhb53420c2016-03-09 14:32:57 +05307621 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05307622 rate_limit_interval, vdev_id);
7623
7624 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7625 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7626 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307627 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307628 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307629 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307630 }
7631
Govind Singhb53420c2016-03-09 14:32:57 +05307632 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307633
7634}
7635#endif /* FEATURE_WLAN_RA_FILTERING */
7636
7637/**
7638 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7639 * @wmi_handle: wmi handle
7640 * @vdev_id: vdev id
7641 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307642 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307643 */
Govind Singhb53420c2016-03-09 14:32:57 +05307644QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307645{
7646 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7647 wmi_buf_t buf;
7648 int32_t len = sizeof(*cmd);
7649
Govind Singhb53420c2016-03-09 14:32:57 +05307650 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307651 buf = wmi_buf_alloc(wmi_handle, len);
7652 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307653 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307654 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307655 }
7656 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7657 wmi_buf_data(buf);
7658 WMITLV_SET_HDR(&cmd->tlv_header,
7659 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7660 WMITLV_GET_STRUCT_TLVLEN
7661 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7662 cmd->vdev_id = vdev_id;
7663 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7664 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7665 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307666 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307667 __func__);
7668 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307669 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307670 }
7671
7672 return 0;
7673}
7674
7675/**
7676 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7677 * @wmi_handle: wmi handle
7678 * @vdev_id: vdev id
7679 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307680 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307681 */
Govind Singhb53420c2016-03-09 14:32:57 +05307682QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307683 uint8_t vdev_id)
7684{
7685 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7686 wmi_buf_t buf;
7687 int32_t len = sizeof(*cmd);
7688
Govind Singhb53420c2016-03-09 14:32:57 +05307689 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307690 buf = wmi_buf_alloc(wmi_handle, len);
7691 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307692 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307693 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307694 }
7695 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7696 WMITLV_SET_HDR(&cmd->tlv_header,
7697 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7698 WMITLV_GET_STRUCT_TLVLEN
7699 (wmi_csa_offload_enable_cmd_fixed_param));
7700 cmd->vdev_id = vdev_id;
7701 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7702 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7703 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307704 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307705 __func__);
7706 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307707 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307708 }
7709
7710 return 0;
7711}
7712
7713/**
7714 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7715 * @wmi_handle: wmi handle
7716 * @startOemDataReq: start request params
7717 *
7718 * Return: CDF status
7719 */
Govind Singhb53420c2016-03-09 14:32:57 +05307720QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007721 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307722 uint8_t *data)
7723{
7724 wmi_buf_t buf;
7725 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307726 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307727
7728 buf = wmi_buf_alloc(wmi_handle,
7729 (data_len + WMI_TLV_HDR_SIZE));
7730 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307731 WMI_LOGE(FL("wmi_buf_alloc failed"));
7732 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307733 }
7734
7735 cmd = (uint8_t *) wmi_buf_data(buf);
7736
7737 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7738 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307739 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307740 data_len);
7741
Govind Singhb53420c2016-03-09 14:32:57 +05307742 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307743 data_len);
7744
7745 ret = wmi_unified_cmd_send(wmi_handle, buf,
7746 (data_len +
7747 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7748
Govind Singh67922e82016-04-01 16:48:57 +05307749 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307750 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307751 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307752 }
7753
Govind Singh67922e82016-04-01 16:48:57 +05307754 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307755}
7756
7757/**
7758 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7759 * @wmi_handle: wmi handle
7760 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7761 *
7762 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7763 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7764 * to firmware based on phyerr filtering
7765 * offload status.
7766 *
7767 * Return: 1 success, 0 failure
7768 */
Govind Singhb53420c2016-03-09 14:32:57 +05307769QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307770send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7771 bool dfs_phyerr_filter_offload)
7772{
7773 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7774 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7775 wmi_buf_t buf;
7776 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307777 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307778
7779
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007780 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307781 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307782 __func__);
7783 len = sizeof(*disable_phyerr_offload_cmd);
7784 buf = wmi_buf_alloc(wmi_handle, len);
7785 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307786 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307787 return 0;
7788 }
7789 disable_phyerr_offload_cmd =
7790 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7791 wmi_buf_data(buf);
7792
7793 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7794 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7795 WMITLV_GET_STRUCT_TLVLEN
7796 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7797
7798 /*
7799 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7800 * to the firmware to disable the phyerror
7801 * filtering offload.
7802 */
7803 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7804 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307805 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307806 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307807 __func__, ret);
7808 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307809 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307810 }
Govind Singhb53420c2016-03-09 14:32:57 +05307811 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307812 __func__);
7813 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307814 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307815 __func__);
7816
7817 len = sizeof(*enable_phyerr_offload_cmd);
7818 buf = wmi_buf_alloc(wmi_handle, len);
7819 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307820 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7821 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307822 }
7823
7824 enable_phyerr_offload_cmd =
7825 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7826 wmi_buf_data(buf);
7827
7828 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7829 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7830 WMITLV_GET_STRUCT_TLVLEN
7831 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7832
7833 /*
7834 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7835 * to the firmware to enable the phyerror
7836 * filtering offload.
7837 */
7838 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7839 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7840
Govind Singh67922e82016-04-01 16:48:57 +05307841 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307842 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307843 __func__, ret);
7844 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307845 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307846 }
Govind Singhb53420c2016-03-09 14:32:57 +05307847 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307848 __func__);
7849 }
7850
Govind Singhb53420c2016-03-09 14:32:57 +05307851 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307852}
7853
7854#if !defined(REMOVE_PKT_LOG)
7855/**
7856 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7857 * @wmi_handle: wmi handle
7858 * @pktlog_event: pktlog event
7859 * @cmd_id: pktlog cmd id
7860 *
7861 * Return: CDF status
7862 */
Govind Singhb53420c2016-03-09 14:32:57 +05307863QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307864 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307865 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307866{
7867 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7868 WMI_CMD_ID CMD_ID;
7869 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7870 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7871 int len = 0;
7872 wmi_buf_t buf;
7873
7874 PKTLOG_EVENT = pktlog_event;
7875 CMD_ID = cmd_id;
7876
7877 switch (CMD_ID) {
7878 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7879 len = sizeof(*cmd);
7880 buf = wmi_buf_alloc(wmi_handle, len);
7881 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307882 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7883 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307884 }
7885 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7886 wmi_buf_data(buf);
7887 WMITLV_SET_HDR(&cmd->tlv_header,
7888 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7889 WMITLV_GET_STRUCT_TLVLEN
7890 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7891 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307892 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7893 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007894 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307895 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7896 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307897 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307898 goto wmi_send_failed;
7899 }
7900 break;
7901 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7902 len = sizeof(*disable_cmd);
7903 buf = wmi_buf_alloc(wmi_handle, len);
7904 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307905 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7906 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307907 }
7908 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7909 wmi_buf_data(buf);
7910 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7911 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7912 WMITLV_GET_STRUCT_TLVLEN
7913 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007914 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307915 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7916 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307917 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307918 goto wmi_send_failed;
7919 }
7920 break;
7921 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307922 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307923 break;
7924 }
7925
Govind Singhb53420c2016-03-09 14:32:57 +05307926 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307927
7928wmi_send_failed:
7929 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307930 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307931}
7932#endif /* REMOVE_PKT_LOG */
7933
7934/**
7935 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
7936 * @wmi_handle: wmi handle
7937 * @vdev_id: vdev id
7938 * @bitmap: Event bitmap
7939 * @enable: enable/disable
7940 *
7941 * Return: CDF status
7942 */
Govind Singhb53420c2016-03-09 14:32:57 +05307943QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307944 uint32_t vdev_id,
7945 uint32_t bitmap,
7946 bool enable)
7947{
7948 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
7949 uint16_t len;
7950 wmi_buf_t buf;
7951 int ret;
7952
7953 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
7954 buf = wmi_buf_alloc(wmi_handle, len);
7955 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307956 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7957 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307958 }
7959 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
7960 WMITLV_SET_HDR(&cmd->tlv_header,
7961 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
7962 WMITLV_GET_STRUCT_TLVLEN
7963 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
7964 cmd->vdev_id = vdev_id;
7965 cmd->is_add = enable;
7966 cmd->event_bitmap = bitmap;
7967
7968 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7969 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
7970 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307971 WMI_LOGE("Failed to config wow wakeup event");
Govind Singh20c5dac2016-03-07 15:33:31 +05307972 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307973 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307974 }
7975
Govind Singhb53420c2016-03-09 14:32:57 +05307976 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
Govind Singh20c5dac2016-03-07 15:33:31 +05307977 enable ? "enabled" : "disabled");
7978
Govind Singhb53420c2016-03-09 14:32:57 +05307979 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307980}
7981
7982/**
7983 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
7984 * @wmi_handle: wmi handle
7985 * @vdev_id: vdev id
7986 * @ptrn_id: pattern id
7987 * @ptrn: pattern
7988 * @ptrn_len: pattern length
7989 * @ptrn_offset: pattern offset
7990 * @mask: mask
7991 * @mask_len: mask length
7992 * @user: true for user configured pattern and false for default pattern
7993 * @default_patterns: default patterns
7994 *
7995 * Return: CDF status
7996 */
Govind Singhb53420c2016-03-09 14:32:57 +05307997QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307998 uint8_t vdev_id, uint8_t ptrn_id,
7999 const uint8_t *ptrn, uint8_t ptrn_len,
8000 uint8_t ptrn_offset, const uint8_t *mask,
8001 uint8_t mask_len, bool user,
8002 uint8_t default_patterns)
8003{
8004 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
8005 WOW_BITMAP_PATTERN_T *bitmap_pattern;
8006 wmi_buf_t buf;
8007 uint8_t *buf_ptr;
8008 int32_t len;
8009 int ret;
8010
8011
8012 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
8013 WMI_TLV_HDR_SIZE +
8014 1 * sizeof(WOW_BITMAP_PATTERN_T) +
8015 WMI_TLV_HDR_SIZE +
8016 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
8017 WMI_TLV_HDR_SIZE +
8018 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
8019 WMI_TLV_HDR_SIZE +
8020 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
8021 WMI_TLV_HDR_SIZE +
8022 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
8023
8024 buf = wmi_buf_alloc(wmi_handle, len);
8025 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308026 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8027 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308028 }
8029
8030 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8031 buf_ptr = (uint8_t *) cmd;
8032
8033 WMITLV_SET_HDR(&cmd->tlv_header,
8034 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
8035 WMITLV_GET_STRUCT_TLVLEN
8036 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
8037 cmd->vdev_id = vdev_id;
8038 cmd->pattern_id = ptrn_id;
8039
8040 cmd->pattern_type = WOW_BITMAP_PATTERN;
8041 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
8042
8043 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8044 sizeof(WOW_BITMAP_PATTERN_T));
8045 buf_ptr += WMI_TLV_HDR_SIZE;
8046 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
8047
8048 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
8049 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
8050 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
8051
Govind Singhb53420c2016-03-09 14:32:57 +05308052 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
8053 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308054
8055 bitmap_pattern->pattern_offset = ptrn_offset;
8056 bitmap_pattern->pattern_len = ptrn_len;
8057
8058 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
8059 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
8060
8061 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
8062 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
8063
8064 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
8065 bitmap_pattern->pattern_id = ptrn_id;
8066
Govind Singhb53420c2016-03-09 14:32:57 +05308067 WMI_LOGI("vdev id : %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308068 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
8069 bitmap_pattern->pattern_offset, user);
Govind Singh87542482016-06-08 19:40:11 +05308070#ifdef CONFIG_MCL
Govind Singhb53420c2016-03-09 14:32:57 +05308071 WMI_LOGI("Pattern : ");
8072 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05308073 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
8074
Govind Singhb53420c2016-03-09 14:32:57 +05308075 WMI_LOGI("Mask : ");
8076 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05308077 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
Govind Singh87542482016-06-08 19:40:11 +05308078#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308079
8080 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
8081
8082 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
8083 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8084 buf_ptr += WMI_TLV_HDR_SIZE;
8085
8086 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
8087 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8088 buf_ptr += WMI_TLV_HDR_SIZE;
8089
8090 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
8091 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8092 buf_ptr += WMI_TLV_HDR_SIZE;
8093
8094 /* Fill TLV for pattern_info_timeout but no data. */
8095 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
8096 buf_ptr += WMI_TLV_HDR_SIZE;
8097
8098 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
8099 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
8100 buf_ptr += WMI_TLV_HDR_SIZE;
8101 *(A_UINT32 *) buf_ptr = 0;
8102
8103 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8104 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
8105 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308106 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308107 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308108 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308109 }
8110
Govind Singhb53420c2016-03-09 14:32:57 +05308111 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308112}
8113
8114/**
8115 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8116 * @wmi_handle: wmi handle
8117 * @ptrn_id: pattern id
8118 * @vdev_id: vdev id
8119 *
8120 * Return: CDF status
8121 */
Govind Singhb53420c2016-03-09 14:32:57 +05308122QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle, uint8_t ptrn_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308123 uint8_t vdev_id)
8124{
8125 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8126 wmi_buf_t buf;
8127 int32_t len;
8128 int ret;
8129
8130 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8131
8132
8133 buf = wmi_buf_alloc(wmi_handle, len);
8134 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308135 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8136 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308137 }
8138
8139 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8140
8141 WMITLV_SET_HDR(&cmd->tlv_header,
8142 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8143 WMITLV_GET_STRUCT_TLVLEN(
8144 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8145 cmd->vdev_id = vdev_id;
8146 cmd->pattern_id = ptrn_id;
8147 cmd->pattern_type = WOW_BITMAP_PATTERN;
8148
Govind Singhb53420c2016-03-09 14:32:57 +05308149 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308150 cmd->pattern_id, vdev_id);
8151
8152 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8153 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8154 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308155 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308156 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308157 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308158 }
8159
Govind Singhb53420c2016-03-09 14:32:57 +05308160 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308161}
8162
8163/**
8164 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8165 * @wmi_handle: wmi handle
8166 *
8167 * Sends host wakeup indication to FW. On receiving this indication,
8168 * FW will come out of WOW.
8169 *
8170 * Return: CDF status
8171 */
Govind Singhb53420c2016-03-09 14:32:57 +05308172QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308173{
8174 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8175 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308176 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308177 int32_t len;
8178 int ret;
8179
8180 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8181
8182 buf = wmi_buf_alloc(wmi_handle, len);
8183 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308184 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8185 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308186 }
8187
8188 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8189 wmi_buf_data(buf);
8190 WMITLV_SET_HDR(&cmd->tlv_header,
8191 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8192 WMITLV_GET_STRUCT_TLVLEN
8193 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8194
8195
8196 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8197 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8198 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308199 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308200 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308201 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308202 }
8203
Govind Singhb53420c2016-03-09 14:32:57 +05308204 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308205}
8206
8207/**
8208 * send_del_ts_cmd_tlv() - send DELTS request to fw
8209 * @wmi_handle: wmi handle
8210 * @msg: delts params
8211 *
8212 * Return: CDF status
8213 */
Govind Singhb53420c2016-03-09 14:32:57 +05308214QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308215 uint8_t ac)
8216{
8217 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8218 wmi_buf_t buf;
8219 int32_t len = sizeof(*cmd);
8220
8221 buf = wmi_buf_alloc(wmi_handle, len);
8222 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308223 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8224 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308225 }
8226 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8227 WMITLV_SET_HDR(&cmd->tlv_header,
8228 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8229 WMITLV_GET_STRUCT_TLVLEN
8230 (wmi_vdev_wmm_delts_cmd_fixed_param));
8231 cmd->vdev_id = vdev_id;
8232 cmd->ac = ac;
8233
Govind Singhb53420c2016-03-09 14:32:57 +05308234 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308235 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8236 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8237 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308238 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308239 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308240 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308241 }
8242
Govind Singhb53420c2016-03-09 14:32:57 +05308243 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308244}
8245
8246/**
8247 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8248 * @wmi_handle: handle to wmi
8249 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8250 *
Govind Singhb53420c2016-03-09 14:32:57 +05308251 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308252 * ADD_TS requestes to firmware in loop for all the ACs with
8253 * active flow.
8254 *
8255 * Return: CDF status
8256 */
Govind Singhb53420c2016-03-09 14:32:57 +05308257QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308258 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8259{
8260 int i = 0;
8261 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8262 wmi_buf_t buf;
8263 int32_t len = sizeof(*cmd);
8264
8265 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8266 /* if flow in this AC is active */
8267 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8268 /*
8269 * as per implementation of wma_add_ts_req() we
8270 * are not waiting any response from firmware so
8271 * apart from sending ADDTS to firmware just send
8272 * success to upper layers
8273 */
Govind Singhb53420c2016-03-09 14:32:57 +05308274 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308275
8276 buf = wmi_buf_alloc(wmi_handle, len);
8277 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308278 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8279 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308280 }
8281 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8282 wmi_buf_data(buf);
8283 WMITLV_SET_HDR(&cmd->tlv_header,
8284 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8285 WMITLV_GET_STRUCT_TLVLEN
8286 (wmi_vdev_wmm_addts_cmd_fixed_param));
8287 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8288 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308289 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308290 traffic.userPrio);
8291 cmd->medium_time_us =
8292 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8293 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308294 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308295 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8296 cmd->medium_time_us, cmd->downgrade_type);
8297 if (wmi_unified_cmd_send
8298 (wmi_handle, buf, len,
8299 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308300 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308301 __func__);
8302 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308303 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308304 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308305 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308306 }
8307 }
8308 }
8309
Govind Singhb53420c2016-03-09 14:32:57 +05308310 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308311}
8312
8313/**
8314 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8315 * @wmi_handle: wmi handle
8316 * @msg: ADDTS params
8317 *
8318 * Return: CDF status
8319 */
Govind Singhb53420c2016-03-09 14:32:57 +05308320QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308321 struct add_ts_param *msg)
8322{
8323 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8324 wmi_buf_t buf;
8325 int32_t len = sizeof(*cmd);
8326
Govind Singhb53420c2016-03-09 14:32:57 +05308327 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308328
8329 buf = wmi_buf_alloc(wmi_handle, len);
8330 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308331 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8332 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308333 }
8334 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8335 WMITLV_SET_HDR(&cmd->tlv_header,
8336 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8337 WMITLV_GET_STRUCT_TLVLEN
8338 (wmi_vdev_wmm_addts_cmd_fixed_param));
8339 cmd->vdev_id = msg->sme_session_id;
8340 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8341 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8342 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308343 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308344 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8345 cmd->downgrade_type, __func__, __LINE__);
8346 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8347 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308348 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8349 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308350 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308351 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308352 }
8353
Govind Singhb53420c2016-03-09 14:32:57 +05308354 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308355}
8356
8357/**
8358 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
8359 * @wmi_handle: wmi handle
8360 * @vdev_id: vdev id
8361 * @enable: Flag to enable/disable packet filter
8362 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308363 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308364 */
Govind Singhb53420c2016-03-09 14:32:57 +05308365QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308366 uint8_t vdev_id, bool enable)
8367{
8368 int32_t len;
8369 int ret = 0;
8370 wmi_buf_t buf;
8371 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
8372
8373 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
8374
8375 buf = wmi_buf_alloc(wmi_handle, len);
8376 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308377 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308378 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308379 }
8380
8381 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
8382 WMITLV_SET_HDR(&cmd->tlv_header,
8383 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
8384 WMITLV_GET_STRUCT_TLVLEN(
8385 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
8386
8387 cmd->vdev_id = vdev_id;
8388 if (enable)
8389 cmd->enable = PACKET_FILTER_SET_ENABLE;
8390 else
8391 cmd->enable = PACKET_FILTER_SET_DISABLE;
8392
Govind Singhb53420c2016-03-09 14:32:57 +05308393 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308394 __func__, cmd->enable, vdev_id);
8395
8396 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8397 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308398 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308399 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308400 wmi_buf_free(buf);
8401 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308402
8403 return ret;
8404}
8405
8406/**
8407 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
8408 * @wmi_handle: wmi handle
8409 * @vdev_id: vdev id
8410 * @rcv_filter_param: Packet filter parameters
8411 * @filter_id: Filter id
8412 * @enable: Flag to add/delete packet filter configuration
8413 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308414 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308415 */
Govind Singhb53420c2016-03-09 14:32:57 +05308416QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308417 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8418 uint8_t filter_id, bool enable)
8419{
8420 int len, i;
8421 int err = 0;
8422 wmi_buf_t buf;
8423 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8424
8425
8426 /* allocate the memory */
8427 len = sizeof(*cmd);
8428 buf = wmi_buf_alloc(wmi_handle, len);
8429 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308430 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308431 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308432 }
8433
8434 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8435 WMITLV_SET_HDR(&cmd->tlv_header,
8436 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8437 WMITLV_GET_STRUCT_TLVLEN
8438 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8439
8440 cmd->vdev_id = vdev_id;
8441 cmd->filter_id = filter_id;
8442 if (enable)
8443 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8444 else
8445 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8446
8447 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308448 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308449 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8450 rcv_filter_param->numFieldParams);
8451 cmd->filter_type = rcv_filter_param->filterType;
8452 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8453
8454 for (i = 0; i < cmd->num_params; i++) {
8455 cmd->paramsData[i].proto_type =
8456 rcv_filter_param->paramsData[i].protocolLayer;
8457 cmd->paramsData[i].cmp_type =
8458 rcv_filter_param->paramsData[i].cmpFlag;
8459 cmd->paramsData[i].data_length =
8460 rcv_filter_param->paramsData[i].dataLength;
8461 cmd->paramsData[i].data_offset =
8462 rcv_filter_param->paramsData[i].dataOffset;
8463 memcpy(&cmd->paramsData[i].compareData,
8464 rcv_filter_param->paramsData[i].compareData,
8465 sizeof(cmd->paramsData[i].compareData));
8466 memcpy(&cmd->paramsData[i].dataMask,
8467 rcv_filter_param->paramsData[i].dataMask,
8468 sizeof(cmd->paramsData[i].dataMask));
8469 }
8470 }
8471
Govind Singhb53420c2016-03-09 14:32:57 +05308472 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308473 cmd->filter_action, cmd->filter_id, cmd->num_params);
8474 /* send the command along with data */
8475 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8476 WMI_PACKET_FILTER_CONFIG_CMDID);
8477 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308478 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308479 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308480 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308481 }
8482
8483
8484 return 0;
8485}
8486
8487/**
8488 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
8489 * @wmi_handle: wmi handle
8490 * @vdev_id: vdev id
8491 * @multicastAddr: mcast address
8492 * @clearList: clear list flag
8493 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308494 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308495 */
Govind Singhb53420c2016-03-09 14:32:57 +05308496QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308497 uint8_t vdev_id,
Govind Singhb53420c2016-03-09 14:32:57 +05308498 struct qdf_mac_addr multicast_addr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308499 bool clearList)
8500{
8501 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
8502 wmi_buf_t buf;
8503 int err;
8504
8505 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8506 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308507 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308508 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308509 }
8510
8511 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308512 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308513
8514 WMITLV_SET_HDR(&cmd->tlv_header,
8515 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
8516 WMITLV_GET_STRUCT_TLVLEN
8517 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
8518 cmd->action =
8519 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
8520 cmd->vdev_id = vdev_id;
8521 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
Dustin Brown4103e4a2016-11-14 16:11:26 -08008522
8523 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
8524 cmd->action, vdev_id, clearList, multicast_addr.bytes);
8525
Govind Singh20c5dac2016-03-07 15:33:31 +05308526 err = wmi_unified_cmd_send(wmi_handle, buf,
8527 sizeof(*cmd),
8528 WMI_SET_MCASTBCAST_FILTER_CMDID);
8529 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308530 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308531 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308532 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308533 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308534
Dustin Brown4103e4a2016-11-14 16:11:26 -08008535 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308536}
8537
8538/**
8539 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
8540 * @wmi_handle: wmi handle
8541 * @vdev_id: vdev id
8542 * @params: GTK offload parameters
8543 *
8544 * Return: CDF status
8545 */
Govind Singhb53420c2016-03-09 14:32:57 +05308546QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308547 struct gtk_offload_params *params,
8548 bool enable_offload,
8549 uint32_t gtk_offload_opcode)
8550{
8551 int len;
8552 wmi_buf_t buf;
8553 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308554 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308555
Govind Singhb53420c2016-03-09 14:32:57 +05308556 WMI_LOGD("%s Enter", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308557
8558 len = sizeof(*cmd);
8559
8560 /* alloc wmi buffer */
8561 buf = wmi_buf_alloc(wmi_handle, len);
8562 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308563 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8564 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308565 goto out;
8566 }
8567
8568 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8569 WMITLV_SET_HDR(&cmd->tlv_header,
8570 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8571 WMITLV_GET_STRUCT_TLVLEN
8572 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8573
8574 cmd->vdev_id = vdev_id;
8575
8576 /* Request target to enable GTK offload */
Siddarth Poddar9500f2e2016-04-01 17:45:06 +05308577 if (enable_offload == WMI_GTK_OFFLOAD_ENABLE) {
Govind Singh20c5dac2016-03-07 15:33:31 +05308578 cmd->flags = gtk_offload_opcode;
8579
8580 /* Copy the keys and replay counter */
Govind Singhb53420c2016-03-09 14:32:57 +05308581 qdf_mem_copy(cmd->KCK, params->aKCK, WMI_GTK_OFFLOAD_KCK_BYTES);
8582 qdf_mem_copy(cmd->KEK, params->aKEK, WMI_GTK_OFFLOAD_KEK_BYTES);
8583 qdf_mem_copy(cmd->replay_counter, &params->ullKeyReplayCounter,
Govind Singh20c5dac2016-03-07 15:33:31 +05308584 GTK_REPLAY_COUNTER_BYTES);
8585 } else {
8586 cmd->flags = gtk_offload_opcode;
8587 }
8588
Dustin Brown4103e4a2016-11-14 16:11:26 -08008589 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
8590
Govind Singh20c5dac2016-03-07 15:33:31 +05308591 /* send the wmi command */
8592 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8593 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308594 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
Govind Singh20c5dac2016-03-07 15:33:31 +05308595 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308596 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308597 }
8598
Govind Singh20c5dac2016-03-07 15:33:31 +05308599out:
Govind Singhb53420c2016-03-09 14:32:57 +05308600 WMI_LOGD("%s Exit", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308601 return status;
8602}
8603
8604/**
8605 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
8606 * @wmi_handle: wmi handle
8607 * @params: GTK offload params
8608 *
8609 * Return: CDF status
8610 */
Govind Singhb53420c2016-03-09 14:32:57 +05308611QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308612 uint8_t vdev_id,
8613 uint64_t offload_req_opcode)
8614{
8615 int len;
8616 wmi_buf_t buf;
8617 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308618 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308619
8620 len = sizeof(*cmd);
8621
8622 /* alloc wmi buffer */
8623 buf = wmi_buf_alloc(wmi_handle, len);
8624 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308625 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8626 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308627 goto out;
8628 }
8629
8630 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8631 WMITLV_SET_HDR(&cmd->tlv_header,
8632 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8633 WMITLV_GET_STRUCT_TLVLEN
8634 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8635
8636 /* Request for GTK offload status */
8637 cmd->flags = offload_req_opcode;
8638 cmd->vdev_id = vdev_id;
8639
8640 /* send the wmi command */
8641 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8642 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308643 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
Govind Singh20c5dac2016-03-07 15:33:31 +05308644 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308645 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308646 }
8647
8648out:
8649 return status;
8650}
8651
8652/**
8653 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8654 * @wmi_handle: wmi handle
8655 * @pAddPeriodicTxPtrnParams: tx ptrn params
8656 *
8657 * Retrun: CDF status
8658 */
Govind Singhb53420c2016-03-09 14:32:57 +05308659QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308660 struct periodic_tx_pattern *
8661 pAddPeriodicTxPtrnParams,
8662 uint8_t vdev_id)
8663{
8664 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8665 wmi_buf_t wmi_buf;
8666 uint32_t len;
8667 uint8_t *buf_ptr;
8668 uint32_t ptrn_len, ptrn_len_aligned;
8669 int j;
8670
8671 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8672 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8673 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8674 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8675
8676 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8677 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308678 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8679 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308680 }
8681
8682 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8683
8684 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8685 WMITLV_SET_HDR(&cmd->tlv_header,
8686 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8687 WMITLV_GET_STRUCT_TLVLEN
8688 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8689
8690 /* Pass the pattern id to delete for the corresponding vdev id */
8691 cmd->vdev_id = vdev_id;
8692 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8693 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8694 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8695
8696 /* Pattern info */
8697 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8698 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8699 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308700 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308701 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308702 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308703
Govind Singhb53420c2016-03-09 14:32:57 +05308704 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308705 __func__, cmd->pattern_id, cmd->vdev_id);
8706
8707 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8708 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308709 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308710 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308711 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308712 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308713 }
Govind Singhb53420c2016-03-09 14:32:57 +05308714 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308715}
8716
8717/**
8718 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8719 * @wmi_handle: wmi handle
8720 * @vdev_id: vdev id
8721 * @pattern_id: pattern id
8722 *
8723 * Retrun: CDF status
8724 */
Govind Singhb53420c2016-03-09 14:32:57 +05308725QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308726 uint8_t vdev_id,
8727 uint8_t pattern_id)
8728{
8729 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8730 wmi_buf_t wmi_buf;
8731 uint32_t len =
8732 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8733
8734 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8735 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308736 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8737 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308738 }
8739
8740 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8741 wmi_buf_data(wmi_buf);
8742 WMITLV_SET_HDR(&cmd->tlv_header,
8743 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8744 WMITLV_GET_STRUCT_TLVLEN
8745 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8746
8747 /* Pass the pattern id to delete for the corresponding vdev id */
8748 cmd->vdev_id = vdev_id;
8749 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308750 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308751 __func__, cmd->pattern_id, cmd->vdev_id);
8752
8753 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8754 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308755 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308756 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308757 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308758 }
Govind Singhb53420c2016-03-09 14:32:57 +05308759 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308760}
8761
8762/**
8763 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8764 * @wmi_handle: wmi handle
8765 * @preq: stats ext params
8766 *
8767 * Return: CDF status
8768 */
Govind Singhb53420c2016-03-09 14:32:57 +05308769QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308770 struct stats_ext_params *preq)
8771{
Govind Singh67922e82016-04-01 16:48:57 +05308772 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308773 wmi_req_stats_ext_cmd_fixed_param *cmd;
8774 wmi_buf_t buf;
8775 uint16_t len;
8776 uint8_t *buf_ptr;
8777
8778 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8779
8780 buf = wmi_buf_alloc(wmi_handle, len);
8781 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308782 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308783 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308784 }
8785
8786 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8787 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8788
8789 WMITLV_SET_HDR(&cmd->tlv_header,
8790 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8791 WMITLV_GET_STRUCT_TLVLEN
8792 (wmi_req_stats_ext_cmd_fixed_param));
8793 cmd->vdev_id = preq->vdev_id;
8794 cmd->data_len = preq->request_data_len;
8795
Govind Singhb53420c2016-03-09 14:32:57 +05308796 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308797 __func__, preq->request_data_len, preq->vdev_id);
8798
8799 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8800 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8801
8802 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308803 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308804
8805 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8806 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308807 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308808 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308809 ret);
8810 wmi_buf_free(buf);
8811 }
8812
8813 return ret;
8814}
8815
8816/**
8817 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8818 * @wmi_handle: wmi handle
8819 * @params: ext wow params
8820 *
8821 * Return:0 for success or error code
8822 */
Govind Singhb53420c2016-03-09 14:32:57 +05308823QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308824 struct ext_wow_params *params)
8825{
8826 wmi_extwow_enable_cmd_fixed_param *cmd;
8827 wmi_buf_t buf;
8828 int32_t len;
8829 int ret;
8830
8831 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8832 buf = wmi_buf_alloc(wmi_handle, len);
8833 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308834 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8835 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308836 }
8837
8838 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8839
8840 WMITLV_SET_HDR(&cmd->tlv_header,
8841 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8842 WMITLV_GET_STRUCT_TLVLEN
8843 (wmi_extwow_enable_cmd_fixed_param));
8844
8845 cmd->vdev_id = params->vdev_id;
8846 cmd->type = params->type;
8847 cmd->wakeup_pin_num = params->wakeup_pin_num;
8848
Govind Singhb53420c2016-03-09 14:32:57 +05308849 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308850 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8851
8852 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8853 WMI_EXTWOW_ENABLE_CMDID);
8854 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308855 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308856 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308857 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308858 }
8859
Govind Singhb53420c2016-03-09 14:32:57 +05308860 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308861
8862}
8863
8864/**
8865 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8866 * @wmi_handle: wmi handle
8867 * @app_type1_params: app type1 params
8868 *
8869 * Return: CDF status
8870 */
Govind Singhb53420c2016-03-09 14:32:57 +05308871QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308872 struct app_type1_params *app_type1_params)
8873{
8874 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8875 wmi_buf_t buf;
8876 int32_t len;
8877 int ret;
8878
8879 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8880 buf = wmi_buf_alloc(wmi_handle, len);
8881 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308882 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8883 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308884 }
8885
8886 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8887 wmi_buf_data(buf);
8888
8889 WMITLV_SET_HDR(&cmd->tlv_header,
8890 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8891 WMITLV_GET_STRUCT_TLVLEN
8892 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8893
8894 cmd->vdev_id = app_type1_params->vdev_id;
8895 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8896 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308897 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308898 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308899 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308900 cmd->passwd_len = app_type1_params->pass_length;
8901
Govind Singhb53420c2016-03-09 14:32:57 +05308902 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308903 "identification_id %.8s id_length %u "
8904 "password %.16s pass_length %u",
8905 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8906 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8907
8908 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8909 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8910 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308911 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308912 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308913 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308914 }
8915
Govind Singhb53420c2016-03-09 14:32:57 +05308916 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308917}
8918
8919/**
8920 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8921 * @wmi_handle: wmi handle
8922 * @appType2Params: app type2 params
8923 *
8924 * Return: CDF status
8925 */
Govind Singhb53420c2016-03-09 14:32:57 +05308926QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308927 struct app_type2_params *appType2Params)
8928{
8929 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8930 wmi_buf_t buf;
8931 int32_t len;
8932 int ret;
8933
8934 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8935 buf = wmi_buf_alloc(wmi_handle, len);
8936 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308937 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8938 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308939 }
8940
8941 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8942 wmi_buf_data(buf);
8943
8944 WMITLV_SET_HDR(&cmd->tlv_header,
8945 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8946 WMITLV_GET_STRUCT_TLVLEN
8947 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8948
8949 cmd->vdev_id = appType2Params->vdev_id;
8950
Govind Singhb53420c2016-03-09 14:32:57 +05308951 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308952 cmd->rc4_key_len = appType2Params->rc4_key_len;
8953
8954 cmd->ip_id = appType2Params->ip_id;
8955 cmd->ip_device_ip = appType2Params->ip_device_ip;
8956 cmd->ip_server_ip = appType2Params->ip_server_ip;
8957
8958 cmd->tcp_src_port = appType2Params->tcp_src_port;
8959 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8960 cmd->tcp_seq = appType2Params->tcp_seq;
8961 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8962
8963 cmd->keepalive_init = appType2Params->keepalive_init;
8964 cmd->keepalive_min = appType2Params->keepalive_min;
8965 cmd->keepalive_max = appType2Params->keepalive_max;
8966 cmd->keepalive_inc = appType2Params->keepalive_inc;
8967
8968 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8969 &cmd->gateway_mac);
8970 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8971 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8972
Govind Singhb53420c2016-03-09 14:32:57 +05308973 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308974 "rc4_key %.16s rc4_key_len %u "
8975 "ip_id %x ip_device_ip %x ip_server_ip %x "
8976 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8977 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8978 "keepalive_max %u keepalive_inc %u "
8979 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8980 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8981 cmd->rc4_key, cmd->rc4_key_len,
8982 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8983 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8984 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8985 cmd->keepalive_max, cmd->keepalive_inc,
8986 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8987
8988 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8989 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8990 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308991 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308992 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308993 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308994 }
8995
Govind Singhb53420c2016-03-09 14:32:57 +05308996 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308997
8998}
8999
9000/**
9001 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9002 * @wmi_handle: wmi handle
9003 * @timer_val: auto shutdown timer value
9004 *
9005 * Return: CDF status
9006 */
Govind Singhb53420c2016-03-09 14:32:57 +05309007QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309008 uint32_t timer_val)
9009{
Govind Singh67922e82016-04-01 16:48:57 +05309010 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309011 wmi_buf_t buf = NULL;
9012 uint8_t *buf_ptr;
9013 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9014 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9015
Govind Singhb53420c2016-03-09 14:32:57 +05309016 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309017 __func__, timer_val);
9018
9019 buf = wmi_buf_alloc(wmi_handle, len);
9020 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309021 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9022 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309023 }
9024
9025 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9026 wmi_auto_sh_cmd =
9027 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9028 wmi_auto_sh_cmd->timer_value = timer_val;
9029
9030 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9031 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9032 WMITLV_GET_STRUCT_TLVLEN
9033 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9034
9035 status = wmi_unified_cmd_send(wmi_handle, buf,
9036 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309037 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309038 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309039 __func__, status);
9040 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309041 }
9042
Govind Singh67922e82016-04-01 16:48:57 +05309043 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309044}
9045
9046/**
9047 * send_nan_req_cmd_tlv() - to send nan request to target
9048 * @wmi_handle: wmi handle
9049 * @nan_req: request data which will be non-null
9050 *
9051 * Return: CDF status
9052 */
Govind Singhb53420c2016-03-09 14:32:57 +05309053QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309054 struct nan_req_params *nan_req)
9055{
Govind Singh67922e82016-04-01 16:48:57 +05309056 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309057 wmi_nan_cmd_param *cmd;
9058 wmi_buf_t buf;
9059 uint16_t len = sizeof(*cmd);
9060 uint16_t nan_data_len, nan_data_len_aligned;
9061 uint8_t *buf_ptr;
9062
9063 /*
9064 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9065 * +------------+----------+-----------------------+--------------+
9066 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9067 * +------------+----------+-----------------------+--------------+
9068 */
9069 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309070 WMI_LOGE("%s:nan req is not valid", __func__);
9071 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309072 }
9073 nan_data_len = nan_req->request_data_len;
9074 nan_data_len_aligned = roundup(nan_req->request_data_len,
9075 sizeof(uint32_t));
9076 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9077 buf = wmi_buf_alloc(wmi_handle, len);
9078 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309079 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9080 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309081 }
9082 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9083 cmd = (wmi_nan_cmd_param *) buf_ptr;
9084 WMITLV_SET_HDR(&cmd->tlv_header,
9085 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9086 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9087 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309088 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309089 __func__, nan_req->request_data_len);
9090 buf_ptr += sizeof(wmi_nan_cmd_param);
9091 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9092 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309093 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309094
9095 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9096 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309097 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309098 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309099 __func__, ret);
9100 wmi_buf_free(buf);
9101 }
9102
9103 return ret;
9104}
9105
9106/**
9107 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9108 * @wmi_handle: wmi handle
9109 * @pDhcpSrvOffloadInfo: DHCP server offload info
9110 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309111 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309112 */
Govind Singhb53420c2016-03-09 14:32:57 +05309113QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309114 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
9115{
9116 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9117 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309118 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309119
9120 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9121 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309122 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309123 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309124 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309125 }
9126
9127 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309128 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05309129
9130 WMITLV_SET_HDR(&cmd->tlv_header,
9131 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9132 WMITLV_GET_STRUCT_TLVLEN
9133 (wmi_set_dhcp_server_offload_cmd_fixed_param));
9134 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
9135 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
9136 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
9137 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
9138 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309139 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309140 sizeof(*cmd),
9141 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309142 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309143 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309144 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309145 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309146 }
Govind Singhb53420c2016-03-09 14:32:57 +05309147 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309148 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309149
9150 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309151}
9152
9153/**
9154 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9155 * @wmi_handle: wmi handle
9156 * @flashing: flashing request
9157 *
9158 * Return: CDF status
9159 */
Govind Singhb53420c2016-03-09 14:32:57 +05309160QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309161 struct flashing_req_params *flashing)
9162{
9163 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309164 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309165 wmi_buf_t buf;
9166 uint8_t *buf_ptr;
9167 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9168
9169 buf = wmi_buf_alloc(wmi_handle, len);
9170 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309171 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309172 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309173 }
9174 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9175 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9176 WMITLV_SET_HDR(&cmd->tlv_header,
9177 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9178 WMITLV_GET_STRUCT_TLVLEN
9179 (wmi_set_led_flashing_cmd_fixed_param));
9180 cmd->pattern_id = flashing->pattern_id;
9181 cmd->led_x0 = flashing->led_x0;
9182 cmd->led_x1 = flashing->led_x1;
9183
9184 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9185 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309186 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309187 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309188 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309189 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309190 }
Govind Singh67922e82016-04-01 16:48:57 +05309191
9192 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309193}
9194
9195/**
9196 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9197 * @wmi_handle: wmi handle
9198 * @ch_avoid_update_req: channel avoid update params
9199 *
9200 * Return: CDF status
9201 */
Govind Singhb53420c2016-03-09 14:32:57 +05309202QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309203{
Govind Singh67922e82016-04-01 16:48:57 +05309204 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309205 wmi_buf_t buf = NULL;
9206 uint8_t *buf_ptr;
9207 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9208 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9209
9210
9211 buf = wmi_buf_alloc(wmi_handle, len);
9212 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309213 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9214 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309215 }
9216
9217 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9218 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9219 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9220 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9221 WMITLV_GET_STRUCT_TLVLEN
9222 (wmi_chan_avoid_update_cmd_param));
9223
9224 status = wmi_unified_cmd_send(wmi_handle, buf,
9225 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309226 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309227 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309228 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9229 " returned Error %d", status);
9230 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309231 }
9232
Govind Singh67922e82016-04-01 16:48:57 +05309233 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309234}
9235
9236/**
9237 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9238 * @wmi_handle: wmi handle
9239 * @reg_dmn: reg domain
9240 * @regdmn2G: 2G reg domain
9241 * @regdmn5G: 5G reg domain
9242 * @ctl2G: 2G test limit
9243 * @ctl5G: 5G test limit
9244 *
9245 * Return: none
9246 */
Govind Singhb53420c2016-03-09 14:32:57 +05309247QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309248 uint32_t reg_dmn, uint16_t regdmn2G,
9249 uint16_t regdmn5G, int8_t ctl2G,
9250 int8_t ctl5G)
9251{
9252 wmi_buf_t buf;
9253 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9254 int32_t len = sizeof(*cmd);
9255
9256
9257 buf = wmi_buf_alloc(wmi_handle, len);
9258 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309259 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9260 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309261 }
9262 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9263 WMITLV_SET_HDR(&cmd->tlv_header,
9264 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9265 WMITLV_GET_STRUCT_TLVLEN
9266 (wmi_pdev_set_regdomain_cmd_fixed_param));
9267 cmd->reg_domain = reg_dmn;
9268 cmd->reg_domain_2G = regdmn2G;
9269 cmd->reg_domain_5G = regdmn5G;
9270 cmd->conformance_test_limit_2G = ctl2G;
9271 cmd->conformance_test_limit_5G = ctl5G;
9272
9273 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9274 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309275 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309276 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309277 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309278 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309279 }
9280
Govind Singhb53420c2016-03-09 14:32:57 +05309281 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309282}
9283
9284
9285/**
9286 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9287 * @wmi_handle: wmi handle
9288 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9289 *
9290 * This function sets tdls off channel mode
9291 *
9292 * Return: 0 on success; Negative errno otherwise
9293 */
Govind Singhb53420c2016-03-09 14:32:57 +05309294QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309295 struct tdls_channel_switch_params *chan_switch_params)
9296{
9297 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9298 wmi_buf_t wmi_buf;
9299 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9300
9301 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9302 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309303 WMI_LOGE(FL("wmi_buf_alloc failed"));
9304 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309305 }
9306 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9307 wmi_buf_data(wmi_buf);
9308 WMITLV_SET_HDR(&cmd->tlv_header,
9309 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9310 WMITLV_GET_STRUCT_TLVLEN(
9311 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9312
9313 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9314 &cmd->peer_macaddr);
9315 cmd->vdev_id = chan_switch_params->vdev_id;
9316 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9317 cmd->is_peer_responder = chan_switch_params->is_responder;
9318 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9319 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9320 cmd->offchan_oper_class = chan_switch_params->oper_class;
9321
Govind Singhb53420c2016-03-09 14:32:57 +05309322 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309323 cmd->peer_macaddr.mac_addr31to0,
9324 cmd->peer_macaddr.mac_addr47to32);
9325
Govind Singhb53420c2016-03-09 14:32:57 +05309326 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309327 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9328 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9329 ),
9330 cmd->vdev_id,
9331 cmd->offchan_mode,
9332 cmd->offchan_num,
9333 cmd->offchan_bw_bitmap,
9334 cmd->is_peer_responder,
9335 cmd->offchan_oper_class);
9336
9337 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9338 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309339 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309340 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309341 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309342 }
9343
9344
Govind Singhb53420c2016-03-09 14:32:57 +05309345 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309346}
9347
9348/**
9349 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9350 * @wmi_handle: wmi handle
9351 * @pwmaTdlsparams: TDLS params
9352 *
9353 * Return: 0 for sucess or error code
9354 */
Govind Singhb53420c2016-03-09 14:32:57 +05309355QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309356 void *tdls_param, uint8_t tdls_state)
9357{
9358 wmi_tdls_set_state_cmd_fixed_param *cmd;
9359 wmi_buf_t wmi_buf;
9360
9361 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9362 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9363
9364 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9365 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309366 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9367 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309368 }
9369 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9370 WMITLV_SET_HDR(&cmd->tlv_header,
9371 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9372 WMITLV_GET_STRUCT_TLVLEN
9373 (wmi_tdls_set_state_cmd_fixed_param));
9374 cmd->vdev_id = wmi_tdls->vdev_id;
9375 cmd->state = tdls_state;
9376 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9377 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9378 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9379 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9380 cmd->rssi_delta = wmi_tdls->rssi_delta;
9381 cmd->tdls_options = wmi_tdls->tdls_options;
9382 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9383 cmd->tdls_peer_traffic_response_timeout_ms =
9384 wmi_tdls->peer_traffic_response_timeout;
9385 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9386 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9387 cmd->tdls_puapsd_rx_frame_threshold =
9388 wmi_tdls->puapsd_rx_frame_threshold;
9389 cmd->teardown_notification_ms =
9390 wmi_tdls->teardown_notification_ms;
9391 cmd->tdls_peer_kickout_threshold =
9392 wmi_tdls->tdls_peer_kickout_threshold;
9393
Govind Singhb53420c2016-03-09 14:32:57 +05309394 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309395 "notification_interval_ms: %d, "
9396 "tx_discovery_threshold: %d, "
9397 "tx_teardown_threshold: %d, "
9398 "rssi_teardown_threshold: %d, "
9399 "rssi_delta: %d, "
9400 "tdls_options: 0x%x, "
9401 "tdls_peer_traffic_ind_window: %d, "
9402 "tdls_peer_traffic_response_timeout: %d, "
9403 "tdls_puapsd_mask: 0x%x, "
9404 "tdls_puapsd_inactivity_time: %d, "
9405 "tdls_puapsd_rx_frame_threshold: %d, "
9406 "teardown_notification_ms: %d, "
9407 "tdls_peer_kickout_threshold: %d",
9408 __func__, tdls_state, cmd->state,
9409 cmd->notification_interval_ms,
9410 cmd->tx_discovery_threshold,
9411 cmd->tx_teardown_threshold,
9412 cmd->rssi_teardown_threshold,
9413 cmd->rssi_delta,
9414 cmd->tdls_options,
9415 cmd->tdls_peer_traffic_ind_window,
9416 cmd->tdls_peer_traffic_response_timeout_ms,
9417 cmd->tdls_puapsd_mask,
9418 cmd->tdls_puapsd_inactivity_time_ms,
9419 cmd->tdls_puapsd_rx_frame_threshold,
9420 cmd->teardown_notification_ms,
9421 cmd->tdls_peer_kickout_threshold);
9422
9423 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9424 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309425 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309426 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309427 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309428 }
Govind Singhb53420c2016-03-09 14:32:57 +05309429 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309430
Govind Singhb53420c2016-03-09 14:32:57 +05309431 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309432}
9433
9434/**
9435 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9436 * @wmi_handle: wmi handle
9437 * @peerStateParams: TDLS peer state params
9438 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309439 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309440 */
Govind Singhb53420c2016-03-09 14:32:57 +05309441QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309442 struct tdls_peer_state_params *peerStateParams,
9443 uint32_t *ch_mhz)
9444{
9445 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9446 wmi_tdls_peer_capabilities *peer_cap;
9447 wmi_channel *chan_info;
9448 wmi_buf_t wmi_buf;
9449 uint8_t *buf_ptr;
9450 uint32_t i;
9451 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9452 sizeof(wmi_tdls_peer_capabilities);
9453
9454
9455 len += WMI_TLV_HDR_SIZE +
9456 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9457
9458 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9459 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309460 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9461 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309462 }
9463
9464 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9465 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9466 WMITLV_SET_HDR(&cmd->tlv_header,
9467 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9468 WMITLV_GET_STRUCT_TLVLEN
9469 (wmi_tdls_peer_update_cmd_fixed_param));
9470
9471 cmd->vdev_id = peerStateParams->vdevId;
9472 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9473 &cmd->peer_macaddr);
9474
9475
9476 cmd->peer_state = peerStateParams->peerState;
9477
Govind Singhb53420c2016-03-09 14:32:57 +05309478 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309479 "peer_macaddr.mac_addr31to0: 0x%x, "
9480 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9481 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9482 cmd->peer_macaddr.mac_addr31to0,
9483 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9484
9485 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9486 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9487 WMITLV_SET_HDR(&peer_cap->tlv_header,
9488 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9489 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9490
9491 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9492 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9493 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9494 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9495 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9496 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9497 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9498 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9499
9500 /* Ack and More Data Ack are sent as 0, so no need to set
9501 * but fill SP
9502 */
9503 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9504 peerStateParams->peerCap.peerMaxSp);
9505
9506 peer_cap->buff_sta_support =
9507 peerStateParams->peerCap.peerBuffStaSupport;
9508 peer_cap->off_chan_support =
9509 peerStateParams->peerCap.peerOffChanSupport;
9510 peer_cap->peer_curr_operclass =
9511 peerStateParams->peerCap.peerCurrOperClass;
9512 /* self curr operclass is not being used and so pass op class for
9513 * preferred off chan in it.
9514 */
9515 peer_cap->self_curr_operclass =
9516 peerStateParams->peerCap.opClassForPrefOffChan;
9517 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9518 peer_cap->peer_operclass_len =
9519 peerStateParams->peerCap.peerOperClassLen;
9520
Govind Singhb53420c2016-03-09 14:32:57 +05309521 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309522 __func__, peer_cap->peer_operclass_len);
9523 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9524 peer_cap->peer_operclass[i] =
9525 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309526 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309527 __func__, i, peer_cap->peer_operclass[i]);
9528 }
9529
9530 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9531 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9532 peer_cap->pref_offchan_bw =
9533 peerStateParams->peerCap.prefOffChanBandwidth;
9534
Govind Singhb53420c2016-03-09 14:32:57 +05309535 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309536 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9537 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9538 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9539 " %d, pref_offchan_bw: %d",
9540 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9541 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9542 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9543 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9544 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9545
9546 /* next fill variable size array of peer chan info */
9547 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9548 WMITLV_SET_HDR(buf_ptr,
9549 WMITLV_TAG_ARRAY_STRUC,
9550 sizeof(wmi_channel) *
9551 peerStateParams->peerCap.peerChanLen);
9552 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9553
9554 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9555 WMITLV_SET_HDR(&chan_info->tlv_header,
9556 WMITLV_TAG_STRUC_wmi_channel,
9557 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9558 chan_info->mhz = ch_mhz[i];
9559 chan_info->band_center_freq1 = chan_info->mhz;
9560 chan_info->band_center_freq2 = 0;
9561
Govind Singhb53420c2016-03-09 14:32:57 +05309562 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309563
9564 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9565 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309566 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309567 peerStateParams->peerCap.peerChan[i].chanId,
9568 peerStateParams->peerCap.peerChan[i].dfsSet);
9569 }
9570
9571 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9572 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9573 else
9574 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9575
9576 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9577 peerStateParams->peerCap.
9578 peerChan[i].pwr);
9579
9580 WMI_SET_CHANNEL_REG_POWER(chan_info,
9581 peerStateParams->peerCap.peerChan[i].
9582 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309583 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309584 peerStateParams->peerCap.peerChan[i].pwr);
9585
9586 chan_info++;
9587 }
9588
9589 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9590 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309591 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309592 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309593 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309594 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309595 }
9596
9597
Govind Singhb53420c2016-03-09 14:32:57 +05309598 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309599}
9600
9601/*
9602 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9603 * firmware
9604 * @wmi_handle: Pointer to wmi handle
9605 * @mem_dump_req: Pointer for mem_dump_req
9606 *
9607 * This function sends memory dump request to firmware
9608 *
Govind Singhb53420c2016-03-09 14:32:57 +05309609 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309610 *
9611 */
Govind Singhb53420c2016-03-09 14:32:57 +05309612QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309613 struct fw_dump_req_param *mem_dump_req)
9614{
9615 wmi_get_fw_mem_dump_fixed_param *cmd;
9616 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309617 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309618 int32_t len;
9619 wmi_buf_t buf;
9620 u_int8_t *buf_ptr;
9621 int ret, loop;
9622
9623 /*
9624 * len = sizeof(fixed param) that includes tlv header +
9625 * tlv header for array of struc +
9626 * sizeof (each struct)
9627 */
9628 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9629 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9630 buf = wmi_buf_alloc(wmi_handle, len);
9631
9632 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309633 WMI_LOGE(FL("Failed allocate wmi buffer"));
9634 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309635 }
9636
9637 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309638 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309639 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9640
9641 WMITLV_SET_HDR(&cmd->tlv_header,
9642 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9643 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9644
9645 cmd->request_id = mem_dump_req->request_id;
9646 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9647
9648 /* TLV indicating array of structures to follow */
9649 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9650 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9651 sizeof(wmi_fw_mem_dump) *
9652 cmd->num_fw_mem_dump_segs);
9653
9654 buf_ptr += WMI_TLV_HDR_SIZE;
9655 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9656
Govind Singhb53420c2016-03-09 14:32:57 +05309657 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309658 mem_dump_req->request_id, mem_dump_req->num_seg);
9659 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309660 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309661 ((uint8_t *)(mem_dump_req->segment) +
9662 loop * sizeof(*seg_req));
9663 WMITLV_SET_HDR(&dump_params->tlv_header,
9664 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9665 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9666 dump_params->seg_id = seg_req->seg_id;
9667 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9668 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9669 dump_params->seg_length = seg_req->seg_length;
9670 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9671 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309672 WMI_LOGI(FL("seg_number:%d"), loop);
9673 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309674 dump_params->seg_id, dump_params->seg_start_addr_lo,
9675 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309676 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309677 dump_params->seg_length, dump_params->dest_addr_lo,
9678 dump_params->dest_addr_hi);
9679 dump_params++;
9680 }
9681
9682 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9683 WMI_GET_FW_MEM_DUMP_CMDID);
9684 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309685 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309686 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309687 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309688 }
9689
Govind Singhb53420c2016-03-09 14:32:57 +05309690 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9691 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309692}
9693
9694/*
9695 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9696 * @wmi_handle: Pointer to WMi handle
9697 * @ie_data: Pointer for ie data
9698 *
9699 * This function sends IE information to firmware
9700 *
Govind Singhb53420c2016-03-09 14:32:57 +05309701 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309702 *
9703 */
Govind Singhb53420c2016-03-09 14:32:57 +05309704QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309705 struct vdev_ie_info_param *ie_info)
9706{
9707 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9708 wmi_buf_t buf;
9709 uint8_t *buf_ptr;
9710 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309711 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309712
9713
9714 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9715 /* Allocate memory for the WMI command */
9716 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9717
9718 buf = wmi_buf_alloc(wmi_handle, len);
9719 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309720 WMI_LOGE(FL("wmi_buf_alloc failed"));
9721 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309722 }
9723
9724 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309725 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309726
9727 /* Populate the WMI command */
9728 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9729
9730 WMITLV_SET_HDR(&cmd->tlv_header,
9731 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9732 WMITLV_GET_STRUCT_TLVLEN(
9733 wmi_vdev_set_ie_cmd_fixed_param));
9734 cmd->vdev_id = ie_info->vdev_id;
9735 cmd->ie_id = ie_info->ie_id;
9736 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009737 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309738
Govind Singhb53420c2016-03-09 14:32:57 +05309739 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309740 ie_info->length, ie_info->vdev_id);
9741
9742 buf_ptr += sizeof(*cmd);
9743 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9744 buf_ptr += WMI_TLV_HDR_SIZE;
9745
Govind Singhb53420c2016-03-09 14:32:57 +05309746 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309747
9748 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9749 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309750 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309751 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309752 wmi_buf_free(buf);
9753 }
9754
9755 return ret;
9756}
9757
Jeff Johnson9366d7a2016-10-07 13:03:02 -07009758static
Govind Singh9ddd5162016-03-07 16:30:32 +05309759void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05309760 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05309761{
Govind Singhe7f2f342016-05-23 12:12:52 +05309762 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05309763 resource_cfg->num_peers = tgt_res_cfg->num_peers;
9764 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
9765 resource_cfg->num_offload_reorder_buffs =
9766 tgt_res_cfg->num_offload_reorder_buffs;
9767 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
9768 resource_cfg->num_tids = tgt_res_cfg->num_tids;
9769 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
9770 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
9771 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
9772 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
9773 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
9774 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
9775 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
9776 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
9777 resource_cfg->scan_max_pending_req =
9778 tgt_res_cfg->scan_max_pending_req;
9779 resource_cfg->bmiss_offload_max_vdev =
9780 tgt_res_cfg->bmiss_offload_max_vdev;
9781 resource_cfg->roam_offload_max_vdev =
9782 tgt_res_cfg->roam_offload_max_vdev;
9783 resource_cfg->roam_offload_max_ap_profiles =
9784 tgt_res_cfg->roam_offload_max_ap_profiles;
9785 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
9786 resource_cfg->num_mcast_table_elems =
9787 tgt_res_cfg->num_mcast_table_elems;
9788 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
9789 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
9790 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
9791 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
9792 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
9793 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
9794 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
9795 resource_cfg->vow_config = tgt_res_cfg->vow_config;
9796 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
9797 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
9798 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
9799 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
9800 resource_cfg->num_tdls_conn_table_entries =
9801 tgt_res_cfg->num_tdls_conn_table_entries;
9802 resource_cfg->beacon_tx_offload_max_vdev =
9803 tgt_res_cfg->beacon_tx_offload_max_vdev;
9804 resource_cfg->num_multicast_filter_entries =
9805 tgt_res_cfg->num_multicast_filter_entries;
9806 resource_cfg->num_wow_filters =
9807 tgt_res_cfg->num_wow_filters;
9808 resource_cfg->num_keep_alive_pattern =
9809 tgt_res_cfg->num_keep_alive_pattern;
9810 resource_cfg->keep_alive_pattern_size =
9811 tgt_res_cfg->keep_alive_pattern_size;
9812 resource_cfg->max_tdls_concurrent_sleep_sta =
9813 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
9814 resource_cfg->max_tdls_concurrent_buffer_sta =
9815 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
9816 resource_cfg->wmi_send_separate =
9817 tgt_res_cfg->wmi_send_separate;
9818 resource_cfg->num_ocb_vdevs =
9819 tgt_res_cfg->num_ocb_vdevs;
9820 resource_cfg->num_ocb_channels =
9821 tgt_res_cfg->num_ocb_channels;
9822 resource_cfg->num_ocb_schedules =
9823 tgt_res_cfg->num_ocb_schedules;
9824
9825}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309826#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309827/**
9828 * send_init_cmd_tlv() - wmi init command
9829 * @wmi_handle: pointer to wmi handle
9830 * @res_cfg: resource config
9831 * @num_mem_chunks: no of mem chunck
9832 * @mem_chunk: pointer to mem chunck structure
9833 *
9834 * This function sends IE information to firmware
9835 *
Govind Singhb53420c2016-03-09 14:32:57 +05309836 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309837 *
9838 */
Govind Singhb53420c2016-03-09 14:32:57 +05309839QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309840 wmi_resource_config *tgt_res_cfg,
9841 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
9842 bool action)
9843{
9844 wmi_buf_t buf;
9845 wmi_init_cmd_fixed_param *cmd;
9846 wmi_abi_version my_vers;
9847 int num_whitelist;
9848 uint8_t *buf_ptr;
9849 wmi_resource_config *resource_cfg;
9850 wlan_host_memory_chunk *host_mem_chunks;
9851 uint32_t mem_chunk_len = 0;
9852 uint16_t idx;
9853 int len;
9854 int ret;
9855
9856 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
9857 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
9858 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
9859 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309860 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
9861 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309862 }
9863
9864 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9865 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
9866 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
9867
9868 host_mem_chunks = (wlan_host_memory_chunk *)
9869 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
9870 + WMI_TLV_HDR_SIZE);
9871
9872 WMITLV_SET_HDR(&cmd->tlv_header,
9873 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
9874 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
9875
Govind Singhb53420c2016-03-09 14:32:57 +05309876 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +05309877 WMITLV_SET_HDR(&resource_cfg->tlv_header,
9878 WMITLV_TAG_STRUC_wmi_resource_config,
9879 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
9880
9881 for (idx = 0; idx < num_mem_chunks; ++idx) {
9882 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
9883 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
9884 WMITLV_GET_STRUCT_TLVLEN
9885 (wlan_host_memory_chunk));
9886 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
9887 host_mem_chunks[idx].size = mem_chunks[idx].len;
9888 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309889 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +05309890 idx, host_mem_chunks[idx].size,
9891 host_mem_chunks[idx].ptr);
9892 }
9893 cmd->num_host_mem_chunks = num_mem_chunks;
9894 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
9895 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
9896 WMITLV_TAG_ARRAY_STRUC,
9897 (sizeof(wlan_host_memory_chunk) *
9898 num_mem_chunks));
9899
9900 num_whitelist = sizeof(version_whitelist) /
9901 sizeof(wmi_whitelist_version_info);
9902 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
9903 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
9904 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
9905 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
9906 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
9907 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +05309908#ifdef CONFIG_MCL
9909 /* This needs to be enabled for WIN Lithium after removing dependency
9910 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +05309911 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
9912 &my_vers,
9913 &wmi_handle->fw_abi_version,
9914 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +05309915#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309916 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05309917 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
9918 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
9919 cmd->host_abi_vers.abi_version_ns_0,
9920 cmd->host_abi_vers.abi_version_ns_1,
9921 cmd->host_abi_vers.abi_version_ns_2,
9922 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +05309923#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309924 /* Save version sent from host -
9925 * Will be used to check ready event
9926 */
Govind Singhb53420c2016-03-09 14:32:57 +05309927 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309928 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309929#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309930 if (action) {
9931 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9932 WMI_INIT_CMDID);
9933 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309934 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +05309935 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309936 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309937 }
9938 } else {
9939 wmi_handle->saved_wmi_init_cmd.buf = buf;
9940 wmi_handle->saved_wmi_init_cmd.buf_len = len;
9941 }
9942
Govind Singhb53420c2016-03-09 14:32:57 +05309943 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309944
9945}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309946#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309947/**
9948 * send_saved_init_cmd_tlv() - wmi init command
9949 * @wmi_handle: pointer to wmi handle
9950 *
9951 * This function sends IE information to firmware
9952 *
Govind Singhb53420c2016-03-09 14:32:57 +05309953 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309954 *
9955 */
Govind Singhb53420c2016-03-09 14:32:57 +05309956QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +05309957{
9958 int status;
9959
9960 if (!wmi_handle->saved_wmi_init_cmd.buf ||
9961 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05309962 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
9963 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309964 }
9965 status = wmi_unified_cmd_send(wmi_handle,
9966 wmi_handle->saved_wmi_init_cmd.buf,
9967 wmi_handle->saved_wmi_init_cmd.buf_len,
9968 WMI_INIT_CMDID);
9969 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +05309970 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +05309971 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309972 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309973 }
9974 wmi_handle->saved_wmi_init_cmd.buf = NULL;
9975 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
9976
Govind Singhb53420c2016-03-09 14:32:57 +05309977 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309978}
9979
Govind Singhb53420c2016-03-09 14:32:57 +05309980QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05309981{
9982 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
9983 wmi_service_ready_event_fixed_param *ev;
9984
9985
9986 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
9987
9988 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
9989 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05309990 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309991
Govind Singh87542482016-06-08 19:40:11 +05309992#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309993 /*Save fw version from service ready message */
9994 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05309995 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309996 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309997#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309998 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309999}
10000
10001/**
10002 * wmi_unified_save_fw_version_cmd() - save fw version
10003 * @wmi_handle: pointer to wmi handle
10004 * @res_cfg: resource config
10005 * @num_mem_chunks: no of mem chunck
10006 * @mem_chunk: pointer to mem chunck structure
10007 *
10008 * This function sends IE information to firmware
10009 *
Govind Singhb53420c2016-03-09 14:32:57 +053010010 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010011 *
10012 */
Govind Singhb53420c2016-03-09 14:32:57 +053010013QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053010014 void *evt_buf)
10015{
10016 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
10017 wmi_ready_event_fixed_param *ev = NULL;
10018
10019 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
10020 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053010021#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010022 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
10023 &ev->fw_abi_vers)) {
10024 /*
10025 * Error: Our host version and the given firmware version
10026 * are incompatible.
10027 **/
Govind Singhb53420c2016-03-09 14:32:57 +053010028 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053010029 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
10030 __func__,
10031 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
10032 abi_version_0),
10033 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
10034 abi_version_0),
10035 wmi_handle->final_abi_vers.abi_version_ns_0,
10036 wmi_handle->final_abi_vers.abi_version_ns_1,
10037 wmi_handle->final_abi_vers.abi_version_ns_2,
10038 wmi_handle->final_abi_vers.abi_version_ns_3,
10039 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
10040 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
10041 ev->fw_abi_vers.abi_version_ns_0,
10042 ev->fw_abi_vers.abi_version_ns_1,
10043 ev->fw_abi_vers.abi_version_ns_2,
10044 ev->fw_abi_vers.abi_version_ns_3);
10045
Govind Singhb53420c2016-03-09 14:32:57 +053010046 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010047 }
Govind Singhb53420c2016-03-09 14:32:57 +053010048 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010049 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053010050 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010051 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010052#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010053
Govind Singhb53420c2016-03-09 14:32:57 +053010054 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010055}
Govind Singha4836fd2016-03-07 16:45:38 +053010056
10057/**
10058 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
10059 * @wmi_handle: wmi handle
10060 * @custom_addr: base mac address
10061 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010062 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053010063 */
Govind Singhb53420c2016-03-09 14:32:57 +053010064QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010065 uint8_t *custom_addr)
10066{
10067 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
10068 wmi_buf_t buf;
10069 int err;
10070
10071 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10072 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010073 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010074 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010075 }
10076
10077 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010078 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053010079
10080 WMITLV_SET_HDR(&cmd->tlv_header,
10081 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
10082 WMITLV_GET_STRUCT_TLVLEN
10083 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
10084 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -070010085 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010086 err = wmi_unified_cmd_send(wmi_handle, buf,
10087 sizeof(*cmd),
10088 WMI_PDEV_SET_BASE_MACADDR_CMDID);
10089 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053010090 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053010091 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010092 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010093 }
10094
10095 return 0;
10096}
10097
10098/**
10099 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
10100 * @handle: wmi handle
10101 * @event: Event received from FW
10102 * @len: Length of the event
10103 *
10104 * Enables the low frequency events and disables the high frequency
10105 * events. Bit 17 indicates if the event if low/high frequency.
10106 * 1 - high frequency, 0 - low frequency
10107 *
10108 * Return: 0 on successfully enabling/disabling the events
10109 */
Govind Singhb53420c2016-03-09 14:32:57 +053010110QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010111 uint8_t *event,
10112 uint32_t len)
10113{
10114 uint32_t num_of_diag_events_logs;
10115 wmi_diag_event_log_config_fixed_param *cmd;
10116 wmi_buf_t buf;
10117 uint8_t *buf_ptr;
10118 uint32_t *cmd_args, *evt_args;
10119 uint32_t buf_len, i;
10120
10121 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
10122 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
10123
Govind Singhb53420c2016-03-09 14:32:57 +053010124 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053010125
10126 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
10127 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010128 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053010129 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010130 }
10131 wmi_event = param_buf->fixed_param;
10132 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
10133 evt_args = param_buf->diag_events_logs_list;
10134 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053010135 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010136 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053010137 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010138 }
10139
Govind Singhb53420c2016-03-09 14:32:57 +053010140 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010141 __func__, num_of_diag_events_logs);
10142
10143 /* Free any previous allocation */
10144 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053010145 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010146
10147 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053010148 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053010149 sizeof(uint32_t));
10150 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010151 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010152 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010153 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010154 }
10155 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
10156
10157 /* Prepare the send buffer */
10158 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10159 (num_of_diag_events_logs * sizeof(uint32_t));
10160
10161 buf = wmi_buf_alloc(wmi_handle, buf_len);
10162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010163 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10164 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010165 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010166 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010167 }
10168
10169 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10170 buf_ptr = (uint8_t *) cmd;
10171
10172 WMITLV_SET_HDR(&cmd->tlv_header,
10173 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10174 WMITLV_GET_STRUCT_TLVLEN(
10175 wmi_diag_event_log_config_fixed_param));
10176
10177 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
10178
10179 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10180
10181 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10182 (num_of_diag_events_logs * sizeof(uint32_t)));
10183
10184 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10185
10186 /* Populate the events */
10187 for (i = 0; i < num_of_diag_events_logs; i++) {
10188 /* Low freq (0) - Enable (1) the event
10189 * High freq (1) - Disable (0) the event
10190 */
10191 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
10192 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
10193 /* Set the event ID */
10194 WMI_DIAG_ID_SET(cmd_args[i],
10195 WMI_DIAG_ID_GET(evt_args[i]));
10196 /* Set the type */
10197 WMI_DIAG_TYPE_SET(cmd_args[i],
10198 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053010199 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053010200 wmi_handle->events_logs_list[i] = evt_args[i];
10201 }
10202
10203 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
10204 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010205 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010206 __func__);
10207 wmi_buf_free(buf);
10208 /* Not clearing events_logs_list, though wmi cmd failed.
10209 * Host can still have this list
10210 */
Govind Singh67922e82016-04-01 16:48:57 +053010211 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010212 }
10213
10214 return 0;
10215}
10216
10217/**
10218 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
10219 * @wmi_handle: wmi handle
10220 * @start_log: Start logging related parameters
10221 *
10222 * Send the command to the FW based on which specific logging of diag
10223 * event/log id can be started/stopped
10224 *
10225 * Return: None
10226 */
Govind Singhb53420c2016-03-09 14:32:57 +053010227QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010228 struct wmi_wifi_start_log *start_log)
10229{
10230 wmi_diag_event_log_config_fixed_param *cmd;
10231 wmi_buf_t buf;
10232 uint8_t *buf_ptr;
10233 uint32_t len, count, log_level, i;
10234 uint32_t *cmd_args;
10235 uint32_t total_len;
10236 count = 0;
10237
10238 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010239 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053010240 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010241 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010242 }
10243 /* total_len stores the number of events where BITS 17 and 18 are set.
10244 * i.e., events of high frequency (17) and for extended debugging (18)
10245 */
10246 total_len = 0;
10247 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10248 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
10249 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
10250 total_len++;
10251 }
10252
10253 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10254 (total_len * sizeof(uint32_t));
10255
10256 buf = wmi_buf_alloc(wmi_handle, len);
10257 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010258 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010259 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010260 }
10261 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10262 buf_ptr = (uint8_t *) cmd;
10263
10264 WMITLV_SET_HDR(&cmd->tlv_header,
10265 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10266 WMITLV_GET_STRUCT_TLVLEN(
10267 wmi_diag_event_log_config_fixed_param));
10268
10269 cmd->num_of_diag_events_logs = total_len;
10270
10271 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10272
10273 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10274 (total_len * sizeof(uint32_t)));
10275
10276 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10277
Govind Singh224a7312016-06-21 14:33:26 +053010278 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053010279 log_level = 1;
10280 else
10281 log_level = 0;
10282
Govind Singhb53420c2016-03-09 14:32:57 +053010283 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053010284 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10285 uint32_t val = wmi_handle->events_logs_list[i];
10286 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
10287 (WMI_DIAG_EXT_FEATURE_GET(val))) {
10288
10289 WMI_DIAG_ID_SET(cmd_args[count],
10290 WMI_DIAG_ID_GET(val));
10291 WMI_DIAG_TYPE_SET(cmd_args[count],
10292 WMI_DIAG_TYPE_GET(val));
10293 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
10294 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053010295 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053010296 count++;
10297 }
10298 }
10299
10300 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10301 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010302 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010303 __func__);
10304 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010305 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010306 }
10307
Govind Singhb53420c2016-03-09 14:32:57 +053010308 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010309}
10310
10311/**
10312 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
10313 * @wmi_handle: WMI handle
10314 *
10315 * This function is used to send the flush command to the FW,
10316 * that will flush the fw logs that are residue in the FW
10317 *
10318 * Return: None
10319 */
Govind Singhb53420c2016-03-09 14:32:57 +053010320QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053010321{
10322 wmi_debug_mesg_flush_fixed_param *cmd;
10323 wmi_buf_t buf;
10324 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053010325 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010326
10327 buf = wmi_buf_alloc(wmi_handle, len);
10328 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010329 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010330 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010331 }
10332
10333 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
10334 WMITLV_SET_HDR(&cmd->tlv_header,
10335 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
10336 WMITLV_GET_STRUCT_TLVLEN(
10337 wmi_debug_mesg_flush_fixed_param));
10338 cmd->reserved0 = 0;
10339
10340 ret = wmi_unified_cmd_send(wmi_handle,
10341 buf,
10342 len,
10343 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010344 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010345 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053010346 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010347 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010348 }
Govind Singhb53420c2016-03-09 14:32:57 +053010349 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053010350
Govind Singh67922e82016-04-01 16:48:57 +053010351 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010352}
10353
10354/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010355 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010356 * @wmi_handle: wmi handle
10357 * @msg: PCL structure containing the PCL and the number of channels
10358 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010359 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053010360 * firmware. The DBS Manager is the consumer of this information in the WLAN
10361 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
10362 * to migrate to a new channel without host driver involvement. An example of
10363 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
10364 * manage the channel selection without firmware involvement.
10365 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010366 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
10367 * channel list. The weights corresponds to the channels sent in
10368 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
10369 * weightage compared to the non PCL channels.
10370 *
Govind Singha4836fd2016-03-07 16:45:38 +053010371 * Return: Success if the cmd is sent successfully to the firmware
10372 */
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010373QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
10374 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053010375{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010376 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010377 wmi_buf_t buf;
10378 uint8_t *buf_ptr;
10379 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010380 uint32_t chan_len;
10381
10382 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053010383
10384 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010385 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053010386
10387 buf = wmi_buf_alloc(wmi_handle, len);
10388 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010389 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10390 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010391 }
10392
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010393 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010394 buf_ptr = (uint8_t *) cmd;
10395 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010396 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
10397 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053010398
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010399 cmd->pdev_id = WMI_PDEV_ID_SOC;
10400 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053010401 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010402
10403 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053010404 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010405 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053010406 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010407 for (i = 0; i < chan_len ; i++) {
10408 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053010409 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010410 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010411 }
10412 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010413 WMI_PDEV_SET_PCL_CMDID)) {
10414 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010415 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010416 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010417 }
Govind Singhb53420c2016-03-09 14:32:57 +053010418 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010419}
10420
10421/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010422 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010423 * @wmi_handle: wmi handle
10424 * @msg: Structure containing the following parameters
10425 *
10426 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
10427 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
10428 *
10429 * Provides notification to the WLAN firmware that host driver is requesting a
10430 * HardWare (HW) Mode change. This command is needed to support iHelium in the
10431 * configurations that include the Dual Band Simultaneous (DBS) feature.
10432 *
10433 * Return: Success if the cmd is sent successfully to the firmware
10434 */
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010435QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010436 uint32_t hw_mode_index)
10437{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010438 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010439 wmi_buf_t buf;
10440 uint32_t len;
10441
10442 len = sizeof(*cmd);
10443
10444 buf = wmi_buf_alloc(wmi_handle, len);
10445 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010446 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10447 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010448 }
10449
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010450 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010451 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010452 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
10453 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
10454
10455 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010456 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053010457 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053010458
10459 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010460 WMI_PDEV_SET_HW_MODE_CMDID)) {
10461 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010462 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010463 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010464 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010465 }
10466
Govind Singhb53420c2016-03-09 14:32:57 +053010467 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010468}
10469
10470/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010471 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010472 * @wmi_handle: wmi handle
10473 * @msg: Dual MAC config parameters
10474 *
10475 * Configures WLAN firmware with the dual MAC features
10476 *
Govind Singhb53420c2016-03-09 14:32:57 +053010477 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053010478 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010479static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010480QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010481 struct wmi_dual_mac_config *msg)
10482{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010483 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010484 wmi_buf_t buf;
10485 uint32_t len;
10486
10487 len = sizeof(*cmd);
10488
10489 buf = wmi_buf_alloc(wmi_handle, len);
10490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010491 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10492 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010493 }
10494
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010495 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010496 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010497 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053010498 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010499 wmi_pdev_set_mac_config_cmd_fixed_param));
10500
10501 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010502 cmd->concurrent_scan_config_bits = msg->scan_config;
10503 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053010504 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053010505 __func__, msg->scan_config, msg->fw_mode_config);
10506
10507 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010508 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
10509 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010510 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010511 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010512 }
Govind Singhb53420c2016-03-09 14:32:57 +053010513 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010514}
10515
10516/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010517 * fill_arp_offload_params_tlv() - Fill ARP offload data
10518 * @wmi_handle: wmi handle
10519 * @offload_req: offload request
10520 * @buf_ptr: buffer pointer
10521 *
10522 * To fill ARP offload data to firmware
10523 * when target goes to wow mode.
10524 *
10525 * Return: None
10526 */
10527static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
10528 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10529{
10530
10531 int i;
10532 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
10533 bool enable_or_disable = offload_req->enableOrDisable;
10534
10535 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10536 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
10537 *buf_ptr += WMI_TLV_HDR_SIZE;
10538 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
10539 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
10540 WMITLV_SET_HDR(&arp_tuple->tlv_header,
10541 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
10542 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
10543
10544 /* Fill data for ARP and NS in the first tupple for LA */
10545 if ((enable_or_disable & WMI_OFFLOAD_ENABLE) && (i == 0)) {
10546 /* Copy the target ip addr and flags */
10547 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
10548 qdf_mem_copy(&arp_tuple->target_ipaddr,
10549 offload_req->params.hostIpv4Addr,
10550 WMI_IPV4_ADDR_LEN);
10551 WMI_LOGD("ARPOffload IP4 address: %pI4",
10552 offload_req->params.hostIpv4Addr);
10553 }
10554 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
10555 }
10556}
10557
10558#ifdef WLAN_NS_OFFLOAD
10559/**
10560 * fill_ns_offload_params_tlv() - Fill NS offload data
10561 * @wmi|_handle: wmi handle
10562 * @offload_req: offload request
10563 * @buf_ptr: buffer pointer
10564 *
10565 * To fill NS offload data to firmware
10566 * when target goes to wow mode.
10567 *
10568 * Return: None
10569 */
10570static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10571 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10572{
10573
10574 int i;
10575 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10576 struct ns_offload_req_params ns_req;
10577
10578 ns_req = offload_req->nsOffloadInfo;
10579 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10580 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10581 *buf_ptr += WMI_TLV_HDR_SIZE;
10582 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
10583 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10584 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10585 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10586 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
10587
10588 /*
10589 * Fill data only for NS offload in the first ARP tuple for LA
10590 */
10591 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10592 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10593 /* Copy the target/solicitation/remote ip addr */
10594 if (ns_req.targetIPv6AddrValid[i])
10595 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10596 &ns_req.targetIPv6Addr[i],
10597 sizeof(WMI_IPV6_ADDR));
10598 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10599 &ns_req.selfIPv6Addr[i],
10600 sizeof(WMI_IPV6_ADDR));
10601 if (ns_req.target_ipv6_addr_ac_type[i]) {
10602 ns_tuple->flags |=
10603 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10604 }
10605 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10606 i, &ns_req.selfIPv6Addr[i],
10607 &ns_req.targetIPv6Addr[i]);
10608
10609 /* target MAC is optional, check if it is valid,
10610 * if this is not valid, the target will use the known
10611 * local MAC address rather than the tuple
10612 */
10613 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10614 ns_req.self_macaddr.bytes,
10615 &ns_tuple->target_mac);
10616 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10617 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10618 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10619 }
10620 }
10621 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10622 }
10623}
10624
10625
10626/**
10627 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
10628 * @wmi: wmi handle
10629 * @offload_req: offload request
10630 * @buf_ptr: buffer pointer
10631 *
10632 * To fill extended NS offload extended data to firmware
10633 * when target goes to wow mode.
10634 *
10635 * Return: None
10636 */
10637static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10638 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10639{
10640 int i;
10641 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10642 uint32_t count, num_ns_ext_tuples;
10643 struct ns_offload_req_params ns_req;
10644
10645 ns_req = offload_req->nsOffloadInfo;
10646 count = offload_req->num_ns_offload_count;
10647 num_ns_ext_tuples = offload_req->num_ns_offload_count -
10648 WMI_MAX_NS_OFFLOADS;
10649
10650 /* Populate extended NS offload tuples */
10651 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10652 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10653 *buf_ptr += WMI_TLV_HDR_SIZE;
10654 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
10655 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10656 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10657 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10658 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
10659
10660 /*
10661 * Fill data only for NS offload in the first ARP tuple for LA
10662 */
10663 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10664 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10665 /* Copy the target/solicitation/remote ip addr */
10666 if (ns_req.targetIPv6AddrValid[i])
10667 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10668 &ns_req.targetIPv6Addr[i],
10669 sizeof(WMI_IPV6_ADDR));
10670 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10671 &ns_req.selfIPv6Addr[i],
10672 sizeof(WMI_IPV6_ADDR));
10673 if (ns_req.target_ipv6_addr_ac_type[i]) {
10674 ns_tuple->flags |=
10675 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10676 }
10677 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10678 i, &ns_req.selfIPv6Addr[i],
10679 &ns_req.targetIPv6Addr[i]);
10680
10681 /* target MAC is optional, check if it is valid,
10682 * if this is not valid, the target will use the
10683 * known local MAC address rather than the tuple
10684 */
10685 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10686 ns_req.self_macaddr.bytes,
10687 &ns_tuple->target_mac);
10688 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10689 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10690 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10691 }
10692 }
10693 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10694 }
10695}
10696#else
10697static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10698 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10699{
10700 return;
10701}
10702
10703static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10704 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10705{
10706 return;
10707}
10708#endif
10709
10710/**
Govind Singha4836fd2016-03-07 16:45:38 +053010711 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
10712 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010713 * @arp_offload_req: arp offload request
10714 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053010715 * @arp_only: flag
10716 *
10717 * To configure ARP NS off load data to firmware
10718 * when target goes to wow mode.
10719 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010720 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053010721 */
Govind Singhb53420c2016-03-09 14:32:57 +053010722QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010723 struct host_offload_req_param *arp_offload_req,
10724 struct host_offload_req_param *ns_offload_req,
10725 bool arp_only,
Govind Singha4836fd2016-03-07 16:45:38 +053010726 uint8_t vdev_id)
10727{
Govind Singha4836fd2016-03-07 16:45:38 +053010728 int32_t res;
10729 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010730 A_UINT8 *buf_ptr;
10731 wmi_buf_t buf;
10732 int32_t len;
10733 uint32_t count = 0, num_ns_ext_tuples = 0;
10734
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010735 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053010736
Govind Singha4836fd2016-03-07 16:45:38 +053010737 /*
10738 * TLV place holder size for array of NS tuples
10739 * TLV place holder size for array of ARP tuples
10740 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010741 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
10742 WMI_TLV_HDR_SIZE +
10743 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
10744 WMI_TLV_HDR_SIZE +
10745 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010746
10747 /*
10748 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
10749 * extra length for extended NS offload tuples which follows ARP offload
10750 * tuples. Host needs to fill this structure in following format:
10751 * 2 NS ofload tuples
10752 * 2 ARP offload tuples
10753 * N numbers of extended NS offload tuples if HDD has given more than
10754 * 2 NS offload addresses
10755 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010756 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053010757 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010758 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
10759 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010760 }
10761
10762 buf = wmi_buf_alloc(wmi_handle, len);
10763 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010764 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053010765 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010766 }
10767
10768 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
10769 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
10770 WMITLV_SET_HDR(&cmd->tlv_header,
10771 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
10772 WMITLV_GET_STRUCT_TLVLEN
10773 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
10774 cmd->flags = 0;
10775 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010776 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053010777
Govind Singhb53420c2016-03-09 14:32:57 +053010778 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053010779
Govind Singha4836fd2016-03-07 16:45:38 +053010780 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010781 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
10782 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
10783 if (num_ns_ext_tuples)
10784 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053010785
10786 res = wmi_unified_cmd_send(wmi_handle, buf, len,
10787 WMI_SET_ARP_NS_OFFLOAD_CMDID);
10788 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053010789 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053010790 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010791 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010792 }
10793
Govind Singhb53420c2016-03-09 14:32:57 +053010794 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010795}
10796
10797/**
10798 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
10799 * @wmi_handle: wmi handle
10800 * @request: SSID hotlist set request
10801 *
Govind Singhb53420c2016-03-09 14:32:57 +053010802 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053010803 */
Govind Singhb53420c2016-03-09 14:32:57 +053010804QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053010805send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
10806 struct ssid_hotlist_request_params *request)
10807{
10808 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
10809 wmi_buf_t wmi_buf;
10810 uint32_t len;
10811 uint32_t array_size;
10812 uint8_t *buf_ptr;
10813
10814 /* length of fixed portion */
10815 len = sizeof(*cmd);
10816
10817 /* length of variable portion */
10818 array_size =
10819 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
10820 len += WMI_TLV_HDR_SIZE + array_size;
10821
10822 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10823 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010824 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10825 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010826 }
10827
10828 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10829 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
10830 buf_ptr;
10831 WMITLV_SET_HDR
10832 (&cmd->tlv_header,
10833 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
10834 WMITLV_GET_STRUCT_TLVLEN
10835 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
10836
10837 cmd->request_id = request->request_id;
10838 cmd->requestor_id = 0;
10839 cmd->vdev_id = request->session_id;
10840 cmd->table_id = 0;
10841 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
10842 cmd->total_entries = request->ssid_count;
10843 cmd->num_entries_in_page = request->ssid_count;
10844 cmd->first_entry_index = 0;
10845
10846 buf_ptr += sizeof(*cmd);
10847 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
10848
10849 if (request->ssid_count) {
10850 wmi_extscan_hotlist_ssid_entry *entry;
10851 int i;
10852
10853 buf_ptr += WMI_TLV_HDR_SIZE;
10854 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
10855 for (i = 0; i < request->ssid_count; i++) {
10856 WMITLV_SET_HDR
10857 (entry,
10858 WMITLV_TAG_ARRAY_STRUC,
10859 WMITLV_GET_STRUCT_TLVLEN
10860 (wmi_extscan_hotlist_ssid_entry));
10861 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053010862 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053010863 request->ssids[i].ssid.mac_ssid,
10864 request->ssids[i].ssid.length);
10865 entry->band = request->ssids[i].band;
10866 entry->min_rssi = request->ssids[i].rssi_low;
10867 entry->max_rssi = request->ssids[i].rssi_high;
10868 entry++;
10869 }
10870 cmd->mode = WMI_EXTSCAN_MODE_START;
10871 } else {
10872 cmd->mode = WMI_EXTSCAN_MODE_STOP;
10873 }
10874
10875 if (wmi_unified_cmd_send
10876 (wmi_handle, wmi_buf, len,
10877 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010878 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053010879 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010880 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010881 }
10882
Govind Singhb53420c2016-03-09 14:32:57 +053010883 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010884}
10885
10886/**
10887 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
10888 * @wmi_handle: wmi handle
10889 * @vdev_id: vdev id
10890 *
10891 * This function sends roam synch complete event to fw.
10892 *
10893 * Return: CDF STATUS
10894 */
Govind Singhb53420c2016-03-09 14:32:57 +053010895QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010896 uint8_t vdev_id)
10897{
10898 wmi_roam_synch_complete_fixed_param *cmd;
10899 wmi_buf_t wmi_buf;
10900 uint8_t *buf_ptr;
10901 uint16_t len;
10902 len = sizeof(wmi_roam_synch_complete_fixed_param);
10903
10904 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10905 if (!wmi_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 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
10910 buf_ptr = (uint8_t *) cmd;
10911 WMITLV_SET_HDR(&cmd->tlv_header,
10912 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
10913 WMITLV_GET_STRUCT_TLVLEN
10914 (wmi_roam_synch_complete_fixed_param));
10915 cmd->vdev_id = vdev_id;
10916 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10917 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010918 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053010919 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010920 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010921 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010922 }
10923
Govind Singhb53420c2016-03-09 14:32:57 +053010924 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010925}
10926
10927/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053010928 * send_fw_test_cmd_tlv() - send fw test command to fw.
10929 * @wmi_handle: wmi handle
10930 * @wmi_fwtest: fw test command
10931 *
10932 * This function sends fw test command to fw.
10933 *
10934 * Return: CDF STATUS
10935 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010936static
Anurag Chouhan459e0152016-07-22 20:19:54 +053010937QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
10938 struct set_fwtest_params *wmi_fwtest)
10939{
10940 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10941 wmi_buf_t wmi_buf;
10942 uint16_t len;
10943
10944 len = sizeof(*cmd);
10945
10946 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10947 if (!wmi_buf) {
10948 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10949 return QDF_STATUS_E_NOMEM;
10950 }
10951
10952 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10953 WMITLV_SET_HDR(&cmd->tlv_header,
10954 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10955 WMITLV_GET_STRUCT_TLVLEN(
10956 wmi_fwtest_set_param_cmd_fixed_param));
10957 cmd->param_id = wmi_fwtest->arg;
10958 cmd->param_value = wmi_fwtest->value;
10959
10960 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10961 WMI_FWTEST_CMDID)) {
10962 WMI_LOGP("%s: failed to send fw test command", __func__);
10963 qdf_nbuf_free(wmi_buf);
10964 return QDF_STATUS_E_FAILURE;
10965 }
10966
10967 return QDF_STATUS_SUCCESS;
10968}
10969
10970/**
Govind Singha4836fd2016-03-07 16:45:38 +053010971 * send_unit_test_cmd_tlv() - send unit test command to fw.
10972 * @wmi_handle: wmi handle
10973 * @wmi_utest: unit test command
10974 *
10975 * This function send unit test command to fw.
10976 *
10977 * Return: CDF STATUS
10978 */
Govind Singhb53420c2016-03-09 14:32:57 +053010979QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010980 struct wmi_unit_test_cmd *wmi_utest)
10981{
10982 wmi_unit_test_cmd_fixed_param *cmd;
10983 wmi_buf_t wmi_buf;
10984 uint8_t *buf_ptr;
10985 int i;
10986 uint16_t len, args_tlv_len;
10987 A_UINT32 *unit_test_cmd_args;
10988
10989 args_tlv_len =
10990 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
10991 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
10992
10993 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10994 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010995 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10996 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010997 }
10998
10999 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
11000 buf_ptr = (uint8_t *) cmd;
11001 WMITLV_SET_HDR(&cmd->tlv_header,
11002 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
11003 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
11004 cmd->vdev_id = wmi_utest->vdev_id;
11005 cmd->module_id = wmi_utest->module_id;
11006 cmd->num_args = wmi_utest->num_args;
11007 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
11008 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11009 (wmi_utest->num_args * sizeof(uint32_t)));
11010 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053011011 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053011012 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
11013 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053011014 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011015 }
11016 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
11017 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011018 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011019 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011020 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011021 }
11022
Govind Singhb53420c2016-03-09 14:32:57 +053011023 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011024}
11025
11026/**
11027 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
11028 * @wmi_handle: wma handle
11029 * @roaminvoke: roam invoke command
11030 *
11031 * Send roam invoke command to fw for fastreassoc.
11032 *
11033 * Return: CDF STATUS
11034 */
Govind Singhb53420c2016-03-09 14:32:57 +053011035QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011036 struct wmi_roam_invoke_cmd *roaminvoke,
11037 uint32_t ch_hz)
11038{
11039 wmi_roam_invoke_cmd_fixed_param *cmd;
11040 wmi_buf_t wmi_buf;
11041 u_int8_t *buf_ptr;
11042 u_int16_t len, args_tlv_len;
11043 A_UINT32 *channel_list;
11044 wmi_mac_addr *bssid_list;
11045
11046 /* Host sends only one channel and one bssid */
11047 args_tlv_len = 2 * WMI_TLV_HDR_SIZE + sizeof(A_UINT32) +
11048 sizeof(wmi_mac_addr);
11049 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
11050 wmi_buf = wmi_buf_alloc(wmi_handle, len);
11051 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011052 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
11053 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011054 }
11055
11056 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
11057 buf_ptr = (u_int8_t *) cmd;
11058 WMITLV_SET_HDR(&cmd->tlv_header,
11059 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
11060 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
11061 cmd->vdev_id = roaminvoke->vdev_id;
11062 cmd->flags = 0;
11063 cmd->roam_scan_mode = 0;
11064 cmd->roam_ap_sel_mode = 0;
11065 cmd->roam_delay = 0;
11066 cmd->num_chan = 1;
11067 cmd->num_bssid = 1;
11068 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
11069 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11070 (sizeof(u_int32_t)));
11071 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
11072 *channel_list = ch_hz;
11073 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
11074 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
11075 (sizeof(wmi_mac_addr)));
11076 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
11077 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
11078 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
11079 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011080 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053011081 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011082 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011083 }
11084
Govind Singhb53420c2016-03-09 14:32:57 +053011085 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011086}
11087
11088/**
11089 * send_roam_scan_offload_cmd_tlv() - set roam offload command
11090 * @wmi_handle: wmi handle
11091 * @command: command
11092 * @vdev_id: vdev id
11093 *
11094 * This function set roam offload command to fw.
11095 *
11096 * Return: CDF status
11097 */
Govind Singhb53420c2016-03-09 14:32:57 +053011098QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011099 uint32_t command, uint32_t vdev_id)
11100{
Govind Singh67922e82016-04-01 16:48:57 +053011101 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011102 wmi_roam_scan_cmd_fixed_param *cmd_fp;
11103 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053011104 int len;
11105 uint8_t *buf_ptr;
11106
11107 len = sizeof(wmi_roam_scan_cmd_fixed_param);
11108 buf = wmi_buf_alloc(wmi_handle, len);
11109 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011110 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11111 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011112 }
11113
11114 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11115
11116 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
11117 WMITLV_SET_HDR(&cmd_fp->tlv_header,
11118 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
11119 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
11120 cmd_fp->vdev_id = vdev_id;
11121 cmd_fp->command_arg = command;
11122
11123 status = wmi_unified_cmd_send(wmi_handle, buf,
11124 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053011125 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011126 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011127 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011128 goto error;
11129 }
11130
Govind Singhb53420c2016-03-09 14:32:57 +053011131 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
11132 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011133
11134error:
11135 wmi_buf_free(buf);
11136
Govind Singh67922e82016-04-01 16:48:57 +053011137 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011138}
11139
11140/**
11141 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
11142 * @wmi_handle: wmi handle
11143 * @ap_profile_p: ap profile
11144 * @vdev_id: vdev id
11145 *
11146 * Send WMI_ROAM_AP_PROFILE to firmware
11147 *
11148 * Return: CDF status
11149 */
Govind Singhb53420c2016-03-09 14:32:57 +053011150QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011151 wmi_ap_profile *ap_profile_p,
11152 uint32_t vdev_id)
11153{
Govind Singha4836fd2016-03-07 16:45:38 +053011154 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011155 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011156 int len;
11157 uint8_t *buf_ptr;
11158 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
11159
11160 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
11161
11162 buf = wmi_buf_alloc(wmi_handle, len);
11163 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011164 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11165 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011166 }
11167
11168 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11169 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
11170 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
11171 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
11172 WMITLV_GET_STRUCT_TLVLEN
11173 (wmi_roam_ap_profile_fixed_param));
11174 /* fill in threshold values */
11175 roam_ap_profile_fp->vdev_id = vdev_id;
11176 roam_ap_profile_fp->id = 0;
11177 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
11178
Govind Singhb53420c2016-03-09 14:32:57 +053011179 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053011180 WMITLV_SET_HDR(buf_ptr,
11181 WMITLV_TAG_STRUC_wmi_ap_profile,
11182 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
11183 status = wmi_unified_cmd_send(wmi_handle, buf,
11184 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053011185 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011186 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011187 status);
Govind Singh67922e82016-04-01 16:48:57 +053011188 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011189 }
11190
Govind Singhb53420c2016-03-09 14:32:57 +053011191 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053011192
Govind Singh67922e82016-04-01 16:48:57 +053011193 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011194}
11195
11196/**
11197 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
11198 * @wmi_handle: wmi handle
11199 * @scan_period: scan period
11200 * @scan_age: scan age
11201 * @vdev_id: vdev id
11202 *
11203 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
11204 *
11205 * Return: CDF status
11206 */
Govind Singhb53420c2016-03-09 14:32:57 +053011207QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011208 uint32_t scan_period,
11209 uint32_t scan_age,
11210 uint32_t vdev_id)
11211{
Govind Singh67922e82016-04-01 16:48:57 +053011212 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011213 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053011214 int len;
11215 uint8_t *buf_ptr;
11216 wmi_roam_scan_period_fixed_param *scan_period_fp;
11217
11218 /* Send scan period values */
11219 len = sizeof(wmi_roam_scan_period_fixed_param);
11220 buf = wmi_buf_alloc(wmi_handle, len);
11221 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011222 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11223 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011224 }
11225
11226 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11227 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
11228 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
11229 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
11230 WMITLV_GET_STRUCT_TLVLEN
11231 (wmi_roam_scan_period_fixed_param));
11232 /* fill in scan period values */
11233 scan_period_fp->vdev_id = vdev_id;
11234 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
11235 scan_period_fp->roam_scan_age = scan_age;
11236
11237 status = wmi_unified_cmd_send(wmi_handle, buf,
11238 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053011239 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011240 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011241 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011242 goto error;
11243 }
11244
Govind Singhb53420c2016-03-09 14:32:57 +053011245 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011246 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053011247 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011248error:
11249 wmi_buf_free(buf);
11250
Govind Singh67922e82016-04-01 16:48:57 +053011251 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011252}
11253
11254/**
11255 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
11256 * @wmi_handle: wmi handle
11257 * @chan_count: channel count
11258 * @chan_list: channel list
11259 * @list_type: list type
11260 * @vdev_id: vdev id
11261 *
11262 * Set roam offload channel list.
11263 *
11264 * Return: CDF status
11265 */
Govind Singhb53420c2016-03-09 14:32:57 +053011266QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011267 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070011268 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053011269 uint8_t list_type, uint32_t vdev_id)
11270{
Govind Singha4836fd2016-03-07 16:45:38 +053011271 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011272 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011273 int len, list_tlv_len;
11274 int i;
11275 uint8_t *buf_ptr;
11276 wmi_roam_chan_list_fixed_param *chan_list_fp;
11277 A_UINT32 *roam_chan_list_array;
11278
11279 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053011280 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053011281 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053011282 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053011283 }
11284 /* Channel list is a table of 2 TLV's */
11285 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
11286 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
11287 buf = wmi_buf_alloc(wmi_handle, len);
11288 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011289 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11290 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011291 }
11292
11293 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11294 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
11295 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
11296 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
11297 WMITLV_GET_STRUCT_TLVLEN
11298 (wmi_roam_chan_list_fixed_param));
11299 chan_list_fp->vdev_id = vdev_id;
11300 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053011301 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053011302 /* external app is controlling channel list */
11303 chan_list_fp->chan_list_type =
11304 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
11305 } else {
11306 /* umac supplied occupied channel list in LFR */
11307 chan_list_fp->chan_list_type =
11308 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
11309 }
11310
11311 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
11312 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11313 (chan_list_fp->num_chan * sizeof(uint32_t)));
11314 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053011315 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053011316 for (i = 0; ((i < chan_list_fp->num_chan) &&
11317 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
11318 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053011319 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011320 }
11321
11322 status = wmi_unified_cmd_send(wmi_handle, buf,
11323 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053011324 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011325 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011326 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011327 goto error;
11328 }
11329
Govind Singhb53420c2016-03-09 14:32:57 +053011330 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
11331 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011332error:
11333 wmi_buf_free(buf);
11334
Govind Singh67922e82016-04-01 16:48:57 +053011335 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011336}
11337
11338/**
11339 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
11340 * @wmi_handle: wmi handle
11341 * @rssi_change_thresh: RSSI Change threshold
11342 * @bcn_rssi_weight: beacon RSSI weight
11343 * @vdev_id: vdev id
11344 *
11345 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
11346 *
11347 * Return: CDF status
11348 */
Govind Singhb53420c2016-03-09 14:32:57 +053011349QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011350 uint32_t vdev_id,
11351 int32_t rssi_change_thresh,
11352 uint32_t bcn_rssi_weight,
11353 uint32_t hirssi_delay_btw_scans)
11354{
Govind Singha4836fd2016-03-07 16:45:38 +053011355 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011356 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011357 int len;
11358 uint8_t *buf_ptr;
11359 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
11360
11361 /* Send rssi change parameters */
11362 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
11363 buf = wmi_buf_alloc(wmi_handle, len);
11364 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011365 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11366 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011367 }
11368
11369 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11370 rssi_change_fp =
11371 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
11372 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
11373 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
11374 WMITLV_GET_STRUCT_TLVLEN
11375 (wmi_roam_scan_rssi_change_threshold_fixed_param));
11376 /* fill in rssi change threshold (hysteresis) values */
11377 rssi_change_fp->vdev_id = vdev_id;
11378 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
11379 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
11380 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
11381
11382 status = wmi_unified_cmd_send(wmi_handle, buf,
11383 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053011384 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011385 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011386 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011387 goto error;
11388 }
11389
Govind Singhb53420c2016-03-09 14:32:57 +053011390 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053011391 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053011392 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
11393 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011394error:
11395 wmi_buf_free(buf);
11396
Govind Singh67922e82016-04-01 16:48:57 +053011397 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011398}
11399
11400/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
11401 * @wmi_handle: wmi handle.
11402 * @cmd: size of command structure.
11403 * @per_entry_size: per entry size.
11404 *
11405 * This utility function calculates how many hotlist entries can
11406 * fit in one page.
11407 *
11408 * Return: number of entries
11409 */
11410static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
11411 size_t cmd_size,
11412 size_t per_entry_size)
11413{
11414 uint32_t avail_space = 0;
11415 int num_entries = 0;
11416 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
11417
11418 /* Calculate number of hotlist entries that can
11419 * be passed in wma message request.
11420 */
11421 avail_space = max_msg_len - cmd_size;
11422 num_entries = avail_space / per_entry_size;
11423 return num_entries;
11424}
11425
11426/**
11427 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
11428 * @wmi_handle: wmi handle
11429 * @photlist: hotlist command params
11430 * @buf_len: buffer length
11431 *
11432 * This function fills individual elements for hotlist request and
11433 * TLV for bssid entries
11434 *
11435 * Return: CDF Status.
11436 */
Govind Singhb53420c2016-03-09 14:32:57 +053011437QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011438 struct ext_scan_setbssi_hotlist_params *
11439 photlist, int *buf_len)
11440{
11441 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
11442 wmi_extscan_hotlist_entry *dest_hotlist;
11443 struct ap_threshold_params *src_ap = photlist->ap;
11444 wmi_buf_t buf;
11445 uint8_t *buf_ptr;
11446
11447 int j, index = 0;
11448 int cmd_len = 0;
11449 int num_entries;
11450 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080011451 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053011452 int len = sizeof(*cmd);
11453
11454 len += WMI_TLV_HDR_SIZE;
11455 cmd_len = len;
11456
11457 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
11458 cmd_len,
11459 sizeof(*dest_hotlist));
11460 /* setbssid hotlist expects the bssid list
11461 * to be non zero value
11462 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080011463 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080011464 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053011465 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011466 }
11467
11468 /* Split the hot list entry pages and send multiple command
11469 * requests if the buffer reaches the maximum request size
11470 */
11471 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011472 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053011473 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
11474 buf = wmi_buf_alloc(wmi_handle, len);
11475 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011476 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
11477 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011478 }
11479 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11480 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
11481 buf_ptr;
11482 WMITLV_SET_HDR(&cmd->tlv_header,
11483 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
11484 WMITLV_GET_STRUCT_TLVLEN
11485 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
11486
11487 /* Multiple requests are sent until the num_entries_in_page
11488 * matches the total_entries
11489 */
11490 cmd->request_id = photlist->requestId;
11491 cmd->vdev_id = photlist->sessionId;
11492 cmd->total_entries = numap;
11493 cmd->mode = 1;
11494 cmd->num_entries_in_page = min_entries;
11495 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
11496 cmd->first_entry_index = index;
11497
Govind Singhb53420c2016-03-09 14:32:57 +053011498 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011499 __func__, cmd->vdev_id, cmd->total_entries,
11500 cmd->num_entries_in_page,
11501 cmd->lost_ap_scan_count);
11502
11503 buf_ptr += sizeof(*cmd);
11504 WMITLV_SET_HDR(buf_ptr,
11505 WMITLV_TAG_ARRAY_STRUC,
11506 min_entries * sizeof(wmi_extscan_hotlist_entry));
11507 dest_hotlist = (wmi_extscan_hotlist_entry *)
11508 (buf_ptr + WMI_TLV_HDR_SIZE);
11509
11510 /* Populate bssid, channel info and rssi
11511 * for the bssid's that are sent as hotlists.
11512 */
11513 for (j = 0; j < min_entries; j++) {
11514 WMITLV_SET_HDR(dest_hotlist,
11515 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
11516 WMITLV_GET_STRUCT_TLVLEN
11517 (wmi_extscan_hotlist_entry));
11518
11519 dest_hotlist->min_rssi = src_ap->low;
11520 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
11521 &dest_hotlist->bssid);
11522
Govind Singhb53420c2016-03-09 14:32:57 +053011523 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011524 __func__, dest_hotlist->channel,
11525 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053011526 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053011527 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
11528 __func__, dest_hotlist->bssid.mac_addr31to0,
11529 dest_hotlist->bssid.mac_addr47to32);
11530 dest_hotlist++;
11531 src_ap++;
11532 }
11533 buf_ptr += WMI_TLV_HDR_SIZE +
11534 (min_entries * sizeof(wmi_extscan_hotlist_entry));
11535
11536 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11537 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011538 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011539 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011540 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011541 }
11542 index = index + min_entries;
11543 num_entries = numap - min_entries;
11544 len = cmd_len;
11545 }
Govind Singhb53420c2016-03-09 14:32:57 +053011546 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011547}
11548
Govind Singhbca3b1b2016-05-02 17:59:24 +053011549/**
11550 * send_power_dbg_cmd_tlv() - send power debug commands
11551 * @wmi_handle: wmi handle
11552 * @param: wmi power debug parameter
11553 *
11554 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
11555 *
11556 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
11557 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011558static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
11559 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053011560{
11561 wmi_buf_t buf = NULL;
11562 QDF_STATUS status;
11563 int len, args_tlv_len;
11564 uint8_t *buf_ptr;
11565 uint8_t i;
11566 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
11567 uint32_t *cmd_args;
11568
11569 /* Prepare and send power debug cmd parameters */
11570 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
11571 len = sizeof(*cmd) + args_tlv_len;
11572 buf = wmi_buf_alloc(wmi_handle, len);
11573 if (!buf) {
11574 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11575 return QDF_STATUS_E_NOMEM;
11576 }
11577
11578 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11579 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
11580 WMITLV_SET_HDR(&cmd->tlv_header,
11581 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
11582 WMITLV_GET_STRUCT_TLVLEN
11583 (wmi_pdev_wal_power_debug_cmd_fixed_param));
11584
11585 cmd->pdev_id = param->pdev_id;
11586 cmd->module_id = param->module_id;
11587 cmd->num_args = param->num_args;
11588 buf_ptr += sizeof(*cmd);
11589 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11590 (param->num_args * sizeof(uint32_t)));
11591 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11592 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
11593 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
11594 cmd_args[i] = param->args[i];
11595 WMI_LOGI("%d,", param->args[i]);
11596 }
11597
11598 status = wmi_unified_cmd_send(wmi_handle, buf,
11599 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
11600 if (QDF_IS_STATUS_ERROR(status)) {
11601 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
11602 status);
11603 goto error;
11604 }
11605
11606 return QDF_STATUS_SUCCESS;
11607error:
11608 wmi_buf_free(buf);
11609
11610 return status;
11611}
11612
Govind Singhe7f2f342016-05-23 12:12:52 +053011613/**
11614 * init_cmd_send_tlv() - send initialization cmd to fw
11615 * @wmi_handle: wmi handle
11616 * @param tgt_res_cfg: pointer to target resource configuration
11617 * @param num_mem_chunks: Number of memory chunks
11618 * @param mem_chunks: pointer to target memory chunks
11619 *
11620 * Return: QDF_STATUS_SUCCESS for success or error code
11621 */
11622static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
11623 target_resource_config *tgt_res_cfg, uint8_t num_mem_chunks,
11624 struct wmi_host_mem_chunk *mem_chunks)
11625{
11626 wmi_buf_t buf;
11627 wmi_init_cmd_fixed_param *cmd;
11628 wmi_abi_version my_vers;
11629 int num_whitelist;
11630 uint8_t *buf_ptr;
11631 wmi_resource_config *resource_cfg;
11632 wlan_host_memory_chunk *host_mem_chunks;
11633 uint32_t mem_chunk_len = 0;
11634 uint16_t idx;
11635 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053011636 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053011637
11638 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11639 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11640 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11641 if (!buf) {
11642 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11643 return QDF_STATUS_E_FAILURE;
11644 }
11645
11646 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11647 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11648 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11649
11650 host_mem_chunks = (wlan_host_memory_chunk *)
11651 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11652 + WMI_TLV_HDR_SIZE);
11653
11654 WMITLV_SET_HDR(&cmd->tlv_header,
11655 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11656 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11657
11658 wmi_copy_resource_config(resource_cfg, tgt_res_cfg);
11659 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11660 WMITLV_TAG_STRUC_wmi_resource_config,
11661 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11662
11663 for (idx = 0; idx < num_mem_chunks; ++idx) {
11664 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11665 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11666 WMITLV_GET_STRUCT_TLVLEN
11667 (wlan_host_memory_chunk));
11668 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11669 host_mem_chunks[idx].size = mem_chunks[idx].len;
11670 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
11671 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
11672 idx, host_mem_chunks[idx].size,
11673 host_mem_chunks[idx].ptr);
11674 }
11675 cmd->num_host_mem_chunks = num_mem_chunks;
11676 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11677 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11678 WMITLV_TAG_ARRAY_STRUC,
11679 (sizeof(wlan_host_memory_chunk) *
11680 num_mem_chunks));
11681
11682 num_whitelist = sizeof(version_whitelist) /
11683 sizeof(wmi_whitelist_version_info);
11684 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11685 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11686 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11687 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11688 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11689 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
11690
Govind Singh87542482016-06-08 19:40:11 +053011691#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011692 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11693 &my_vers,
11694 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
11695 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011696#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011697 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
11698 __func__,
11699 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11700 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11701 cmd->host_abi_vers.abi_version_ns_0,
11702 cmd->host_abi_vers.abi_version_ns_1,
11703 cmd->host_abi_vers.abi_version_ns_2,
11704 cmd->host_abi_vers.abi_version_ns_3);
11705
11706 /* Save version sent from host -
11707 * Will be used to check ready event
11708 */
Govind Singh87542482016-06-08 19:40:11 +053011709#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011710 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
11711 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011712#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053011713 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
11714 if (QDF_IS_STATUS_ERROR(ret)) {
11715 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
11716 ret);
11717 wmi_buf_free(buf);
11718 }
11719 return ret;
11720
Govind Singhe7f2f342016-05-23 12:12:52 +053011721}
11722
11723/**
11724 * save_service_bitmap_tlv() - save service bitmap
11725 * @wmi_handle: wmi handle
11726 * @param evt_buf: pointer to event buffer
11727 *
11728 * Return: None
11729 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011730#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011731static
Govind Singhe7f2f342016-05-23 12:12:52 +053011732void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11733{
11734 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11735 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11736
11737 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
11738 param_buf->wmi_service_bitmap,
11739 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
11740}
11741#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011742static
Govind Singhe7f2f342016-05-23 12:12:52 +053011743void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11744{
11745 return;
11746}
11747
11748#endif
11749
11750/**
11751 * is_service_enabled_tlv() - Check if service enabled
11752 * @param wmi_handle: wmi handle
11753 * @param service_id: service identifier
11754 *
11755 * Return: 1 enabled, 0 disabled
11756 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011757#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011758static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11759 uint32_t service_id)
11760{
11761 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
11762 service_id);
11763}
11764#else
11765static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11766 uint32_t service_id)
11767{
11768 return false;
11769}
11770#endif
11771
11772/**
11773 * extract_service_ready_tlv() - extract service ready event
11774 * @wmi_handle: wmi handle
11775 * @param evt_buf: pointer to received event buffer
11776 * @param cap: pointer to hold target capability information extracted from even
11777 *
11778 * Return: QDF_STATUS_SUCCESS for success or error code
11779 */
11780static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
11781 void *evt_buf, target_capability_info *cap)
11782{
11783 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11784 wmi_service_ready_event_fixed_param *ev;
11785
11786
11787 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11788
11789 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11790 if (!ev) {
11791 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11792 return QDF_STATUS_E_FAILURE;
11793 }
11794
11795 cap->phy_capability = ev->phy_capability;
11796 cap->max_frag_entry = ev->max_frag_entry;
11797 cap->num_rf_chains = ev->num_rf_chains;
11798 cap->ht_cap_info = ev->ht_cap_info;
11799 cap->vht_cap_info = ev->vht_cap_info;
11800 cap->vht_supp_mcs = ev->vht_supp_mcs;
11801 cap->hw_min_tx_power = ev->hw_min_tx_power;
11802 cap->hw_max_tx_power = ev->hw_max_tx_power;
11803 cap->sys_cap_info = ev->sys_cap_info;
11804 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
11805 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
11806 cap->max_num_scan_channels = ev->max_num_scan_channels;
11807 cap->max_supported_macs = ev->max_supported_macs;
11808 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
11809 cap->txrx_chainmask = ev->txrx_chainmask;
11810 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
11811 cap->num_msdu_desc = ev->num_msdu_desc;
11812
11813 return QDF_STATUS_SUCCESS;
11814}
11815
11816/**
11817 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
11818 * @wmi_handle: wmi handle
11819 * @param evt_buf: Pointer to event buffer
11820 * @param cap: pointer to hold HAL reg capabilities
11821 *
11822 * Return: QDF_STATUS_SUCCESS for success or error code
11823 */
11824static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
11825 void *evt_buf, TARGET_HAL_REG_CAPABILITIES *cap)
11826{
11827 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Pratik Gandhi33bb7142017-01-05 19:38:41 +053011828 u_int32_t wireless_modes_orig = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053011829
11830 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11831
11832 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
11833 sizeof(uint32_t)),
11834 sizeof(TARGET_HAL_REG_CAPABILITIES));
11835
Pratik Gandhi33bb7142017-01-05 19:38:41 +053011836 /* Convert REGDMN_MODE values sent by target to host internal
11837 * WMI_HOST_REGDMN_MODE values.
11838 *
11839 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
11840 * host currently. Add this in the future if required.
11841 *
11842 * 11AX TODO (Phase II) : 11ax related values are not currently
11843 * advertised separately by FW. As part of phase II regulatory bring-up,
11844 * finalize the advertisement mechanism.
11845 */
11846
11847 wireless_modes_orig = param_buf->hal_reg_capabilities->wireless_modes;
11848 cap->wireless_modes = 0;
11849
11850 if (wireless_modes_orig & REGDMN_MODE_11A)
11851 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
11852
11853 if (wireless_modes_orig & REGDMN_MODE_TURBO)
11854 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
11855
11856 if (wireless_modes_orig & REGDMN_MODE_11B)
11857 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
11858
11859 if (wireless_modes_orig & REGDMN_MODE_PUREG)
11860 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
11861
11862 if (wireless_modes_orig & REGDMN_MODE_11G)
11863 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
11864
11865 if (wireless_modes_orig & REGDMN_MODE_108G)
11866 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
11867
11868 if (wireless_modes_orig & REGDMN_MODE_108A)
11869 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
11870
11871 if (wireless_modes_orig & REGDMN_MODE_XR)
11872 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
11873
11874 if (wireless_modes_orig & REGDMN_MODE_11A_HALF_RATE)
11875 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
11876
11877 if (wireless_modes_orig & REGDMN_MODE_11A_QUARTER_RATE)
11878 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
11879
11880 if (wireless_modes_orig & REGDMN_MODE_11NG_HT20)
11881 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
11882
11883 if (wireless_modes_orig & REGDMN_MODE_11NA_HT20)
11884 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
11885
11886 if (wireless_modes_orig & REGDMN_MODE_11NG_HT40PLUS)
11887 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
11888
11889 if (wireless_modes_orig & REGDMN_MODE_11NG_HT40MINUS)
11890 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
11891
11892 if (wireless_modes_orig & REGDMN_MODE_11NA_HT40PLUS)
11893 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
11894
11895 if (wireless_modes_orig & REGDMN_MODE_11NA_HT40MINUS)
11896 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
11897
11898 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT20)
11899 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
11900
11901 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT40PLUS)
11902 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
11903
11904 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT40MINUS)
11905 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
11906
11907 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT80)
11908 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
11909
11910 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT160)
11911 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
11912
11913 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT80_80)
11914 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
11915
Govind Singhe7f2f342016-05-23 12:12:52 +053011916 return QDF_STATUS_SUCCESS;
11917}
11918
11919/**
11920 * extract_host_mem_req_tlv() - Extract host memory request event
11921 * @wmi_handle: wmi handle
11922 * @param evt_buf: pointer to event buffer
11923 * @param num_entries: pointer to hold number of entries requested
11924 *
11925 * Return: Number of entries requested
11926 */
11927static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
11928 void *evt_buf, uint8_t *num_entries)
11929{
11930 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11931 wmi_service_ready_event_fixed_param *ev;
11932
11933 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11934
11935 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11936 if (!ev) {
11937 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11938 return NULL;
11939 }
11940
11941 *num_entries = ev->num_mem_reqs;
11942
11943 return (host_mem_req *)param_buf->mem_reqs;
11944}
11945
11946/**
11947 * save_fw_version_in_service_ready_tlv() - Save fw version in service
11948 * ready function
11949 * @wmi_handle: wmi handle
11950 * @param evt_buf: pointer to event buffer
11951 *
11952 * Return: QDF_STATUS_SUCCESS for success or error code
11953 */
11954static QDF_STATUS
11955save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
11956{
11957 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11958 wmi_service_ready_event_fixed_param *ev;
11959
11960
11961 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11962
11963 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11964 if (!ev) {
11965 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11966 return QDF_STATUS_E_FAILURE;
11967 }
11968
Govind Singh87542482016-06-08 19:40:11 +053011969#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011970 /*Save fw version from service ready message */
11971 /*This will be used while sending INIT message */
11972 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
11973 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011974#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011975 return QDF_STATUS_SUCCESS;
11976}
11977
11978/**
11979 * ready_extract_init_status_tlv() - Extract init status from ready event
11980 * @wmi_handle: wmi handle
11981 * @param evt_buf: Pointer to event buffer
11982 *
11983 * Return: ready status
11984 */
11985static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
11986 void *evt_buf)
11987{
11988 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11989 wmi_ready_event_fixed_param *ev = NULL;
11990
11991
11992 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11993 ev = param_buf->fixed_param;
11994
11995 qdf_print("%s:%d\n", __func__, ev->status);
11996
11997 return ev->status;
11998}
11999
12000/**
12001 * ready_extract_mac_addr_tlv() - extract mac address from ready event
12002 * @wmi_handle: wmi handle
12003 * @param evt_buf: pointer to event buffer
12004 * @param macaddr: Pointer to hold MAC address
12005 *
12006 * Return: QDF_STATUS_SUCCESS for success or error code
12007 */
12008static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
12009 void *evt_buf, uint8_t *macaddr)
12010{
12011 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12012 wmi_ready_event_fixed_param *ev = NULL;
12013
12014
12015 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12016 ev = param_buf->fixed_param;
12017
12018 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
12019
12020 return QDF_STATUS_SUCCESS;
12021}
12022
12023/**
12024 * extract_dbglog_data_len_tlv() - extract debuglog data length
12025 * @wmi_handle: wmi handle
12026 * @param evt_buf: pointer to event buffer
12027 *
12028 * Return: length
12029 */
12030static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
12031 void *evt_buf, uint16_t *len)
12032{
12033 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
12034
12035 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
12036
12037 *len = param_buf->num_bufp;
12038
12039 return param_buf->bufp;
12040}
12041
12042/**
12043 * extract_vdev_start_resp_tlv() - extract vdev start response
12044 * @wmi_handle: wmi handle
12045 * @param evt_buf: pointer to event buffer
12046 * @param vdev_rsp: Pointer to hold vdev response
12047 *
12048 * Return: QDF_STATUS_SUCCESS for success or error code
12049 */
12050static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
12051 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
12052{
12053 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
12054 wmi_vdev_start_response_event_fixed_param *ev;
12055
12056 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
12057 if (!param_buf) {
12058 qdf_print("Invalid start response event buffer\n");
12059 return QDF_STATUS_E_INVAL;
12060 }
12061
12062 ev = param_buf->fixed_param;
12063 if (!ev) {
12064 qdf_print("Invalid start response event buffer\n");
12065 return QDF_STATUS_E_INVAL;
12066 }
12067
12068 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
12069
12070 vdev_rsp->vdev_id = ev->vdev_id;
12071 vdev_rsp->requestor_id = ev->requestor_id;
12072 vdev_rsp->resp_type = ev->resp_type;
12073 vdev_rsp->status = ev->status;
12074 vdev_rsp->chain_mask = ev->chain_mask;
12075 vdev_rsp->smps_mode = ev->smps_mode;
12076 vdev_rsp->mac_id = ev->mac_id;
12077 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
12078 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
12079
12080 return QDF_STATUS_SUCCESS;
12081}
12082
12083/**
12084 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
12085 * @wmi_handle: wmi handle
12086 * @param evt_buf: pointer to event buffer
12087 * @param vdev_map: Pointer to hold vdev map
12088 * @param tbttoffset_list: Pointer to tbtt offset list
12089 *
12090 * Return: QDF_STATUS_SUCCESS for success or error code
12091 */
12092static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
12093 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
12094{
12095 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
12096 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
12097
12098 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
12099 if (!param_buf) {
12100 qdf_print("Invalid tbtt update event buffer\n");
12101 return QDF_STATUS_E_INVAL;
12102 }
12103 tbtt_offset_event = param_buf->fixed_param;
12104
12105 *vdev_map = tbtt_offset_event->vdev_map;
12106 *tbttoffset_list = param_buf->tbttoffset_list;
12107
12108 return QDF_STATUS_SUCCESS;
12109}
12110
12111/**
12112 * extract_mgmt_rx_params_tlv() - extract management rx params from event
12113 * @wmi_handle: wmi handle
12114 * @param evt_buf: pointer to event buffer
12115 * @param hdr: Pointer to hold header
12116 * @param bufp: Pointer to hold pointer to rx param buffer
12117 *
12118 * Return: QDF_STATUS_SUCCESS for success or error code
12119 */
12120static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
12121 void *evt_buf, wmi_host_mgmt_rx_hdr *hdr, uint8_t **bufp)
12122{
12123 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
12124 wmi_mgmt_rx_hdr *ev_hdr = NULL;
12125
12126 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
12127 if (!param_tlvs) {
12128 WMI_LOGE("Get NULL point message from FW");
12129 return QDF_STATUS_E_INVAL;
12130 }
12131
12132 ev_hdr = param_tlvs->hdr;
12133 if (!hdr) {
12134 WMI_LOGE("Rx event is NULL");
12135 return QDF_STATUS_E_INVAL;
12136 }
12137
12138
12139 hdr->channel = ev_hdr->channel;
12140 hdr->snr = ev_hdr->snr;
12141 hdr->rate = ev_hdr->rate;
12142 hdr->phy_mode = ev_hdr->phy_mode;
12143 hdr->buf_len = ev_hdr->buf_len;
12144 hdr->status = ev_hdr->status;
12145 hdr->flags = ev_hdr->flags;
12146 hdr->rssi = ev_hdr->rssi;
12147 hdr->tsf_delta = ev_hdr->tsf_delta;
12148 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
12149
12150 *bufp = param_tlvs->bufp;
12151
12152 return QDF_STATUS_SUCCESS;
12153}
12154
12155/**
12156 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
12157 * @wmi_handle: wmi handle
12158 * @param evt_buf: pointer to event buffer
12159 * @param vdev_id: Pointer to hold vdev identifier
12160 *
12161 * Return: QDF_STATUS_SUCCESS for success or error code
12162 */
12163static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
12164 void *evt_buf, uint32_t *vdev_id)
12165{
12166 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
12167 wmi_vdev_stopped_event_fixed_param *resp_event;
12168
12169 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
12170 if (!param_buf) {
12171 WMI_LOGE("Invalid event buffer");
12172 return QDF_STATUS_E_INVAL;
12173 }
12174 resp_event = param_buf->fixed_param;
12175 *vdev_id = resp_event->vdev_id;
12176
12177 return QDF_STATUS_SUCCESS;
12178}
12179
12180/**
12181 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
12182 * @wmi_handle: wmi handle
12183 * @param evt_buf: pointer to event buffer
12184 * @param param: Pointer to hold roam param
12185 *
12186 * Return: QDF_STATUS_SUCCESS for success or error code
12187 */
12188static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
12189 void *evt_buf, wmi_host_roam_event *param)
12190{
12191 WMI_ROAM_EVENTID_param_tlvs *param_buf;
12192 wmi_roam_event_fixed_param *evt;
12193
12194 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
12195 if (!param_buf) {
12196 WMI_LOGE("Invalid roam event buffer");
12197 return QDF_STATUS_E_INVAL;
12198 }
12199
12200 evt = param_buf->fixed_param;
12201 qdf_mem_zero(param, sizeof(*param));
12202
12203 param->vdev_id = evt->vdev_id;
12204 param->reason = evt->reason;
12205 param->rssi = evt->rssi;
12206
12207 return QDF_STATUS_SUCCESS;
12208}
12209
12210/**
12211 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
12212 * @wmi_handle: wmi handle
12213 * @param evt_buf: pointer to event buffer
12214 * @param param: Pointer to hold vdev scan param
12215 *
12216 * Return: QDF_STATUS_SUCCESS for success or error code
12217 */
12218static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
12219 void *evt_buf, wmi_host_scan_event *param)
12220{
12221 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
12222 wmi_scan_event_fixed_param *evt = NULL;
12223
12224 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
12225 evt = param_buf->fixed_param;
12226
12227 qdf_mem_zero(param, sizeof(*param));
12228 switch (evt->event) {
12229 case WMI_SCAN_EVENT_STARTED:
12230 param->event = WMI_HOST_SCAN_EVENT_STARTED;
12231 break;
12232 case WMI_SCAN_EVENT_COMPLETED:
12233 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
12234 break;
12235 case WMI_SCAN_EVENT_BSS_CHANNEL:
12236 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
12237 break;
12238 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
12239 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
12240 break;
12241 case WMI_SCAN_EVENT_DEQUEUED:
12242 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
12243 break;
12244 case WMI_SCAN_EVENT_PREEMPTED:
12245 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
12246 break;
12247 case WMI_SCAN_EVENT_START_FAILED:
12248 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
12249 break;
12250 case WMI_SCAN_EVENT_RESTARTED:
12251 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
12252 break;
12253 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
12254 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
12255 break;
12256 case WMI_SCAN_EVENT_MAX:
12257 default:
12258 param->event = WMI_HOST_SCAN_EVENT_MAX;
12259 break;
12260 };
12261
12262 switch (evt->reason) {
12263 case WMI_SCAN_REASON_NONE:
12264 param->reason = WMI_HOST_SCAN_REASON_NONE;
12265 break;
12266 case WMI_SCAN_REASON_COMPLETED:
12267 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
12268 break;
12269 case WMI_SCAN_REASON_CANCELLED:
12270 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
12271 break;
12272 case WMI_SCAN_REASON_PREEMPTED:
12273 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
12274 break;
12275 case WMI_SCAN_REASON_TIMEDOUT:
12276 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
12277 break;
12278 case WMI_SCAN_REASON_INTERNAL_FAILURE:
12279 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
12280 break;
12281 case WMI_SCAN_REASON_MAX:
12282 default:
12283 param->reason = WMI_HOST_SCAN_REASON_MAX;
12284 break;
12285 };
12286
12287 param->channel_freq = evt->channel_freq;
12288 param->requestor = evt->requestor;
12289 param->scan_id = evt->scan_id;
12290 param->vdev_id = evt->vdev_id;
12291
12292 return QDF_STATUS_SUCCESS;
12293}
12294
12295/**
12296 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
12297 * @wmi_handle: wmi handle
12298 * @param evt_buf: pointer to event buffer
12299 * @param param: Pointer to hold MGMT TX completion params
12300 *
12301 * Return: QDF_STATUS_SUCCESS for success or error code
12302 */
12303static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
12304 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
12305{
12306 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
12307 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
12308
12309 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
12310 evt_buf;
12311 if (!param_buf) {
12312 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
12313 return QDF_STATUS_E_INVAL;
12314 }
12315 cmpl_params = param_buf->fixed_param;
12316
12317 param->desc_id = cmpl_params->desc_id;
12318 param->status = cmpl_params->status;
12319
12320 return QDF_STATUS_SUCCESS;
12321}
12322
12323/**
12324 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
12325 * @wmi_handle: wmi handle
12326 * @param evt_buf: pointer to event buffer
12327 * @param vdev_map: Pointer to hold vdev map
12328 *
12329 * Return: QDF_STATUS_SUCCESS for success or error code
12330 */
12331static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
12332 void *evt_buf, uint32_t *vdev_map)
12333{
12334 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12335 wmi_host_swba_event_fixed_param *swba_event;
12336
12337 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12338 if (!param_buf) {
12339 WMI_LOGE("Invalid swba event buffer");
12340 return QDF_STATUS_E_INVAL;
12341 }
12342 swba_event = param_buf->fixed_param;
12343 *vdev_map = swba_event->vdev_map;
12344
12345 return QDF_STATUS_SUCCESS;
12346}
12347
12348/**
12349 * extract_swba_tim_info_tlv() - extract swba tim info from event
12350 * @wmi_handle: wmi handle
12351 * @param evt_buf: pointer to event buffer
12352 * @param idx: Index to bcn info
12353 * @param tim_info: Pointer to hold tim info
12354 *
12355 * Return: QDF_STATUS_SUCCESS for success or error code
12356 */
12357static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
12358 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
12359{
12360 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12361 wmi_tim_info *tim_info_ev;
12362
12363 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12364 if (!param_buf) {
12365 WMI_LOGE("Invalid swba event buffer");
12366 return QDF_STATUS_E_INVAL;
12367 }
12368
12369 tim_info_ev = &param_buf->tim_info[idx];
12370
12371 tim_info->tim_len = tim_info_ev->tim_len;
12372 tim_info->tim_mcast = tim_info_ev->tim_mcast;
12373 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
12374 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
12375 tim_info->tim_changed = tim_info_ev->tim_changed;
12376 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
12377
12378 return QDF_STATUS_SUCCESS;
12379}
12380
12381/**
12382 * extract_swba_noa_info_tlv() - extract swba NoA information from event
12383 * @wmi_handle: wmi handle
12384 * @param evt_buf: pointer to event buffer
12385 * @param idx: Index to bcn info
12386 * @param p2p_desc: Pointer to hold p2p NoA info
12387 *
12388 * Return: QDF_STATUS_SUCCESS for success or error code
12389 */
12390static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
12391 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
12392{
12393 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12394 wmi_p2p_noa_info *p2p_noa_info;
12395 uint8_t i = 0;
12396
12397 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12398 if (!param_buf) {
12399 WMI_LOGE("Invalid swba event buffer");
12400 return QDF_STATUS_E_INVAL;
12401 }
12402
12403 p2p_noa_info = &param_buf->p2p_noa_info[idx];
12404
12405 p2p_desc->modified = false;
12406 p2p_desc->num_descriptors = 0;
12407 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
12408 p2p_desc->modified = true;
12409 p2p_desc->index =
12410 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
12411 p2p_desc->oppPS =
12412 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
12413 p2p_desc->ctwindow =
12414 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
12415 p2p_desc->num_descriptors =
12416 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
12417 (p2p_noa_info);
12418 for (i = 0; i < p2p_desc->num_descriptors; i++) {
12419 p2p_desc->noa_descriptors[i].type_count =
12420 (uint8_t) p2p_noa_info->noa_descriptors[i].
12421 type_count;
12422 p2p_desc->noa_descriptors[i].duration =
12423 p2p_noa_info->noa_descriptors[i].duration;
12424 p2p_desc->noa_descriptors[i].interval =
12425 p2p_noa_info->noa_descriptors[i].interval;
12426 p2p_desc->noa_descriptors[i].start_time =
12427 p2p_noa_info->noa_descriptors[i].start_time;
12428 }
12429 }
12430
12431 return QDF_STATUS_SUCCESS;
12432}
12433
12434/**
12435 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
12436 * @wmi_handle: wmi handle
12437 * @param evt_buf: pointer to event buffer
12438 * @param ev: Pointer to hold peer param
12439 *
12440 * Return: QDF_STATUS_SUCCESS for success or error code
12441 */
12442static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
12443 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
12444{
12445 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
12446 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
12447
12448 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
12449 kickout_event = param_buf->fixed_param;
12450
12451 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
12452 ev->peer_macaddr);
12453
12454 ev->reason = kickout_event->reason;
12455 ev->rssi = kickout_event->rssi;
12456
12457 return QDF_STATUS_SUCCESS;
12458}
12459
12460/**
12461 * extract_all_stats_counts_tlv() - extract all stats count from event
12462 * @wmi_handle: wmi handle
12463 * @param evt_buf: pointer to event buffer
12464 * @param stats_param: Pointer to hold stats count
12465 *
12466 * Return: QDF_STATUS_SUCCESS for success or error code
12467 */
12468static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
12469 void *evt_buf, wmi_host_stats_event *stats_param)
12470{
12471 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12472 wmi_stats_event_fixed_param *ev;
12473
12474 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12475
12476 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12477 if (!ev) {
12478 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
12479 return QDF_STATUS_E_FAILURE;
12480 }
12481
12482 switch (ev->stats_id) {
12483 case WMI_REQUEST_PEER_STAT:
12484 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
12485 break;
12486
12487 case WMI_REQUEST_AP_STAT:
12488 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
12489 break;
12490
12491 case WMI_REQUEST_PDEV_STAT:
12492 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
12493 break;
12494
12495 case WMI_REQUEST_VDEV_STAT:
12496 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
12497 break;
12498
12499 case WMI_REQUEST_BCNFLT_STAT:
12500 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
12501 break;
12502
12503 case WMI_REQUEST_VDEV_RATE_STAT:
12504 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
12505 break;
12506
12507 default:
12508 stats_param->stats_id = 0;
12509 break;
12510
12511 }
12512
12513 stats_param->num_pdev_stats = ev->num_pdev_stats;
12514 stats_param->num_pdev_ext_stats = 0;
12515 stats_param->num_vdev_stats = ev->num_vdev_stats;
12516 stats_param->num_peer_stats = ev->num_peer_stats;
12517 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
12518 stats_param->num_chan_stats = ev->num_chan_stats;
12519
12520 return QDF_STATUS_SUCCESS;
12521}
12522
12523/**
12524 * extract_pdev_stats_tlv() - extract pdev stats from event
12525 * @wmi_handle: wmi handle
12526 * @param evt_buf: pointer to event buffer
12527 * @param index: Index into pdev stats
12528 * @param pdev_stats: Pointer to hold pdev stats
12529 *
12530 * Return: QDF_STATUS_SUCCESS for success or error code
12531 */
12532static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
12533 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
12534{
12535 return QDF_STATUS_SUCCESS;
12536}
12537
12538/**
12539 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
12540 * @wmi_handle: wmi handle
12541 * @param evt_buf: pointer to event buffer
12542 * @param index: Index into extended pdev stats
12543 * @param pdev_ext_stats: Pointer to hold extended pdev stats
12544 *
12545 * Return: QDF_STATUS_SUCCESS for success or error code
12546 */
12547static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
12548 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
12549{
12550 return QDF_STATUS_SUCCESS;
12551}
12552
12553/**
12554 * extract_vdev_stats_tlv() - extract vdev stats from event
12555 * @wmi_handle: wmi handle
12556 * @param evt_buf: pointer to event buffer
12557 * @param index: Index into vdev stats
12558 * @param vdev_stats: Pointer to hold vdev stats
12559 *
12560 * Return: QDF_STATUS_SUCCESS for success or error code
12561 */
12562static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
12563 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
12564{
12565 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12566 wmi_stats_event_fixed_param *ev_param;
12567 uint8_t *data;
12568
12569 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12570 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12571 data = (uint8_t *) param_buf->data;
12572
12573 if (index < ev_param->num_vdev_stats) {
12574 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
12575 ((ev_param->num_pdev_stats) *
12576 sizeof(wmi_pdev_stats)) +
12577 (index * sizeof(wmi_vdev_stats)));
12578
12579 vdev_stats->vdev_id = ev->vdev_id;
12580 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
12581 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
12582
12583 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
12584 sizeof(ev->tx_frm_cnt));
12585 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
12586 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
12587 ev->multiple_retry_cnt,
12588 sizeof(ev->multiple_retry_cnt));
12589 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
12590 sizeof(ev->fail_cnt));
12591 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
12592 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
12593 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
12594 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
12595 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
12596 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
12597 sizeof(ev->tx_rate_history));
12598 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
12599 sizeof(ev->bcn_rssi_history));
12600
12601 }
12602
12603 return QDF_STATUS_SUCCESS;
12604}
12605
12606/**
12607 * extract_peer_stats_tlv() - extract peer stats from event
12608 * @wmi_handle: wmi handle
12609 * @param evt_buf: pointer to event buffer
12610 * @param index: Index into peer stats
12611 * @param peer_stats: Pointer to hold peer stats
12612 *
12613 * Return: QDF_STATUS_SUCCESS for success or error code
12614 */
12615static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
12616 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
12617{
12618 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12619 wmi_stats_event_fixed_param *ev_param;
12620 uint8_t *data;
12621
12622 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12623 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12624 data = (uint8_t *) param_buf->data;
12625
12626 if (index < ev_param->num_peer_stats) {
12627 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
12628 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12629 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12630 (index * sizeof(wmi_peer_stats)));
12631
12632 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
12633
12634 OS_MEMCPY(&(peer_stats->peer_macaddr),
12635 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
12636
12637 peer_stats->peer_rssi = ev->peer_rssi;
12638 peer_stats->peer_tx_rate = ev->peer_tx_rate;
12639 peer_stats->peer_rx_rate = ev->peer_rx_rate;
12640 }
12641
12642 return QDF_STATUS_SUCCESS;
12643}
12644
12645/**
12646 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
12647 * @wmi_handle: wmi handle
12648 * @param evt_buf: pointer to event buffer
12649 * @param index: Index into bcn fault stats
12650 * @param bcnflt_stats: Pointer to hold bcn fault stats
12651 *
12652 * Return: QDF_STATUS_SUCCESS for success or error code
12653 */
12654static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
12655 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
12656{
12657 return QDF_STATUS_SUCCESS;
12658}
12659
12660/**
12661 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
12662 * @wmi_handle: wmi handle
12663 * @param evt_buf: pointer to event buffer
12664 * @param index: Index into extended peer stats
12665 * @param peer_extd_stats: Pointer to hold extended peer stats
12666 *
12667 * Return: QDF_STATUS_SUCCESS for success or error code
12668 */
12669static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
12670 void *evt_buf, uint32_t index,
12671 wmi_host_peer_extd_stats *peer_extd_stats)
12672{
12673 return QDF_STATUS_SUCCESS;
12674}
12675
12676/**
12677 * extract_chan_stats_tlv() - extract chan stats from event
12678 * @wmi_handle: wmi handle
12679 * @param evt_buf: pointer to event buffer
12680 * @param index: Index into chan stats
12681 * @param vdev_extd_stats: Pointer to hold chan stats
12682 *
12683 * Return: QDF_STATUS_SUCCESS for success or error code
12684 */
12685static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
12686 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
12687{
12688 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12689 wmi_stats_event_fixed_param *ev_param;
12690 uint8_t *data;
12691
12692 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12693 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12694 data = (uint8_t *) param_buf->data;
12695
12696 if (index < ev_param->num_chan_stats) {
12697 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
12698 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12699 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12700 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
12701 (index * sizeof(wmi_chan_stats)));
12702
12703
12704 /* Non-TLV doesnt have num_chan_stats */
12705 chan_stats->chan_mhz = ev->chan_mhz;
12706 chan_stats->sampling_period_us = ev->sampling_period_us;
12707 chan_stats->rx_clear_count = ev->rx_clear_count;
12708 chan_stats->tx_duration_us = ev->tx_duration_us;
12709 chan_stats->rx_duration_us = ev->rx_duration_us;
12710 }
12711
12712 return QDF_STATUS_SUCCESS;
12713}
12714
12715/**
12716 * extract_profile_ctx_tlv() - extract profile context from event
12717 * @wmi_handle: wmi handle
12718 * @param evt_buf: pointer to event buffer
12719 * @idx: profile stats index to extract
12720 * @param profile_ctx: Pointer to hold profile context
12721 *
12722 * Return: QDF_STATUS_SUCCESS for success or error code
12723 */
12724static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
12725 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
12726{
12727 return QDF_STATUS_SUCCESS;
12728}
12729
12730/**
12731 * extract_profile_data_tlv() - extract profile data from event
12732 * @wmi_handle: wmi handle
12733 * @param evt_buf: pointer to event buffer
12734 * @param profile_data: Pointer to hold profile data
12735 *
12736 * Return: QDF_STATUS_SUCCESS for success or error code
12737 */
12738static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
12739 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
12740{
12741
12742 return QDF_STATUS_SUCCESS;
12743}
12744
12745/**
12746 * extract_chan_info_event_tlv() - extract chan information from event
12747 * @wmi_handle: wmi handle
12748 * @param evt_buf: pointer to event buffer
12749 * @param chan_info: Pointer to hold chan information
12750 *
12751 * Return: QDF_STATUS_SUCCESS for success or error code
12752 */
12753static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
12754 void *evt_buf, wmi_host_chan_info_event *chan_info)
12755{
12756 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
12757 wmi_chan_info_event_fixed_param *ev;
12758
12759 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
12760
12761 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
12762 if (!ev) {
12763 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
12764 return QDF_STATUS_E_FAILURE;
12765 }
12766
12767 chan_info->err_code = ev->err_code;
12768 chan_info->freq = ev->freq;
12769 chan_info->cmd_flags = ev->cmd_flags;
12770 chan_info->noise_floor = ev->noise_floor;
12771 chan_info->rx_clear_count = ev->rx_clear_count;
12772 chan_info->cycle_count = ev->cycle_count;
12773
12774 return QDF_STATUS_SUCCESS;
12775}
12776
12777/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053012778 * extract_pdev_utf_event_tlv() - extract UTF data info from event
12779 * @wmi_handle: WMI handle
12780 * @param evt_buf: Pointer to event buffer
12781 * @param param: Pointer to hold data
12782 *
12783 * Return : QDF_STATUS_SUCCESS for success or error code
12784 */
12785static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
12786 uint8_t *evt_buf,
12787 struct wmi_host_pdev_utf_event *event)
12788{
12789 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
12790
12791 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
12792 event->data = param_buf->data;
12793 event->datalen = param_buf->num_data;
12794
12795 return QDF_STATUS_SUCCESS;
12796}
12797/**
Govind Singhe7f2f342016-05-23 12:12:52 +053012798 * extract_channel_hopping_event_tlv() - extract channel hopping param
12799 * from event
12800 * @wmi_handle: wmi handle
12801 * @param evt_buf: pointer to event buffer
12802 * @param ch_hopping: Pointer to hold channel hopping param
12803 *
12804 * Return: QDF_STATUS_SUCCESS for success or error code
12805 */
12806static QDF_STATUS extract_channel_hopping_event_tlv(wmi_unified_t wmi_handle,
12807 void *evt_buf, wmi_host_pdev_channel_hopping_event *chan_info)
12808{
12809 return QDF_STATUS_SUCCESS;
12810}
12811
Kiran Venkatappa06520822016-08-10 23:55:40 +053012812/**
12813 * extract_service_ready_ext_tlv() - extract basic extended service ready params
12814 * from event
12815 * @wmi_handle: wmi handle
12816 * @param evt_buf: pointer to event buffer
12817 * @param param: Pointer to hold evt buf
12818 *
12819 * Return: QDF_STATUS_SUCCESS for success or error code
12820 */
12821static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
12822 uint8_t *event, struct wmi_host_service_ext_param *param)
12823{
12824 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12825 wmi_service_ready_ext_event_fixed_param *ev;
12826 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
12827 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
12828
12829 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12830 if (!param_buf)
12831 return -EINVAL;
12832
12833 ev = param_buf->fixed_param;
12834 if (!ev)
12835 return -EINVAL;
12836
12837 /* Move this to host based bitmap */
12838 param->default_conc_scan_config_bits =
12839 ev->default_conc_scan_config_bits;
12840 param->default_fw_config_bits = ev->default_fw_config_bits;
12841 param->he_cap_info = ev->he_cap_info;
12842 param->mpdu_density = ev->mpdu_density;
12843 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
12844 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
12845
12846 hw_caps = param_buf->soc_hw_mode_caps;
12847 param->num_hw_modes = hw_caps->num_hw_modes;
12848
12849 reg_caps = param_buf->soc_hal_reg_caps;
12850 param->num_phy = reg_caps->num_phy;
12851
12852 return QDF_STATUS_SUCCESS;
12853}
12854
12855/**
12856 * extract_hw_mode_cap_service_ready_ext_tlv() -
12857 * extract HW mode cap from service ready event
12858 * @wmi_handle: wmi handle
12859 * @param evt_buf: pointer to event buffer
12860 * @param param: Pointer to hold evt buf
12861 * @param hw_mode_idx: hw mode idx should be less than num_mode
12862 *
12863 * Return: QDF_STATUS_SUCCESS for success or error code
12864 */
12865static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
12866 wmi_unified_t wmi_handle,
12867 uint8_t *event, uint8_t hw_mode_idx,
12868 struct wmi_host_hw_mode_caps *param)
12869{
12870 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12871 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
12872
12873 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12874 if (!param_buf)
12875 return -EINVAL;
12876
12877 hw_caps = param_buf->soc_hw_mode_caps;
12878 if (hw_mode_idx >= hw_caps->num_hw_modes)
12879 return -EINVAL;
12880
12881 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
12882 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
12883
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053012884 param->hw_mode_config_type =
12885 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
12886
Kiran Venkatappa06520822016-08-10 23:55:40 +053012887 return QDF_STATUS_SUCCESS;
12888}
12889
12890/**
12891 * extract_mac_phy_cap_service_ready_ext_tlv() -
12892 * extract MAC phy cap from service ready event
12893 * @wmi_handle: wmi handle
12894 * @param evt_buf: pointer to event buffer
12895 * @param param: Pointer to hold evt buf
12896 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053012897 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053012898 *
12899 * Return: QDF_STATUS_SUCCESS for success or error code
12900 */
12901static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
12902 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053012903 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Kiran Venkatappa06520822016-08-10 23:55:40 +053012904 struct wmi_host_mac_phy_caps *param)
12905{
12906 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053012907 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053012908 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
12909 uint32_t phy_map;
12910 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053012911
12912 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12913 if (!param_buf)
12914 return -EINVAL;
12915
12916 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053012917 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
12918 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
12919 break;
12920
12921 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
12922 while (phy_map) {
12923 phy_map >>= 1;
12924 phy_idx++;
12925 }
12926 }
12927
12928 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa06520822016-08-10 23:55:40 +053012929 return -EINVAL;
12930
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053012931 phy_idx += phy_id;
12932 if (phy_idx >= param_buf->num_mac_phy_caps)
12933 return -EINVAL;
12934
12935 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053012936
12937 param->hw_mode_id = mac_phy_caps->hw_mode_id;
12938 param->pdev_id = mac_phy_caps->pdev_id;
12939 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053012940 param->supports_11b =
12941 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
12942 param->supports_11g =
12943 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
12944 param->supports_11a =
12945 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
12946 param->supports_11n =
12947 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
12948 param->supports_11ac =
12949 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
12950 param->supports_11ax =
12951 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053012952
12953 param->supported_bands = mac_phy_caps->supported_bands;
12954 param->ampdu_density = mac_phy_caps->ampdu_density;
12955 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
12956 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
12957 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
12958 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
12959 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
12960 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
12961 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
12962 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
12963 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
12964 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
12965 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
12966 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
12967 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
12968 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
12969 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
12970 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
12971
12972 return QDF_STATUS_SUCCESS;
12973}
12974
12975/**
12976 * extract_reg_cap_service_ready_ext_tlv() -
12977 * extract REG cap from service ready event
12978 * @wmi_handle: wmi handle
12979 * @param evt_buf: pointer to event buffer
12980 * @param param: Pointer to hold evt buf
12981 * @param phy_idx: phy idx should be less than num_mode
12982 *
12983 * Return: QDF_STATUS_SUCCESS for success or error code
12984 */
12985static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
12986 wmi_unified_t wmi_handle,
12987 uint8_t *event, uint8_t phy_idx,
12988 struct WMI_HOST_HAL_REG_CAPABILITIES_EXT *param)
12989{
12990 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
12991 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
12992 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
12993
12994 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
12995 if (!param_buf)
12996 return -EINVAL;
12997
12998 reg_caps = param_buf->soc_hal_reg_caps;
12999 if (phy_idx >= reg_caps->num_phy)
13000 return -EINVAL;
13001
13002 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
13003
13004 param->phy_id = ext_reg_cap->phy_id;
13005 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
13006 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
13007 param->regcap1 = ext_reg_cap->regcap1;
13008 param->regcap2 = ext_reg_cap->regcap2;
13009 param->wireless_modes = ext_reg_cap->wireless_modes;
13010 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
13011 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
13012 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
13013 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
13014
13015 return QDF_STATUS_SUCCESS;
13016}
13017
Kiran Venkatappafea8a802016-12-29 18:09:32 +053013018/**
13019 * extract_dcs_interference_type_tlv() - extract dcs interference type
13020 * from event
13021 * @wmi_handle: wmi handle
13022 * @param evt_buf: pointer to event buffer
13023 * @param param: Pointer to hold dcs interference param
13024 *
13025 * Return: 0 for success or error code
13026 */
13027static QDF_STATUS extract_dcs_interference_type_tlv(
13028 wmi_unified_t wmi_handle,
13029 void *evt_buf, struct wmi_host_dcs_interference_param *param)
13030{
13031 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
13032
13033 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
13034 if (!param_buf)
13035 return -EINVAL;
13036
13037 param->interference_type = param_buf->fixed_param->interference_type;
13038 param->pdev_id = param_buf->fixed_param->pdev_id;
13039
13040 return QDF_STATUS_SUCCESS;
13041}
13042
13043/*
13044 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
13045 * @wmi_handle: wmi handle
13046 * @param evt_buf: pointer to event buffer
13047 * @param cw_int: Pointer to hold cw interference
13048 *
13049 * Return: 0 for success or error code
13050 */
13051static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
13052 void *evt_buf,
13053 wmi_host_ath_dcs_cw_int *cw_int)
13054{
13055 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
13056 wlan_dcs_cw_int *ev;
13057
13058 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
13059 if (!param_buf)
13060 return -EINVAL;
13061
13062 ev = param_buf->cw_int;
13063
13064 cw_int->channel = ev->channel;
13065
13066 return QDF_STATUS_SUCCESS;
13067}
13068
13069/**
13070 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
13071 * @wmi_handle: wmi handle
13072 * @param evt_buf: pointer to event buffer
13073 * @param wlan_stat: Pointer to hold wlan stats
13074 *
13075 * Return: 0 for success or error code
13076 */
13077static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
13078 void *evt_buf,
13079 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
13080{
13081 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
13082 wlan_dcs_im_tgt_stats_t *ev;
13083
13084 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
13085 if (!param_buf)
13086 return -EINVAL;
13087
13088 ev = param_buf->wlan_stat;
13089 wlan_stat->reg_tsf32 = ev->reg_tsf32;
13090 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
13091 wlan_stat->tx_waste_time = ev->tx_waste_time;
13092 wlan_stat->rx_time = ev->rx_time;
13093 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
13094 wlan_stat->mib_stats.listen_time = ev->listen_time;
13095 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
13096 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
13097 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
13098 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
13099 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
13100 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
13101 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
13102 wlan_stat->chan_nf = ev->chan_nf;
13103 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
13104
13105 return QDF_STATUS_SUCCESS;
13106}
13107
Kiran Venkatappac813ec92016-12-29 22:07:14 +053013108#ifdef BIG_ENDIAN_HOST
13109/**
13110 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
13111 * @param data_len - data length
13112 * @param data - pointer to data
13113 *
13114 * Return: QDF_STATUS - success or error status
13115 */
13116static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
13117{
13118 uint8_t *data_aligned = NULL;
13119 int c;
13120 unsigned char *data_unaligned;
13121
13122 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
13123 FIPS_ALIGN));
13124 /* Assigning unaligned space to copy the data */
13125 /* Checking if kmalloc does succesful allocation */
13126 if (data_unaligned == NULL)
13127 return QDF_STATUS_E_FAILURE;
13128
13129 /* Checking if space is alligned */
13130 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13131 /* align the data space */
13132 data_aligned =
13133 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
13134 } else {
13135 data_aligned = (u_int8_t *)data_unaligned;
13136 }
13137
13138 /* memset and copy content from data to data aligned */
13139 OS_MEMSET(data_aligned, 0, data_len);
13140 OS_MEMCPY(data_aligned, data, data_len);
13141 /* Endianness to LE */
13142 for (c = 0; c < data_len/4; c++) {
13143 *((u_int32_t *)data_aligned + c) =
13144 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
13145 }
13146
13147 /* Copy content to event->data */
13148 OS_MEMCPY(data, data_aligned, data_len);
13149
13150 /* clean up allocated space */
13151 qdf_mem_free(data_unaligned);
13152 data_aligned = NULL;
13153 data_unaligned = NULL;
13154
13155 /*************************************************************/
13156
13157 return QDF_STATUS_SUCCESS;
13158}
13159#else
13160/**
13161 * fips_conv_data_be() - DUMMY for LE platform
13162 *
13163 * Return: QDF_STATUS - success
13164 */
13165static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
13166{
13167 return QDF_STATUS_SUCCESS;
13168}
13169#endif
13170
13171/**
13172 * extract_fips_event_data_tlv() - extract fips event data
13173 * @wmi_handle: wmi handle
13174 * @param evt_buf: pointer to event buffer
13175 * @param param: pointer FIPS event params
13176 *
13177 * Return: 0 for success or error code
13178 */
13179static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
13180 void *evt_buf, struct wmi_host_fips_event_param *param)
13181{
13182 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
13183 wmi_pdev_fips_event_fixed_param *event;
13184
13185 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
13186 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
13187
13188 if (fips_conv_data_be(event->data_len, param_buf->data) !=
13189 QDF_STATUS_SUCCESS)
13190 return QDF_STATUS_E_FAILURE;
13191
13192 param->data = (uint32_t *)param_buf->data;
13193 param->data_len = event->data_len;
13194 param->error_status = event->error_status;
13195
13196 return QDF_STATUS_SUCCESS;
13197}
13198
Govind Singh06c18392016-06-10 10:33:19 +053013199#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhecf03cd2016-05-12 12:45:51 +053013200static bool is_management_record_tlv(uint32_t cmd_id)
13201{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053013202 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053013203 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053013204
Govind Singhecf03cd2016-05-12 12:45:51 +053013205 return false;
13206}
Govind Singh06c18392016-06-10 10:33:19 +053013207#endif
Govind Singhecf03cd2016-05-12 12:45:51 +053013208
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053013209static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
13210{
13211 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
13212
13213 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
13214
13215 switch (set_cmd->param_id) {
13216 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
13217 case WMI_VDEV_PARAM_DTIM_POLICY:
13218 return HTC_TX_PACKET_TAG_AUTO_PM;
13219 default:
13220 break;
13221 }
13222
13223 return 0;
13224}
13225
13226static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
13227{
13228 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
13229
13230 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
13231
13232 switch (ps_cmd->param) {
13233 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
13234 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
13235 case WMI_STA_PS_ENABLE_QPOWER:
13236 return HTC_TX_PACKET_TAG_AUTO_PM;
13237 default:
13238 break;
13239 }
13240
13241 return 0;
13242}
13243
13244static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
13245 uint32_t cmd_id)
13246{
13247 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
13248 return 0;
13249
13250 switch (cmd_id) {
13251 case WMI_VDEV_SET_PARAM_CMDID:
13252 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
13253 case WMI_STA_POWERSAVE_PARAM_CMDID:
13254 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
13255 default:
13256 break;
13257 }
13258
13259 return 0;
13260}
13261
13262static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
13263{
13264 uint16_t tag = 0;
13265
13266 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
13267 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
13268 __func__);
13269 return tag;
13270 }
13271
13272 if (wmi_handle->tag_crash_inject)
13273 tag = HTC_TX_PACKET_TAG_AUTO_PM;
13274
13275 wmi_handle->tag_crash_inject = false;
13276 return tag;
13277}
13278
13279/**
13280 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
13281 * @wmi_handle: WMI handle
13282 * @buf: WMI buffer
13283 * @cmd_id: WMI command Id
13284 *
13285 * Return htc_tx_tag
13286 */
13287static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
13288 wmi_buf_t buf,
13289 uint32_t cmd_id)
13290{
13291 uint16_t htc_tx_tag = 0;
13292
13293 switch (cmd_id) {
13294 case WMI_WOW_ENABLE_CMDID:
13295 case WMI_PDEV_SUSPEND_CMDID:
13296 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
13297 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
13298 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
13299 case WMI_PDEV_RESUME_CMDID:
13300 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
13301 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
13302#ifdef FEATURE_WLAN_D0WOW
13303 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
13304#endif
13305 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
13306 break;
13307 case WMI_FORCE_FW_HANG_CMDID:
13308 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
13309 break;
13310 case WMI_VDEV_SET_PARAM_CMDID:
13311 case WMI_STA_POWERSAVE_PARAM_CMDID:
13312 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
13313 default:
13314 break;
13315 }
13316
13317 return htc_tx_tag;
13318}
13319
Govind Singh5eb51532016-03-09 11:34:12 +053013320struct wmi_ops tlv_ops = {
13321 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
13322 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
13323 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053013324 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
13325 .send_hidden_ssid_vdev_restart_cmd =
13326 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053013327 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
13328 .send_peer_param_cmd = send_peer_param_cmd_tlv,
13329 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053013330 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053013331 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053013332 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070013333 .send_peer_rx_reorder_queue_setup_cmd =
13334 send_peer_rx_reorder_queue_setup_cmd_tlv,
13335 .send_peer_rx_reorder_queue_remove_cmd =
13336 send_peer_rx_reorder_queue_remove_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053013337 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
13338 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
13339 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
13340 .send_suspend_cmd = send_suspend_cmd_tlv,
13341 .send_resume_cmd = send_resume_cmd_tlv,
13342 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
13343 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
13344 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
13345 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
13346 .send_dbglog_cmd = send_dbglog_cmd_tlv,
13347 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
13348 .send_stats_request_cmd = send_stats_request_cmd_tlv,
13349 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
13350 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013351#ifndef CONFIG_MCL
13352 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
13353#endif
Govind Singh5eb51532016-03-09 11:34:12 +053013354 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
13355 .send_scan_start_cmd = send_scan_start_cmd_tlv,
13356 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
13357 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053013358 .send_mgmt_cmd = send_mgmt_cmd_tlv,
13359 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
13360 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013361 .send_set_sta_uapsd_auto_trig_cmd =
13362 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053013363 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
13364 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
13365 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
13366 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
13367 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053013368 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
13369 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
13370 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
13371 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
13372 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
13373 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
13374 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013375 .send_ocb_start_timing_advert_cmd =
13376 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053013377 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
13378 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
13379 .send_set_mcc_channel_time_latency_cmd =
13380 send_set_mcc_channel_time_latency_cmd_tlv,
13381 .send_set_mcc_channel_time_quota_cmd =
13382 send_set_mcc_channel_time_quota_cmd_tlv,
13383 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
13384 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053013385 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013386 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
13387 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
13388 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013389 .send_probe_rsp_tmpl_send_cmd =
13390 send_probe_rsp_tmpl_send_cmd_tlv,
13391 .send_p2p_go_set_beacon_ie_cmd =
13392 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053013393 .send_setup_install_key_cmd =
13394 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013395 .send_set_gateway_params_cmd =
13396 send_set_gateway_params_cmd_tlv,
13397 .send_set_rssi_monitoring_cmd =
13398 send_set_rssi_monitoring_cmd_tlv,
13399 .send_scan_probe_setoui_cmd =
13400 send_scan_probe_setoui_cmd_tlv,
13401 .send_reset_passpoint_network_list_cmd =
13402 send_reset_passpoint_network_list_cmd_tlv,
13403 .send_set_passpoint_network_list_cmd =
13404 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053013405 .send_roam_scan_offload_rssi_thresh_cmd =
13406 send_roam_scan_offload_rssi_thresh_cmd_tlv,
13407 .send_roam_scan_filter_cmd =
13408 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013409 .send_set_epno_network_list_cmd =
13410 send_set_epno_network_list_cmd_tlv,
13411 .send_ipa_offload_control_cmd =
13412 send_ipa_offload_control_cmd_tlv,
13413 .send_extscan_get_capabilities_cmd =
13414 send_extscan_get_capabilities_cmd_tlv,
13415 .send_extscan_get_cached_results_cmd =
13416 send_extscan_get_cached_results_cmd_tlv,
13417 .send_extscan_stop_change_monitor_cmd =
13418 send_extscan_stop_change_monitor_cmd_tlv,
13419 .send_extscan_start_change_monitor_cmd =
13420 send_extscan_start_change_monitor_cmd_tlv,
13421 .send_extscan_stop_hotlist_monitor_cmd =
13422 send_extscan_stop_hotlist_monitor_cmd_tlv,
13423 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
13424 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
13425 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
13426 .send_plm_start_cmd = send_plm_start_cmd_tlv,
13427 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013428#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053013429 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013430#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053013431 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
13432 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
13433 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
13434 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
13435 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053013436 .send_snr_request_cmd = send_snr_request_cmd_tlv,
13437 .send_snr_cmd = send_snr_cmd_tlv,
13438 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013439#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053013440 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
13441 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
13442 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
13443 .send_lphb_config_udp_pkt_filter_cmd =
13444 send_lphb_config_udp_pkt_filter_cmd_tlv,
13445 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
13446 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
13447 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Paul Zhangd19abd82017-01-04 16:45:42 +080013448 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013449 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
13450 .send_process_update_edca_param_cmd =
13451 send_process_update_edca_param_cmd_tlv,
13452 .send_roam_scan_offload_mode_cmd =
13453 send_roam_scan_offload_mode_cmd_tlv,
13454 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
13455 .send_roam_scan_offload_ap_profile_cmd =
13456 send_roam_scan_offload_ap_profile_cmd_tlv,
13457#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053013458 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
13459 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013460#ifdef FEATURE_WLAN_RA_FILTERING
Govind Singh20c5dac2016-03-07 15:33:31 +053013461 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013462#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053013463 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
13464 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
13465 .send_dfs_phyerr_filter_offload_en_cmd =
13466 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053013467 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
13468 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
13469 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
13470 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
13471 .send_del_ts_cmd = send_del_ts_cmd_tlv,
13472 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
13473 .send_add_ts_cmd = send_add_ts_cmd_tlv,
13474 .send_enable_disable_packet_filter_cmd =
13475 send_enable_disable_packet_filter_cmd_tlv,
13476 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
13477 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
13478 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
13479 .send_process_gtk_offload_getinfo_cmd =
13480 send_process_gtk_offload_getinfo_cmd_tlv,
13481 .send_process_add_periodic_tx_ptrn_cmd =
13482 send_process_add_periodic_tx_ptrn_cmd_tlv,
13483 .send_process_del_periodic_tx_ptrn_cmd =
13484 send_process_del_periodic_tx_ptrn_cmd_tlv,
13485 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
13486 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
13487 .send_set_app_type2_params_in_fw_cmd =
13488 send_set_app_type2_params_in_fw_cmd_tlv,
13489 .send_set_auto_shutdown_timer_cmd =
13490 send_set_auto_shutdown_timer_cmd_tlv,
13491 .send_nan_req_cmd = send_nan_req_cmd_tlv,
13492 .send_process_dhcpserver_offload_cmd =
13493 send_process_dhcpserver_offload_cmd_tlv,
13494 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
13495 .send_process_ch_avoid_update_cmd =
13496 send_process_ch_avoid_update_cmd_tlv,
13497 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
13498 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
13499 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
13500 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
13501 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
13502 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053013503#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053013504 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053013505#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053013506 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053013507 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053013508 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053013509 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053013510 .send_set_base_macaddr_indicate_cmd =
13511 send_set_base_macaddr_indicate_cmd_tlv,
13512 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
13513 .send_enable_specific_fw_logs_cmd =
13514 send_enable_specific_fw_logs_cmd_tlv,
13515 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013516 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013517 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013518 .send_pdev_set_dual_mac_config_cmd =
13519 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053013520 .send_enable_arp_ns_offload_cmd =
13521 send_enable_arp_ns_offload_cmd_tlv,
13522 .send_app_type1_params_in_fw_cmd =
13523 send_app_type1_params_in_fw_cmd_tlv,
13524 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
13525 .send_process_roam_synch_complete_cmd =
13526 send_process_roam_synch_complete_cmd_tlv,
13527 .send_unit_test_cmd = send_unit_test_cmd_tlv,
13528 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
13529 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053013530 .send_roam_scan_offload_scan_period_cmd =
13531 send_roam_scan_offload_scan_period_cmd_tlv,
13532 .send_roam_scan_offload_chan_list_cmd =
13533 send_roam_scan_offload_chan_list_cmd_tlv,
13534 .send_roam_scan_offload_rssi_change_cmd =
13535 send_roam_scan_offload_rssi_change_cmd_tlv,
13536 .send_get_buf_extscan_hotlist_cmd =
13537 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053013538 .send_adapt_dwelltime_params_cmd =
13539 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053013540 .init_cmd_send = init_cmd_send_tlv,
13541 .get_target_cap_from_service_ready = extract_service_ready_tlv,
13542 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
13543 .extract_host_mem_req = extract_host_mem_req_tlv,
13544 .save_service_bitmap = save_service_bitmap_tlv,
13545 .is_service_enabled = is_service_enabled_tlv,
13546 .save_fw_version = save_fw_version_in_service_ready_tlv,
13547 .ready_extract_init_status = ready_extract_init_status_tlv,
13548 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
13549 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
13550 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
13551 .extract_tbttoffset_update_params =
13552 extract_tbttoffset_update_params_tlv,
13553 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
13554 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
13555 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
13556 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
13557 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
13558 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
13559 .extract_swba_tim_info = extract_swba_tim_info_tlv,
13560 .extract_swba_noa_info = extract_swba_noa_info_tlv,
13561 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
13562 .extract_all_stats_count = extract_all_stats_counts_tlv,
13563 .extract_pdev_stats = extract_pdev_stats_tlv,
13564 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
13565 .extract_vdev_stats = extract_vdev_stats_tlv,
13566 .extract_peer_stats = extract_peer_stats_tlv,
13567 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
13568 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
13569 .extract_chan_stats = extract_chan_stats_tlv,
13570 .extract_profile_ctx = extract_profile_ctx_tlv,
13571 .extract_profile_data = extract_profile_data_tlv,
13572 .extract_chan_info_event = extract_chan_info_event_tlv,
13573 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053013574 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053013575 .send_encrypt_decrypt_send_cmd =
13576 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080013577 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053013578 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053013579 .extract_service_ready_ext = extract_service_ready_ext_tlv,
13580 .extract_hw_mode_cap_service_ready_ext =
13581 extract_hw_mode_cap_service_ready_ext_tlv,
13582 .extract_mac_phy_cap_service_ready_ext =
13583 extract_mac_phy_cap_service_ready_ext_tlv,
13584 .extract_reg_cap_service_ready_ext =
13585 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053013586 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053013587 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053013588 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
13589 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
13590 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053013591 .extract_fips_event_data = extract_fips_event_data_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053013592};
13593
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013594#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013595/**
13596 * populate_tlv_service() - populates wmi services
13597 *
13598 * @param wmi_service: Pointer to hold wmi_service
13599 * Return: None
13600 */
13601static void populate_tlv_service(uint32_t *wmi_service)
13602{
13603 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
13604 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
13605 wmi_service[wmi_service_roam_scan_offload] =
13606 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
13607 wmi_service[wmi_service_bcn_miss_offload] =
13608 WMI_SERVICE_BCN_MISS_OFFLOAD;
13609 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
13610 wmi_service[wmi_service_sta_advanced_pwrsave] =
13611 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
13612 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
13613 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
13614 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
13615 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
13616 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
13617 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
13618 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
13619 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
13620 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
13621 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
13622 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
13623 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
13624 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
13625 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
13626 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
13627 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
13628 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
13629 wmi_service[wmi_service_packet_power_save] =
13630 WMI_SERVICE_PACKET_POWER_SAVE;
13631 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
13632 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
13633 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
13634 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
13635 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
13636 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
13637 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
13638 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
13639 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
13640 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
13641 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
13642 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
13643 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
13644 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
13645 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
13646 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
13647 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
13648 wmi_service[wmi_service_mcc_bcn_interval_change] =
13649 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
13650 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
13651 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
13652 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
13653 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
13654 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
13655 wmi_service[wmi_service_lte_ant_share_support] =
13656 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
13657 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
13658 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
13659 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
13660 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
13661 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
13662 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
13663 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
13664 wmi_service[wmi_service_bcn_txrate_override] =
13665 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
13666 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
13667 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
13668 wmi_service[wmi_service_estimate_linkspeed] =
13669 WMI_SERVICE_ESTIMATE_LINKSPEED;
13670 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
13671 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
13672 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
13673 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
13674 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
13675 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
13676 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
13677 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
13678 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
13679 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
13680 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
13681 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
13682 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
13683 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
13684 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
13685 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
13686 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
13687 wmi_service[wmi_service_sap_auth_offload] =
13688 WMI_SERVICE_SAP_AUTH_OFFLOAD;
13689 wmi_service[wmi_service_dual_band_simultaneous_support] =
13690 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
13691 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
13692 wmi_service[wmi_service_ap_arpns_offload] =
13693 WMI_SERVICE_AP_ARPNS_OFFLOAD;
13694 wmi_service[wmi_service_per_band_chainmask_support] =
13695 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
13696 wmi_service[wmi_service_packet_filter_offload] =
13697 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
13698 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
13699 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
13700 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
13701 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
13702
13703 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
13704 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
13705 wmi_service[wmi_service_smart_antenna_sw_support] =
13706 WMI_SERVICE_UNAVAILABLE;
13707 wmi_service[wmi_service_smart_antenna_hw_support] =
13708 WMI_SERVICE_UNAVAILABLE;
13709 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
13710 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
13711 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
13712 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
13713 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
13714 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
13715 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
13716 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
13717 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
13718 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
13719 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
13720
13721 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
13722 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
13723 wmi_service[wmi_service_periodic_chan_stat_support] =
13724 WMI_SERVICE_UNAVAILABLE;
13725 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
13726 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
13727 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
Sathish Kumar699f6b52016-11-10 15:30:22 +053013728 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053013729}
13730
13731/**
13732 * populate_tlv_event_id() - populates wmi event ids
13733 *
13734 * @param event_ids: Pointer to hold event ids
13735 * Return: None
13736 */
13737static void populate_tlv_events_id(uint32_t *event_ids)
13738{
13739 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
13740 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
13741 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
13742 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
13743 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
13744 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
13745 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
13746 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
13747 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
13748 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
13749 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
13750 event_ids[wmi_service_ready_ext_event_id] =
13751 WMI_SERVICE_READY_EXT_EVENTID;
13752 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
13753 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
13754 event_ids[wmi_vdev_install_key_complete_event_id] =
13755 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
13756 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
13757 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
13758
13759 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
13760 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
13761 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
13762 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
13763 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
13764 event_ids[wmi_peer_estimated_linkspeed_event_id] =
13765 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
13766 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
13767 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
13768 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
13769 event_ids[wmi_tbttoffset_update_event_id] =
13770 WMI_TBTTOFFSET_UPDATE_EVENTID;
13771 event_ids[wmi_offload_bcn_tx_status_event_id] =
13772 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
13773 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
13774 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
13775 event_ids[wmi_mgmt_tx_completion_event_id] =
13776 WMI_MGMT_TX_COMPLETION_EVENTID;
13777
13778 event_ids[wmi_tx_delba_complete_event_id] =
13779 WMI_TX_DELBA_COMPLETE_EVENTID;
13780 event_ids[wmi_tx_addba_complete_event_id] =
13781 WMI_TX_ADDBA_COMPLETE_EVENTID;
13782 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
13783
13784 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
13785
13786 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
13787 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
13788
13789 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
13790
13791 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
13792
13793 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
13794
13795 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
13796 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
13797 event_ids[wmi_do_wow_disable_ack_event_id] =
13798 WMI_D0_WOW_DISABLE_ACK_EVENTID;
13799 event_ids[wmi_wow_initial_wakeup_event_id] =
13800 WMI_WOW_INITIAL_WAKEUP_EVENTID;
13801
13802 event_ids[wmi_rtt_meas_report_event_id] =
13803 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
13804 event_ids[wmi_tsf_meas_report_event_id] =
13805 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
13806 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
13807 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
13808 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
13809 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
13810 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
13811 event_ids[wmi_update_fw_mem_dump_event_id] =
13812 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
13813 event_ids[wmi_diag_event_id_log_supported_event_id] =
13814 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
13815 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
13816 event_ids[wmi_nlo_scan_complete_event_id] =
13817 WMI_NLO_SCAN_COMPLETE_EVENTID;
13818 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
13819 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
13820
13821 event_ids[wmi_gtk_offload_status_event_id] =
13822 WMI_GTK_OFFLOAD_STATUS_EVENTID;
13823 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
13824 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
13825 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
13826
13827 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
13828
13829 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
13830
13831 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
13832 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
13833 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
13834 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
13835 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
13836 event_ids[wmi_wlan_profile_data_event_id] =
13837 WMI_WLAN_PROFILE_DATA_EVENTID;
13838 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
13839 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
13840 event_ids[wmi_vdev_get_keepalive_event_id] =
13841 WMI_VDEV_GET_KEEPALIVE_EVENTID;
13842 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
13843
13844 event_ids[wmi_diag_container_event_id] =
13845 WMI_DIAG_DATA_CONTAINER_EVENTID;
13846
13847 event_ids[wmi_host_auto_shutdown_event_id] =
13848 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
13849
13850 event_ids[wmi_update_whal_mib_stats_event_id] =
13851 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
13852
13853 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
13854 event_ids[wmi_update_vdev_rate_stats_event_id] =
13855 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
13856
13857 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
13858
13859 /** Set OCB Sched Response, deprecated */
13860 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
13861
13862 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
13863 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
13864 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
13865
13866 /* GPIO Event */
13867 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
13868 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
13869
13870 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
13871 event_ids[wmi_rfkill_state_change_event_id] =
13872 WMI_RFKILL_STATE_CHANGE_EVENTID;
13873
13874 /* TDLS Event */
13875 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
13876
13877 event_ids[wmi_batch_scan_enabled_event_id] =
13878 WMI_BATCH_SCAN_ENABLED_EVENTID;
13879 event_ids[wmi_batch_scan_result_event_id] =
13880 WMI_BATCH_SCAN_RESULT_EVENTID;
13881 /* OEM Event */
13882 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
13883 event_ids[wmi_oem_meas_report_event_id] =
13884 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
13885 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
13886
13887 /* NAN Event */
13888 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
13889
13890 /* LPI Event */
13891 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
13892 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
13893 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
13894
13895 /* ExtScan events */
13896 event_ids[wmi_extscan_start_stop_event_id] =
13897 WMI_EXTSCAN_START_STOP_EVENTID;
13898 event_ids[wmi_extscan_operation_event_id] =
13899 WMI_EXTSCAN_OPERATION_EVENTID;
13900 event_ids[wmi_extscan_table_usage_event_id] =
13901 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
13902 event_ids[wmi_extscan_cached_results_event_id] =
13903 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
13904 event_ids[wmi_extscan_wlan_change_results_event_id] =
13905 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
13906 event_ids[wmi_extscan_hotlist_match_event_id] =
13907 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
13908 event_ids[wmi_extscan_capabilities_event_id] =
13909 WMI_EXTSCAN_CAPABILITIES_EVENTID;
13910 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
13911 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
13912
13913 /* mDNS offload events */
13914 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
13915
13916 /* SAP Authentication offload events */
13917 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
13918 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
13919
13920 /** Out-of-context-of-bss (OCB) events */
13921 event_ids[wmi_ocb_set_config_resp_event_id] =
13922 WMI_OCB_SET_CONFIG_RESP_EVENTID;
13923 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
13924 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
13925 event_ids[wmi_dcc_get_stats_resp_event_id] =
13926 WMI_DCC_GET_STATS_RESP_EVENTID;
13927 event_ids[wmi_dcc_update_ndl_resp_event_id] =
13928 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
13929 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
13930 /* System-On-Chip events */
13931 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
13932 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
13933 event_ids[wmi_soc_hw_mode_transition_event_id] =
13934 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
13935 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
13936 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
13937}
13938
13939/**
13940 * populate_pdev_param_tlv() - populates pdev params
13941 *
13942 * @param pdev_param: Pointer to hold pdev params
13943 * Return: None
13944 */
13945static void populate_pdev_param_tlv(uint32_t *pdev_param)
13946{
13947 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
13948 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
13949 pdev_param[wmi_pdev_param_txpower_limit2g] =
13950 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
13951 pdev_param[wmi_pdev_param_txpower_limit5g] =
13952 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
13953 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
13954 pdev_param[wmi_pdev_param_beacon_gen_mode] =
13955 WMI_PDEV_PARAM_BEACON_GEN_MODE;
13956 pdev_param[wmi_pdev_param_beacon_tx_mode] =
13957 WMI_PDEV_PARAM_BEACON_TX_MODE;
13958 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
13959 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
13960 pdev_param[wmi_pdev_param_protection_mode] =
13961 WMI_PDEV_PARAM_PROTECTION_MODE;
13962 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
13963 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
13964 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
13965 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
13966 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
13967 pdev_param[wmi_pdev_param_sta_kickout_th] =
13968 WMI_PDEV_PARAM_STA_KICKOUT_TH;
13969 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
13970 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
13971 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
13972 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
13973 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
13974 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
13975 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
13976 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
13977 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
13978 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
13979 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
13980 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
13981 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
13982 pdev_param[wmi_pdev_param_ltr_sleep_override] =
13983 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
13984 pdev_param[wmi_pdev_param_ltr_rx_override] =
13985 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
13986 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
13987 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
13988 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
13989 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
13990 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
13991 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
13992 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
13993 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
13994 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
13995 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
13996 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
13997 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
13998 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
13999 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
14000 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
14001 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
14002 pdev_param[wmi_pdev_param_peer_stats_update_period] =
14003 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
14004 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
14005 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
14006 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
14007 pdev_param[wmi_pdev_param_arp_ac_override] =
14008 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
14009 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
14010 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
14011 pdev_param[wmi_pdev_param_ani_poll_period] =
14012 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
14013 pdev_param[wmi_pdev_param_ani_listen_period] =
14014 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
14015 pdev_param[wmi_pdev_param_ani_ofdm_level] =
14016 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
14017 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
14018 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
14019 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
14020 pdev_param[wmi_pdev_param_idle_ps_config] =
14021 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
14022 pdev_param[wmi_pdev_param_power_gating_sleep] =
14023 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
14024 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
14025 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
14026 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
14027 pdev_param[wmi_pdev_param_hw_rfkill_config] =
14028 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
14029 pdev_param[wmi_pdev_param_low_power_rf_enable] =
14030 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
14031 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
14032 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
14033 pdev_param[wmi_pdev_param_power_collapse_enable] =
14034 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
14035 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
14036 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
14037 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
14038 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
14039 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
14040 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
14041 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
14042 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
14043 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
14044 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
14045 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
14046 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
14047 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
14048 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
14049 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
14050 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
14051 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
14052 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
14053 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
14054 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
14055 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
14056 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
14057 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
14058 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
14059 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
14060 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
14061 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
14062 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
14063 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
14064 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
14065 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
14066 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
14067 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
14068 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
14069 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
14070 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
14071 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
14072 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
14073 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
14074 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
14075 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
14076 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
14077 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
14078 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
14079 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
14080 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
14081 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
14082 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
14083 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
14084 WMI_UNAVAILABLE_PARAM;
14085 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
14086 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
14087 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
14088 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
14089 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
14090 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
14091 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
14092 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
14093 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
14094 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
14095 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
14096 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
14097 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
14098 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
14099 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
14100 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
14101 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
14102 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
14103 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
14104 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
14105 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
14106 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
14107 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
14108 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
14109 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
14110 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
14111 WMI_UNAVAILABLE_PARAM;
14112 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
14113 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
14114 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
14115 WMI_UNAVAILABLE_PARAM;
14116 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
14117 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
14118 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
14119 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
14120 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
14121 WMI_UNAVAILABLE_PARAM;
14122 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
14123 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
14124 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053014125 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
14126 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053014127 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
14128}
14129
14130/**
14131 * populate_vdev_param_tlv() - populates vdev params
14132 *
14133 * @param vdev_param: Pointer to hold vdev params
14134 * Return: None
14135 */
14136static void populate_vdev_param_tlv(uint32_t *vdev_param)
14137{
14138 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
14139 vdev_param[wmi_vdev_param_fragmentation_threshold] =
14140 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
14141 vdev_param[wmi_vdev_param_beacon_interval] =
14142 WMI_VDEV_PARAM_BEACON_INTERVAL;
14143 vdev_param[wmi_vdev_param_listen_interval] =
14144 WMI_VDEV_PARAM_LISTEN_INTERVAL;
14145 vdev_param[wmi_vdev_param_multicast_rate] =
14146 WMI_VDEV_PARAM_MULTICAST_RATE;
14147 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
14148 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
14149 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
14150 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
14151 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
14152 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
14153 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
14154 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
14155 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
14156 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
14157 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
14158 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
14159 vdev_param[wmi_vdev_param_bmiss_count_max] =
14160 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
14161 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
14162 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
14163 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
14164 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
14165 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
14166 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
14167 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
14168 vdev_param[wmi_vdev_param_disable_htprotection] =
14169 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
14170 vdev_param[wmi_vdev_param_sta_quickkickout] =
14171 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
14172 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
14173 vdev_param[wmi_vdev_param_protection_mode] =
14174 WMI_VDEV_PARAM_PROTECTION_MODE;
14175 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
14176 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
14177 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
14178 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
14179 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
14180 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
14181 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
14182 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
14183 vdev_param[wmi_vdev_param_bcast_data_rate] =
14184 WMI_VDEV_PARAM_BCAST_DATA_RATE;
14185 vdev_param[wmi_vdev_param_mcast_data_rate] =
14186 WMI_VDEV_PARAM_MCAST_DATA_RATE;
14187 vdev_param[wmi_vdev_param_mcast_indicate] =
14188 WMI_VDEV_PARAM_MCAST_INDICATE;
14189 vdev_param[wmi_vdev_param_dhcp_indicate] =
14190 WMI_VDEV_PARAM_DHCP_INDICATE;
14191 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
14192 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
14193 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
14194 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
14195 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
14196 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
14197 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
14198 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
14199 vdev_param[wmi_vdev_param_ap_enable_nawds] =
14200 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
14201 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
14202 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
14203 vdev_param[wmi_vdev_param_packet_powersave] =
14204 WMI_VDEV_PARAM_PACKET_POWERSAVE;
14205 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
14206 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
14207 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
14208 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
14209 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
14210 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
14211 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
14212 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
14213 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
14214 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
14215 vdev_param[wmi_vdev_param_early_rx_slop_step] =
14216 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
14217 vdev_param[wmi_vdev_param_early_rx_init_slop] =
14218 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
14219 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
14220 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
14221 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
14222 vdev_param[wmi_vdev_param_snr_num_for_cal] =
14223 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
14224 vdev_param[wmi_vdev_param_roam_fw_offload] =
14225 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
14226 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
14227 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
14228 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
14229 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
14230 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
14231 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
14232 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
14233 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
14234 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
14235 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
14236 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
14237 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
14238 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
14239 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
14240 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
14241 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
14242 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
14243 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
14244 vdev_param[wmi_vdev_param_inactivity_cnt] =
14245 WMI_VDEV_PARAM_INACTIVITY_CNT;
14246 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
14247 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
14248 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
14249 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
14250 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
14251 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
14252 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
14253 vdev_param[wmi_vdev_param_rx_leak_window] =
14254 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
14255 vdev_param[wmi_vdev_param_stats_avg_factor] =
14256 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
14257 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
14258 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
14259 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
14260 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
14261 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
14262 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053014263 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
14264 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053014265}
14266#endif
14267
Govind Singh5eb51532016-03-09 11:34:12 +053014268/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +053014269 * wmi_tlv_attach() - Attach TLV APIs
Govind Singh5eb51532016-03-09 11:34:12 +053014270 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053014271 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053014272 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053014273#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014274void wmi_tlv_attach(wmi_unified_t wmi_handle)
14275{
14276 wmi_handle->ops = &tlv_ops;
14277#ifdef WMI_INTERFACE_EVENT_LOGGING
14278 wmi_handle->log_info.buf_offset_command = 2;
14279 wmi_handle->log_info.buf_offset_event = 4;
14280 wmi_handle->log_info.is_management_record =
14281 is_management_record_tlv;
14282#endif
14283 populate_tlv_service(wmi_handle->services);
14284 populate_tlv_events_id(wmi_handle->wmi_events);
14285 populate_pdev_param_tlv(wmi_handle->pdev_param);
14286 populate_vdev_param_tlv(wmi_handle->vdev_param);
14287}
14288#else
Govind Singhe7d9f3e2016-04-15 13:58:27 +053014289void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053014290{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053014291 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053014292#ifdef WMI_INTERFACE_EVENT_LOGGING
14293 wmi_handle->log_info.buf_offset_command = 2;
14294 wmi_handle->log_info.buf_offset_event = 4;
14295 wmi_handle->log_info.is_management_record =
14296 is_management_record_tlv;
14297#endif
Govind Singh5eb51532016-03-09 11:34:12 +053014298}
Govind Singhe7f2f342016-05-23 12:12:52 +053014299#endif