blob: 8aa3a702c9abee7ea13227b45fe53f2233113e2d [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
Govind Singh5eb51532016-03-09 11:34:12 +053028#include "wmi_unified_api.h"
29#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053030#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053031#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053032#include "wmi_version_whitelist.h"
Govind Singh5eb51532016-03-09 11:34:12 +053033
34/**
35 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
36 * @wmi_handle: wmi handle
37 * @param: pointer to hold vdev create parameter
38 * @macaddr: vdev mac address
39 *
Govind Singhe7f2f342016-05-23 12:12:52 +053040 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053041 */
Sathish Kumarfd347372017-02-13 12:29:09 +053042static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053043 uint8_t macaddr[IEEE80211_ADDR_LEN],
44 struct vdev_create_params *param)
45{
46 wmi_vdev_create_cmd_fixed_param *cmd;
47 wmi_buf_t buf;
48 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053049 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070050 int num_bands = 2;
51 uint8_t *buf_ptr;
52 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053053
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070054 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053055 buf = wmi_buf_alloc(wmi_handle, len);
56 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053057 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053058 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053059 }
60 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
61 WMITLV_SET_HDR(&cmd->tlv_header,
62 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
63 WMITLV_GET_STRUCT_TLVLEN
64 (wmi_vdev_create_cmd_fixed_param));
65 cmd->vdev_id = param->if_id;
66 cmd->vdev_type = param->type;
67 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070068 cmd->num_cfg_txrx_streams = num_bands;
Govind Singh4df47142016-04-16 19:24:23 -070069 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +053070 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +053071 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +053072 __func__, param->if_id,
73 macaddr[0], macaddr[1], macaddr[2],
74 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070075 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
76 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
77 (num_bands * sizeof(wmi_vdev_txrx_streams)));
78 buf_ptr += WMI_TLV_HDR_SIZE;
79
Govind Singh224a7312016-06-21 14:33:26 +053080 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070081 param->type, param->subtype,
82 param->nss_2g, param->nss_5g);
83 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
84 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
85 txrx_streams->supported_tx_streams = param->nss_2g;
86 txrx_streams->supported_rx_streams = param->nss_2g;
87 WMITLV_SET_HDR(&txrx_streams->tlv_header,
88 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
89 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
90
91 txrx_streams++;
92 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
93 txrx_streams->supported_tx_streams = param->nss_5g;
94 txrx_streams->supported_rx_streams = param->nss_5g;
95 WMITLV_SET_HDR(&txrx_streams->tlv_header,
96 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
97 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +053098 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053099 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530100 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530101 wmi_buf_free(buf);
102 }
103
104 return ret;
105}
106
107/**
108 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
109 * @wmi_handle: wmi handle
110 * @if_id: vdev id
111 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530112 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530113 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530114static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530115 uint8_t if_id)
116{
117 wmi_vdev_delete_cmd_fixed_param *cmd;
118 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530119 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530120
121 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
122 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530123 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530124 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530125 }
126
127 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
128 WMITLV_SET_HDR(&cmd->tlv_header,
129 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
130 WMITLV_GET_STRUCT_TLVLEN
131 (wmi_vdev_delete_cmd_fixed_param));
132 cmd->vdev_id = if_id;
133 ret = wmi_unified_cmd_send(wmi_handle, buf,
134 sizeof(wmi_vdev_delete_cmd_fixed_param),
135 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530136 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530137 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530138 wmi_buf_free(buf);
139 }
Govind Singhb53420c2016-03-09 14:32:57 +0530140 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530141
142 return ret;
143}
144
145/**
146 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
147 * @wmi: wmi handle
148 * @vdev_id: vdev id
149 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530150 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530151 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530152static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530153 uint8_t vdev_id)
154{
155 wmi_vdev_stop_cmd_fixed_param *cmd;
156 wmi_buf_t buf;
157 int32_t len = sizeof(*cmd);
158
159 buf = wmi_buf_alloc(wmi, len);
160 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530161 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530162 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530163 }
164 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
165 WMITLV_SET_HDR(&cmd->tlv_header,
166 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
167 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
168 cmd->vdev_id = vdev_id;
169 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530170 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530171 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530172 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530173 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530174 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530175
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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530186static QDF_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
Naveen Rawat44f2f432016-12-01 12:58:57 -0800230 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530231 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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530275static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530276 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));
Naveen Rawat44f2f432016-12-01 12:58:57 -0800337 WMI_LOGA("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x 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",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800341 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530342 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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530369static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530370 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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530441static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530482static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530607static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530654static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530695static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530825static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530866static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530972static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301022static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301066static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301100static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301148static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301189static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301229static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301269 static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301348static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301398static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301439static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301440 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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301453static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301469static QDF_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
Sathish Kumarfd347372017-02-13 12:29:09 +05301518static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301519 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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301531static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301532 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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301694static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301863static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302002static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302047static QDF_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
Sathish Kumarfd347372017-02-13 12:29:09 +05302116static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302117 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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302216static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302284static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302323static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302366static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302429static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302473static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302541static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302586static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302638static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302701static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302748static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302811static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302853static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302897static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302972static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303021static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303126static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303335static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303383static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303455static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303541static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303593static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303673static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303674 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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303737static QDF_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
Sathish Kumarfd347372017-02-13 12:29:09 +05303783static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303832static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303908static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303961static QDF_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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304021static QDF_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
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304086#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304087#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 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304128static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304129 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
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304156
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304157 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4158 cmd->key_flags |= key_params->key_flags;
4159 cmd->key_cipher = key_params->key_cipher;
4160 if ((key_params->key_txmic_len) &&
4161 (key_params->key_rxmic_len)) {
4162 cmd->key_txmic_len = key_params->key_txmic_len;
4163 cmd->key_rxmic_len = key_params->key_rxmic_len;
4164 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304165#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304166 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4167 key_params->tx_iv,
4168 cmd->wpi_key_rsc_counter,
4169 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304170#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304171 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4172 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4173 roundup(key_params->key_len, sizeof(uint32_t)));
4174 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4175 qdf_mem_copy((void *)key_data,
4176 (const void *)key_params->key_data, key_params->key_len);
4177 cmd->key_len = key_params->key_len;
4178
4179 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4180 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304181 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304182 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304183
Govind Singh67922e82016-04-01 16:48:57 +05304184 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304185}
4186
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304187/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004188 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4189 * @wmi_handle: wmi handle
4190 * @params: sar limit params
4191 *
4192 * Return: QDF_STATUS_SUCCESS for success or error code
4193 */
4194static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4195 struct sar_limit_cmd_params *sar_limit_params)
4196{
4197 wmi_buf_t buf;
4198 QDF_STATUS qdf_status;
4199 wmi_sar_limits_cmd_fixed_param *cmd;
4200 int i;
4201 uint8_t *buf_ptr;
4202 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4203 struct sar_limit_cmd_row *sar_rows_list;
4204 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4205
4206 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4207 buf = wmi_buf_alloc(wmi_handle, len);
4208 if (!buf) {
4209 WMI_LOGE("Failed to allocate memory");
4210 qdf_status = QDF_STATUS_E_NOMEM;
4211 goto end;
4212 }
4213
4214 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4215 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4216 WMITLV_SET_HDR(&cmd->tlv_header,
4217 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4218 WMITLV_GET_STRUCT_TLVLEN
4219 (wmi_sar_limits_cmd_fixed_param));
4220 cmd->sar_enable = sar_limit_params->sar_enable;
4221 cmd->commit_limits = sar_limit_params->commit_limits;
4222 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4223
4224 WMI_LOGD("no of sar rows = %d, len = %d",
4225 sar_limit_params->num_limit_rows, len);
4226 buf_ptr += sizeof(*cmd);
4227 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4228 sizeof(wmi_sar_limit_cmd_row) *
4229 sar_limit_params->num_limit_rows);
4230 if (cmd->num_limit_rows == 0)
4231 goto send_sar_limits;
4232
4233 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4234 (buf_ptr + WMI_TLV_HDR_SIZE);
4235 sar_rows_list = sar_limit_params->sar_limit_row_list;
4236
4237 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4238 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4239 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4240 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4241 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4242 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4243 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4244 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4245 wmi_sar_rows_list->validity_bitmap =
4246 sar_rows_list->validity_bitmap;
4247 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4248 i, wmi_sar_rows_list->band_id,
4249 wmi_sar_rows_list->chain_id,
4250 wmi_sar_rows_list->mod_id,
4251 wmi_sar_rows_list->limit_value,
4252 wmi_sar_rows_list->validity_bitmap);
4253 sar_rows_list++;
4254 wmi_sar_rows_list++;
4255 }
4256send_sar_limits:
4257 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4258 WMI_SAR_LIMITS_CMDID);
4259
4260 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4261 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4262 wmi_buf_free(buf);
4263 }
4264
4265end:
4266 return qdf_status;
4267}
4268
4269/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304270 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4271 * @wmi_handle: wmi handle
4272 * @params: encrypt/decrypt params
4273 *
4274 * Return: QDF_STATUS_SUCCESS for success or error code
4275 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004276static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304277QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4278 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4279{
4280 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4281 wmi_buf_t wmi_buf;
4282 uint8_t *buf_ptr;
4283 QDF_STATUS ret;
4284 uint32_t len;
4285
4286 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4287
4288 len = sizeof(*cmd) +
4289 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4290 WMI_TLV_HDR_SIZE;
4291 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4292 if (!wmi_buf) {
4293 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4294 __func__);
4295 return QDF_STATUS_E_NOMEM;
4296 }
4297
4298 buf_ptr = wmi_buf_data(wmi_buf);
4299 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4300
4301 WMITLV_SET_HDR(&cmd->tlv_header,
4302 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4303 WMITLV_GET_STRUCT_TLVLEN(
4304 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4305
4306 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4307 cmd->key_flag = encrypt_decrypt_params->key_flag;
4308 cmd->key_idx = encrypt_decrypt_params->key_idx;
4309 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4310 cmd->key_len = encrypt_decrypt_params->key_len;
4311 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4312 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4313
4314 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4315 encrypt_decrypt_params->key_len);
4316
4317 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4318 MAX_MAC_HEADER_LEN);
4319
4320 cmd->data_len = encrypt_decrypt_params->data_len;
4321
4322 if (cmd->data_len) {
4323 buf_ptr += sizeof(*cmd);
4324 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4325 roundup(encrypt_decrypt_params->data_len,
4326 sizeof(A_UINT32)));
4327 buf_ptr += WMI_TLV_HDR_SIZE;
4328 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4329 encrypt_decrypt_params->data_len);
4330 }
4331
4332 /* This conversion is to facilitate data to FW in little endian */
4333 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4334 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4335 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4336 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4337 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4338 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4339
4340 ret = wmi_unified_cmd_send(wmi_handle,
4341 wmi_buf, len,
4342 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4343 if (QDF_IS_STATUS_ERROR(ret)) {
4344 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4345 wmi_buf_free(wmi_buf);
4346 }
4347
4348 return ret;
4349}
4350
4351
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304352
Govind Singh4eacd2b2016-03-07 14:24:22 +05304353/**
4354 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4355 * @wmi_handle: wmi handle
4356 * @vdev_id: vdev id
4357 * @p2p_ie: p2p IE
4358 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304359 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304360 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304361static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304362 A_UINT32 vdev_id, uint8_t *p2p_ie)
4363{
Govind Singh67922e82016-04-01 16:48:57 +05304364 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304365 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4366 wmi_buf_t wmi_buf;
4367 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4368 uint8_t *buf_ptr;
4369
4370 ie_len = (uint32_t) (p2p_ie[1] + 2);
4371
4372 /* More than one P2P IE may be included in a single frame.
4373 If multiple P2P IEs are present, the complete P2P attribute
4374 data consists of the concatenation of the P2P Attribute
4375 fields of the P2P IEs. The P2P Attributes field of each
4376 P2P IE may be any length up to the maximum (251 octets).
4377 In this case host sends one P2P IE to firmware so the length
4378 should not exceed more than 251 bytes
4379 */
4380 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304381 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304382 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304383 }
4384
4385 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4386
4387 wmi_buf_len =
4388 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4389 WMI_TLV_HDR_SIZE;
4390
4391 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4392 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304393 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304394 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304395 }
4396
4397 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4398
4399 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4400 WMITLV_SET_HDR(&cmd->tlv_header,
4401 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4402 WMITLV_GET_STRUCT_TLVLEN
4403 (wmi_p2p_go_set_beacon_ie_fixed_param));
4404 cmd->vdev_id = vdev_id;
4405 cmd->ie_buf_len = ie_len;
4406
4407 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4408 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4409 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304410 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304411
Govind Singhb53420c2016-03-09 14:32:57 +05304412 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304413
4414 ret = wmi_unified_cmd_send(wmi_handle,
4415 wmi_buf, wmi_buf_len,
4416 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304417 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304418 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304419 wmi_buf_free(wmi_buf);
4420 }
4421
Govind Singhb53420c2016-03-09 14:32:57 +05304422 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304423 return ret;
4424}
4425
4426/**
4427 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4428 * @wmi_handle: wmi handle
4429 * @req: gateway parameter update request structure
4430 *
4431 * This function reads the incoming @req and fill in the destination
4432 * WMI structure and sends down the gateway configs down to the firmware
4433 *
Govind Singhb53420c2016-03-09 14:32:57 +05304434 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304435 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304436static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304437 struct gateway_update_req_param *req)
4438{
4439 wmi_roam_subnet_change_config_fixed_param *cmd;
4440 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304441 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304442 int len = sizeof(*cmd);
4443
4444 buf = wmi_buf_alloc(wmi_handle, len);
4445 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304446 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4447 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304448 }
4449
4450 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4451 WMITLV_SET_HDR(&cmd->tlv_header,
4452 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4453 WMITLV_GET_STRUCT_TLVLEN(
4454 wmi_roam_subnet_change_config_fixed_param));
4455
4456 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304457 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4458 QDF_IPV4_ADDR_SIZE);
4459 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4460 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304461 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4462 &cmd->inet_gw_mac_addr);
4463 cmd->max_retries = req->max_retries;
4464 cmd->timeout = req->timeout;
4465 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4466 cmd->flag = 0;
4467 if (req->ipv4_addr_type)
4468 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4469
4470 if (req->ipv6_addr_type)
4471 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4472
4473 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4474 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304475 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304476 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304477 ret);
4478 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304479 }
4480
Govind Singh67922e82016-04-01 16:48:57 +05304481 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304482}
4483
4484/**
4485 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4486 * @wmi_handle: wmi handle
4487 * @req: rssi monitoring request structure
4488 *
4489 * This function reads the incoming @req and fill in the destination
4490 * WMI structure and send down the rssi monitoring configs down to the firmware
4491 *
4492 * Return: 0 on success; error number otherwise
4493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304494static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304495 struct rssi_monitor_param *req)
4496{
4497 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4498 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304499 QDF_STATUS ret;
4500 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304501
4502 buf = wmi_buf_alloc(wmi_handle, len);
4503 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304504 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4505 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304506 }
4507
4508 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4509 WMITLV_SET_HDR(&cmd->tlv_header,
4510 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4511 WMITLV_GET_STRUCT_TLVLEN(
4512 wmi_rssi_breach_monitor_config_fixed_param));
4513
4514 cmd->vdev_id = req->session_id;
4515 cmd->request_id = req->request_id;
4516 cmd->lo_rssi_reenable_hysteresis = 0;
4517 cmd->hi_rssi_reenable_histeresis = 0;
4518 cmd->min_report_interval = 0;
4519 cmd->max_num_report = 1;
4520 if (req->control) {
4521 /* enable one threshold for each min/max */
4522 cmd->enabled_bitmap = 0x09;
4523 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4524 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4525 } else {
4526 cmd->enabled_bitmap = 0;
4527 cmd->low_rssi_breach_threshold[0] = 0;
4528 cmd->hi_rssi_breach_threshold[0] = 0;
4529 }
4530
4531 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4532 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304533 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304534 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304535 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304536 }
4537
Govind Singhb53420c2016-03-09 14:32:57 +05304538 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304539 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304540}
4541
4542/**
4543 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4544 * @wmi_handle: wmi handle
4545 * @psetoui: OUI parameters
4546 *
4547 * set scan probe OUI parameters in firmware
4548 *
4549 * Return: CDF status
4550 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304551static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304552 struct scan_mac_oui *psetoui)
4553{
4554 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4555 wmi_buf_t wmi_buf;
4556 uint32_t len;
4557 uint8_t *buf_ptr;
4558 uint32_t *oui_buf;
4559
4560 len = sizeof(*cmd);
4561 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4562 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304563 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4564 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304565 }
4566 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4567 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4568 WMITLV_SET_HDR(&cmd->tlv_header,
4569 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4570 WMITLV_GET_STRUCT_TLVLEN
4571 (wmi_scan_prob_req_oui_cmd_fixed_param));
4572
4573 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304574 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304575 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4576 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304577 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304578 cmd->prob_req_oui);
4579
4580 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4581 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304582 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304583 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304584 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304585 }
Govind Singhb53420c2016-03-09 14:32:57 +05304586 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304587}
4588
4589/**
4590 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
4591 * @wmi_handle: wmi handle
4592 * @req: passpoint network request structure
4593 *
4594 * This function sends down WMI command with network id set to wildcard id.
4595 * firmware shall clear all the config entries
4596 *
Govind Singhb53420c2016-03-09 14:32:57 +05304597 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304598 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304599static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304600 struct wifi_passpoint_req_param *req)
4601{
4602 wmi_passpoint_config_cmd_fixed_param *cmd;
4603 wmi_buf_t buf;
4604 uint32_t len;
4605 int ret;
4606
4607 len = sizeof(*cmd);
4608 buf = wmi_buf_alloc(wmi_handle, len);
4609 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304610 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4611 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304612 }
4613
4614 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
4615
4616 WMITLV_SET_HDR(&cmd->tlv_header,
4617 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4618 WMITLV_GET_STRUCT_TLVLEN(
4619 wmi_passpoint_config_cmd_fixed_param));
4620 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
4621
4622 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4623 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4624 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304625 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304626 __func__);
4627 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304628 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304629 }
4630
Govind Singhb53420c2016-03-09 14:32:57 +05304631 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304632}
4633
4634/**
4635 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
4636 * @wmi_handle: wmi handle
4637 * @req: passpoint network request structure
4638 *
4639 * This function reads the incoming @req and fill in the destination
4640 * WMI structure and send down the passpoint configs down to the firmware
4641 *
Govind Singhb53420c2016-03-09 14:32:57 +05304642 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304643 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304644static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304645 struct wifi_passpoint_req_param *req)
4646{
4647 wmi_passpoint_config_cmd_fixed_param *cmd;
4648 u_int8_t i, j, *bytes;
4649 wmi_buf_t buf;
4650 uint32_t len;
4651 int ret;
4652
4653 len = sizeof(*cmd);
4654 for (i = 0; i < req->num_networks; i++) {
4655 buf = wmi_buf_alloc(wmi_handle, len);
4656 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304657 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4658 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304659 }
4660
4661 cmd = (wmi_passpoint_config_cmd_fixed_param *)
4662 wmi_buf_data(buf);
4663
4664 WMITLV_SET_HDR(&cmd->tlv_header,
4665 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4666 WMITLV_GET_STRUCT_TLVLEN(
4667 wmi_passpoint_config_cmd_fixed_param));
4668 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05304669 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
4670 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304671 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05304672 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304673 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
4674 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05304675 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304676 j, bytes[0], bytes[1], bytes[2], bytes[3],
4677 bytes[4], bytes[5], bytes[6], bytes[7]);
4678
Govind Singhb53420c2016-03-09 14:32:57 +05304679 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05304680 &req->networks[i].roaming_consortium_ids[j],
4681 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
4682 }
Govind Singhb53420c2016-03-09 14:32:57 +05304683 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304684 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304685 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304686 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
4687
4688 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4689 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4690 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304691 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304692 __func__);
4693 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304694 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304695 }
4696 }
4697
Govind Singhb53420c2016-03-09 14:32:57 +05304698 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304699}
4700
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304701/**
4702 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
4703 * @wmi_handle: wmi handle
4704 * @scan_cmd_fp: start scan command ptr
4705 * @roam_req: roam request param
4706 *
4707 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
4708 * of WMI_ROAM_SCAN_MODE.
4709 *
4710 * Return: QDF status
4711 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304712static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304713 wmi_start_scan_cmd_fixed_param *
4714 scan_cmd_fp,
4715 struct roam_offload_scan_params *roam_req)
4716{
4717 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304718 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304719 int len;
4720 uint8_t *buf_ptr;
4721 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05304722
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304723#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4724 int auth_mode = roam_req->auth_mode;
4725 wmi_roam_offload_tlv_param *roam_offload_params;
4726 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
4727 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
4728 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304729 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304730#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4731 /* Need to create a buf with roam_scan command at
4732 * front and piggyback with scan command */
4733 len = sizeof(wmi_roam_scan_mode_fixed_param) +
4734#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4735 (2 * WMI_TLV_HDR_SIZE) +
4736#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4737 sizeof(wmi_start_scan_cmd_fixed_param);
4738#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4739 if (roam_req->is_roam_req_valid &&
4740 roam_req->roam_offload_enabled) {
4741 len += sizeof(wmi_roam_offload_tlv_param);
4742 len += WMI_TLV_HDR_SIZE;
4743 if ((auth_mode != WMI_AUTH_NONE) &&
4744 ((auth_mode != WMI_AUTH_OPEN) ||
4745 (auth_mode == WMI_AUTH_OPEN &&
4746 roam_req->mdid.mdie_present) ||
4747 roam_req->is_ese_assoc)) {
4748 len += WMI_TLV_HDR_SIZE;
4749 if (roam_req->is_ese_assoc)
4750 len +=
4751 sizeof(wmi_roam_ese_offload_tlv_param);
4752 else if (auth_mode == WMI_AUTH_FT_RSNA ||
4753 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
4754 (auth_mode == WMI_AUTH_OPEN &&
4755 roam_req->mdid.mdie_present))
4756 len +=
4757 sizeof(wmi_roam_11r_offload_tlv_param);
4758 else
4759 len +=
4760 sizeof(wmi_roam_11i_offload_tlv_param);
4761 } else {
4762 len += WMI_TLV_HDR_SIZE;
4763 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304764
4765 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
4766 + roundup(roam_req->assoc_ie_length,
4767 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304768 } else {
4769 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05304770 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304771 __func__, roam_req->roam_offload_enabled);
4772 else
Govind Singhe7f2f342016-05-23 12:12:52 +05304773 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304774 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304775 }
4776 if (roam_req->is_roam_req_valid &&
4777 roam_req->roam_offload_enabled) {
4778 roam_req->mode = roam_req->mode |
4779 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
4780 }
4781#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4782
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304783 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4784 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4785 len = sizeof(wmi_roam_scan_mode_fixed_param);
4786
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304787 buf = wmi_buf_alloc(wmi_handle, len);
4788 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304789 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304790 return QDF_STATUS_E_NOMEM;
4791 }
4792
4793 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304794
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304795 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
4796 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
4797 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
4798 WMITLV_GET_STRUCT_TLVLEN
4799 (wmi_roam_scan_mode_fixed_param));
4800
4801 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
4802 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304803 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
4804 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
4805 goto send_roam_scan_mode_cmd;
4806
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304807 /* Fill in scan parameters suitable for roaming scan */
4808 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05304809
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304810 qdf_mem_copy(buf_ptr, scan_cmd_fp,
4811 sizeof(wmi_start_scan_cmd_fixed_param));
4812 /* Ensure there is no additional IEs */
4813 scan_cmd_fp->ie_len = 0;
4814 WMITLV_SET_HDR(buf_ptr,
4815 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
4816 WMITLV_GET_STRUCT_TLVLEN
4817 (wmi_start_scan_cmd_fixed_param));
4818#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4819 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
4820 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
4821 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4822 sizeof(wmi_roam_offload_tlv_param));
4823 buf_ptr += WMI_TLV_HDR_SIZE;
4824 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
4825 WMITLV_SET_HDR(buf_ptr,
4826 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
4827 WMITLV_GET_STRUCT_TLVLEN
4828 (wmi_roam_offload_tlv_param));
4829 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
4830 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
4831 roam_offload_params->select_5g_margin =
4832 roam_req->select_5ghz_margin;
4833 roam_offload_params->reassoc_failure_timeout =
4834 roam_req->reassoc_failure_timeout;
4835
4836 /* Fill the capabilities */
4837 roam_offload_params->capability =
4838 roam_req->roam_offload_params.capability;
4839 roam_offload_params->ht_caps_info =
4840 roam_req->roam_offload_params.ht_caps_info;
4841 roam_offload_params->ampdu_param =
4842 roam_req->roam_offload_params.ampdu_param;
4843 roam_offload_params->ht_ext_cap =
4844 roam_req->roam_offload_params.ht_ext_cap;
4845 roam_offload_params->ht_txbf =
4846 roam_req->roam_offload_params.ht_txbf;
4847 roam_offload_params->asel_cap =
4848 roam_req->roam_offload_params.asel_cap;
4849 roam_offload_params->qos_caps =
4850 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08004851 roam_offload_params->qos_enabled =
4852 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304853 roam_offload_params->wmm_caps =
4854 roam_req->roam_offload_params.wmm_caps;
4855 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
4856 (uint8_t *)roam_req->roam_offload_params.mcsset,
4857 ROAM_OFFLOAD_NUM_MCS_SET);
4858
4859 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
4860 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
4861 * they are filled in the same order.Depending on the
4862 * authentication type, the other mode TLV's are nullified
4863 * and only headers are filled.*/
4864 if ((auth_mode != WMI_AUTH_NONE) &&
4865 ((auth_mode != WMI_AUTH_OPEN) ||
4866 (auth_mode == WMI_AUTH_OPEN
4867 && roam_req->mdid.mdie_present) ||
4868 roam_req->is_ese_assoc)) {
4869 if (roam_req->is_ese_assoc) {
4870 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4871 WMITLV_GET_STRUCT_TLVLEN(0));
4872 buf_ptr += WMI_TLV_HDR_SIZE;
4873 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4874 WMITLV_GET_STRUCT_TLVLEN(0));
4875 buf_ptr += WMI_TLV_HDR_SIZE;
4876 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4877 sizeof(wmi_roam_ese_offload_tlv_param));
4878 buf_ptr += WMI_TLV_HDR_SIZE;
4879 roam_offload_ese =
4880 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
4881 qdf_mem_copy(roam_offload_ese->krk,
4882 roam_req->krk,
4883 sizeof(roam_req->krk));
4884 qdf_mem_copy(roam_offload_ese->btk,
4885 roam_req->btk,
4886 sizeof(roam_req->btk));
4887 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
4888 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
4889 WMITLV_GET_STRUCT_TLVLEN
4890 (wmi_roam_ese_offload_tlv_param));
4891 buf_ptr +=
4892 sizeof(wmi_roam_ese_offload_tlv_param);
4893 } else if (auth_mode == WMI_AUTH_FT_RSNA
4894 || auth_mode == WMI_AUTH_FT_RSNA_PSK
4895 || (auth_mode == WMI_AUTH_OPEN
4896 && roam_req->mdid.mdie_present)) {
4897 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4898 0);
4899 buf_ptr += WMI_TLV_HDR_SIZE;
4900 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4901 sizeof(wmi_roam_11r_offload_tlv_param));
4902 buf_ptr += WMI_TLV_HDR_SIZE;
4903 roam_offload_11r =
4904 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
4905 roam_offload_11r->r0kh_id_len =
4906 roam_req->rokh_id_length;
4907 qdf_mem_copy(roam_offload_11r->r0kh_id,
4908 roam_req->rokh_id,
4909 roam_offload_11r->r0kh_id_len);
4910 qdf_mem_copy(roam_offload_11r->psk_msk,
4911 roam_req->psk_pmk,
4912 sizeof(roam_req->psk_pmk));
4913 roam_offload_11r->psk_msk_len =
4914 roam_req->pmk_len;
4915 roam_offload_11r->mdie_present =
4916 roam_req->mdid.mdie_present;
4917 roam_offload_11r->mdid =
4918 roam_req->mdid.mobility_domain;
4919 if (auth_mode == WMI_AUTH_OPEN) {
4920 /* If FT-Open ensure pmk length
4921 and r0khid len are zero */
4922 roam_offload_11r->r0kh_id_len = 0;
4923 roam_offload_11r->psk_msk_len = 0;
4924 }
4925 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
4926 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
4927 WMITLV_GET_STRUCT_TLVLEN
4928 (wmi_roam_11r_offload_tlv_param));
4929 buf_ptr +=
4930 sizeof(wmi_roam_11r_offload_tlv_param);
4931 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4932 WMITLV_GET_STRUCT_TLVLEN(0));
4933 buf_ptr += WMI_TLV_HDR_SIZE;
4934 } else {
4935 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4936 sizeof(wmi_roam_11i_offload_tlv_param));
4937 buf_ptr += WMI_TLV_HDR_SIZE;
4938 roam_offload_11i =
4939 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07004940 if (roam_req->roam_key_mgmt_offload_enabled &&
4941 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304942 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
4943 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304944 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304945 } else {
4946 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
4947 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304948 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304949 }
4950
4951 qdf_mem_copy(roam_offload_11i->pmk,
4952 roam_req->psk_pmk,
4953 sizeof(roam_req->psk_pmk));
4954 roam_offload_11i->pmk_len = roam_req->pmk_len;
4955 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
4956 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
4957 WMITLV_GET_STRUCT_TLVLEN
4958 (wmi_roam_11i_offload_tlv_param));
4959 buf_ptr +=
4960 sizeof(wmi_roam_11i_offload_tlv_param);
4961 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4962 0);
4963 buf_ptr += WMI_TLV_HDR_SIZE;
4964 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4965 0);
4966 buf_ptr += WMI_TLV_HDR_SIZE;
4967 }
4968 } else {
4969 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4970 WMITLV_GET_STRUCT_TLVLEN(0));
4971 buf_ptr += WMI_TLV_HDR_SIZE;
4972 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4973 WMITLV_GET_STRUCT_TLVLEN(0));
4974 buf_ptr += WMI_TLV_HDR_SIZE;
4975 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4976 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304977 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304978 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05304979
4980 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4981 sizeof(*assoc_ies));
4982 buf_ptr += WMI_TLV_HDR_SIZE;
4983
4984 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
4985 WMITLV_SET_HDR(&assoc_ies->tlv_header,
4986 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
4987 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
4988 assoc_ies->buf_len = roam_req->assoc_ie_length;
4989
4990 buf_ptr += sizeof(*assoc_ies);
4991
4992 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4993 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
4994 buf_ptr += WMI_TLV_HDR_SIZE;
4995
4996 if (assoc_ies->buf_len != 0) {
4997 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
4998 assoc_ies->buf_len);
4999 }
5000
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305001 } else {
5002 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5003 WMITLV_GET_STRUCT_TLVLEN(0));
5004 buf_ptr += WMI_TLV_HDR_SIZE;
5005 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5006 WMITLV_GET_STRUCT_TLVLEN(0));
5007 buf_ptr += WMI_TLV_HDR_SIZE;
5008 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5009 WMITLV_GET_STRUCT_TLVLEN(0));
5010 buf_ptr += WMI_TLV_HDR_SIZE;
5011 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5012 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305013 buf_ptr += WMI_TLV_HDR_SIZE;
5014 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5015 WMITLV_GET_STRUCT_TLVLEN(0));
5016 buf_ptr += WMI_TLV_HDR_SIZE;
5017 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5018 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305019 }
5020#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305021
5022send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305023 status = wmi_unified_cmd_send(wmi_handle, buf,
5024 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305025 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305026 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305027 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5028 status);
5029 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305030 }
5031
Govind Singh67922e82016-04-01 16:48:57 +05305032 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305033}
5034
5035
5036/**
5037 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5038 * rssi threashold
5039 * @wmi_handle: wmi handle
5040 * @roam_req: Roaming request buffer
5041 *
5042 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5043 *
5044 * Return: QDF status
5045 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305046static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305047 struct roam_offload_scan_rssi_params *roam_req)
5048{
5049 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305050 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305051 int len;
5052 uint8_t *buf_ptr;
5053 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5054 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5055 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305056 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305057
5058 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5059 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5060 len += sizeof(wmi_roam_scan_extended_threshold_param);
5061 len += WMI_TLV_HDR_SIZE;
5062 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305063 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5064 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305065 buf = wmi_buf_alloc(wmi_handle, len);
5066 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305067 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305068 return QDF_STATUS_E_NOMEM;
5069 }
5070
5071 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5072 rssi_threshold_fp =
5073 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5074 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5075 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5076 WMITLV_GET_STRUCT_TLVLEN
5077 (wmi_roam_scan_rssi_threshold_fixed_param));
5078 /* fill in threshold values */
5079 rssi_threshold_fp->vdev_id = roam_req->session_id;
5080 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5081 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5082 rssi_threshold_fp->hirssi_scan_max_count =
5083 roam_req->hi_rssi_scan_max_count;
5084 rssi_threshold_fp->hirssi_scan_delta =
5085 roam_req->hi_rssi_scan_rssi_delta;
5086 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5087
5088 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5089 WMITLV_SET_HDR(buf_ptr,
5090 WMITLV_TAG_ARRAY_STRUC,
5091 sizeof(wmi_roam_scan_extended_threshold_param));
5092 buf_ptr += WMI_TLV_HDR_SIZE;
5093 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5094
5095 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5096 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5097 ext_thresholds->boost_threshold_5g =
5098 roam_req->boost_threshold_5g;
5099
5100 ext_thresholds->boost_algorithm_5g =
5101 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5102 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5103 ext_thresholds->penalty_algorithm_5g =
5104 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5105 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5106 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5107 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5108 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5109
5110 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5111 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5112 WMITLV_GET_STRUCT_TLVLEN
5113 (wmi_roam_scan_extended_threshold_param));
5114 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5115 WMITLV_SET_HDR(buf_ptr,
5116 WMITLV_TAG_ARRAY_STRUC,
5117 sizeof(wmi_roam_earlystop_rssi_thres_param));
5118 buf_ptr += WMI_TLV_HDR_SIZE;
5119 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5120 early_stop_thresholds->roam_earlystop_thres_min =
5121 roam_req->roam_earlystop_thres_min;
5122 early_stop_thresholds->roam_earlystop_thres_max =
5123 roam_req->roam_earlystop_thres_max;
5124 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5125 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5126 WMITLV_GET_STRUCT_TLVLEN
5127 (wmi_roam_earlystop_rssi_thres_param));
5128
Gupta, Kapil7e652922016-04-12 15:02:00 +05305129 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5130 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5131 sizeof(wmi_roam_dense_thres_param));
5132 buf_ptr += WMI_TLV_HDR_SIZE;
5133 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5134 dense_thresholds->roam_dense_rssi_thres_offset =
5135 roam_req->dense_rssi_thresh_offset;
5136 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5137 dense_thresholds->roam_dense_traffic_thres =
5138 roam_req->traffic_threshold;
5139 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5140 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5141 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5142 WMITLV_GET_STRUCT_TLVLEN
5143 (wmi_roam_dense_thres_param));
5144
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305145 status = wmi_unified_cmd_send(wmi_handle, buf,
5146 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305147 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305148 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305149 status);
5150 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305151 }
5152
Govind Singh67922e82016-04-01 16:48:57 +05305153 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305154}
5155
5156/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305157 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5158 * configuration params
5159 * @wma_handle: wma handler
5160 * @dwelltime_params: pointer to dwelltime_params
5161 *
5162 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5163 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005164static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305165QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5166 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5167{
5168 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5169 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5170 wmi_buf_t buf;
5171 uint8_t *buf_ptr;
5172 int32_t err;
5173 int len;
5174
5175 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5176 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5177 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5178 buf = wmi_buf_alloc(wmi_handle, len);
5179 if (!buf) {
5180 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5181 __func__);
5182 return QDF_STATUS_E_NOMEM;
5183 }
5184 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5185 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5186 WMITLV_SET_HDR(&dwell_param->tlv_header,
5187 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5188 WMITLV_GET_STRUCT_TLVLEN
5189 (wmi_scan_adaptive_dwell_config_fixed_param));
5190
5191 dwell_param->enable = dwelltime_params->is_enabled;
5192 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5193 WMITLV_SET_HDR(buf_ptr,
5194 WMITLV_TAG_ARRAY_STRUC,
5195 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5196 buf_ptr += WMI_TLV_HDR_SIZE;
5197
5198 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5199 WMITLV_SET_HDR(&cmd->tlv_header,
5200 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5201 WMITLV_GET_STRUCT_TLVLEN(
5202 wmi_scan_adaptive_dwell_parameters_tlv));
5203
5204 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5205 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5206 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5207 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5208 err = wmi_unified_cmd_send(wmi_handle, buf,
5209 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5210 if (err) {
5211 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5212 wmi_buf_free(buf);
5213 return QDF_STATUS_E_FAILURE;
5214 }
5215
5216 return QDF_STATUS_SUCCESS;
5217}
5218
5219
5220/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305221 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5222 * @wmi_handle: wmi handle
5223 * @roam_req: Request which contains the filters
5224 *
5225 * There are filters such as whitelist, blacklist and preferred
5226 * list that need to be applied to the scan results to form the
5227 * probable candidates for roaming.
5228 *
5229 * Return: Return success upon succesfully passing the
5230 * parameters to the firmware, otherwise failure.
5231 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305232static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305233 struct roam_scan_filter_params *roam_req)
5234{
5235 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305236 QDF_STATUS status;
5237 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305238 uint32_t len;
5239 uint8_t *buf_ptr;
5240 wmi_roam_filter_fixed_param *roam_filter;
5241 uint8_t *bssid_src_ptr = NULL;
5242 wmi_mac_addr *bssid_dst_ptr = NULL;
5243 wmi_ssid *ssid_ptr = NULL;
5244 uint32_t *bssid_preferred_factor_ptr = NULL;
5245
5246 len = sizeof(wmi_roam_filter_fixed_param);
5247 len += WMI_TLV_HDR_SIZE;
5248 len += roam_req->len;
5249
5250 buf = wmi_buf_alloc(wmi_handle, len);
5251 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305252 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305253 return QDF_STATUS_E_NOMEM;
5254 }
5255
5256 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5257 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5258 WMITLV_SET_HDR(&roam_filter->tlv_header,
5259 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5260 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5261 /* fill in fixed values */
5262 roam_filter->vdev_id = roam_req->session_id;
5263 roam_filter->flags = 0;
5264 roam_filter->op_bitmap = roam_req->op_bitmap;
5265 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5266 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5267 roam_filter->num_bssid_preferred_list =
5268 roam_req->num_bssid_preferred_list;
5269 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5270
5271 WMITLV_SET_HDR((buf_ptr),
5272 WMITLV_TAG_ARRAY_FIXED_STRUC,
5273 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5274 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5275 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5276 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5277 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5278 bssid_src_ptr += ATH_MAC_LEN;
5279 bssid_dst_ptr++;
5280 }
5281 buf_ptr += WMI_TLV_HDR_SIZE +
5282 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5283 WMITLV_SET_HDR((buf_ptr),
5284 WMITLV_TAG_ARRAY_FIXED_STRUC,
5285 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5286 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5287 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5288 qdf_mem_copy(&ssid_ptr->ssid,
5289 &roam_req->ssid_allowed_list[i].mac_ssid,
5290 roam_req->ssid_allowed_list[i].length);
5291 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5292 ssid_ptr++;
5293 }
5294 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5295 sizeof(wmi_ssid));
5296 WMITLV_SET_HDR((buf_ptr),
5297 WMITLV_TAG_ARRAY_FIXED_STRUC,
5298 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5299 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5300 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5301 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5302 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5303 (wmi_mac_addr *)bssid_dst_ptr);
5304 bssid_src_ptr += ATH_MAC_LEN;
5305 bssid_dst_ptr++;
5306 }
5307 buf_ptr += WMI_TLV_HDR_SIZE +
5308 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5309 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5310 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5311 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5312 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5313 *bssid_preferred_factor_ptr =
5314 roam_req->bssid_favored_factor[i];
5315 bssid_preferred_factor_ptr++;
5316 }
5317 buf_ptr += WMI_TLV_HDR_SIZE +
5318 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5319
5320 status = wmi_unified_cmd_send(wmi_handle, buf,
5321 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305322 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305323 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305324 status);
5325 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305326 }
Govind Singh67922e82016-04-01 16:48:57 +05305327
5328 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305329}
5330
Govind Singh4eacd2b2016-03-07 14:24:22 +05305331/** send_set_epno_network_list_cmd_tlv() - set epno network list
5332 * @wmi_handle: wmi handle
5333 * @req: epno config params request structure
5334 *
5335 * This function reads the incoming epno config request structure
5336 * and constructs the WMI message to the firmware.
5337 *
5338 * Returns: 0 on success, error number otherwise
5339 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305340static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305341 struct wifi_enhanched_pno_params *req)
5342{
5343 wmi_nlo_config_cmd_fixed_param *cmd;
5344 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305345 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305346 u_int8_t i, *buf_ptr;
5347 wmi_buf_t buf;
5348 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305349 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305350
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305351 /* Fixed Params */
5352 len = sizeof(*cmd);
5353 if (req->num_networks) {
5354 /* TLV place holder for array of structures
5355 * then each nlo_configured_parameters(nlo_list) TLV.
5356 */
5357 len += WMI_TLV_HDR_SIZE;
5358 len += (sizeof(nlo_configured_parameters)
5359 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5360 /* TLV for array of uint32 channel_list */
5361 len += WMI_TLV_HDR_SIZE;
5362 /* TLV for nlo_channel_prediction_cfg */
5363 len += WMI_TLV_HDR_SIZE;
5364 /* TLV for candidate score params */
5365 len += sizeof(enlo_candidate_score_params);
5366 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305367
5368 buf = wmi_buf_alloc(wmi_handle, len);
5369 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305370 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5371 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305372 }
5373
5374 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5375
5376 buf_ptr = (u_int8_t *) cmd;
5377 WMITLV_SET_HDR(&cmd->tlv_header,
5378 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5379 WMITLV_GET_STRUCT_TLVLEN(
5380 wmi_nlo_config_cmd_fixed_param));
5381 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305382
5383 /* set flag to reset if num of networks are 0 */
5384 cmd->flags = (req->num_networks == 0 ?
5385 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305386
5387 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5388
Govind Singhb53420c2016-03-09 14:32:57 +05305389 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305390 WMI_LOGD("SSID count: %d flags: %d",
5391 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305392
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305393 /* Fill nlo_config only when num_networks are non zero */
5394 if (cmd->no_of_ssids) {
5395 /* Fill networks */
5396 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5397 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5398 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305399
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305400 nlo_list = (nlo_configured_parameters *) buf_ptr;
5401 for (i = 0; i < cmd->no_of_ssids; i++) {
5402 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5403 WMITLV_TAG_ARRAY_BYTE,
5404 WMITLV_GET_STRUCT_TLVLEN(
5405 nlo_configured_parameters));
5406 /* Copy ssid and it's length */
5407 nlo_list[i].ssid.valid = true;
5408 nlo_list[i].ssid.ssid.ssid_len =
5409 req->networks[i].ssid.length;
5410 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5411 req->networks[i].ssid.mac_ssid,
5412 nlo_list[i].ssid.ssid.ssid_len);
5413 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5414 nlo_list[i].ssid.ssid.ssid_len,
5415 (char *) nlo_list[i].ssid.ssid.ssid,
5416 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305417
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305418 /* Copy pno flags */
5419 nlo_list[i].bcast_nw_type.valid = true;
5420 nlo_list[i].bcast_nw_type.bcast_nw_type =
5421 req->networks[i].flags;
5422 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305423 nlo_list[i].bcast_nw_type.bcast_nw_type);
5424
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305425 /* Copy auth bit field */
5426 nlo_list[i].auth_type.valid = true;
5427 nlo_list[i].auth_type.auth_type =
5428 req->networks[i].auth_bit_field;
5429 WMI_LOGD("Auth bit field (%u)",
5430 nlo_list[i].auth_type.auth_type);
5431 }
5432
5433 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5434 /* Fill the channel list */
5435 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5436 buf_ptr += WMI_TLV_HDR_SIZE;
5437
5438 /* Fill prediction_param */
5439 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5440 buf_ptr += WMI_TLV_HDR_SIZE;
5441
5442 /* Fill epno candidate score params */
5443 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5444 WMITLV_SET_HDR(buf_ptr,
5445 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5446 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5447 cand_score_params->min5GHz_rssi =
5448 req->min_5ghz_rssi;
5449 cand_score_params->min24GHz_rssi =
5450 req->min_24ghz_rssi;
5451 cand_score_params->initial_score_max =
5452 req->initial_score_max;
5453 cand_score_params->current_connection_bonus =
5454 req->current_connection_bonus;
5455 cand_score_params->same_network_bonus =
5456 req->same_network_bonus;
5457 cand_score_params->secure_bonus =
5458 req->secure_bonus;
5459 cand_score_params->band5GHz_bonus =
5460 req->band_5ghz_bonus;
5461 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305462 }
5463
Govind Singh4eacd2b2016-03-07 14:24:22 +05305464 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305465 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305466 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305467 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305468 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305469 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305470 }
5471
Govind Singhb53420c2016-03-09 14:32:57 +05305472 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305473 req->session_id);
5474
Govind Singh67922e82016-04-01 16:48:57 +05305475 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305476}
5477
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305478
Govind Singh4eacd2b2016-03-07 14:24:22 +05305479/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5480 * @wmi_handle: wmi handle
5481 * @ipa_offload: ipa offload control parameter
5482 *
5483 * Returns: 0 on success, error number otherwise
5484 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305485static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305486 struct ipa_offload_control_params *ipa_offload)
5487{
5488 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5489 wmi_buf_t wmi_buf;
5490 uint32_t len;
5491 u_int8_t *buf_ptr;
5492
5493 len = sizeof(*cmd);
5494 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5495 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305496 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5497 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305498 }
5499
Govind Singhb53420c2016-03-09 14:32:57 +05305500 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305501 ipa_offload->offload_type, ipa_offload->enable);
5502
5503 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5504
5505 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5506 WMITLV_SET_HDR(&cmd->tlv_header,
5507 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5508 WMITLV_GET_STRUCT_TLVLEN(
5509 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5510
5511 cmd->offload_type = ipa_offload->offload_type;
5512 cmd->vdev_id = ipa_offload->vdev_id;
5513 cmd->enable = ipa_offload->enable;
5514
5515 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5516 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305517 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305518 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305519 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305520 }
5521
Govind Singhb53420c2016-03-09 14:32:57 +05305522 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305523}
5524
5525/**
5526 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5527 * @wmi_handle: wmi handle
5528 * @pgetcapab: get capabilities params
5529 *
5530 * This function send request to fw to get extscan capabilities.
5531 *
5532 * Return: CDF status
5533 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305534static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305535 struct extscan_capabilities_params *pgetcapab)
5536{
5537 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5538 wmi_buf_t wmi_buf;
5539 uint32_t len;
5540 uint8_t *buf_ptr;
5541
5542 len = sizeof(*cmd);
5543 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5544 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305545 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5546 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305547 }
5548 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5549
5550 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5551 WMITLV_SET_HDR(&cmd->tlv_header,
5552 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5553 WMITLV_GET_STRUCT_TLVLEN
5554 (wmi_extscan_get_capabilities_cmd_fixed_param));
5555
5556 cmd->request_id = pgetcapab->request_id;
5557
5558 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5559 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305560 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305561 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305562 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305563 }
Govind Singhb53420c2016-03-09 14:32:57 +05305564 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305565}
5566
5567/**
5568 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5569 * @wmi_handle: wmi handle
5570 * @pcached_results: cached results parameters
5571 *
5572 * This function send request to fw to get cached results.
5573 *
5574 * Return: CDF status
5575 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305576static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305577 struct extscan_cached_result_params *pcached_results)
5578{
5579 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5580 wmi_buf_t wmi_buf;
5581 uint32_t len;
5582 uint8_t *buf_ptr;
5583
5584 len = sizeof(*cmd);
5585 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5586 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305587 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5588 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305589 }
5590 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5591
5592 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
5593 WMITLV_SET_HDR(&cmd->tlv_header,
5594 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
5595 WMITLV_GET_STRUCT_TLVLEN
5596 (wmi_extscan_get_cached_results_cmd_fixed_param));
5597
5598 cmd->request_id = pcached_results->request_id;
5599 cmd->vdev_id = pcached_results->session_id;
5600 cmd->control_flags = pcached_results->flush;
5601
5602 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5603 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305604 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305605 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305606 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305607 }
Govind Singhb53420c2016-03-09 14:32:57 +05305608 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305609}
5610
5611/**
5612 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
5613 * @wmi_handle: wmi handle
5614 * @reset_req: Reset change request params
5615 *
5616 * This function sends stop change monitor request to fw.
5617 *
5618 * Return: CDF status
5619 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305620static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305621 struct extscan_capabilities_reset_params *reset_req)
5622{
5623 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5624 wmi_buf_t wmi_buf;
5625 uint32_t len;
5626 uint8_t *buf_ptr;
5627 int change_list = 0;
5628
5629 len = sizeof(*cmd);
5630
5631 /* reset significant change tlv is set to 0 */
5632 len += WMI_TLV_HDR_SIZE;
5633 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
5634 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5635 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305636 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5637 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305638 }
5639 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5640
5641 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5642 buf_ptr;
5643 WMITLV_SET_HDR(&cmd->tlv_header,
5644 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5645 WMITLV_GET_STRUCT_TLVLEN
5646 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5647
5648 cmd->request_id = reset_req->request_id;
5649 cmd->vdev_id = reset_req->session_id;
5650 cmd->mode = 0;
5651
5652 buf_ptr += sizeof(*cmd);
5653 WMITLV_SET_HDR(buf_ptr,
5654 WMITLV_TAG_ARRAY_STRUC,
5655 change_list *
5656 sizeof(wmi_extscan_wlan_change_bssid_param));
5657 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
5658 sizeof
5659 (wmi_extscan_wlan_change_bssid_param));
5660
5661 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5662 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305663 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305664 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305665 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305666 }
Govind Singhb53420c2016-03-09 14:32:57 +05305667 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305668}
5669
5670/**
5671 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
5672 * @wmi_handle: wmi handle
5673 * @psigchange: change monitor request params
5674 * @buf: wmi buffer
5675 * @buf_len: buffer length
5676 *
5677 * This function fills elements of change monitor request buffer.
5678 *
5679 * Return: CDF status
5680 */
Govind Singhb53420c2016-03-09 14:32:57 +05305681static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305682 struct extscan_set_sig_changereq_params
5683 *psigchange, wmi_buf_t *buf, int *buf_len)
5684{
5685 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5686 wmi_extscan_wlan_change_bssid_param *dest_chglist;
5687 uint8_t *buf_ptr;
5688 int j;
5689 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08005690 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305691 struct ap_threshold_params *src_ap = psigchange->ap;
5692
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08005693 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305694 WMI_LOGE("%s: Invalid number of bssid's", __func__);
5695 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305696 }
5697 len += WMI_TLV_HDR_SIZE;
5698 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
5699
5700 *buf = wmi_buf_alloc(wmi_handle, len);
5701 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305702 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305703 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305704 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305705 }
5706 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5707 cmd =
5708 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5709 buf_ptr;
5710 WMITLV_SET_HDR(&cmd->tlv_header,
5711 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5712 WMITLV_GET_STRUCT_TLVLEN
5713 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5714
5715 cmd->request_id = psigchange->request_id;
5716 cmd->vdev_id = psigchange->session_id;
5717 cmd->total_entries = numap;
5718 cmd->mode = 1;
5719 cmd->num_entries_in_page = numap;
5720 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
5721 cmd->max_rssi_samples = psigchange->rssi_sample_size;
5722 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
5723 cmd->max_out_of_range_count = psigchange->min_breaching;
5724
5725 buf_ptr += sizeof(*cmd);
5726 WMITLV_SET_HDR(buf_ptr,
5727 WMITLV_TAG_ARRAY_STRUC,
5728 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5729 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
5730 (buf_ptr + WMI_TLV_HDR_SIZE);
5731
5732 for (j = 0; j < numap; j++) {
5733 WMITLV_SET_HDR(dest_chglist,
5734 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5735 WMITLV_GET_STRUCT_TLVLEN
5736 (wmi_extscan_wlan_change_bssid_param));
5737
5738 dest_chglist->lower_rssi_limit = src_ap->low;
5739 dest_chglist->upper_rssi_limit = src_ap->high;
5740 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
5741 &dest_chglist->bssid);
5742
Govind Singhb53420c2016-03-09 14:32:57 +05305743 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305744 dest_chglist->lower_rssi_limit);
5745 dest_chglist++;
5746 src_ap++;
5747 }
5748 buf_ptr += WMI_TLV_HDR_SIZE +
5749 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
5750 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305751 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305752}
5753
5754/**
5755 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
5756 * @wmi_handle: wmi handle
5757 * @psigchange: change monitor request params
5758 *
5759 * This function sends start change monitor request to fw.
5760 *
5761 * Return: CDF status
5762 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305763static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305764 struct extscan_set_sig_changereq_params *
5765 psigchange)
5766{
Govind Singhb53420c2016-03-09 14:32:57 +05305767 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305768 wmi_buf_t buf;
5769 int len;
5770
5771
Govind Singhb53420c2016-03-09 14:32:57 +05305772 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305773 psigchange, &buf,
5774 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305775 if (qdf_status != QDF_STATUS_SUCCESS) {
5776 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305777 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305778 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305779 }
5780 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305781 WMI_LOGE("%s: Failed to get buffer", __func__);
5782 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305783 }
5784 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5785 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305786 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305787 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305788 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305789 }
Govind Singhb53420c2016-03-09 14:32:57 +05305790 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305791}
5792
5793/**
5794 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
5795 * @wmi_handle: wmi handle
5796 * @photlist_reset: hotlist reset params
5797 *
5798 * This function configures hotlist monitor to stop in fw.
5799 *
5800 * Return: CDF status
5801 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305802static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305803 struct extscan_bssid_hotlist_reset_params *photlist_reset)
5804{
5805 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
5806 wmi_buf_t wmi_buf;
5807 uint32_t len;
5808 uint8_t *buf_ptr;
5809 int hotlist_entries = 0;
5810
5811 len = sizeof(*cmd);
5812
5813 /* reset bssid hotlist with tlv set to 0 */
5814 len += WMI_TLV_HDR_SIZE;
5815 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
5816
5817 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5818 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305819 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5820 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305821 }
5822
5823 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5824 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
5825 buf_ptr;
5826 WMITLV_SET_HDR(&cmd->tlv_header,
5827 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
5828 WMITLV_GET_STRUCT_TLVLEN
5829 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
5830
5831 cmd->request_id = photlist_reset->request_id;
5832 cmd->vdev_id = photlist_reset->session_id;
5833 cmd->mode = 0;
5834
5835 buf_ptr += sizeof(*cmd);
5836 WMITLV_SET_HDR(buf_ptr,
5837 WMITLV_TAG_ARRAY_STRUC,
5838 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5839 buf_ptr += WMI_TLV_HDR_SIZE +
5840 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
5841
5842 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5843 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305844 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305845 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305846 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305847 }
Govind Singhb53420c2016-03-09 14:32:57 +05305848 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305849}
5850
5851/**
5852 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
5853 * @wmi_handle: wmi handle
5854 * @pstopcmd: stop scan command request params
5855 *
5856 * This function sends stop extscan request to fw.
5857 *
5858 * Return: CDF Status.
5859 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305860static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305861 struct extscan_stop_req_params *pstopcmd)
5862{
5863 wmi_extscan_stop_cmd_fixed_param *cmd;
5864 wmi_buf_t wmi_buf;
5865 uint32_t len;
5866 uint8_t *buf_ptr;
5867
5868 len = sizeof(*cmd);
5869 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5870 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305871 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5872 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305873 }
5874 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5875 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
5876 WMITLV_SET_HDR(&cmd->tlv_header,
5877 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
5878 WMITLV_GET_STRUCT_TLVLEN
5879 (wmi_extscan_stop_cmd_fixed_param));
5880
5881 cmd->request_id = pstopcmd->request_id;
5882 cmd->vdev_id = pstopcmd->session_id;
5883
5884 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5885 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305886 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305887 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305888 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305889 }
5890
Govind Singhb53420c2016-03-09 14:32:57 +05305891 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305892}
5893
5894/**
5895 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
5896 * @wmi_handle: wmi handle
5897 * @pstart: scan command request params
5898 * @buf: event buffer
5899 * @buf_len: length of buffer
5900 *
5901 * This function fills individual elements of extscan request and
5902 * TLV for buckets, channel list.
5903 *
5904 * Return: CDF Status.
5905 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005906static
Govind Singhb53420c2016-03-09 14:32:57 +05305907QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305908 struct wifi_scan_cmd_req_params *pstart,
5909 wmi_buf_t *buf, int *buf_len)
5910{
5911 wmi_extscan_start_cmd_fixed_param *cmd;
5912 wmi_extscan_bucket *dest_blist;
5913 wmi_extscan_bucket_channel *dest_clist;
5914 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
5915 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
5916 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
5917
5918 uint8_t *buf_ptr;
5919 int i, k, count = 0;
5920 int len = sizeof(*cmd);
5921 int nbuckets = pstart->numBuckets;
5922 int nchannels = 0;
5923
5924 /* These TLV's are are NULL by default */
5925 uint32_t ie_len_with_pad = 0;
5926 int num_ssid = 0;
5927 int num_bssid = 0;
5928 int ie_len = 0;
5929
5930 uint32_t base_period = pstart->basePeriod;
5931
5932 /* TLV placeholder for ssid_list (NULL) */
5933 len += WMI_TLV_HDR_SIZE;
5934 len += num_ssid * sizeof(wmi_ssid);
5935
5936 /* TLV placeholder for bssid_list (NULL) */
5937 len += WMI_TLV_HDR_SIZE;
5938 len += num_bssid * sizeof(wmi_mac_addr);
5939
5940 /* TLV placeholder for ie_data (NULL) */
5941 len += WMI_TLV_HDR_SIZE;
5942 len += ie_len * sizeof(uint32_t);
5943
5944 /* TLV placeholder for bucket */
5945 len += WMI_TLV_HDR_SIZE;
5946 len += nbuckets * sizeof(wmi_extscan_bucket);
5947
5948 /* TLV channel placeholder */
5949 len += WMI_TLV_HDR_SIZE;
5950 for (i = 0; i < nbuckets; i++) {
5951 nchannels += src_bucket->numChannels;
5952 src_bucket++;
5953 }
5954
Govind Singhb53420c2016-03-09 14:32:57 +05305955 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305956 __func__, nbuckets, nchannels);
5957 len += nchannels * sizeof(wmi_extscan_bucket_channel);
5958 /* Allocate the memory */
5959 *buf = wmi_buf_alloc(wmi_handle, len);
5960 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305961 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05305962 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305963 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305964 }
5965 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5966 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
5967 WMITLV_SET_HDR(&cmd->tlv_header,
5968 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
5969 WMITLV_GET_STRUCT_TLVLEN
5970 (wmi_extscan_start_cmd_fixed_param));
5971
5972 cmd->request_id = pstart->requestId;
5973 cmd->vdev_id = pstart->sessionId;
5974 cmd->base_period = pstart->basePeriod;
5975 cmd->num_buckets = nbuckets;
5976 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05305977 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305978 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05305979 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305980 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05305981#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05305982 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
5983 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05305984 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
5985 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
5986#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05305987 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5988
5989 /* The max dwell time is retrieved from the first channel
5990 * of the first bucket and kept common for all channels.
5991 */
5992 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
5993 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
5994 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
5995 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
5996 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5997 cmd->max_table_usage = pstart->report_threshold_percent;
5998 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
5999
6000 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306001 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306002 cmd->probe_delay = 0;
6003 cmd->probe_spacing_time = 0;
6004 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306005 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6006 WMI_SCAN_ADD_CCK_RATES |
6007 WMI_SCAN_ADD_OFDM_RATES |
6008 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6009 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306010 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6011 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306012 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306013 cmd->num_ssids = 0;
6014 cmd->num_bssid = 0;
6015 cmd->ie_len = 0;
6016 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6017 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6018
6019 buf_ptr += sizeof(*cmd);
6020 WMITLV_SET_HDR(buf_ptr,
6021 WMITLV_TAG_ARRAY_FIXED_STRUC,
6022 num_ssid * sizeof(wmi_ssid));
6023 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6024
6025 WMITLV_SET_HDR(buf_ptr,
6026 WMITLV_TAG_ARRAY_FIXED_STRUC,
6027 num_bssid * sizeof(wmi_mac_addr));
6028 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6029
6030 ie_len_with_pad = 0;
6031 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6032 ie_len_with_pad);
6033 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6034
6035 WMITLV_SET_HDR(buf_ptr,
6036 WMITLV_TAG_ARRAY_STRUC,
6037 nbuckets * sizeof(wmi_extscan_bucket));
6038 dest_blist = (wmi_extscan_bucket *)
6039 (buf_ptr + WMI_TLV_HDR_SIZE);
6040 src_bucket = pstart->buckets;
6041
6042 /* Retrieve scanning information from each bucket and
6043 * channels and send it to the target
6044 */
6045 for (i = 0; i < nbuckets; i++) {
6046 WMITLV_SET_HDR(dest_blist,
6047 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6048 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6049
6050 dest_blist->bucket_id = src_bucket->bucket;
6051 dest_blist->base_period_multiplier =
6052 src_bucket->period / base_period;
6053 dest_blist->min_period = src_bucket->period;
6054 dest_blist->max_period = src_bucket->max_period;
6055 dest_blist->exp_backoff = src_bucket->exponent;
6056 dest_blist->exp_max_step_count = src_bucket->step_count;
6057 dest_blist->channel_band = src_bucket->band;
6058 dest_blist->num_channels = src_bucket->numChannels;
6059 dest_blist->notify_extscan_events = 0;
6060
6061 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6062 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006063 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6064 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306065
6066 if (src_bucket->reportEvents &
6067 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6068 dest_blist->forwarding_flags =
6069 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6070 dest_blist->notify_extscan_events |=
6071 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6072 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6073 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6074 } else {
6075 dest_blist->forwarding_flags =
6076 WMI_EXTSCAN_NO_FORWARDING;
6077 }
6078
6079 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6080 dest_blist->configuration_flags = 0;
6081 else
6082 dest_blist->configuration_flags =
6083 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6084
Govind Singhb53420c2016-03-09 14:32:57 +05306085 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306086 __func__, dest_blist->notify_extscan_events,
6087 dest_blist->configuration_flags,
6088 dest_blist->forwarding_flags);
6089
6090 dest_blist->min_dwell_time_active =
6091 src_bucket->min_dwell_time_active;
6092 dest_blist->max_dwell_time_active =
6093 src_bucket->max_dwell_time_active;
6094 dest_blist->min_dwell_time_passive =
6095 src_bucket->min_dwell_time_passive;
6096 dest_blist->max_dwell_time_passive =
6097 src_bucket->max_dwell_time_passive;
6098 src_channel = src_bucket->channels;
6099
6100 /* save the channel info to later populate
6101 * the channel TLV
6102 */
6103 for (k = 0; k < src_bucket->numChannels; k++) {
6104 save_channel[count++].channel = src_channel->channel;
6105 src_channel++;
6106 }
6107 dest_blist++;
6108 src_bucket++;
6109 }
6110 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6111 WMITLV_SET_HDR(buf_ptr,
6112 WMITLV_TAG_ARRAY_STRUC,
6113 nchannels * sizeof(wmi_extscan_bucket_channel));
6114 dest_clist = (wmi_extscan_bucket_channel *)
6115 (buf_ptr + WMI_TLV_HDR_SIZE);
6116
6117 /* Active or passive scan is based on the bucket dwell time
6118 * and channel specific active,passive scans are not
6119 * supported yet
6120 */
6121 for (i = 0; i < nchannels; i++) {
6122 WMITLV_SET_HDR(dest_clist,
6123 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6124 WMITLV_GET_STRUCT_TLVLEN
6125 (wmi_extscan_bucket_channel));
6126 dest_clist->channel = save_channel[i].channel;
6127 dest_clist++;
6128 }
6129 buf_ptr += WMI_TLV_HDR_SIZE +
6130 (nchannels * sizeof(wmi_extscan_bucket_channel));
6131 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306132 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306133}
6134
6135/**
6136 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6137 * @wmi_handle: wmi handle
6138 * @pstart: scan command request params
6139 *
6140 * This function sends start extscan request to fw.
6141 *
6142 * Return: CDF Status.
6143 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306144static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306145 struct wifi_scan_cmd_req_params *pstart)
6146{
Govind Singhb53420c2016-03-09 14:32:57 +05306147 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306148 wmi_buf_t buf;
6149 int len;
6150
6151 /* Fill individual elements of extscan request and
6152 * TLV for buckets, channel list.
6153 */
Govind Singhb53420c2016-03-09 14:32:57 +05306154 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306155 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306156 if (qdf_status != QDF_STATUS_SUCCESS) {
6157 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6158 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306159 }
6160 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306161 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306162 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306163 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306164 }
6165 if (wmi_unified_cmd_send(wmi_handle, buf,
6166 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306167 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306168 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306169 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306170 }
6171
Govind Singhb53420c2016-03-09 14:32:57 +05306172 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306173}
6174
6175/**
6176 * send_plm_stop_cmd_tlv() - plm stop request
6177 * @wmi_handle: wmi handle
6178 * @plm: plm request parameters
6179 *
6180 * This function request FW to stop PLM.
6181 *
6182 * Return: CDF status
6183 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306184static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306185 const struct plm_req_params *plm)
6186{
6187 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6188 int32_t len;
6189 wmi_buf_t buf;
6190 uint8_t *buf_ptr;
6191 int ret;
6192
6193 len = sizeof(*cmd);
6194 buf = wmi_buf_alloc(wmi_handle, len);
6195 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306196 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6197 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306198 }
6199
6200 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6201
6202 buf_ptr = (uint8_t *) cmd;
6203
6204 WMITLV_SET_HDR(&cmd->tlv_header,
6205 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6206 WMITLV_GET_STRUCT_TLVLEN
6207 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6208
6209 cmd->vdev_id = plm->session_id;
6210
6211 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306212 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306213
6214 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6215 WMI_VDEV_PLMREQ_STOP_CMDID);
6216 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306217 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306218 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306219 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306220 }
6221
Govind Singhb53420c2016-03-09 14:32:57 +05306222 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306223}
6224
6225/**
6226 * send_plm_start_cmd_tlv() - plm start request
6227 * @wmi_handle: wmi handle
6228 * @plm: plm request parameters
6229 *
6230 * This function request FW to start PLM.
6231 *
6232 * Return: CDF status
6233 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306234static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306235 const struct plm_req_params *plm,
6236 uint32_t *gchannel_list)
6237{
6238 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6239 uint32_t *channel_list;
6240 int32_t len;
6241 wmi_buf_t buf;
6242 uint8_t *buf_ptr;
6243 uint8_t count;
6244 int ret;
6245
6246 /* TLV place holder for channel_list */
6247 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6248 len += sizeof(uint32_t) * plm->plm_num_ch;
6249
6250 buf = wmi_buf_alloc(wmi_handle, len);
6251 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306252 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6253 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306254 }
6255 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6256
6257 buf_ptr = (uint8_t *) cmd;
6258
6259 WMITLV_SET_HDR(&cmd->tlv_header,
6260 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6261 WMITLV_GET_STRUCT_TLVLEN
6262 (wmi_vdev_plmreq_start_cmd_fixed_param));
6263
6264 cmd->vdev_id = plm->session_id;
6265
6266 cmd->meas_token = plm->meas_token;
6267 cmd->dialog_token = plm->diag_token;
6268 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306269 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306270 cmd->off_duration = plm->meas_duration;
6271 cmd->burst_cycle = plm->burst_len;
6272 cmd->tx_power = plm->desired_tx_pwr;
6273 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6274 cmd->num_chans = plm->plm_num_ch;
6275
6276 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6277
Govind Singhb53420c2016-03-09 14:32:57 +05306278 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6279 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6280 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6281 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6282 WMI_LOGD("off_duration: %d", cmd->off_duration);
6283 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6284 WMI_LOGD("tx_power: %d", cmd->tx_power);
6285 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306286
6287 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6288 (cmd->num_chans * sizeof(uint32_t)));
6289
6290 buf_ptr += WMI_TLV_HDR_SIZE;
6291 if (cmd->num_chans) {
6292 channel_list = (uint32_t *) buf_ptr;
6293 for (count = 0; count < cmd->num_chans; count++) {
6294 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306295 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306296 channel_list[count] =
6297 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306298 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306299 }
6300 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6301 }
6302
6303 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6304 WMI_VDEV_PLMREQ_START_CMDID);
6305 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306306 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306307 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306308 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306309 }
6310
Govind Singhb53420c2016-03-09 14:32:57 +05306311 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306312}
6313
6314/**
6315 * send_pno_stop_cmd_tlv() - PNO stop request
6316 * @wmi_handle: wmi handle
6317 * @vdev_id: vdev id
6318 *
6319 * This function request FW to stop ongoing PNO operation.
6320 *
6321 * Return: CDF status
6322 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306323static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306324{
6325 wmi_nlo_config_cmd_fixed_param *cmd;
6326 int32_t len = sizeof(*cmd);
6327 wmi_buf_t buf;
6328 uint8_t *buf_ptr;
6329 int ret;
6330
6331 /*
6332 * TLV place holder for array of structures nlo_configured_parameters
6333 * TLV place holder for array of uint32_t channel_list
6334 * TLV place holder for chnl prediction cfg
6335 */
6336 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6337 buf = wmi_buf_alloc(wmi_handle, len);
6338 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306339 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6340 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306341 }
6342
6343 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6344 buf_ptr = (uint8_t *) cmd;
6345
6346 WMITLV_SET_HDR(&cmd->tlv_header,
6347 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6348 WMITLV_GET_STRUCT_TLVLEN
6349 (wmi_nlo_config_cmd_fixed_param));
6350
6351 cmd->vdev_id = vdev_id;
6352 cmd->flags = WMI_NLO_CONFIG_STOP;
6353 buf_ptr += sizeof(*cmd);
6354
6355 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6356 buf_ptr += WMI_TLV_HDR_SIZE;
6357
6358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6359 buf_ptr += WMI_TLV_HDR_SIZE;
6360
6361 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6362 buf_ptr += WMI_TLV_HDR_SIZE;
6363
6364
6365 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6366 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6367 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306368 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306369 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306370 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306371 }
6372
Govind Singhb53420c2016-03-09 14:32:57 +05306373 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306374}
6375
6376/**
Govind Singhccb0c272016-04-01 16:30:08 +05306377 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6378 * @buf_ptr: Buffer passed by upper layers
6379 * @pno: Buffer to be sent to the firmware
6380 *
6381 * Copy the PNO Channel prediction configuration parameters
6382 * passed by the upper layers to a WMI format TLV and send it
6383 * down to the firmware.
6384 *
6385 * Return: None
6386 */
6387static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6388 struct pno_scan_req_params *pno)
6389{
6390 nlo_channel_prediction_cfg *channel_prediction_cfg =
6391 (nlo_channel_prediction_cfg *) buf_ptr;
6392 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6393 WMITLV_TAG_ARRAY_BYTE,
6394 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306395#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306396 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6397 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6398 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6399 channel_prediction_cfg->full_scan_period_ms =
6400 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306401#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306402 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6403 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6404 channel_prediction_cfg->enable,
6405 channel_prediction_cfg->top_k_num,
6406 channel_prediction_cfg->stationary_threshold,
6407 channel_prediction_cfg->full_scan_period_ms);
6408}
6409
6410/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306411 * send_pno_start_cmd_tlv() - PNO start request
6412 * @wmi_handle: wmi handle
6413 * @pno: PNO request
6414 *
6415 * This function request FW to start PNO request.
6416 * Request: CDF status
6417 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306418static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306419 struct pno_scan_req_params *pno,
6420 uint32_t *gchannel_freq_list)
6421{
6422 wmi_nlo_config_cmd_fixed_param *cmd;
6423 nlo_configured_parameters *nlo_list;
6424 uint32_t *channel_list;
6425 int32_t len;
6426 wmi_buf_t buf;
6427 uint8_t *buf_ptr;
6428 uint8_t i;
6429 int ret;
6430
6431 /*
6432 * TLV place holder for array nlo_configured_parameters(nlo_list)
6433 * TLV place holder for array of uint32_t channel_list
6434 * TLV place holder for chnnl prediction cfg
6435 */
6436 len = sizeof(*cmd) +
6437 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6438
Govind Singhb53420c2016-03-09 14:32:57 +05306439 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306440 WMI_NLO_MAX_CHAN);
6441 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306442 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306443 len += sizeof(nlo_channel_prediction_cfg);
6444
6445 buf = wmi_buf_alloc(wmi_handle, len);
6446 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306447 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6448 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306449 }
6450
6451 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6452
6453 buf_ptr = (uint8_t *) cmd;
6454 WMITLV_SET_HDR(&cmd->tlv_header,
6455 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6456 WMITLV_GET_STRUCT_TLVLEN
6457 (wmi_nlo_config_cmd_fixed_param));
6458 cmd->vdev_id = pno->sessionId;
6459 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6460
Govind Singh87542482016-06-08 19:40:11 +05306461#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306462 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6463 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306464#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306465 /* Current FW does not support min-max range for dwell time */
6466 cmd->active_dwell_time = pno->active_max_time;
6467 cmd->passive_dwell_time = pno->passive_max_time;
6468
6469 /* Copy scan interval */
6470 cmd->fast_scan_period = pno->fast_scan_period;
6471 cmd->slow_scan_period = pno->slow_scan_period;
6472 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306473 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306474 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306475 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306476
6477 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6478
Govind Singhb53420c2016-03-09 14:32:57 +05306479 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6480 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306481 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6482 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6483 buf_ptr += WMI_TLV_HDR_SIZE;
6484
6485 nlo_list = (nlo_configured_parameters *) buf_ptr;
6486 for (i = 0; i < cmd->no_of_ssids; i++) {
6487 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6488 WMITLV_TAG_ARRAY_BYTE,
6489 WMITLV_GET_STRUCT_TLVLEN
6490 (nlo_configured_parameters));
6491 /* Copy ssid and it's length */
6492 nlo_list[i].ssid.valid = true;
6493 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306494 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306495 pno->aNetworks[i].ssid.mac_ssid,
6496 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306497 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306498 nlo_list[i].ssid.ssid.ssid_len,
6499 (char *)nlo_list[i].ssid.ssid.ssid,
6500 nlo_list[i].ssid.ssid.ssid_len);
6501
6502 /* Copy rssi threshold */
6503 if (pno->aNetworks[i].rssiThreshold &&
6504 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6505 nlo_list[i].rssi_cond.valid = true;
6506 nlo_list[i].rssi_cond.rssi =
6507 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306508 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306509 nlo_list[i].rssi_cond.rssi);
6510 }
6511 nlo_list[i].bcast_nw_type.valid = true;
6512 nlo_list[i].bcast_nw_type.bcast_nw_type =
6513 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306514 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306515 nlo_list[i].bcast_nw_type.bcast_nw_type);
6516 }
6517 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6518
6519 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306520 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306521 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306522 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306523 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6524 (cmd->num_of_channels * sizeof(uint32_t)));
6525 buf_ptr += WMI_TLV_HDR_SIZE;
6526
6527 channel_list = (uint32_t *) buf_ptr;
6528 for (i = 0; i < cmd->num_of_channels; i++) {
6529 channel_list[i] = pno->aNetworks[0].aChannels[i];
6530
6531 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6532 channel_list[i] = gchannel_freq_list[i];
6533
Govind Singhb53420c2016-03-09 14:32:57 +05306534 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306535 }
6536 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6537 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6538 sizeof(nlo_channel_prediction_cfg));
6539 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306540 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306541 buf_ptr += WMI_TLV_HDR_SIZE;
6542 /** TODO: Discrete firmware doesn't have command/option to configure
6543 * App IE which comes from wpa_supplicant as of part PNO start request.
6544 */
6545 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6546 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6547 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306548 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306549 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306550 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306551 }
6552
Govind Singhb53420c2016-03-09 14:32:57 +05306553 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306554}
6555
6556/* send_set_ric_req_cmd_tlv() - set ric request element
6557 * @wmi_handle: wmi handle
6558 * @msg: message
6559 * @is_add_ts: is addts required
6560 *
6561 * This function sets ric request element for 11r roaming.
6562 *
6563 * Return: CDF status
6564 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306565static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306566 void *msg, uint8_t is_add_ts)
6567{
6568 wmi_ric_request_fixed_param *cmd;
6569 wmi_ric_tspec *tspec_param;
6570 wmi_buf_t buf;
6571 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306572 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306573 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6574 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6575
6576 buf = wmi_buf_alloc(wmi_handle, len);
6577 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306578 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6579 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306580 }
6581
6582 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6583
6584 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6585 WMITLV_SET_HDR(&cmd->tlv_header,
6586 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6587 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6588 if (is_add_ts)
6589 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
6590 else
6591 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
6592 cmd->num_ric_request = 1;
6593 cmd->is_add_ric = is_add_ts;
6594
6595 buf_ptr += sizeof(wmi_ric_request_fixed_param);
6596 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
6597
6598 buf_ptr += WMI_TLV_HDR_SIZE;
6599 tspec_param = (wmi_ric_tspec *) buf_ptr;
6600 WMITLV_SET_HDR(&tspec_param->tlv_header,
6601 WMITLV_TAG_STRUC_wmi_ric_tspec,
6602 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
6603
6604 if (is_add_ts)
6605 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05306606#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05306607 else
6608 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05306609#endif
6610 if (ptspecIE) {
6611 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05306612#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05306613 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
6614 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306615#else
Govind Singh87542482016-06-08 19:40:11 +05306616 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
6617 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306618#endif /* ANI_LITTLE_BIT_ENDIAN */
6619
Govind Singh87542482016-06-08 19:40:11 +05306620 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
6621 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
6622 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
6623 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
6624 tspec_param->inactivity_interval = ptspecIE->inactInterval;
6625 tspec_param->suspension_interval = ptspecIE->suspendInterval;
6626 tspec_param->svc_start_time = ptspecIE->svcStartTime;
6627 tspec_param->min_data_rate = ptspecIE->minDataRate;
6628 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
6629 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
6630 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
6631 tspec_param->delay_bound = ptspecIE->delayBound;
6632 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
6633 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
6634 tspec_param->medium_time = 0;
6635 }
Govind Singhb53420c2016-03-09 14:32:57 +05306636 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306637
6638 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6639 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306640 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306641 __func__);
6642 if (is_add_ts)
6643 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05306644 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05306645 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306646 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306647 }
6648
Govind Singhb53420c2016-03-09 14:32:57 +05306649 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306650}
6651
6652/**
6653 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
6654 * @wmi_handle: wmi handle
6655 * @clear_req: ll stats clear request command params
6656 *
Govind Singhb53420c2016-03-09 14:32:57 +05306657 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306658 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306659static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306660 const struct ll_stats_clear_params *clear_req,
6661 uint8_t addr[IEEE80211_ADDR_LEN])
6662{
6663 wmi_clear_link_stats_cmd_fixed_param *cmd;
6664 int32_t len;
6665 wmi_buf_t buf;
6666 uint8_t *buf_ptr;
6667 int ret;
6668
6669 len = sizeof(*cmd);
6670 buf = wmi_buf_alloc(wmi_handle, len);
6671
6672 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306673 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6674 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306675 }
6676
6677 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306678 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306679 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
6680
6681 WMITLV_SET_HDR(&cmd->tlv_header,
6682 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
6683 WMITLV_GET_STRUCT_TLVLEN
6684 (wmi_clear_link_stats_cmd_fixed_param));
6685
6686 cmd->stop_stats_collection_req = clear_req->stop_req;
6687 cmd->vdev_id = clear_req->sta_id;
6688 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
6689
6690 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6691 &cmd->peer_macaddr);
6692
Govind Singhb53420c2016-03-09 14:32:57 +05306693 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
6694 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
6695 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
6696 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
6697 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306698 cmd->peer_macaddr); */
6699
6700 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6701 WMI_CLEAR_LINK_STATS_CMDID);
6702 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306703 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306704 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306705 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306706 }
6707
Govind Singhb53420c2016-03-09 14:32:57 +05306708 WMI_LOGD("Clear Link Layer Stats request sent successfully");
6709 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306710}
6711
6712/**
6713 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
6714 * @wmi_handle: wmi handle
6715 * @setReq: ll stats set request command params
6716 *
Govind Singhb53420c2016-03-09 14:32:57 +05306717 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306718 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306719static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306720 const struct ll_stats_set_params *set_req)
6721{
6722 wmi_start_link_stats_cmd_fixed_param *cmd;
6723 int32_t len;
6724 wmi_buf_t buf;
6725 uint8_t *buf_ptr;
6726 int ret;
6727
6728 len = sizeof(*cmd);
6729 buf = wmi_buf_alloc(wmi_handle, len);
6730
6731 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306732 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6733 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306734 }
6735
6736 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306737 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306738 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
6739
6740 WMITLV_SET_HDR(&cmd->tlv_header,
6741 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
6742 WMITLV_GET_STRUCT_TLVLEN
6743 (wmi_start_link_stats_cmd_fixed_param));
6744
6745 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
6746 cmd->aggressive_statistics_gathering =
6747 set_req->aggressive_statistics_gathering;
6748
Govind Singhb53420c2016-03-09 14:32:57 +05306749 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
6750 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
6751 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306752
6753 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6754 WMI_START_LINK_STATS_CMDID);
6755 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306756 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306757 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306758 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306759 }
6760
Govind Singhb53420c2016-03-09 14:32:57 +05306761 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306762}
6763
6764/**
6765 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
6766 * @wmi_handle:wmi handle
6767 * @get_req:ll stats get request command params
6768 * @addr: mac address
6769 *
Govind Singhb53420c2016-03-09 14:32:57 +05306770 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306771 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306772static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306773 const struct ll_stats_get_params *get_req,
6774 uint8_t addr[IEEE80211_ADDR_LEN])
6775{
6776 wmi_request_link_stats_cmd_fixed_param *cmd;
6777 int32_t len;
6778 wmi_buf_t buf;
6779 uint8_t *buf_ptr;
6780 int ret;
6781
6782 len = sizeof(*cmd);
6783 buf = wmi_buf_alloc(wmi_handle, len);
6784
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05306785 if (!buf) {
6786 WMI_LOGE("%s: buf allocation failed", __func__);
6787 return QDF_STATUS_E_NOMEM;
6788 }
6789
Govind Singh4eacd2b2016-03-07 14:24:22 +05306790 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306791 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306792 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
6793
6794 WMITLV_SET_HDR(&cmd->tlv_header,
6795 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
6796 WMITLV_GET_STRUCT_TLVLEN
6797 (wmi_request_link_stats_cmd_fixed_param));
6798
6799 cmd->request_id = get_req->req_id;
6800 cmd->stats_type = get_req->param_id_mask;
6801 cmd->vdev_id = get_req->sta_id;
6802
6803 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
6804 &cmd->peer_macaddr);
6805
Govind Singhb53420c2016-03-09 14:32:57 +05306806 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
6807 WMI_LOGD("Request ID : %d", cmd->request_id);
6808 WMI_LOGD("Stats Type : %d", cmd->stats_type);
6809 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
6810 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306811
6812 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6813 WMI_REQUEST_LINK_STATS_CMDID);
6814 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306815 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306816 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306817 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306818 }
6819
Govind Singhb53420c2016-03-09 14:32:57 +05306820 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306821}
6822
6823/**
6824 * send_get_stats_cmd_tlv() - get stats request
6825 * @wmi_handle: wmi handle
6826 * @get_stats_param: stats params
6827 * @addr: mac address
6828 *
6829 * Return: CDF status
6830 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306831static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306832 struct pe_stats_req *get_stats_param,
6833 uint8_t addr[IEEE80211_ADDR_LEN])
6834{
6835 wmi_buf_t buf;
6836 wmi_request_stats_cmd_fixed_param *cmd;
6837 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6838
6839 buf = wmi_buf_alloc(wmi_handle, len);
6840 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306841 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
6842 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306843 }
6844
6845
6846 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6847 WMITLV_SET_HDR(&cmd->tlv_header,
6848 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6849 WMITLV_GET_STRUCT_TLVLEN
6850 (wmi_request_stats_cmd_fixed_param));
6851 cmd->stats_id =
6852 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05306853 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306854 cmd->vdev_id = get_stats_param->session_id;
6855 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05306856 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306857 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6858 WMI_REQUEST_STATS_CMDID)) {
6859
Govind Singhb53420c2016-03-09 14:32:57 +05306860 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306861 __func__);
6862 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306863 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306864 }
6865
Govind Singhb53420c2016-03-09 14:32:57 +05306866 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306867
6868}
6869
Govind Singh20c5dac2016-03-07 15:33:31 +05306870/**
6871 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
6872 * @wmi_handle: wmi handle
6873 * @rssi_req: get RSSI request
6874 *
6875 * Return: CDF status
6876 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306877static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05306878{
6879 wmi_buf_t buf;
6880 wmi_request_stats_cmd_fixed_param *cmd;
6881 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6882
6883 buf = wmi_buf_alloc(wmi_handle, len);
6884 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306885 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6886 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306887 }
6888
6889 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6890 WMITLV_SET_HDR(&cmd->tlv_header,
6891 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6892 WMITLV_GET_STRUCT_TLVLEN
6893 (wmi_request_stats_cmd_fixed_param));
6894 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6895 if (wmi_unified_cmd_send
6896 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306897 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306898 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306899 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306900 }
6901
Govind Singhb53420c2016-03-09 14:32:57 +05306902 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306903}
6904
6905/**
6906 * send_snr_cmd_tlv() - get RSSI from fw
6907 * @wmi_handle: wmi handle
6908 * @vdev_id: vdev id
6909 *
6910 * Return: CDF status
6911 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306912static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05306913{
6914 wmi_buf_t buf;
6915 wmi_request_stats_cmd_fixed_param *cmd;
6916 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6917
6918 buf = wmi_buf_alloc(wmi_handle, len);
6919 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306920 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6921 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306922 }
6923
6924 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6925 cmd->vdev_id = vdev_id;
6926
6927 WMITLV_SET_HDR(&cmd->tlv_header,
6928 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6929 WMITLV_GET_STRUCT_TLVLEN
6930 (wmi_request_stats_cmd_fixed_param));
6931 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6932 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6933 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306934 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306935 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306936 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306937 }
6938
Govind Singhb53420c2016-03-09 14:32:57 +05306939 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306940}
6941
6942/**
6943 * send_link_status_req_cmd_tlv() - process link status request from UMAC
6944 * @wmi_handle: wmi handle
6945 * @link_status: get link params
6946 *
6947 * Return: CDF status
6948 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306949static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306950 struct link_status_params *link_status)
6951{
6952 wmi_buf_t buf;
6953 wmi_request_stats_cmd_fixed_param *cmd;
6954 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6955
6956 buf = wmi_buf_alloc(wmi_handle, len);
6957 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306958 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6959 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306960 }
6961
6962 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6963 WMITLV_SET_HDR(&cmd->tlv_header,
6964 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6965 WMITLV_GET_STRUCT_TLVLEN
6966 (wmi_request_stats_cmd_fixed_param));
6967 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
6968 cmd->vdev_id = link_status->session_id;
6969 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6970 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306971 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306972 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306973 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306974 }
6975
Govind Singhb53420c2016-03-09 14:32:57 +05306976 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306977}
6978
6979#ifdef FEATURE_WLAN_LPHB
6980
6981/**
6982 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
6983 * @wmi_handle: wmi handle
6984 * @lphb_conf_req: configuration info
6985 *
6986 * Return: CDF status
6987 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306988static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306989 wmi_hb_set_enable_cmd_fixed_param *params)
6990{
Govind Singh67922e82016-04-01 16:48:57 +05306991 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306992 wmi_buf_t buf = NULL;
6993 uint8_t *buf_ptr;
6994 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
6995 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
6996
6997
6998 buf = wmi_buf_alloc(wmi_handle, len);
6999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307000 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7001 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307002 }
7003
7004 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7005 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
7006 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
7007 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
7008 WMITLV_GET_STRUCT_TLVLEN
7009 (wmi_hb_set_enable_cmd_fixed_param));
7010
7011 /* fill in values */
7012 hb_enable_fp->vdev_id = params->session;
7013 hb_enable_fp->enable = params->enable;
7014 hb_enable_fp->item = params->item;
7015 hb_enable_fp->session = params->session;
7016
7017 status = wmi_unified_cmd_send(wmi_handle, buf,
7018 len, WMI_HB_SET_ENABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307019 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307020 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_ENABLE returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307021 status);
Govind Singh67922e82016-04-01 16:48:57 +05307022 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307023 }
7024
Govind Singh67922e82016-04-01 16:48:57 +05307025 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307026}
7027
7028/**
7029 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
7030 * @wmi_handle: wmi handle
7031 * @lphb_conf_req: lphb config request
7032 *
7033 * Return: CDF status
7034 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307035static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307036 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
7037{
Govind Singh67922e82016-04-01 16:48:57 +05307038 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307039 wmi_buf_t buf = NULL;
7040 uint8_t *buf_ptr;
7041 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
7042 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
7043
7044 buf = wmi_buf_alloc(wmi_handle, len);
7045 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307046 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7047 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307048 }
7049
7050 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7051 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
7052 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
7053 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
7054 WMITLV_GET_STRUCT_TLVLEN
7055 (wmi_hb_set_tcp_params_cmd_fixed_param));
7056
7057 /* fill in values */
7058 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
7059 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
7060 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
7061 hb_tcp_params_fp->seq = lphb_conf_req->seq;
7062 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
7063 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
7064 hb_tcp_params_fp->interval = lphb_conf_req->interval;
7065 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
7066 hb_tcp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05307067 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05307068 &lphb_conf_req->gateway_mac,
7069 sizeof(hb_tcp_params_fp->gateway_mac));
7070
7071 status = wmi_unified_cmd_send(wmi_handle, buf,
7072 len, WMI_HB_SET_TCP_PARAMS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307073 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307074 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307075 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307076 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307077 }
7078
Govind Singh67922e82016-04-01 16:48:57 +05307079 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307080}
7081
7082/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307083 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
7084 * @wmi_handle: wmi handle
7085 * @lphb_conf_req: lphb config request
7086 *
7087 * Return: CDF status
7088 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307089static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307090 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
7091{
Govind Singh67922e82016-04-01 16:48:57 +05307092 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307093 wmi_buf_t buf = NULL;
7094 uint8_t *buf_ptr;
7095 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
7096 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
7097
7098 buf = wmi_buf_alloc(wmi_handle, len);
7099 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307100 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7101 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307102 }
7103
7104 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7105 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
7106 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
7107 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
7108 WMITLV_GET_STRUCT_TLVLEN
7109 (wmi_hb_set_udp_params_cmd_fixed_param));
7110
7111 /* fill in values */
7112 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
7113 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
7114 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
7115 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
7116 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
7117 hb_udp_params_fp->interval = lphb_conf_req->interval;
7118 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
7119 hb_udp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05307120 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05307121 &lphb_conf_req->gateway_mac,
7122 sizeof(lphb_conf_req->gateway_mac));
7123
7124 status = wmi_unified_cmd_send(wmi_handle, buf,
7125 len, WMI_HB_SET_UDP_PARAMS_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307126 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307127 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307128 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307129 wmi_buf_free(buf);
7130 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307131
Govind Singh67922e82016-04-01 16:48:57 +05307132 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307133}
7134
7135/**
7136 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
7137 * @wmi_handle: wmi handle
7138 * @lphb_conf_req: lphb config request
7139 *
7140 * Return: CDF status
7141 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307142static QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307143 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
7144{
Govind Singh67922e82016-04-01 16:48:57 +05307145 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307146 wmi_buf_t buf = NULL;
7147 uint8_t *buf_ptr;
7148 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
7149 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
7150
7151 buf = wmi_buf_alloc(wmi_handle, len);
7152 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307153 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7154 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307155 }
7156
7157 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7158 hb_udp_filter_fp =
7159 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
7160 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
7161 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
7162 WMITLV_GET_STRUCT_TLVLEN
7163 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
7164
7165 /* fill in values */
7166 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
7167 hb_udp_filter_fp->length = lphb_conf_req->length;
7168 hb_udp_filter_fp->offset = lphb_conf_req->offset;
7169 hb_udp_filter_fp->session = lphb_conf_req->session;
7170 memcpy((void *)&hb_udp_filter_fp->filter,
7171 (void *)&lphb_conf_req->filter,
7172 WMI_WLAN_HB_MAX_FILTER_SIZE);
7173
7174 status = wmi_unified_cmd_send(wmi_handle, buf,
7175 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307176 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307177 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307178 status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307179 wmi_buf_free(buf);
7180 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307181
Govind Singh67922e82016-04-01 16:48:57 +05307182 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307183}
7184#endif /* FEATURE_WLAN_LPHB */
7185
7186/**
7187 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7188 * @wmi_handle: wmi handle
7189 * @ta_dhcp_ind: DHCP indication parameter
7190 *
7191 * Return: CDF Status
7192 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307193static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307194 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7195{
Govind Singh67922e82016-04-01 16:48:57 +05307196 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307197 wmi_buf_t buf = NULL;
7198 uint8_t *buf_ptr;
7199 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7200 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7201
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 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7211 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7212 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7213 WMITLV_GET_STRUCT_TLVLEN
7214 (wmi_peer_set_param_cmd_fixed_param));
7215
7216 /* fill in values */
7217 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7218 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7219 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307220 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307221 &ta_dhcp_ind->peer_macaddr,
7222 sizeof(ta_dhcp_ind->peer_macaddr));
7223
7224 status = wmi_unified_cmd_send(wmi_handle, buf,
7225 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307226 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307227 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307228 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307229 wmi_buf_free(buf);
7230 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307231
Govind Singh67922e82016-04-01 16:48:57 +05307232 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307233}
7234
7235/**
7236 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7237 * @wmi_handle: wmi handle
7238 * @pLinkSpeed: link speed info
7239 *
7240 * Return: CDF status
7241 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307242static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307243 wmi_mac_addr peer_macaddr)
7244{
7245 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7246 wmi_buf_t wmi_buf;
7247 uint32_t len;
7248 uint8_t *buf_ptr;
7249
7250 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7251 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7252 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307253 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7254 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307255 }
7256 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7257
7258 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7259 WMITLV_SET_HDR(&cmd->tlv_header,
7260 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7261 WMITLV_GET_STRUCT_TLVLEN
7262 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7263
7264 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307265 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307266 &peer_macaddr,
7267 sizeof(peer_macaddr));
7268
7269
7270 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7271 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307272 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307273 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307274 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307275 }
Govind Singhb53420c2016-03-09 14:32:57 +05307276 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307277}
7278
7279/**
7280 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7281 * @wmi_handle: wmi handler
7282 * @egap_params: pointer to egap_params
7283 *
7284 * Return: 0 for success, otherwise appropriate error code
7285 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307286static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307287 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7288{
7289 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7290 wmi_buf_t buf;
7291 int32_t err;
7292
7293 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7294 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307295 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7296 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307297 }
7298 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7299 WMITLV_SET_HDR(&cmd->tlv_header,
7300 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7301 WMITLV_GET_STRUCT_TLVLEN(
7302 wmi_ap_ps_egap_param_cmd_fixed_param));
7303
7304 cmd->enable = egap_params->enable;
7305 cmd->inactivity_time = egap_params->inactivity_time;
7306 cmd->wait_time = egap_params->wait_time;
7307 cmd->flags = egap_params->flags;
7308 err = wmi_unified_cmd_send(wmi_handle, buf,
7309 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7310 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307311 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307312 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307313 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307314 }
7315
Govind Singhb53420c2016-03-09 14:32:57 +05307316 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307317}
7318
7319/**
Paul Zhangd19abd82017-01-04 16:45:42 +08007320 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
7321 * @wmi_handle: wmi handler
7322 * @action_params: pointer to action_params
7323 *
7324 * Return: 0 for success, otherwise appropriate error code
7325 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307326static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
Paul Zhangd19abd82017-01-04 16:45:42 +08007327 struct action_wakeup_set_param *action_params)
7328{
7329 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
7330 wmi_buf_t buf;
7331 int i;
7332 int32_t err;
7333
7334 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7335 if (!buf) {
7336 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
7337 return QDF_STATUS_E_NOMEM;
7338 }
7339 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
7340 WMITLV_SET_HDR(&cmd->tlv_header,
7341 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
7342 WMITLV_GET_STRUCT_TLVLEN(
7343 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
7344
7345 cmd->vdev_id = action_params->vdev_id;
7346 cmd->operation = action_params->operation;
7347
7348 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
7349 cmd->action_category_map[i] =
7350 action_params->action_category_map[i];
7351
7352 err = wmi_unified_cmd_send(wmi_handle, buf,
7353 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
7354 if (err) {
7355 WMI_LOGE("Failed to send ap_ps_egap cmd");
7356 wmi_buf_free(buf);
7357 return QDF_STATUS_E_FAILURE;
7358 }
7359
7360 return QDF_STATUS_SUCCESS;
7361}
7362
7363/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307364 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7365 * @wmi_handl: wmi handle
7366 * @cmd: Profiling command index
7367 * @value1: parameter1 value
7368 * @value2: parameter2 value
7369 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307370 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307371 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307372static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307373 uint32_t cmd, uint32_t value1, uint32_t value2)
7374{
7375 wmi_buf_t buf;
7376 int32_t len = 0;
7377 int ret;
7378 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7379 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7380 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7381 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7382
7383 switch (cmd) {
7384 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7385 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7386 buf = wmi_buf_alloc(wmi_handle, len);
7387 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307388 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307389 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307390 }
7391 prof_trig_cmd =
7392 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7393 wmi_buf_data(buf);
7394 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7395 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7396 WMITLV_GET_STRUCT_TLVLEN
7397 (wmi_wlan_profile_trigger_cmd_fixed_param));
7398 prof_trig_cmd->enable = value1;
7399 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7400 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7401 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307402 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307403 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307404 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307405 return ret;
7406 }
7407 break;
7408
7409 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7410 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7411 buf = wmi_buf_alloc(wmi_handle, len);
7412 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307413 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307414 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307415 }
7416 profile_getdata_cmd =
7417 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7418 wmi_buf_data(buf);
7419 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7420 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7421 WMITLV_GET_STRUCT_TLVLEN
7422 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7423 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7424 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7425 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307426 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307427 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307428 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307429 return ret;
7430 }
7431 break;
7432
7433 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7434 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7435 buf = wmi_buf_alloc(wmi_handle, len);
7436 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307437 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307438 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307439 }
7440 hist_intvl_cmd =
7441 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7442 wmi_buf_data(buf);
7443 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7444 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7445 WMITLV_GET_STRUCT_TLVLEN
7446 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7447 hist_intvl_cmd->profile_id = value1;
7448 hist_intvl_cmd->value = value2;
7449 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7450 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7451 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307452 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307453 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307454 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307455 return ret;
7456 }
7457 break;
7458
7459 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7460 len =
7461 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7462 buf = wmi_buf_alloc(wmi_handle, len);
7463 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307464 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307465 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307466 }
7467 profile_enable_cmd =
7468 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7469 wmi_buf_data(buf);
7470 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7471 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7472 WMITLV_GET_STRUCT_TLVLEN
7473 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7474 profile_enable_cmd->profile_id = value1;
7475 profile_enable_cmd->enable = value2;
7476 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7477 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7478 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307479 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307480 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307481 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307482 return ret;
7483 }
7484 break;
7485
7486 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307487 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307488 break;
7489 }
7490
7491 return 0;
7492}
7493
7494#ifdef FEATURE_WLAN_RA_FILTERING
7495/**
7496 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
7497 * @wmi_handle: wmi handle
7498 * @vdev_id: vdev id
7499 *
7500 * Return: CDF status
7501 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307502static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307503 uint8_t vdev_id, uint8_t default_pattern,
7504 uint16_t rate_limit_interval)
7505{
7506
7507 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7508 wmi_buf_t buf;
7509 uint8_t *buf_ptr;
7510 int32_t len;
7511 int ret;
7512
7513 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7514 WMI_TLV_HDR_SIZE +
7515 0 * sizeof(WOW_BITMAP_PATTERN_T) +
7516 WMI_TLV_HDR_SIZE +
7517 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7518 WMI_TLV_HDR_SIZE +
7519 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7520 WMI_TLV_HDR_SIZE +
7521 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7522 WMI_TLV_HDR_SIZE +
7523 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7524
7525 buf = wmi_buf_alloc(wmi_handle, len);
7526 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307527 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7528 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307529 }
7530
7531 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7532 buf_ptr = (uint8_t *) cmd;
7533
7534 WMITLV_SET_HDR(&cmd->tlv_header,
7535 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7536 WMITLV_GET_STRUCT_TLVLEN
7537 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7538 cmd->vdev_id = vdev_id;
7539 cmd->pattern_id = default_pattern,
7540 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
7541 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7542
7543 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
7544 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7545 buf_ptr += WMI_TLV_HDR_SIZE;
7546
7547 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7548 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7549 buf_ptr += WMI_TLV_HDR_SIZE;
7550
7551 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7552 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7553 buf_ptr += WMI_TLV_HDR_SIZE;
7554
7555 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7556 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7557 buf_ptr += WMI_TLV_HDR_SIZE;
7558
7559 /* Fill TLV for pattern_info_timeout but no data. */
7560 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7561 buf_ptr += WMI_TLV_HDR_SIZE;
7562
7563 /* Fill TLV for ra_ratelimit_interval. */
7564 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
7565 buf_ptr += WMI_TLV_HDR_SIZE;
7566
7567 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
7568
Govind Singhb53420c2016-03-09 14:32:57 +05307569 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05307570 rate_limit_interval, vdev_id);
7571
7572 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7573 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7574 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307575 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307576 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307577 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307578 }
7579
Govind Singhb53420c2016-03-09 14:32:57 +05307580 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307581
7582}
7583#endif /* FEATURE_WLAN_RA_FILTERING */
7584
7585/**
7586 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7587 * @wmi_handle: wmi handle
7588 * @vdev_id: vdev id
7589 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307590 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307591 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307592static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307593{
7594 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7595 wmi_buf_t buf;
7596 int32_t len = sizeof(*cmd);
7597
Govind Singhb53420c2016-03-09 14:32:57 +05307598 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307599 buf = wmi_buf_alloc(wmi_handle, len);
7600 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307601 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307602 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307603 }
7604 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7605 wmi_buf_data(buf);
7606 WMITLV_SET_HDR(&cmd->tlv_header,
7607 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7608 WMITLV_GET_STRUCT_TLVLEN
7609 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7610 cmd->vdev_id = vdev_id;
7611 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7612 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7613 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307614 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307615 __func__);
7616 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307617 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307618 }
7619
7620 return 0;
7621}
7622
7623/**
7624 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7625 * @wmi_handle: wmi handle
7626 * @vdev_id: vdev id
7627 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307628 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307629 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307630static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307631 uint8_t vdev_id)
7632{
7633 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7634 wmi_buf_t buf;
7635 int32_t len = sizeof(*cmd);
7636
Govind Singhb53420c2016-03-09 14:32:57 +05307637 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307638 buf = wmi_buf_alloc(wmi_handle, len);
7639 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307640 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307641 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307642 }
7643 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7644 WMITLV_SET_HDR(&cmd->tlv_header,
7645 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7646 WMITLV_GET_STRUCT_TLVLEN
7647 (wmi_csa_offload_enable_cmd_fixed_param));
7648 cmd->vdev_id = vdev_id;
7649 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7650 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7651 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307652 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307653 __func__);
7654 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307655 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307656 }
7657
7658 return 0;
7659}
7660
7661/**
7662 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7663 * @wmi_handle: wmi handle
7664 * @startOemDataReq: start request params
7665 *
7666 * Return: CDF status
7667 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307668static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007669 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307670 uint8_t *data)
7671{
7672 wmi_buf_t buf;
7673 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307674 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307675
7676 buf = wmi_buf_alloc(wmi_handle,
7677 (data_len + WMI_TLV_HDR_SIZE));
7678 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307679 WMI_LOGE(FL("wmi_buf_alloc failed"));
7680 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307681 }
7682
7683 cmd = (uint8_t *) wmi_buf_data(buf);
7684
7685 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7686 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307687 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307688 data_len);
7689
Govind Singhb53420c2016-03-09 14:32:57 +05307690 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307691 data_len);
7692
7693 ret = wmi_unified_cmd_send(wmi_handle, buf,
7694 (data_len +
7695 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7696
Govind Singh67922e82016-04-01 16:48:57 +05307697 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307698 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307699 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307700 }
7701
Govind Singh67922e82016-04-01 16:48:57 +05307702 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307703}
7704
7705/**
7706 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7707 * @wmi_handle: wmi handle
7708 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7709 *
7710 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7711 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7712 * to firmware based on phyerr filtering
7713 * offload status.
7714 *
7715 * Return: 1 success, 0 failure
7716 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307717static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307718send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7719 bool dfs_phyerr_filter_offload)
7720{
7721 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7722 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7723 wmi_buf_t buf;
7724 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307725 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307726
7727
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007728 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307729 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307730 __func__);
7731 len = sizeof(*disable_phyerr_offload_cmd);
7732 buf = wmi_buf_alloc(wmi_handle, len);
7733 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307734 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307735 return 0;
7736 }
7737 disable_phyerr_offload_cmd =
7738 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7739 wmi_buf_data(buf);
7740
7741 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7742 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7743 WMITLV_GET_STRUCT_TLVLEN
7744 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7745
7746 /*
7747 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7748 * to the firmware to disable the phyerror
7749 * filtering offload.
7750 */
7751 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7752 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307753 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307754 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307755 __func__, ret);
7756 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307757 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307758 }
Govind Singhb53420c2016-03-09 14:32:57 +05307759 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307760 __func__);
7761 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307762 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307763 __func__);
7764
7765 len = sizeof(*enable_phyerr_offload_cmd);
7766 buf = wmi_buf_alloc(wmi_handle, len);
7767 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307768 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7769 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307770 }
7771
7772 enable_phyerr_offload_cmd =
7773 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7774 wmi_buf_data(buf);
7775
7776 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7777 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7778 WMITLV_GET_STRUCT_TLVLEN
7779 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7780
7781 /*
7782 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7783 * to the firmware to enable the phyerror
7784 * filtering offload.
7785 */
7786 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7787 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7788
Govind Singh67922e82016-04-01 16:48:57 +05307789 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307790 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307791 __func__, ret);
7792 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307793 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307794 }
Govind Singhb53420c2016-03-09 14:32:57 +05307795 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307796 __func__);
7797 }
7798
Govind Singhb53420c2016-03-09 14:32:57 +05307799 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307800}
7801
7802#if !defined(REMOVE_PKT_LOG)
7803/**
7804 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7805 * @wmi_handle: wmi handle
7806 * @pktlog_event: pktlog event
7807 * @cmd_id: pktlog cmd id
7808 *
7809 * Return: CDF status
7810 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307811static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307812 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307813 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307814{
7815 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7816 WMI_CMD_ID CMD_ID;
7817 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7818 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7819 int len = 0;
7820 wmi_buf_t buf;
7821
7822 PKTLOG_EVENT = pktlog_event;
7823 CMD_ID = cmd_id;
7824
7825 switch (CMD_ID) {
7826 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7827 len = sizeof(*cmd);
7828 buf = wmi_buf_alloc(wmi_handle, len);
7829 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307830 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7831 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307832 }
7833 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7834 wmi_buf_data(buf);
7835 WMITLV_SET_HDR(&cmd->tlv_header,
7836 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7837 WMITLV_GET_STRUCT_TLVLEN
7838 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7839 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307840 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7841 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007842 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307843 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7844 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307845 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307846 goto wmi_send_failed;
7847 }
7848 break;
7849 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7850 len = sizeof(*disable_cmd);
7851 buf = wmi_buf_alloc(wmi_handle, len);
7852 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307853 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7854 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307855 }
7856 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7857 wmi_buf_data(buf);
7858 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7859 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7860 WMITLV_GET_STRUCT_TLVLEN
7861 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007862 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307863 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7864 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307865 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307866 goto wmi_send_failed;
7867 }
7868 break;
7869 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307870 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307871 break;
7872 }
7873
Govind Singhb53420c2016-03-09 14:32:57 +05307874 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307875
7876wmi_send_failed:
7877 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307878 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307879}
7880#endif /* REMOVE_PKT_LOG */
7881
7882/**
7883 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
7884 * @wmi_handle: wmi handle
7885 * @vdev_id: vdev id
7886 * @bitmap: Event bitmap
7887 * @enable: enable/disable
7888 *
7889 * Return: CDF status
7890 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307891static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307892 uint32_t vdev_id,
7893 uint32_t bitmap,
7894 bool enable)
7895{
7896 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
7897 uint16_t len;
7898 wmi_buf_t buf;
7899 int ret;
7900
7901 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
7902 buf = wmi_buf_alloc(wmi_handle, len);
7903 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307904 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7905 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307906 }
7907 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
7908 WMITLV_SET_HDR(&cmd->tlv_header,
7909 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
7910 WMITLV_GET_STRUCT_TLVLEN
7911 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
7912 cmd->vdev_id = vdev_id;
7913 cmd->is_add = enable;
7914 cmd->event_bitmap = bitmap;
7915
7916 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7917 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
7918 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307919 WMI_LOGE("Failed to config wow wakeup event");
Govind Singh20c5dac2016-03-07 15:33:31 +05307920 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307921 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307922 }
7923
Govind Singhb53420c2016-03-09 14:32:57 +05307924 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
Govind Singh20c5dac2016-03-07 15:33:31 +05307925 enable ? "enabled" : "disabled");
7926
Govind Singhb53420c2016-03-09 14:32:57 +05307927 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307928}
7929
7930/**
7931 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
7932 * @wmi_handle: wmi handle
7933 * @vdev_id: vdev id
7934 * @ptrn_id: pattern id
7935 * @ptrn: pattern
7936 * @ptrn_len: pattern length
7937 * @ptrn_offset: pattern offset
7938 * @mask: mask
7939 * @mask_len: mask length
7940 * @user: true for user configured pattern and false for default pattern
7941 * @default_patterns: default patterns
7942 *
7943 * Return: CDF status
7944 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307945static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307946 uint8_t vdev_id, uint8_t ptrn_id,
7947 const uint8_t *ptrn, uint8_t ptrn_len,
7948 uint8_t ptrn_offset, const uint8_t *mask,
7949 uint8_t mask_len, bool user,
7950 uint8_t default_patterns)
7951{
7952 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7953 WOW_BITMAP_PATTERN_T *bitmap_pattern;
7954 wmi_buf_t buf;
7955 uint8_t *buf_ptr;
7956 int32_t len;
7957 int ret;
7958
7959
7960 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7961 WMI_TLV_HDR_SIZE +
7962 1 * sizeof(WOW_BITMAP_PATTERN_T) +
7963 WMI_TLV_HDR_SIZE +
7964 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7965 WMI_TLV_HDR_SIZE +
7966 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7967 WMI_TLV_HDR_SIZE +
7968 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7969 WMI_TLV_HDR_SIZE +
7970 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7971
7972 buf = wmi_buf_alloc(wmi_handle, len);
7973 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307974 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7975 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307976 }
7977
7978 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7979 buf_ptr = (uint8_t *) cmd;
7980
7981 WMITLV_SET_HDR(&cmd->tlv_header,
7982 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7983 WMITLV_GET_STRUCT_TLVLEN
7984 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7985 cmd->vdev_id = vdev_id;
7986 cmd->pattern_id = ptrn_id;
7987
7988 cmd->pattern_type = WOW_BITMAP_PATTERN;
7989 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7990
7991 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7992 sizeof(WOW_BITMAP_PATTERN_T));
7993 buf_ptr += WMI_TLV_HDR_SIZE;
7994 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
7995
7996 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
7997 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
7998 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
7999
Govind Singhb53420c2016-03-09 14:32:57 +05308000 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
8001 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308002
8003 bitmap_pattern->pattern_offset = ptrn_offset;
8004 bitmap_pattern->pattern_len = ptrn_len;
8005
8006 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
8007 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
8008
8009 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
8010 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
8011
8012 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
8013 bitmap_pattern->pattern_id = ptrn_id;
8014
Govind Singhb53420c2016-03-09 14:32:57 +05308015 WMI_LOGI("vdev id : %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308016 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
8017 bitmap_pattern->pattern_offset, user);
Govind Singh87542482016-06-08 19:40:11 +05308018#ifdef CONFIG_MCL
Govind Singhb53420c2016-03-09 14:32:57 +05308019 WMI_LOGI("Pattern : ");
8020 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05308021 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
8022
Govind Singhb53420c2016-03-09 14:32:57 +05308023 WMI_LOGI("Mask : ");
8024 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05308025 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
Govind Singh87542482016-06-08 19:40:11 +05308026#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308027
8028 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
8029
8030 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
8031 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8032 buf_ptr += WMI_TLV_HDR_SIZE;
8033
8034 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
8035 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8036 buf_ptr += WMI_TLV_HDR_SIZE;
8037
8038 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
8039 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8040 buf_ptr += WMI_TLV_HDR_SIZE;
8041
8042 /* Fill TLV for pattern_info_timeout but no data. */
8043 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
8044 buf_ptr += WMI_TLV_HDR_SIZE;
8045
8046 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
8047 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
8048 buf_ptr += WMI_TLV_HDR_SIZE;
8049 *(A_UINT32 *) buf_ptr = 0;
8050
8051 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8052 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
8053 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308054 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308055 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308056 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308057 }
8058
Govind Singhb53420c2016-03-09 14:32:57 +05308059 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308060}
8061
8062/**
8063 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8064 * @wmi_handle: wmi handle
8065 * @ptrn_id: pattern id
8066 * @vdev_id: vdev id
8067 *
8068 * Return: CDF status
8069 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308070static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle, uint8_t ptrn_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308071 uint8_t vdev_id)
8072{
8073 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8074 wmi_buf_t buf;
8075 int32_t len;
8076 int ret;
8077
8078 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8079
8080
8081 buf = wmi_buf_alloc(wmi_handle, len);
8082 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308083 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8084 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308085 }
8086
8087 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8088
8089 WMITLV_SET_HDR(&cmd->tlv_header,
8090 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8091 WMITLV_GET_STRUCT_TLVLEN(
8092 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8093 cmd->vdev_id = vdev_id;
8094 cmd->pattern_id = ptrn_id;
8095 cmd->pattern_type = WOW_BITMAP_PATTERN;
8096
Govind Singhb53420c2016-03-09 14:32:57 +05308097 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308098 cmd->pattern_id, vdev_id);
8099
8100 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8101 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8102 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308103 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308104 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308105 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308106 }
8107
Govind Singhb53420c2016-03-09 14:32:57 +05308108 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308109}
8110
8111/**
8112 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8113 * @wmi_handle: wmi handle
8114 *
8115 * Sends host wakeup indication to FW. On receiving this indication,
8116 * FW will come out of WOW.
8117 *
8118 * Return: CDF status
8119 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308120static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308121{
8122 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8123 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308124 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308125 int32_t len;
8126 int ret;
8127
8128 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8129
8130 buf = wmi_buf_alloc(wmi_handle, len);
8131 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308132 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8133 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308134 }
8135
8136 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8137 wmi_buf_data(buf);
8138 WMITLV_SET_HDR(&cmd->tlv_header,
8139 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8140 WMITLV_GET_STRUCT_TLVLEN
8141 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8142
8143
8144 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8145 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8146 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308147 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308148 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308149 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308150 }
8151
Govind Singhb53420c2016-03-09 14:32:57 +05308152 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308153}
8154
8155/**
8156 * send_del_ts_cmd_tlv() - send DELTS request to fw
8157 * @wmi_handle: wmi handle
8158 * @msg: delts params
8159 *
8160 * Return: CDF status
8161 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308162static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308163 uint8_t ac)
8164{
8165 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8166 wmi_buf_t buf;
8167 int32_t len = sizeof(*cmd);
8168
8169 buf = wmi_buf_alloc(wmi_handle, len);
8170 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308171 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8172 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308173 }
8174 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8175 WMITLV_SET_HDR(&cmd->tlv_header,
8176 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8177 WMITLV_GET_STRUCT_TLVLEN
8178 (wmi_vdev_wmm_delts_cmd_fixed_param));
8179 cmd->vdev_id = vdev_id;
8180 cmd->ac = ac;
8181
Govind Singhb53420c2016-03-09 14:32:57 +05308182 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308183 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8184 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8185 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308186 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308187 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308188 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308189 }
8190
Govind Singhb53420c2016-03-09 14:32:57 +05308191 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308192}
8193
8194/**
8195 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8196 * @wmi_handle: handle to wmi
8197 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8198 *
Govind Singhb53420c2016-03-09 14:32:57 +05308199 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308200 * ADD_TS requestes to firmware in loop for all the ACs with
8201 * active flow.
8202 *
8203 * Return: CDF status
8204 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308205static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308206 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8207{
8208 int i = 0;
8209 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8210 wmi_buf_t buf;
8211 int32_t len = sizeof(*cmd);
8212
8213 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8214 /* if flow in this AC is active */
8215 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8216 /*
8217 * as per implementation of wma_add_ts_req() we
8218 * are not waiting any response from firmware so
8219 * apart from sending ADDTS to firmware just send
8220 * success to upper layers
8221 */
Govind Singhb53420c2016-03-09 14:32:57 +05308222 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308223
8224 buf = wmi_buf_alloc(wmi_handle, len);
8225 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308226 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8227 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308228 }
8229 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8230 wmi_buf_data(buf);
8231 WMITLV_SET_HDR(&cmd->tlv_header,
8232 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8233 WMITLV_GET_STRUCT_TLVLEN
8234 (wmi_vdev_wmm_addts_cmd_fixed_param));
8235 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8236 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308237 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308238 traffic.userPrio);
8239 cmd->medium_time_us =
8240 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8241 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308242 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308243 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8244 cmd->medium_time_us, cmd->downgrade_type);
8245 if (wmi_unified_cmd_send
8246 (wmi_handle, buf, len,
8247 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308248 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308249 __func__);
8250 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308251 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308252 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308253 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308254 }
8255 }
8256 }
8257
Govind Singhb53420c2016-03-09 14:32:57 +05308258 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308259}
8260
8261/**
8262 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8263 * @wmi_handle: wmi handle
8264 * @msg: ADDTS params
8265 *
8266 * Return: CDF status
8267 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308268static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308269 struct add_ts_param *msg)
8270{
8271 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8272 wmi_buf_t buf;
8273 int32_t len = sizeof(*cmd);
8274
Govind Singhb53420c2016-03-09 14:32:57 +05308275 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308276
8277 buf = wmi_buf_alloc(wmi_handle, len);
8278 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308279 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8280 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308281 }
8282 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) 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 = msg->sme_session_id;
8288 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8289 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8290 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308291 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308292 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8293 cmd->downgrade_type, __func__, __LINE__);
8294 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8295 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308296 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8297 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308298 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308299 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308300 }
8301
Govind Singhb53420c2016-03-09 14:32:57 +05308302 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308303}
8304
8305/**
8306 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
8307 * @wmi_handle: wmi handle
8308 * @vdev_id: vdev id
8309 * @enable: Flag to enable/disable packet filter
8310 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308311 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308312 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308313static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308314 uint8_t vdev_id, bool enable)
8315{
8316 int32_t len;
8317 int ret = 0;
8318 wmi_buf_t buf;
8319 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
8320
8321 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
8322
8323 buf = wmi_buf_alloc(wmi_handle, len);
8324 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308325 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308326 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308327 }
8328
8329 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
8330 WMITLV_SET_HDR(&cmd->tlv_header,
8331 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
8332 WMITLV_GET_STRUCT_TLVLEN(
8333 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
8334
8335 cmd->vdev_id = vdev_id;
8336 if (enable)
8337 cmd->enable = PACKET_FILTER_SET_ENABLE;
8338 else
8339 cmd->enable = PACKET_FILTER_SET_DISABLE;
8340
Govind Singhb53420c2016-03-09 14:32:57 +05308341 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308342 __func__, cmd->enable, vdev_id);
8343
8344 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8345 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308346 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308347 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308348 wmi_buf_free(buf);
8349 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308350
8351 return ret;
8352}
8353
8354/**
8355 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
8356 * @wmi_handle: wmi handle
8357 * @vdev_id: vdev id
8358 * @rcv_filter_param: Packet filter parameters
8359 * @filter_id: Filter id
8360 * @enable: Flag to add/delete packet filter configuration
8361 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308362 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308363 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308364static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308365 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8366 uint8_t filter_id, bool enable)
8367{
8368 int len, i;
8369 int err = 0;
8370 wmi_buf_t buf;
8371 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8372
8373
8374 /* allocate the memory */
8375 len = sizeof(*cmd);
8376 buf = wmi_buf_alloc(wmi_handle, len);
8377 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308378 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308379 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308380 }
8381
8382 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8383 WMITLV_SET_HDR(&cmd->tlv_header,
8384 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8385 WMITLV_GET_STRUCT_TLVLEN
8386 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8387
8388 cmd->vdev_id = vdev_id;
8389 cmd->filter_id = filter_id;
8390 if (enable)
8391 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8392 else
8393 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8394
8395 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308396 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308397 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8398 rcv_filter_param->numFieldParams);
8399 cmd->filter_type = rcv_filter_param->filterType;
8400 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8401
8402 for (i = 0; i < cmd->num_params; i++) {
8403 cmd->paramsData[i].proto_type =
8404 rcv_filter_param->paramsData[i].protocolLayer;
8405 cmd->paramsData[i].cmp_type =
8406 rcv_filter_param->paramsData[i].cmpFlag;
8407 cmd->paramsData[i].data_length =
8408 rcv_filter_param->paramsData[i].dataLength;
8409 cmd->paramsData[i].data_offset =
8410 rcv_filter_param->paramsData[i].dataOffset;
8411 memcpy(&cmd->paramsData[i].compareData,
8412 rcv_filter_param->paramsData[i].compareData,
8413 sizeof(cmd->paramsData[i].compareData));
8414 memcpy(&cmd->paramsData[i].dataMask,
8415 rcv_filter_param->paramsData[i].dataMask,
8416 sizeof(cmd->paramsData[i].dataMask));
8417 }
8418 }
8419
Govind Singhb53420c2016-03-09 14:32:57 +05308420 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308421 cmd->filter_action, cmd->filter_id, cmd->num_params);
8422 /* send the command along with data */
8423 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8424 WMI_PACKET_FILTER_CONFIG_CMDID);
8425 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308426 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308427 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308428 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308429 }
8430
8431
8432 return 0;
8433}
8434
8435/**
8436 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
8437 * @wmi_handle: wmi handle
8438 * @vdev_id: vdev id
8439 * @multicastAddr: mcast address
8440 * @clearList: clear list flag
8441 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308442 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308443 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308444static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308445 uint8_t vdev_id,
Govind Singhb53420c2016-03-09 14:32:57 +05308446 struct qdf_mac_addr multicast_addr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308447 bool clearList)
8448{
8449 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
8450 wmi_buf_t buf;
8451 int err;
8452
8453 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8454 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308455 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308456 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308457 }
8458
8459 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308460 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308461
8462 WMITLV_SET_HDR(&cmd->tlv_header,
8463 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
8464 WMITLV_GET_STRUCT_TLVLEN
8465 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
8466 cmd->action =
8467 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
8468 cmd->vdev_id = vdev_id;
8469 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
Dustin Brown4103e4a2016-11-14 16:11:26 -08008470
8471 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
8472 cmd->action, vdev_id, clearList, multicast_addr.bytes);
8473
Govind Singh20c5dac2016-03-07 15:33:31 +05308474 err = wmi_unified_cmd_send(wmi_handle, buf,
8475 sizeof(*cmd),
8476 WMI_SET_MCASTBCAST_FILTER_CMDID);
8477 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308478 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +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 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308482
Dustin Brown4103e4a2016-11-14 16:11:26 -08008483 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308484}
8485
8486/**
8487 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
8488 * @wmi_handle: wmi handle
8489 * @vdev_id: vdev id
8490 * @params: GTK offload parameters
8491 *
8492 * Return: CDF status
8493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308494static QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308495 struct gtk_offload_params *params,
8496 bool enable_offload,
8497 uint32_t gtk_offload_opcode)
8498{
8499 int len;
8500 wmi_buf_t buf;
8501 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308502 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308503
Govind Singhb53420c2016-03-09 14:32:57 +05308504 WMI_LOGD("%s Enter", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308505
8506 len = sizeof(*cmd);
8507
8508 /* alloc wmi buffer */
8509 buf = wmi_buf_alloc(wmi_handle, len);
8510 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308511 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8512 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308513 goto out;
8514 }
8515
8516 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8517 WMITLV_SET_HDR(&cmd->tlv_header,
8518 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8519 WMITLV_GET_STRUCT_TLVLEN
8520 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8521
8522 cmd->vdev_id = vdev_id;
8523
8524 /* Request target to enable GTK offload */
Siddarth Poddar9500f2e2016-04-01 17:45:06 +05308525 if (enable_offload == WMI_GTK_OFFLOAD_ENABLE) {
Govind Singh20c5dac2016-03-07 15:33:31 +05308526 cmd->flags = gtk_offload_opcode;
8527
8528 /* Copy the keys and replay counter */
Govind Singhb53420c2016-03-09 14:32:57 +05308529 qdf_mem_copy(cmd->KCK, params->aKCK, WMI_GTK_OFFLOAD_KCK_BYTES);
8530 qdf_mem_copy(cmd->KEK, params->aKEK, WMI_GTK_OFFLOAD_KEK_BYTES);
8531 qdf_mem_copy(cmd->replay_counter, &params->ullKeyReplayCounter,
Govind Singh20c5dac2016-03-07 15:33:31 +05308532 GTK_REPLAY_COUNTER_BYTES);
8533 } else {
8534 cmd->flags = gtk_offload_opcode;
8535 }
8536
Dustin Brown4103e4a2016-11-14 16:11:26 -08008537 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
8538
Govind Singh20c5dac2016-03-07 15:33:31 +05308539 /* send the wmi command */
8540 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8541 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308542 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
Govind Singh20c5dac2016-03-07 15:33:31 +05308543 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308544 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308545 }
8546
Govind Singh20c5dac2016-03-07 15:33:31 +05308547out:
Govind Singhb53420c2016-03-09 14:32:57 +05308548 WMI_LOGD("%s Exit", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308549 return status;
8550}
8551
8552/**
8553 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
8554 * @wmi_handle: wmi handle
8555 * @params: GTK offload params
8556 *
8557 * Return: CDF status
8558 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308559static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308560 uint8_t vdev_id,
8561 uint64_t offload_req_opcode)
8562{
8563 int len;
8564 wmi_buf_t buf;
8565 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05308566 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308567
8568 len = sizeof(*cmd);
8569
8570 /* alloc wmi buffer */
8571 buf = wmi_buf_alloc(wmi_handle, len);
8572 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308573 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
8574 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308575 goto out;
8576 }
8577
8578 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
8579 WMITLV_SET_HDR(&cmd->tlv_header,
8580 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
8581 WMITLV_GET_STRUCT_TLVLEN
8582 (WMI_GTK_OFFLOAD_CMD_fixed_param));
8583
8584 /* Request for GTK offload status */
8585 cmd->flags = offload_req_opcode;
8586 cmd->vdev_id = vdev_id;
8587
8588 /* send the wmi command */
8589 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8590 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308591 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
Govind Singh20c5dac2016-03-07 15:33:31 +05308592 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308593 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308594 }
8595
8596out:
8597 return status;
8598}
8599
8600/**
8601 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8602 * @wmi_handle: wmi handle
8603 * @pAddPeriodicTxPtrnParams: tx ptrn params
8604 *
8605 * Retrun: CDF status
8606 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308607static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308608 struct periodic_tx_pattern *
8609 pAddPeriodicTxPtrnParams,
8610 uint8_t vdev_id)
8611{
8612 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8613 wmi_buf_t wmi_buf;
8614 uint32_t len;
8615 uint8_t *buf_ptr;
8616 uint32_t ptrn_len, ptrn_len_aligned;
8617 int j;
8618
8619 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8620 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8621 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8622 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8623
8624 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8625 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308626 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8627 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308628 }
8629
8630 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8631
8632 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8633 WMITLV_SET_HDR(&cmd->tlv_header,
8634 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8635 WMITLV_GET_STRUCT_TLVLEN
8636 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8637
8638 /* Pass the pattern id to delete for the corresponding vdev id */
8639 cmd->vdev_id = vdev_id;
8640 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8641 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8642 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8643
8644 /* Pattern info */
8645 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8646 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8647 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308648 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308649 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308650 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308651
Govind Singhb53420c2016-03-09 14:32:57 +05308652 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308653 __func__, cmd->pattern_id, cmd->vdev_id);
8654
8655 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8656 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308657 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308658 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308659 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308660 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308661 }
Govind Singhb53420c2016-03-09 14:32:57 +05308662 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308663}
8664
8665/**
8666 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8667 * @wmi_handle: wmi handle
8668 * @vdev_id: vdev id
8669 * @pattern_id: pattern id
8670 *
8671 * Retrun: CDF status
8672 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308673static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308674 uint8_t vdev_id,
8675 uint8_t pattern_id)
8676{
8677 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8678 wmi_buf_t wmi_buf;
8679 uint32_t len =
8680 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8681
8682 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8683 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308684 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8685 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308686 }
8687
8688 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8689 wmi_buf_data(wmi_buf);
8690 WMITLV_SET_HDR(&cmd->tlv_header,
8691 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8692 WMITLV_GET_STRUCT_TLVLEN
8693 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8694
8695 /* Pass the pattern id to delete for the corresponding vdev id */
8696 cmd->vdev_id = vdev_id;
8697 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308698 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308699 __func__, cmd->pattern_id, cmd->vdev_id);
8700
8701 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8702 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308703 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308704 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308705 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308706 }
Govind Singhb53420c2016-03-09 14:32:57 +05308707 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308708}
8709
8710/**
8711 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8712 * @wmi_handle: wmi handle
8713 * @preq: stats ext params
8714 *
8715 * Return: CDF status
8716 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308717static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308718 struct stats_ext_params *preq)
8719{
Govind Singh67922e82016-04-01 16:48:57 +05308720 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308721 wmi_req_stats_ext_cmd_fixed_param *cmd;
8722 wmi_buf_t buf;
8723 uint16_t len;
8724 uint8_t *buf_ptr;
8725
8726 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8727
8728 buf = wmi_buf_alloc(wmi_handle, len);
8729 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308730 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308731 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308732 }
8733
8734 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8735 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8736
8737 WMITLV_SET_HDR(&cmd->tlv_header,
8738 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8739 WMITLV_GET_STRUCT_TLVLEN
8740 (wmi_req_stats_ext_cmd_fixed_param));
8741 cmd->vdev_id = preq->vdev_id;
8742 cmd->data_len = preq->request_data_len;
8743
Govind Singhb53420c2016-03-09 14:32:57 +05308744 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308745 __func__, preq->request_data_len, preq->vdev_id);
8746
8747 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8748 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8749
8750 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308751 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308752
8753 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8754 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308755 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308756 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308757 ret);
8758 wmi_buf_free(buf);
8759 }
8760
8761 return ret;
8762}
8763
8764/**
8765 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8766 * @wmi_handle: wmi handle
8767 * @params: ext wow params
8768 *
8769 * Return:0 for success or error code
8770 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308771static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308772 struct ext_wow_params *params)
8773{
8774 wmi_extwow_enable_cmd_fixed_param *cmd;
8775 wmi_buf_t buf;
8776 int32_t len;
8777 int ret;
8778
8779 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8780 buf = wmi_buf_alloc(wmi_handle, len);
8781 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308782 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8783 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308784 }
8785
8786 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8787
8788 WMITLV_SET_HDR(&cmd->tlv_header,
8789 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8790 WMITLV_GET_STRUCT_TLVLEN
8791 (wmi_extwow_enable_cmd_fixed_param));
8792
8793 cmd->vdev_id = params->vdev_id;
8794 cmd->type = params->type;
8795 cmd->wakeup_pin_num = params->wakeup_pin_num;
8796
Govind Singhb53420c2016-03-09 14:32:57 +05308797 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308798 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8799
8800 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8801 WMI_EXTWOW_ENABLE_CMDID);
8802 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308803 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308804 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308805 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308806 }
8807
Govind Singhb53420c2016-03-09 14:32:57 +05308808 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308809
8810}
8811
8812/**
8813 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8814 * @wmi_handle: wmi handle
8815 * @app_type1_params: app type1 params
8816 *
8817 * Return: CDF status
8818 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308819static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308820 struct app_type1_params *app_type1_params)
8821{
8822 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8823 wmi_buf_t buf;
8824 int32_t len;
8825 int ret;
8826
8827 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8828 buf = wmi_buf_alloc(wmi_handle, len);
8829 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308830 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8831 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308832 }
8833
8834 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8835 wmi_buf_data(buf);
8836
8837 WMITLV_SET_HDR(&cmd->tlv_header,
8838 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8839 WMITLV_GET_STRUCT_TLVLEN
8840 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8841
8842 cmd->vdev_id = app_type1_params->vdev_id;
8843 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8844 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308845 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308846 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308847 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308848 cmd->passwd_len = app_type1_params->pass_length;
8849
Govind Singhb53420c2016-03-09 14:32:57 +05308850 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308851 "identification_id %.8s id_length %u "
8852 "password %.16s pass_length %u",
8853 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8854 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8855
8856 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8857 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8858 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308859 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308860 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308861 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308862 }
8863
Govind Singhb53420c2016-03-09 14:32:57 +05308864 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308865}
8866
8867/**
8868 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8869 * @wmi_handle: wmi handle
8870 * @appType2Params: app type2 params
8871 *
8872 * Return: CDF status
8873 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308874static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308875 struct app_type2_params *appType2Params)
8876{
8877 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8878 wmi_buf_t buf;
8879 int32_t len;
8880 int ret;
8881
8882 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8883 buf = wmi_buf_alloc(wmi_handle, len);
8884 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308885 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8886 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308887 }
8888
8889 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8890 wmi_buf_data(buf);
8891
8892 WMITLV_SET_HDR(&cmd->tlv_header,
8893 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8894 WMITLV_GET_STRUCT_TLVLEN
8895 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8896
8897 cmd->vdev_id = appType2Params->vdev_id;
8898
Govind Singhb53420c2016-03-09 14:32:57 +05308899 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308900 cmd->rc4_key_len = appType2Params->rc4_key_len;
8901
8902 cmd->ip_id = appType2Params->ip_id;
8903 cmd->ip_device_ip = appType2Params->ip_device_ip;
8904 cmd->ip_server_ip = appType2Params->ip_server_ip;
8905
8906 cmd->tcp_src_port = appType2Params->tcp_src_port;
8907 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8908 cmd->tcp_seq = appType2Params->tcp_seq;
8909 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8910
8911 cmd->keepalive_init = appType2Params->keepalive_init;
8912 cmd->keepalive_min = appType2Params->keepalive_min;
8913 cmd->keepalive_max = appType2Params->keepalive_max;
8914 cmd->keepalive_inc = appType2Params->keepalive_inc;
8915
8916 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8917 &cmd->gateway_mac);
8918 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8919 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8920
Govind Singhb53420c2016-03-09 14:32:57 +05308921 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308922 "rc4_key %.16s rc4_key_len %u "
8923 "ip_id %x ip_device_ip %x ip_server_ip %x "
8924 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8925 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8926 "keepalive_max %u keepalive_inc %u "
8927 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8928 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8929 cmd->rc4_key, cmd->rc4_key_len,
8930 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8931 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8932 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8933 cmd->keepalive_max, cmd->keepalive_inc,
8934 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8935
8936 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8937 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8938 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308939 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308940 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308941 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308942 }
8943
Govind Singhb53420c2016-03-09 14:32:57 +05308944 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308945
8946}
8947
8948/**
8949 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8950 * @wmi_handle: wmi handle
8951 * @timer_val: auto shutdown timer value
8952 *
8953 * Return: CDF status
8954 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308955static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308956 uint32_t timer_val)
8957{
Govind Singh67922e82016-04-01 16:48:57 +05308958 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308959 wmi_buf_t buf = NULL;
8960 uint8_t *buf_ptr;
8961 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8962 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8963
Govind Singhb53420c2016-03-09 14:32:57 +05308964 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308965 __func__, timer_val);
8966
8967 buf = wmi_buf_alloc(wmi_handle, len);
8968 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308969 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8970 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308971 }
8972
8973 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8974 wmi_auto_sh_cmd =
8975 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8976 wmi_auto_sh_cmd->timer_value = timer_val;
8977
8978 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8979 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8980 WMITLV_GET_STRUCT_TLVLEN
8981 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8982
8983 status = wmi_unified_cmd_send(wmi_handle, buf,
8984 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308985 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308986 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308987 __func__, status);
8988 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308989 }
8990
Govind Singh67922e82016-04-01 16:48:57 +05308991 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308992}
8993
8994/**
8995 * send_nan_req_cmd_tlv() - to send nan request to target
8996 * @wmi_handle: wmi handle
8997 * @nan_req: request data which will be non-null
8998 *
8999 * Return: CDF status
9000 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309001static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309002 struct nan_req_params *nan_req)
9003{
Govind Singh67922e82016-04-01 16:48:57 +05309004 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309005 wmi_nan_cmd_param *cmd;
9006 wmi_buf_t buf;
9007 uint16_t len = sizeof(*cmd);
9008 uint16_t nan_data_len, nan_data_len_aligned;
9009 uint8_t *buf_ptr;
9010
9011 /*
9012 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9013 * +------------+----------+-----------------------+--------------+
9014 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9015 * +------------+----------+-----------------------+--------------+
9016 */
9017 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309018 WMI_LOGE("%s:nan req is not valid", __func__);
9019 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309020 }
9021 nan_data_len = nan_req->request_data_len;
9022 nan_data_len_aligned = roundup(nan_req->request_data_len,
9023 sizeof(uint32_t));
9024 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9025 buf = wmi_buf_alloc(wmi_handle, len);
9026 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309027 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9028 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309029 }
9030 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9031 cmd = (wmi_nan_cmd_param *) buf_ptr;
9032 WMITLV_SET_HDR(&cmd->tlv_header,
9033 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9034 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9035 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309036 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309037 __func__, nan_req->request_data_len);
9038 buf_ptr += sizeof(wmi_nan_cmd_param);
9039 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9040 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309041 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309042
9043 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9044 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309045 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309046 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309047 __func__, ret);
9048 wmi_buf_free(buf);
9049 }
9050
9051 return ret;
9052}
9053
9054/**
9055 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9056 * @wmi_handle: wmi handle
9057 * @pDhcpSrvOffloadInfo: DHCP server offload info
9058 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309059 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309060 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309061static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309062 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
9063{
9064 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9065 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309066 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309067
9068 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9069 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309070 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309071 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309072 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309073 }
9074
9075 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309076 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05309077
9078 WMITLV_SET_HDR(&cmd->tlv_header,
9079 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9080 WMITLV_GET_STRUCT_TLVLEN
9081 (wmi_set_dhcp_server_offload_cmd_fixed_param));
9082 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
9083 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
9084 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
9085 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
9086 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309087 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309088 sizeof(*cmd),
9089 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309090 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309091 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309092 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309093 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309094 }
Govind Singhb53420c2016-03-09 14:32:57 +05309095 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309096 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309097
9098 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309099}
9100
9101/**
9102 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9103 * @wmi_handle: wmi handle
9104 * @flashing: flashing request
9105 *
9106 * Return: CDF status
9107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309108static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309109 struct flashing_req_params *flashing)
9110{
9111 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309112 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309113 wmi_buf_t buf;
9114 uint8_t *buf_ptr;
9115 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9116
9117 buf = wmi_buf_alloc(wmi_handle, len);
9118 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309119 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309120 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309121 }
9122 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9123 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9124 WMITLV_SET_HDR(&cmd->tlv_header,
9125 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9126 WMITLV_GET_STRUCT_TLVLEN
9127 (wmi_set_led_flashing_cmd_fixed_param));
9128 cmd->pattern_id = flashing->pattern_id;
9129 cmd->led_x0 = flashing->led_x0;
9130 cmd->led_x1 = flashing->led_x1;
9131
9132 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9133 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309134 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309135 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309136 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309137 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309138 }
Govind Singh67922e82016-04-01 16:48:57 +05309139
9140 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309141}
9142
9143/**
9144 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9145 * @wmi_handle: wmi handle
9146 * @ch_avoid_update_req: channel avoid update params
9147 *
9148 * Return: CDF status
9149 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309150static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309151{
Govind Singh67922e82016-04-01 16:48:57 +05309152 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309153 wmi_buf_t buf = NULL;
9154 uint8_t *buf_ptr;
9155 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9156 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9157
9158
9159 buf = wmi_buf_alloc(wmi_handle, len);
9160 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309161 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9162 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309163 }
9164
9165 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9166 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9167 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9168 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9169 WMITLV_GET_STRUCT_TLVLEN
9170 (wmi_chan_avoid_update_cmd_param));
9171
9172 status = wmi_unified_cmd_send(wmi_handle, buf,
9173 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309174 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309175 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309176 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9177 " returned Error %d", status);
9178 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309179 }
9180
Govind Singh67922e82016-04-01 16:48:57 +05309181 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309182}
9183
9184/**
9185 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9186 * @wmi_handle: wmi handle
9187 * @reg_dmn: reg domain
9188 * @regdmn2G: 2G reg domain
9189 * @regdmn5G: 5G reg domain
9190 * @ctl2G: 2G test limit
9191 * @ctl5G: 5G test limit
9192 *
9193 * Return: none
9194 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309195static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309196 uint32_t reg_dmn, uint16_t regdmn2G,
9197 uint16_t regdmn5G, int8_t ctl2G,
9198 int8_t ctl5G)
9199{
9200 wmi_buf_t buf;
9201 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9202 int32_t len = sizeof(*cmd);
9203
9204
9205 buf = wmi_buf_alloc(wmi_handle, len);
9206 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309207 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9208 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309209 }
9210 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9211 WMITLV_SET_HDR(&cmd->tlv_header,
9212 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9213 WMITLV_GET_STRUCT_TLVLEN
9214 (wmi_pdev_set_regdomain_cmd_fixed_param));
9215 cmd->reg_domain = reg_dmn;
9216 cmd->reg_domain_2G = regdmn2G;
9217 cmd->reg_domain_5G = regdmn5G;
9218 cmd->conformance_test_limit_2G = ctl2G;
9219 cmd->conformance_test_limit_5G = ctl5G;
9220
9221 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9222 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309223 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309224 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309225 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309226 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309227 }
9228
Govind Singhb53420c2016-03-09 14:32:57 +05309229 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309230}
9231
9232
9233/**
9234 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9235 * @wmi_handle: wmi handle
9236 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9237 *
9238 * This function sets tdls off channel mode
9239 *
9240 * Return: 0 on success; Negative errno otherwise
9241 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309242static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309243 struct tdls_channel_switch_params *chan_switch_params)
9244{
9245 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9246 wmi_buf_t wmi_buf;
9247 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9248
9249 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9250 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309251 WMI_LOGE(FL("wmi_buf_alloc failed"));
9252 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309253 }
9254 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9255 wmi_buf_data(wmi_buf);
9256 WMITLV_SET_HDR(&cmd->tlv_header,
9257 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9258 WMITLV_GET_STRUCT_TLVLEN(
9259 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9260
9261 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9262 &cmd->peer_macaddr);
9263 cmd->vdev_id = chan_switch_params->vdev_id;
9264 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9265 cmd->is_peer_responder = chan_switch_params->is_responder;
9266 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9267 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9268 cmd->offchan_oper_class = chan_switch_params->oper_class;
9269
Govind Singhb53420c2016-03-09 14:32:57 +05309270 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309271 cmd->peer_macaddr.mac_addr31to0,
9272 cmd->peer_macaddr.mac_addr47to32);
9273
Govind Singhb53420c2016-03-09 14:32:57 +05309274 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309275 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9276 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9277 ),
9278 cmd->vdev_id,
9279 cmd->offchan_mode,
9280 cmd->offchan_num,
9281 cmd->offchan_bw_bitmap,
9282 cmd->is_peer_responder,
9283 cmd->offchan_oper_class);
9284
9285 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9286 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309287 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309288 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309289 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309290 }
9291
9292
Govind Singhb53420c2016-03-09 14:32:57 +05309293 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309294}
9295
9296/**
9297 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9298 * @wmi_handle: wmi handle
9299 * @pwmaTdlsparams: TDLS params
9300 *
9301 * Return: 0 for sucess or error code
9302 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309303static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309304 void *tdls_param, uint8_t tdls_state)
9305{
9306 wmi_tdls_set_state_cmd_fixed_param *cmd;
9307 wmi_buf_t wmi_buf;
9308
9309 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9310 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9311
9312 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9313 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309314 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9315 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309316 }
9317 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9318 WMITLV_SET_HDR(&cmd->tlv_header,
9319 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9320 WMITLV_GET_STRUCT_TLVLEN
9321 (wmi_tdls_set_state_cmd_fixed_param));
9322 cmd->vdev_id = wmi_tdls->vdev_id;
9323 cmd->state = tdls_state;
9324 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9325 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9326 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9327 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9328 cmd->rssi_delta = wmi_tdls->rssi_delta;
9329 cmd->tdls_options = wmi_tdls->tdls_options;
9330 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9331 cmd->tdls_peer_traffic_response_timeout_ms =
9332 wmi_tdls->peer_traffic_response_timeout;
9333 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9334 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9335 cmd->tdls_puapsd_rx_frame_threshold =
9336 wmi_tdls->puapsd_rx_frame_threshold;
9337 cmd->teardown_notification_ms =
9338 wmi_tdls->teardown_notification_ms;
9339 cmd->tdls_peer_kickout_threshold =
9340 wmi_tdls->tdls_peer_kickout_threshold;
9341
Govind Singhb53420c2016-03-09 14:32:57 +05309342 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309343 "notification_interval_ms: %d, "
9344 "tx_discovery_threshold: %d, "
9345 "tx_teardown_threshold: %d, "
9346 "rssi_teardown_threshold: %d, "
9347 "rssi_delta: %d, "
9348 "tdls_options: 0x%x, "
9349 "tdls_peer_traffic_ind_window: %d, "
9350 "tdls_peer_traffic_response_timeout: %d, "
9351 "tdls_puapsd_mask: 0x%x, "
9352 "tdls_puapsd_inactivity_time: %d, "
9353 "tdls_puapsd_rx_frame_threshold: %d, "
9354 "teardown_notification_ms: %d, "
9355 "tdls_peer_kickout_threshold: %d",
9356 __func__, tdls_state, cmd->state,
9357 cmd->notification_interval_ms,
9358 cmd->tx_discovery_threshold,
9359 cmd->tx_teardown_threshold,
9360 cmd->rssi_teardown_threshold,
9361 cmd->rssi_delta,
9362 cmd->tdls_options,
9363 cmd->tdls_peer_traffic_ind_window,
9364 cmd->tdls_peer_traffic_response_timeout_ms,
9365 cmd->tdls_puapsd_mask,
9366 cmd->tdls_puapsd_inactivity_time_ms,
9367 cmd->tdls_puapsd_rx_frame_threshold,
9368 cmd->teardown_notification_ms,
9369 cmd->tdls_peer_kickout_threshold);
9370
9371 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9372 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309373 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309374 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309375 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309376 }
Govind Singhb53420c2016-03-09 14:32:57 +05309377 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309378
Govind Singhb53420c2016-03-09 14:32:57 +05309379 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309380}
9381
9382/**
9383 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9384 * @wmi_handle: wmi handle
9385 * @peerStateParams: TDLS peer state params
9386 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309387 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309388 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309389static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309390 struct tdls_peer_state_params *peerStateParams,
9391 uint32_t *ch_mhz)
9392{
9393 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9394 wmi_tdls_peer_capabilities *peer_cap;
9395 wmi_channel *chan_info;
9396 wmi_buf_t wmi_buf;
9397 uint8_t *buf_ptr;
9398 uint32_t i;
9399 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9400 sizeof(wmi_tdls_peer_capabilities);
9401
9402
9403 len += WMI_TLV_HDR_SIZE +
9404 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9405
9406 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9407 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309408 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9409 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309410 }
9411
9412 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9413 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9414 WMITLV_SET_HDR(&cmd->tlv_header,
9415 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9416 WMITLV_GET_STRUCT_TLVLEN
9417 (wmi_tdls_peer_update_cmd_fixed_param));
9418
9419 cmd->vdev_id = peerStateParams->vdevId;
9420 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9421 &cmd->peer_macaddr);
9422
9423
9424 cmd->peer_state = peerStateParams->peerState;
9425
Govind Singhb53420c2016-03-09 14:32:57 +05309426 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309427 "peer_macaddr.mac_addr31to0: 0x%x, "
9428 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9429 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9430 cmd->peer_macaddr.mac_addr31to0,
9431 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9432
9433 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9434 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9435 WMITLV_SET_HDR(&peer_cap->tlv_header,
9436 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9437 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9438
9439 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9440 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9441 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9442 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9443 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9444 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9445 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9446 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9447
9448 /* Ack and More Data Ack are sent as 0, so no need to set
9449 * but fill SP
9450 */
9451 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9452 peerStateParams->peerCap.peerMaxSp);
9453
9454 peer_cap->buff_sta_support =
9455 peerStateParams->peerCap.peerBuffStaSupport;
9456 peer_cap->off_chan_support =
9457 peerStateParams->peerCap.peerOffChanSupport;
9458 peer_cap->peer_curr_operclass =
9459 peerStateParams->peerCap.peerCurrOperClass;
9460 /* self curr operclass is not being used and so pass op class for
9461 * preferred off chan in it.
9462 */
9463 peer_cap->self_curr_operclass =
9464 peerStateParams->peerCap.opClassForPrefOffChan;
9465 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9466 peer_cap->peer_operclass_len =
9467 peerStateParams->peerCap.peerOperClassLen;
9468
Govind Singhb53420c2016-03-09 14:32:57 +05309469 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309470 __func__, peer_cap->peer_operclass_len);
9471 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9472 peer_cap->peer_operclass[i] =
9473 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309474 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309475 __func__, i, peer_cap->peer_operclass[i]);
9476 }
9477
9478 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9479 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9480 peer_cap->pref_offchan_bw =
9481 peerStateParams->peerCap.prefOffChanBandwidth;
9482
Govind Singhb53420c2016-03-09 14:32:57 +05309483 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309484 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9485 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9486 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9487 " %d, pref_offchan_bw: %d",
9488 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9489 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9490 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9491 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9492 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9493
9494 /* next fill variable size array of peer chan info */
9495 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9496 WMITLV_SET_HDR(buf_ptr,
9497 WMITLV_TAG_ARRAY_STRUC,
9498 sizeof(wmi_channel) *
9499 peerStateParams->peerCap.peerChanLen);
9500 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9501
9502 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9503 WMITLV_SET_HDR(&chan_info->tlv_header,
9504 WMITLV_TAG_STRUC_wmi_channel,
9505 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9506 chan_info->mhz = ch_mhz[i];
9507 chan_info->band_center_freq1 = chan_info->mhz;
9508 chan_info->band_center_freq2 = 0;
9509
Govind Singhb53420c2016-03-09 14:32:57 +05309510 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309511
9512 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9513 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309514 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309515 peerStateParams->peerCap.peerChan[i].chanId,
9516 peerStateParams->peerCap.peerChan[i].dfsSet);
9517 }
9518
9519 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9520 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9521 else
9522 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9523
9524 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9525 peerStateParams->peerCap.
9526 peerChan[i].pwr);
9527
9528 WMI_SET_CHANNEL_REG_POWER(chan_info,
9529 peerStateParams->peerCap.peerChan[i].
9530 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309531 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309532 peerStateParams->peerCap.peerChan[i].pwr);
9533
9534 chan_info++;
9535 }
9536
9537 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9538 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309539 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309540 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309541 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309542 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309543 }
9544
9545
Govind Singhb53420c2016-03-09 14:32:57 +05309546 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309547}
9548
9549/*
9550 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9551 * firmware
9552 * @wmi_handle: Pointer to wmi handle
9553 * @mem_dump_req: Pointer for mem_dump_req
9554 *
9555 * This function sends memory dump request to firmware
9556 *
Govind Singhb53420c2016-03-09 14:32:57 +05309557 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309558 *
9559 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309560static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309561 struct fw_dump_req_param *mem_dump_req)
9562{
9563 wmi_get_fw_mem_dump_fixed_param *cmd;
9564 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309565 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309566 int32_t len;
9567 wmi_buf_t buf;
9568 u_int8_t *buf_ptr;
9569 int ret, loop;
9570
9571 /*
9572 * len = sizeof(fixed param) that includes tlv header +
9573 * tlv header for array of struc +
9574 * sizeof (each struct)
9575 */
9576 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9577 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9578 buf = wmi_buf_alloc(wmi_handle, len);
9579
9580 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309581 WMI_LOGE(FL("Failed allocate wmi buffer"));
9582 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309583 }
9584
9585 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309586 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309587 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9588
9589 WMITLV_SET_HDR(&cmd->tlv_header,
9590 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9591 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9592
9593 cmd->request_id = mem_dump_req->request_id;
9594 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9595
9596 /* TLV indicating array of structures to follow */
9597 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9598 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9599 sizeof(wmi_fw_mem_dump) *
9600 cmd->num_fw_mem_dump_segs);
9601
9602 buf_ptr += WMI_TLV_HDR_SIZE;
9603 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9604
Govind Singhb53420c2016-03-09 14:32:57 +05309605 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309606 mem_dump_req->request_id, mem_dump_req->num_seg);
9607 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309608 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309609 ((uint8_t *)(mem_dump_req->segment) +
9610 loop * sizeof(*seg_req));
9611 WMITLV_SET_HDR(&dump_params->tlv_header,
9612 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9613 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9614 dump_params->seg_id = seg_req->seg_id;
9615 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9616 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9617 dump_params->seg_length = seg_req->seg_length;
9618 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9619 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309620 WMI_LOGI(FL("seg_number:%d"), loop);
9621 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309622 dump_params->seg_id, dump_params->seg_start_addr_lo,
9623 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309624 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309625 dump_params->seg_length, dump_params->dest_addr_lo,
9626 dump_params->dest_addr_hi);
9627 dump_params++;
9628 }
9629
9630 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9631 WMI_GET_FW_MEM_DUMP_CMDID);
9632 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309633 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309634 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309635 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309636 }
9637
Govind Singhb53420c2016-03-09 14:32:57 +05309638 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9639 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309640}
9641
9642/*
9643 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9644 * @wmi_handle: Pointer to WMi handle
9645 * @ie_data: Pointer for ie data
9646 *
9647 * This function sends IE information to firmware
9648 *
Govind Singhb53420c2016-03-09 14:32:57 +05309649 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309650 *
9651 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309652static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309653 struct vdev_ie_info_param *ie_info)
9654{
9655 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9656 wmi_buf_t buf;
9657 uint8_t *buf_ptr;
9658 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309659 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309660
9661
9662 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9663 /* Allocate memory for the WMI command */
9664 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9665
9666 buf = wmi_buf_alloc(wmi_handle, len);
9667 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309668 WMI_LOGE(FL("wmi_buf_alloc failed"));
9669 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309670 }
9671
9672 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309673 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309674
9675 /* Populate the WMI command */
9676 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9677
9678 WMITLV_SET_HDR(&cmd->tlv_header,
9679 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9680 WMITLV_GET_STRUCT_TLVLEN(
9681 wmi_vdev_set_ie_cmd_fixed_param));
9682 cmd->vdev_id = ie_info->vdev_id;
9683 cmd->ie_id = ie_info->ie_id;
9684 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009685 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309686
Govind Singhb53420c2016-03-09 14:32:57 +05309687 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309688 ie_info->length, ie_info->vdev_id);
9689
9690 buf_ptr += sizeof(*cmd);
9691 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9692 buf_ptr += WMI_TLV_HDR_SIZE;
9693
Govind Singhb53420c2016-03-09 14:32:57 +05309694 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309695
9696 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9697 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309698 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309699 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309700 wmi_buf_free(buf);
9701 }
9702
9703 return ret;
9704}
9705
Jeff Johnson9366d7a2016-10-07 13:03:02 -07009706static
Govind Singh9ddd5162016-03-07 16:30:32 +05309707void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05309708 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05309709{
Govind Singhe7f2f342016-05-23 12:12:52 +05309710 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05309711 resource_cfg->num_peers = tgt_res_cfg->num_peers;
9712 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
9713 resource_cfg->num_offload_reorder_buffs =
9714 tgt_res_cfg->num_offload_reorder_buffs;
9715 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
9716 resource_cfg->num_tids = tgt_res_cfg->num_tids;
9717 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
9718 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
9719 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
9720 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
9721 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
9722 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
9723 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
9724 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
9725 resource_cfg->scan_max_pending_req =
9726 tgt_res_cfg->scan_max_pending_req;
9727 resource_cfg->bmiss_offload_max_vdev =
9728 tgt_res_cfg->bmiss_offload_max_vdev;
9729 resource_cfg->roam_offload_max_vdev =
9730 tgt_res_cfg->roam_offload_max_vdev;
9731 resource_cfg->roam_offload_max_ap_profiles =
9732 tgt_res_cfg->roam_offload_max_ap_profiles;
9733 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
9734 resource_cfg->num_mcast_table_elems =
9735 tgt_res_cfg->num_mcast_table_elems;
9736 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
9737 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
9738 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
9739 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
9740 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
9741 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
9742 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
9743 resource_cfg->vow_config = tgt_res_cfg->vow_config;
9744 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
9745 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
9746 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
9747 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
9748 resource_cfg->num_tdls_conn_table_entries =
9749 tgt_res_cfg->num_tdls_conn_table_entries;
9750 resource_cfg->beacon_tx_offload_max_vdev =
9751 tgt_res_cfg->beacon_tx_offload_max_vdev;
9752 resource_cfg->num_multicast_filter_entries =
9753 tgt_res_cfg->num_multicast_filter_entries;
9754 resource_cfg->num_wow_filters =
9755 tgt_res_cfg->num_wow_filters;
9756 resource_cfg->num_keep_alive_pattern =
9757 tgt_res_cfg->num_keep_alive_pattern;
9758 resource_cfg->keep_alive_pattern_size =
9759 tgt_res_cfg->keep_alive_pattern_size;
9760 resource_cfg->max_tdls_concurrent_sleep_sta =
9761 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
9762 resource_cfg->max_tdls_concurrent_buffer_sta =
9763 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
9764 resource_cfg->wmi_send_separate =
9765 tgt_res_cfg->wmi_send_separate;
9766 resource_cfg->num_ocb_vdevs =
9767 tgt_res_cfg->num_ocb_vdevs;
9768 resource_cfg->num_ocb_channels =
9769 tgt_res_cfg->num_ocb_channels;
9770 resource_cfg->num_ocb_schedules =
9771 tgt_res_cfg->num_ocb_schedules;
9772
9773}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309774#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309775/**
9776 * send_init_cmd_tlv() - wmi init command
9777 * @wmi_handle: pointer to wmi handle
9778 * @res_cfg: resource config
9779 * @num_mem_chunks: no of mem chunck
9780 * @mem_chunk: pointer to mem chunck structure
9781 *
9782 * This function sends IE information to firmware
9783 *
Govind Singhb53420c2016-03-09 14:32:57 +05309784 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309785 *
9786 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309787static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309788 wmi_resource_config *tgt_res_cfg,
9789 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
9790 bool action)
9791{
9792 wmi_buf_t buf;
9793 wmi_init_cmd_fixed_param *cmd;
9794 wmi_abi_version my_vers;
9795 int num_whitelist;
9796 uint8_t *buf_ptr;
9797 wmi_resource_config *resource_cfg;
9798 wlan_host_memory_chunk *host_mem_chunks;
9799 uint32_t mem_chunk_len = 0;
9800 uint16_t idx;
9801 int len;
9802 int ret;
9803
9804 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
9805 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
9806 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
9807 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309808 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
9809 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309810 }
9811
9812 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9813 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
9814 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
9815
9816 host_mem_chunks = (wlan_host_memory_chunk *)
9817 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
9818 + WMI_TLV_HDR_SIZE);
9819
9820 WMITLV_SET_HDR(&cmd->tlv_header,
9821 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
9822 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
9823
Govind Singhb53420c2016-03-09 14:32:57 +05309824 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +05309825 WMITLV_SET_HDR(&resource_cfg->tlv_header,
9826 WMITLV_TAG_STRUC_wmi_resource_config,
9827 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
9828
9829 for (idx = 0; idx < num_mem_chunks; ++idx) {
9830 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
9831 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
9832 WMITLV_GET_STRUCT_TLVLEN
9833 (wlan_host_memory_chunk));
9834 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
9835 host_mem_chunks[idx].size = mem_chunks[idx].len;
9836 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309837 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +05309838 idx, host_mem_chunks[idx].size,
9839 host_mem_chunks[idx].ptr);
9840 }
9841 cmd->num_host_mem_chunks = num_mem_chunks;
9842 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
9843 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
9844 WMITLV_TAG_ARRAY_STRUC,
9845 (sizeof(wlan_host_memory_chunk) *
9846 num_mem_chunks));
9847
9848 num_whitelist = sizeof(version_whitelist) /
9849 sizeof(wmi_whitelist_version_info);
9850 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
9851 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
9852 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
9853 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
9854 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
9855 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +05309856#ifdef CONFIG_MCL
9857 /* This needs to be enabled for WIN Lithium after removing dependency
9858 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +05309859 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
9860 &my_vers,
9861 &wmi_handle->fw_abi_version,
9862 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +05309863#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309864 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05309865 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
9866 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
9867 cmd->host_abi_vers.abi_version_ns_0,
9868 cmd->host_abi_vers.abi_version_ns_1,
9869 cmd->host_abi_vers.abi_version_ns_2,
9870 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +05309871#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309872 /* Save version sent from host -
9873 * Will be used to check ready event
9874 */
Govind Singhb53420c2016-03-09 14:32:57 +05309875 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309876 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309877#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309878 if (action) {
9879 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9880 WMI_INIT_CMDID);
9881 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309882 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +05309883 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309884 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309885 }
9886 } else {
9887 wmi_handle->saved_wmi_init_cmd.buf = buf;
9888 wmi_handle->saved_wmi_init_cmd.buf_len = len;
9889 }
9890
Govind Singhb53420c2016-03-09 14:32:57 +05309891 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309892
9893}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05309894#endif
Govind Singh9ddd5162016-03-07 16:30:32 +05309895/**
9896 * send_saved_init_cmd_tlv() - wmi init command
9897 * @wmi_handle: pointer to wmi handle
9898 *
9899 * This function sends IE information to firmware
9900 *
Govind Singhb53420c2016-03-09 14:32:57 +05309901 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309902 *
9903 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309904static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +05309905{
9906 int status;
9907
9908 if (!wmi_handle->saved_wmi_init_cmd.buf ||
9909 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05309910 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
9911 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309912 }
9913 status = wmi_unified_cmd_send(wmi_handle,
9914 wmi_handle->saved_wmi_init_cmd.buf,
9915 wmi_handle->saved_wmi_init_cmd.buf_len,
9916 WMI_INIT_CMDID);
9917 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +05309918 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +05309919 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309920 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309921 }
9922 wmi_handle->saved_wmi_init_cmd.buf = NULL;
9923 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
9924
Govind Singhb53420c2016-03-09 14:32:57 +05309925 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309926}
9927
Sathish Kumarfd347372017-02-13 12:29:09 +05309928static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05309929{
9930 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
9931 wmi_service_ready_event_fixed_param *ev;
9932
9933
9934 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
9935
9936 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
9937 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05309938 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309939
Govind Singh87542482016-06-08 19:40:11 +05309940#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309941 /*Save fw version from service ready message */
9942 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05309943 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309944 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +05309945#endif
Govind Singhb53420c2016-03-09 14:32:57 +05309946 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309947}
9948
9949/**
9950 * wmi_unified_save_fw_version_cmd() - save fw version
9951 * @wmi_handle: pointer to wmi handle
9952 * @res_cfg: resource config
9953 * @num_mem_chunks: no of mem chunck
9954 * @mem_chunk: pointer to mem chunck structure
9955 *
9956 * This function sends IE information to firmware
9957 *
Govind Singhb53420c2016-03-09 14:32:57 +05309958 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309959 *
9960 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309961static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309962 void *evt_buf)
9963{
9964 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
9965 wmi_ready_event_fixed_param *ev = NULL;
9966
9967 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
9968 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +05309969#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +05309970 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
9971 &ev->fw_abi_vers)) {
9972 /*
9973 * Error: Our host version and the given firmware version
9974 * are incompatible.
9975 **/
Govind Singhb53420c2016-03-09 14:32:57 +05309976 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +05309977 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
9978 __func__,
9979 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
9980 abi_version_0),
9981 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
9982 abi_version_0),
9983 wmi_handle->final_abi_vers.abi_version_ns_0,
9984 wmi_handle->final_abi_vers.abi_version_ns_1,
9985 wmi_handle->final_abi_vers.abi_version_ns_2,
9986 wmi_handle->final_abi_vers.abi_version_ns_3,
9987 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
9988 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
9989 ev->fw_abi_vers.abi_version_ns_0,
9990 ev->fw_abi_vers.abi_version_ns_1,
9991 ev->fw_abi_vers.abi_version_ns_2,
9992 ev->fw_abi_vers.abi_version_ns_3);
9993
Govind Singhb53420c2016-03-09 14:32:57 +05309994 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309995 }
Govind Singhb53420c2016-03-09 14:32:57 +05309996 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309997 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +05309998 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309999 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010000#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010001
Govind Singhb53420c2016-03-09 14:32:57 +053010002 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010003}
Govind Singha4836fd2016-03-07 16:45:38 +053010004
10005/**
10006 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
10007 * @wmi_handle: wmi handle
10008 * @custom_addr: base mac address
10009 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010010 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053010011 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010012static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010013 uint8_t *custom_addr)
10014{
10015 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
10016 wmi_buf_t buf;
10017 int err;
10018
10019 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10020 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010021 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010022 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010023 }
10024
10025 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010026 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053010027
10028 WMITLV_SET_HDR(&cmd->tlv_header,
10029 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
10030 WMITLV_GET_STRUCT_TLVLEN
10031 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
10032 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -070010033 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010034 err = wmi_unified_cmd_send(wmi_handle, buf,
10035 sizeof(*cmd),
10036 WMI_PDEV_SET_BASE_MACADDR_CMDID);
10037 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053010038 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053010039 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010040 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010041 }
10042
10043 return 0;
10044}
10045
10046/**
10047 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
10048 * @handle: wmi handle
10049 * @event: Event received from FW
10050 * @len: Length of the event
10051 *
10052 * Enables the low frequency events and disables the high frequency
10053 * events. Bit 17 indicates if the event if low/high frequency.
10054 * 1 - high frequency, 0 - low frequency
10055 *
10056 * Return: 0 on successfully enabling/disabling the events
10057 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010058static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010059 uint8_t *event,
10060 uint32_t len)
10061{
10062 uint32_t num_of_diag_events_logs;
10063 wmi_diag_event_log_config_fixed_param *cmd;
10064 wmi_buf_t buf;
10065 uint8_t *buf_ptr;
10066 uint32_t *cmd_args, *evt_args;
10067 uint32_t buf_len, i;
10068
10069 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
10070 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
10071
Govind Singhb53420c2016-03-09 14:32:57 +053010072 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053010073
10074 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
10075 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010076 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053010077 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010078 }
10079 wmi_event = param_buf->fixed_param;
10080 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
10081 evt_args = param_buf->diag_events_logs_list;
10082 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053010083 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010084 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053010085 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010086 }
10087
Govind Singhb53420c2016-03-09 14:32:57 +053010088 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010089 __func__, num_of_diag_events_logs);
10090
10091 /* Free any previous allocation */
10092 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053010093 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010094
10095 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053010096 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053010097 sizeof(uint32_t));
10098 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010099 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010100 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010101 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010102 }
10103 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
10104
10105 /* Prepare the send buffer */
10106 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10107 (num_of_diag_events_logs * sizeof(uint32_t));
10108
10109 buf = wmi_buf_alloc(wmi_handle, buf_len);
10110 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010111 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10112 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010113 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010114 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010115 }
10116
10117 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10118 buf_ptr = (uint8_t *) cmd;
10119
10120 WMITLV_SET_HDR(&cmd->tlv_header,
10121 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10122 WMITLV_GET_STRUCT_TLVLEN(
10123 wmi_diag_event_log_config_fixed_param));
10124
10125 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
10126
10127 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10128
10129 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10130 (num_of_diag_events_logs * sizeof(uint32_t)));
10131
10132 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10133
10134 /* Populate the events */
10135 for (i = 0; i < num_of_diag_events_logs; i++) {
10136 /* Low freq (0) - Enable (1) the event
10137 * High freq (1) - Disable (0) the event
10138 */
10139 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
10140 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
10141 /* Set the event ID */
10142 WMI_DIAG_ID_SET(cmd_args[i],
10143 WMI_DIAG_ID_GET(evt_args[i]));
10144 /* Set the type */
10145 WMI_DIAG_TYPE_SET(cmd_args[i],
10146 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053010147 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053010148 wmi_handle->events_logs_list[i] = evt_args[i];
10149 }
10150
10151 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
10152 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010153 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010154 __func__);
10155 wmi_buf_free(buf);
10156 /* Not clearing events_logs_list, though wmi cmd failed.
10157 * Host can still have this list
10158 */
Govind Singh67922e82016-04-01 16:48:57 +053010159 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010160 }
10161
10162 return 0;
10163}
10164
10165/**
10166 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
10167 * @wmi_handle: wmi handle
10168 * @start_log: Start logging related parameters
10169 *
10170 * Send the command to the FW based on which specific logging of diag
10171 * event/log id can be started/stopped
10172 *
10173 * Return: None
10174 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010175static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010176 struct wmi_wifi_start_log *start_log)
10177{
10178 wmi_diag_event_log_config_fixed_param *cmd;
10179 wmi_buf_t buf;
10180 uint8_t *buf_ptr;
10181 uint32_t len, count, log_level, i;
10182 uint32_t *cmd_args;
10183 uint32_t total_len;
10184 count = 0;
10185
10186 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010187 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053010188 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010189 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010190 }
10191 /* total_len stores the number of events where BITS 17 and 18 are set.
10192 * i.e., events of high frequency (17) and for extended debugging (18)
10193 */
10194 total_len = 0;
10195 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10196 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
10197 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
10198 total_len++;
10199 }
10200
10201 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10202 (total_len * sizeof(uint32_t));
10203
10204 buf = wmi_buf_alloc(wmi_handle, len);
10205 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010206 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010207 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010208 }
10209 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
10210 buf_ptr = (uint8_t *) cmd;
10211
10212 WMITLV_SET_HDR(&cmd->tlv_header,
10213 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
10214 WMITLV_GET_STRUCT_TLVLEN(
10215 wmi_diag_event_log_config_fixed_param));
10216
10217 cmd->num_of_diag_events_logs = total_len;
10218
10219 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
10220
10221 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10222 (total_len * sizeof(uint32_t)));
10223
10224 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10225
Govind Singh224a7312016-06-21 14:33:26 +053010226 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053010227 log_level = 1;
10228 else
10229 log_level = 0;
10230
Govind Singhb53420c2016-03-09 14:32:57 +053010231 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053010232 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
10233 uint32_t val = wmi_handle->events_logs_list[i];
10234 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
10235 (WMI_DIAG_EXT_FEATURE_GET(val))) {
10236
10237 WMI_DIAG_ID_SET(cmd_args[count],
10238 WMI_DIAG_ID_GET(val));
10239 WMI_DIAG_TYPE_SET(cmd_args[count],
10240 WMI_DIAG_TYPE_GET(val));
10241 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
10242 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053010243 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053010244 count++;
10245 }
10246 }
10247
10248 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10249 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010250 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010251 __func__);
10252 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010253 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010254 }
10255
Govind Singhb53420c2016-03-09 14:32:57 +053010256 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010257}
10258
10259/**
10260 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
10261 * @wmi_handle: WMI handle
10262 *
10263 * This function is used to send the flush command to the FW,
10264 * that will flush the fw logs that are residue in the FW
10265 *
10266 * Return: None
10267 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010268static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053010269{
10270 wmi_debug_mesg_flush_fixed_param *cmd;
10271 wmi_buf_t buf;
10272 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053010273 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010274
10275 buf = wmi_buf_alloc(wmi_handle, len);
10276 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010277 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010278 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010279 }
10280
10281 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
10282 WMITLV_SET_HDR(&cmd->tlv_header,
10283 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
10284 WMITLV_GET_STRUCT_TLVLEN(
10285 wmi_debug_mesg_flush_fixed_param));
10286 cmd->reserved0 = 0;
10287
10288 ret = wmi_unified_cmd_send(wmi_handle,
10289 buf,
10290 len,
10291 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010292 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010293 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053010294 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010295 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010296 }
Govind Singhb53420c2016-03-09 14:32:57 +053010297 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053010298
Govind Singh67922e82016-04-01 16:48:57 +053010299 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053010300}
10301
10302/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010303 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010304 * @wmi_handle: wmi handle
10305 * @msg: PCL structure containing the PCL and the number of channels
10306 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010307 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053010308 * firmware. The DBS Manager is the consumer of this information in the WLAN
10309 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
10310 * to migrate to a new channel without host driver involvement. An example of
10311 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
10312 * manage the channel selection without firmware involvement.
10313 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010314 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
10315 * channel list. The weights corresponds to the channels sent in
10316 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
10317 * weightage compared to the non PCL channels.
10318 *
Govind Singha4836fd2016-03-07 16:45:38 +053010319 * Return: Success if the cmd is sent successfully to the firmware
10320 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010321static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010322 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053010323{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010324 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010325 wmi_buf_t buf;
10326 uint8_t *buf_ptr;
10327 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010328 uint32_t chan_len;
10329
10330 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053010331
10332 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010333 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053010334
10335 buf = wmi_buf_alloc(wmi_handle, len);
10336 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010337 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10338 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010339 }
10340
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010341 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010342 buf_ptr = (uint8_t *) cmd;
10343 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010344 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
10345 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053010346
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010347 cmd->pdev_id = WMI_PDEV_ID_SOC;
10348 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053010349 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010350
10351 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053010352 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010353 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053010354 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010355 for (i = 0; i < chan_len ; i++) {
10356 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053010357 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010358 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010359 }
10360 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053010361 WMI_PDEV_SET_PCL_CMDID)) {
10362 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010363 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010364 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010365 }
Govind Singhb53420c2016-03-09 14:32:57 +053010366 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010367}
10368
10369/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010370 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010371 * @wmi_handle: wmi handle
10372 * @msg: Structure containing the following parameters
10373 *
10374 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
10375 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
10376 *
10377 * Provides notification to the WLAN firmware that host driver is requesting a
10378 * HardWare (HW) Mode change. This command is needed to support iHelium in the
10379 * configurations that include the Dual Band Simultaneous (DBS) feature.
10380 *
10381 * Return: Success if the cmd is sent successfully to the firmware
10382 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010383static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010384 uint32_t hw_mode_index)
10385{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010386 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010387 wmi_buf_t buf;
10388 uint32_t len;
10389
10390 len = sizeof(*cmd);
10391
10392 buf = wmi_buf_alloc(wmi_handle, len);
10393 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010394 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10395 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010396 }
10397
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010398 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010399 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010400 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
10401 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
10402
10403 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010404 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053010405 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053010406
10407 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053010408 WMI_PDEV_SET_HW_MODE_CMDID)) {
10409 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010410 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010411 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010412 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010413 }
10414
Govind Singhb53420c2016-03-09 14:32:57 +053010415 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010416}
10417
10418/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010419 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053010420 * @wmi_handle: wmi handle
10421 * @msg: Dual MAC config parameters
10422 *
10423 * Configures WLAN firmware with the dual MAC features
10424 *
Govind Singhb53420c2016-03-09 14:32:57 +053010425 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053010426 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010427static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010428QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010429 struct wmi_dual_mac_config *msg)
10430{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010431 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010432 wmi_buf_t buf;
10433 uint32_t len;
10434
10435 len = sizeof(*cmd);
10436
10437 buf = wmi_buf_alloc(wmi_handle, len);
10438 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010439 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10440 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010441 }
10442
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010443 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010444 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010445 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053010446 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010447 wmi_pdev_set_mac_config_cmd_fixed_param));
10448
10449 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010450 cmd->concurrent_scan_config_bits = msg->scan_config;
10451 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053010452 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053010453 __func__, msg->scan_config, msg->fw_mode_config);
10454
10455 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053010456 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
10457 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053010458 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010459 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010460 }
Govind Singhb53420c2016-03-09 14:32:57 +053010461 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010462}
10463
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053010464#ifdef BIG_ENDIAN_HOST
10465/**
10466* fips_conv_data_be() - LE to BE conversion of FIPS ev data
10467* @param data_len - data length
10468* @param data - pointer to data
10469*
10470* Return: QDF_STATUS - success or error status
10471*/
10472static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
10473 struct fips_params *param)
10474{
10475 unsigned char *key_unaligned, *data_unaligned;
10476 int c;
10477 u_int8_t *key_aligned = NULL;
10478 u_int8_t *data_aligned = NULL;
10479
10480 /* Assigning unaligned space to copy the key */
10481 key_unaligned = qdf_mem_malloc(
10482 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
10483 data_unaligned = qdf_mem_malloc(
10484 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
10485
10486 /* Checking if kmalloc is succesful to allocate space */
10487 if (key_unaligned == NULL)
10488 return QDF_STATUS_SUCCESS;
10489 /* Checking if space is aligned */
10490 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
10491 /* align to 4 */
10492 key_aligned =
10493 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
10494 FIPS_ALIGN);
10495 } else {
10496 key_aligned = (u_int8_t *)key_unaligned;
10497 }
10498
10499 /* memset and copy content from key to key aligned */
10500 OS_MEMSET(key_aligned, 0, param->key_len);
10501 OS_MEMCPY(key_aligned, param->key, param->key_len);
10502
10503 /* print a hexdump for host debug */
10504 print_hex_dump(KERN_DEBUG,
10505 "\t Aligned and Copied Key:@@@@ ",
10506 DUMP_PREFIX_NONE,
10507 16, 1, key_aligned, param->key_len, true);
10508
10509 /* Checking if kmalloc is succesful to allocate space */
10510 if (data_unaligned == NULL)
10511 return QDF_STATUS_SUCCESS;
10512 /* Checking of space is aligned */
10513 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
10514 /* align to 4 */
10515 data_aligned =
10516 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
10517 FIPS_ALIGN);
10518 } else {
10519 data_aligned = (u_int8_t *)data_unaligned;
10520 }
10521
10522 /* memset and copy content from data to data aligned */
10523 OS_MEMSET(data_aligned, 0, param->data_len);
10524 OS_MEMCPY(data_aligned, param->data, param->data_len);
10525
10526 /* print a hexdump for host debug */
10527 print_hex_dump(KERN_DEBUG,
10528 "\t Properly Aligned and Copied Data:@@@@ ",
10529 DUMP_PREFIX_NONE,
10530 16, 1, data_aligned, param->data_len, true);
10531
10532 /* converting to little Endian both key_aligned and
10533 * data_aligned*/
10534 for (c = 0; c < param->key_len/4; c++) {
10535 *((u_int32_t *)key_aligned+c) =
10536 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
10537 }
10538 for (c = 0; c < param->data_len/4; c++) {
10539 *((u_int32_t *)data_aligned+c) =
10540 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
10541 }
10542
10543 /* update endian data to key and data vectors */
10544 OS_MEMCPY(param->key, key_aligned, param->key_len);
10545 OS_MEMCPY(param->data, data_aligned, param->data_len);
10546
10547 /* clean up allocated spaces */
10548 qdf_mem_free(key_unaligned);
10549 key_unaligned = NULL;
10550 key_aligned = NULL;
10551
10552 qdf_mem_free(data_unaligned);
10553 data_unaligned = NULL;
10554 data_aligned = NULL;
10555
10556 return QDF_STATUS_SUCCESS;
10557}
10558#else
10559/**
10560* fips_align_data_be() - DUMMY for LE platform
10561*
10562* Return: QDF_STATUS - success
10563*/
10564static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
10565 struct fips_params *param)
10566{
10567 return QDF_STATUS_SUCCESS;
10568}
10569#endif
10570
10571
10572/**
10573 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
10574 * @wmi_handle: wmi handle
10575 * @param: pointer to hold pdev fips param
10576 *
10577 * Return: 0 for success or error code
10578 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010579static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053010580send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
10581 struct fips_params *param)
10582{
10583 wmi_pdev_fips_cmd_fixed_param *cmd;
10584 wmi_buf_t buf;
10585 uint8_t *buf_ptr;
10586 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
10587 QDF_STATUS retval = QDF_STATUS_SUCCESS;
10588
10589 /* Length TLV placeholder for array of bytes */
10590 len += WMI_TLV_HDR_SIZE;
10591 if (param->data_len)
10592 len += (param->data_len*sizeof(uint8_t));
10593
10594 /*
10595 * Data length must be multiples of 16 bytes - checked against 0xF -
10596 * and must be less than WMI_SVC_MSG_SIZE - static size of
10597 * wmi_pdev_fips_cmd structure
10598 */
10599
10600 /* do sanity on the input */
10601 if (!(((param->data_len & 0xF) == 0) &&
10602 ((param->data_len > 0) &&
10603 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
10604 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
10605 return QDF_STATUS_E_INVAL;
10606 }
10607
10608 buf = wmi_buf_alloc(wmi_handle, len);
10609 if (!buf) {
10610 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
10611 return QDF_STATUS_E_FAILURE;
10612 }
10613
10614 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10615 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
10616 WMITLV_SET_HDR(&cmd->tlv_header,
10617 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
10618 WMITLV_GET_STRUCT_TLVLEN
10619 (wmi_pdev_fips_cmd_fixed_param));
10620
10621 cmd->pdev_id = param->pdev_id;
10622 if (param->key != NULL && param->data != NULL) {
10623 cmd->key_len = param->key_len;
10624 cmd->data_len = param->data_len;
10625 cmd->fips_cmd = !!(param->op);
10626
10627 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
10628 return QDF_STATUS_E_FAILURE;
10629
10630 qdf_mem_copy(cmd->key, param->key, param->key_len);
10631
10632 if (param->mode == FIPS_ENGINE_AES_CTR ||
10633 param->mode == FIPS_ENGINE_AES_MIC) {
10634 cmd->mode = param->mode;
10635 } else {
10636 cmd->mode = FIPS_ENGINE_AES_CTR;
10637 }
10638 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
10639 cmd->key_len, cmd->data_len);
10640
10641 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
10642 cmd->key, cmd->key_len, true);
10643 buf_ptr += sizeof(*cmd);
10644
10645 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
10646
10647 buf_ptr += WMI_TLV_HDR_SIZE;
10648 if (param->data_len)
10649 qdf_mem_copy(buf_ptr,
10650 (uint8_t *) param->data, param->data_len);
10651
10652 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
10653 16, 1, buf_ptr, cmd->data_len, true);
10654
10655 buf_ptr += param->data_len;
10656
10657 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10658 WMI_PDEV_FIPS_CMDID);
10659 qdf_print("%s return value %d\n", __func__, retval);
10660 } else {
10661 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
10662 wmi_buf_free(buf);
10663 retval = -QDF_STATUS_E_BADMSG;
10664 }
10665
10666 return retval;
10667}
10668
Govind Singha4836fd2016-03-07 16:45:38 +053010669/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010670 * fill_arp_offload_params_tlv() - Fill ARP offload data
10671 * @wmi_handle: wmi handle
10672 * @offload_req: offload request
10673 * @buf_ptr: buffer pointer
10674 *
10675 * To fill ARP offload data to firmware
10676 * when target goes to wow mode.
10677 *
10678 * Return: None
10679 */
10680static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
10681 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10682{
10683
10684 int i;
10685 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
10686 bool enable_or_disable = offload_req->enableOrDisable;
10687
10688 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10689 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
10690 *buf_ptr += WMI_TLV_HDR_SIZE;
10691 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
10692 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
10693 WMITLV_SET_HDR(&arp_tuple->tlv_header,
10694 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
10695 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
10696
10697 /* Fill data for ARP and NS in the first tupple for LA */
10698 if ((enable_or_disable & WMI_OFFLOAD_ENABLE) && (i == 0)) {
10699 /* Copy the target ip addr and flags */
10700 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
10701 qdf_mem_copy(&arp_tuple->target_ipaddr,
10702 offload_req->params.hostIpv4Addr,
10703 WMI_IPV4_ADDR_LEN);
10704 WMI_LOGD("ARPOffload IP4 address: %pI4",
10705 offload_req->params.hostIpv4Addr);
10706 }
10707 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
10708 }
10709}
10710
10711#ifdef WLAN_NS_OFFLOAD
10712/**
10713 * fill_ns_offload_params_tlv() - Fill NS offload data
10714 * @wmi|_handle: wmi handle
10715 * @offload_req: offload request
10716 * @buf_ptr: buffer pointer
10717 *
10718 * To fill NS offload data to firmware
10719 * when target goes to wow mode.
10720 *
10721 * Return: None
10722 */
10723static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10724 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10725{
10726
10727 int i;
10728 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10729 struct ns_offload_req_params ns_req;
10730
10731 ns_req = offload_req->nsOffloadInfo;
10732 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10733 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10734 *buf_ptr += WMI_TLV_HDR_SIZE;
10735 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
10736 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10737 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10738 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10739 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
10740
10741 /*
10742 * Fill data only for NS offload in the first ARP tuple for LA
10743 */
10744 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10745 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10746 /* Copy the target/solicitation/remote ip addr */
10747 if (ns_req.targetIPv6AddrValid[i])
10748 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10749 &ns_req.targetIPv6Addr[i],
10750 sizeof(WMI_IPV6_ADDR));
10751 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10752 &ns_req.selfIPv6Addr[i],
10753 sizeof(WMI_IPV6_ADDR));
10754 if (ns_req.target_ipv6_addr_ac_type[i]) {
10755 ns_tuple->flags |=
10756 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10757 }
10758 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10759 i, &ns_req.selfIPv6Addr[i],
10760 &ns_req.targetIPv6Addr[i]);
10761
10762 /* target MAC is optional, check if it is valid,
10763 * if this is not valid, the target will use the known
10764 * local MAC address rather than the tuple
10765 */
10766 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10767 ns_req.self_macaddr.bytes,
10768 &ns_tuple->target_mac);
10769 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10770 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10771 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10772 }
10773 }
10774 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10775 }
10776}
10777
10778
10779/**
10780 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
10781 * @wmi: wmi handle
10782 * @offload_req: offload request
10783 * @buf_ptr: buffer pointer
10784 *
10785 * To fill extended NS offload extended data to firmware
10786 * when target goes to wow mode.
10787 *
10788 * Return: None
10789 */
10790static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10791 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10792{
10793 int i;
10794 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
10795 uint32_t count, num_ns_ext_tuples;
10796 struct ns_offload_req_params ns_req;
10797
10798 ns_req = offload_req->nsOffloadInfo;
10799 count = offload_req->num_ns_offload_count;
10800 num_ns_ext_tuples = offload_req->num_ns_offload_count -
10801 WMI_MAX_NS_OFFLOADS;
10802
10803 /* Populate extended NS offload tuples */
10804 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10805 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
10806 *buf_ptr += WMI_TLV_HDR_SIZE;
10807 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
10808 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
10809 WMITLV_SET_HDR(&ns_tuple->tlv_header,
10810 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
10811 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
10812
10813 /*
10814 * Fill data only for NS offload in the first ARP tuple for LA
10815 */
10816 if ((offload_req->enableOrDisable & WMI_OFFLOAD_ENABLE)) {
10817 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
10818 /* Copy the target/solicitation/remote ip addr */
10819 if (ns_req.targetIPv6AddrValid[i])
10820 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
10821 &ns_req.targetIPv6Addr[i],
10822 sizeof(WMI_IPV6_ADDR));
10823 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
10824 &ns_req.selfIPv6Addr[i],
10825 sizeof(WMI_IPV6_ADDR));
10826 if (ns_req.target_ipv6_addr_ac_type[i]) {
10827 ns_tuple->flags |=
10828 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
10829 }
10830 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
10831 i, &ns_req.selfIPv6Addr[i],
10832 &ns_req.targetIPv6Addr[i]);
10833
10834 /* target MAC is optional, check if it is valid,
10835 * if this is not valid, the target will use the
10836 * known local MAC address rather than the tuple
10837 */
10838 WMI_CHAR_ARRAY_TO_MAC_ADDR(
10839 ns_req.self_macaddr.bytes,
10840 &ns_tuple->target_mac);
10841 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
10842 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
10843 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
10844 }
10845 }
10846 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
10847 }
10848}
10849#else
10850static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
10851 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10852{
10853 return;
10854}
10855
10856static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
10857 struct host_offload_req_param *offload_req, uint8_t **buf_ptr)
10858{
10859 return;
10860}
10861#endif
10862
10863/**
Govind Singha4836fd2016-03-07 16:45:38 +053010864 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
10865 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010866 * @arp_offload_req: arp offload request
10867 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053010868 * @arp_only: flag
10869 *
10870 * To configure ARP NS off load data to firmware
10871 * when target goes to wow mode.
10872 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010873 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053010874 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010875static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010876 struct host_offload_req_param *arp_offload_req,
10877 struct host_offload_req_param *ns_offload_req,
10878 bool arp_only,
Govind Singha4836fd2016-03-07 16:45:38 +053010879 uint8_t vdev_id)
10880{
Govind Singha4836fd2016-03-07 16:45:38 +053010881 int32_t res;
10882 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053010883 A_UINT8 *buf_ptr;
10884 wmi_buf_t buf;
10885 int32_t len;
10886 uint32_t count = 0, num_ns_ext_tuples = 0;
10887
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010888 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053010889
Govind Singha4836fd2016-03-07 16:45:38 +053010890 /*
10891 * TLV place holder size for array of NS tuples
10892 * TLV place holder size for array of ARP tuples
10893 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010894 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
10895 WMI_TLV_HDR_SIZE +
10896 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
10897 WMI_TLV_HDR_SIZE +
10898 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010899
10900 /*
10901 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
10902 * extra length for extended NS offload tuples which follows ARP offload
10903 * tuples. Host needs to fill this structure in following format:
10904 * 2 NS ofload tuples
10905 * 2 ARP offload tuples
10906 * N numbers of extended NS offload tuples if HDD has given more than
10907 * 2 NS offload addresses
10908 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010909 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053010910 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010911 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
10912 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053010913 }
10914
10915 buf = wmi_buf_alloc(wmi_handle, len);
10916 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010917 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053010918 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010919 }
10920
10921 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
10922 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
10923 WMITLV_SET_HDR(&cmd->tlv_header,
10924 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
10925 WMITLV_GET_STRUCT_TLVLEN
10926 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
10927 cmd->flags = 0;
10928 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010929 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053010930
Govind Singhb53420c2016-03-09 14:32:57 +053010931 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053010932
Govind Singha4836fd2016-03-07 16:45:38 +053010933 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053010934 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
10935 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
10936 if (num_ns_ext_tuples)
10937 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053010938
10939 res = wmi_unified_cmd_send(wmi_handle, buf, len,
10940 WMI_SET_ARP_NS_OFFLOAD_CMDID);
10941 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053010942 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053010943 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010944 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010945 }
10946
Govind Singhb53420c2016-03-09 14:32:57 +053010947 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010948}
10949
Sathish Kumarfd347372017-02-13 12:29:09 +053010950static QDF_STATUS send_enable_broadcast_filter_cmd_tlv(wmi_unified_t wmi_handle,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053010951 uint8_t vdev_id, bool enable)
10952{
10953 int32_t res;
10954 wmi_hw_data_filter_cmd_fixed_param *cmd;
10955 A_UINT8 *buf_ptr;
10956 wmi_buf_t buf;
10957 int32_t len;
10958
10959 /*
10960 * TLV place holder size for array of ARP tuples
10961 */
10962 len = sizeof(wmi_hw_data_filter_cmd_fixed_param);
10963
10964 buf = wmi_buf_alloc(wmi_handle, len);
10965 if (!buf) {
10966 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10967 return QDF_STATUS_E_NOMEM;
10968 }
10969
10970 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
10971 cmd = (wmi_hw_data_filter_cmd_fixed_param *) buf_ptr;
10972 WMITLV_SET_HDR(&cmd->tlv_header,
10973 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
10974 WMITLV_GET_STRUCT_TLVLEN
10975 (wmi_hw_data_filter_cmd_fixed_param));
10976 cmd->vdev_id = vdev_id;
10977 cmd->enable = enable;
10978 cmd->hw_filter_bitmap = WMI_HW_DATA_FILTER_DROP_NON_ARP_BC;
10979
10980 WMI_LOGD("HW Broadcast Filter vdev_id: %d", cmd->vdev_id);
10981
10982 res = wmi_unified_cmd_send(wmi_handle, buf, len,
10983 WMI_HW_DATA_FILTER_CMDID);
10984 if (res) {
10985 WMI_LOGE("Failed to enable ARP NDP/NSffload");
10986 wmi_buf_free(buf);
10987 return QDF_STATUS_E_FAILURE;
10988 }
10989
10990 return QDF_STATUS_SUCCESS;
10991}
10992
Govind Singha4836fd2016-03-07 16:45:38 +053010993/**
10994 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
10995 * @wmi_handle: wmi handle
10996 * @request: SSID hotlist set request
10997 *
Govind Singhb53420c2016-03-09 14:32:57 +053010998 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053010999 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011000static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053011001send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
11002 struct ssid_hotlist_request_params *request)
11003{
11004 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
11005 wmi_buf_t wmi_buf;
11006 uint32_t len;
11007 uint32_t array_size;
11008 uint8_t *buf_ptr;
11009
11010 /* length of fixed portion */
11011 len = sizeof(*cmd);
11012
11013 /* length of variable portion */
11014 array_size =
11015 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
11016 len += WMI_TLV_HDR_SIZE + array_size;
11017
11018 wmi_buf = wmi_buf_alloc(wmi_handle, len);
11019 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011020 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11021 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011022 }
11023
11024 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
11025 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
11026 buf_ptr;
11027 WMITLV_SET_HDR
11028 (&cmd->tlv_header,
11029 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
11030 WMITLV_GET_STRUCT_TLVLEN
11031 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
11032
11033 cmd->request_id = request->request_id;
11034 cmd->requestor_id = 0;
11035 cmd->vdev_id = request->session_id;
11036 cmd->table_id = 0;
11037 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
11038 cmd->total_entries = request->ssid_count;
11039 cmd->num_entries_in_page = request->ssid_count;
11040 cmd->first_entry_index = 0;
11041
11042 buf_ptr += sizeof(*cmd);
11043 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
11044
11045 if (request->ssid_count) {
11046 wmi_extscan_hotlist_ssid_entry *entry;
11047 int i;
11048
11049 buf_ptr += WMI_TLV_HDR_SIZE;
11050 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
11051 for (i = 0; i < request->ssid_count; i++) {
11052 WMITLV_SET_HDR
11053 (entry,
11054 WMITLV_TAG_ARRAY_STRUC,
11055 WMITLV_GET_STRUCT_TLVLEN
11056 (wmi_extscan_hotlist_ssid_entry));
11057 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053011058 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053011059 request->ssids[i].ssid.mac_ssid,
11060 request->ssids[i].ssid.length);
11061 entry->band = request->ssids[i].band;
11062 entry->min_rssi = request->ssids[i].rssi_low;
11063 entry->max_rssi = request->ssids[i].rssi_high;
11064 entry++;
11065 }
11066 cmd->mode = WMI_EXTSCAN_MODE_START;
11067 } else {
11068 cmd->mode = WMI_EXTSCAN_MODE_STOP;
11069 }
11070
11071 if (wmi_unified_cmd_send
11072 (wmi_handle, wmi_buf, len,
11073 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011074 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053011075 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011076 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011077 }
11078
Govind Singhb53420c2016-03-09 14:32:57 +053011079 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011080}
11081
11082/**
11083 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
11084 * @wmi_handle: wmi handle
11085 * @vdev_id: vdev id
11086 *
11087 * This function sends roam synch complete event to fw.
11088 *
11089 * Return: CDF STATUS
11090 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011091static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011092 uint8_t vdev_id)
11093{
11094 wmi_roam_synch_complete_fixed_param *cmd;
11095 wmi_buf_t wmi_buf;
11096 uint8_t *buf_ptr;
11097 uint16_t len;
11098 len = sizeof(wmi_roam_synch_complete_fixed_param);
11099
11100 wmi_buf = wmi_buf_alloc(wmi_handle, len);
11101 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011102 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11103 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011104 }
11105 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
11106 buf_ptr = (uint8_t *) cmd;
11107 WMITLV_SET_HDR(&cmd->tlv_header,
11108 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
11109 WMITLV_GET_STRUCT_TLVLEN
11110 (wmi_roam_synch_complete_fixed_param));
11111 cmd->vdev_id = vdev_id;
11112 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
11113 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011114 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053011115 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011116 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011117 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011118 }
11119
Govind Singhb53420c2016-03-09 14:32:57 +053011120 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011121}
11122
11123/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053011124 * send_fw_test_cmd_tlv() - send fw test command to fw.
11125 * @wmi_handle: wmi handle
11126 * @wmi_fwtest: fw test command
11127 *
11128 * This function sends fw test command to fw.
11129 *
11130 * Return: CDF STATUS
11131 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011132static
Anurag Chouhan459e0152016-07-22 20:19:54 +053011133QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
11134 struct set_fwtest_params *wmi_fwtest)
11135{
11136 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11137 wmi_buf_t wmi_buf;
11138 uint16_t len;
11139
11140 len = sizeof(*cmd);
11141
11142 wmi_buf = wmi_buf_alloc(wmi_handle, len);
11143 if (!wmi_buf) {
11144 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
11145 return QDF_STATUS_E_NOMEM;
11146 }
11147
11148 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
11149 WMITLV_SET_HDR(&cmd->tlv_header,
11150 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11151 WMITLV_GET_STRUCT_TLVLEN(
11152 wmi_fwtest_set_param_cmd_fixed_param));
11153 cmd->param_id = wmi_fwtest->arg;
11154 cmd->param_value = wmi_fwtest->value;
11155
11156 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
11157 WMI_FWTEST_CMDID)) {
11158 WMI_LOGP("%s: failed to send fw test command", __func__);
11159 qdf_nbuf_free(wmi_buf);
11160 return QDF_STATUS_E_FAILURE;
11161 }
11162
11163 return QDF_STATUS_SUCCESS;
11164}
11165
11166/**
Govind Singha4836fd2016-03-07 16:45:38 +053011167 * send_unit_test_cmd_tlv() - send unit test command to fw.
11168 * @wmi_handle: wmi handle
11169 * @wmi_utest: unit test command
11170 *
11171 * This function send unit test command to fw.
11172 *
11173 * Return: CDF STATUS
11174 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011175static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011176 struct wmi_unit_test_cmd *wmi_utest)
11177{
11178 wmi_unit_test_cmd_fixed_param *cmd;
11179 wmi_buf_t wmi_buf;
11180 uint8_t *buf_ptr;
11181 int i;
11182 uint16_t len, args_tlv_len;
11183 A_UINT32 *unit_test_cmd_args;
11184
11185 args_tlv_len =
11186 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
11187 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
11188
11189 wmi_buf = wmi_buf_alloc(wmi_handle, len);
11190 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011191 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
11192 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011193 }
11194
11195 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
11196 buf_ptr = (uint8_t *) cmd;
11197 WMITLV_SET_HDR(&cmd->tlv_header,
11198 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
11199 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
11200 cmd->vdev_id = wmi_utest->vdev_id;
11201 cmd->module_id = wmi_utest->module_id;
11202 cmd->num_args = wmi_utest->num_args;
11203 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
11204 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11205 (wmi_utest->num_args * sizeof(uint32_t)));
11206 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053011207 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053011208 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
11209 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053011210 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011211 }
11212 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
11213 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011214 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011215 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011216 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011217 }
11218
Govind Singhb53420c2016-03-09 14:32:57 +053011219 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011220}
11221
11222/**
11223 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
11224 * @wmi_handle: wma handle
11225 * @roaminvoke: roam invoke command
11226 *
11227 * Send roam invoke command to fw for fastreassoc.
11228 *
11229 * Return: CDF STATUS
11230 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011231static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011232 struct wmi_roam_invoke_cmd *roaminvoke,
11233 uint32_t ch_hz)
11234{
11235 wmi_roam_invoke_cmd_fixed_param *cmd;
11236 wmi_buf_t wmi_buf;
11237 u_int8_t *buf_ptr;
11238 u_int16_t len, args_tlv_len;
11239 A_UINT32 *channel_list;
11240 wmi_mac_addr *bssid_list;
11241
11242 /* Host sends only one channel and one bssid */
11243 args_tlv_len = 2 * WMI_TLV_HDR_SIZE + sizeof(A_UINT32) +
11244 sizeof(wmi_mac_addr);
11245 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
11246 wmi_buf = wmi_buf_alloc(wmi_handle, len);
11247 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011248 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
11249 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011250 }
11251
11252 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
11253 buf_ptr = (u_int8_t *) cmd;
11254 WMITLV_SET_HDR(&cmd->tlv_header,
11255 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
11256 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
11257 cmd->vdev_id = roaminvoke->vdev_id;
11258 cmd->flags = 0;
11259 cmd->roam_scan_mode = 0;
11260 cmd->roam_ap_sel_mode = 0;
11261 cmd->roam_delay = 0;
11262 cmd->num_chan = 1;
11263 cmd->num_bssid = 1;
11264 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
11265 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11266 (sizeof(u_int32_t)));
11267 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
11268 *channel_list = ch_hz;
11269 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
11270 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
11271 (sizeof(wmi_mac_addr)));
11272 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
11273 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
11274 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
11275 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011276 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053011277 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011278 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011279 }
11280
Govind Singhb53420c2016-03-09 14:32:57 +053011281 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011282}
11283
11284/**
11285 * send_roam_scan_offload_cmd_tlv() - set roam offload command
11286 * @wmi_handle: wmi handle
11287 * @command: command
11288 * @vdev_id: vdev id
11289 *
11290 * This function set roam offload command to fw.
11291 *
11292 * Return: CDF status
11293 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011294static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011295 uint32_t command, uint32_t vdev_id)
11296{
Govind Singh67922e82016-04-01 16:48:57 +053011297 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011298 wmi_roam_scan_cmd_fixed_param *cmd_fp;
11299 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053011300 int len;
11301 uint8_t *buf_ptr;
11302
11303 len = sizeof(wmi_roam_scan_cmd_fixed_param);
11304 buf = wmi_buf_alloc(wmi_handle, len);
11305 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011306 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11307 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011308 }
11309
11310 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11311
11312 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
11313 WMITLV_SET_HDR(&cmd_fp->tlv_header,
11314 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
11315 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
11316 cmd_fp->vdev_id = vdev_id;
11317 cmd_fp->command_arg = command;
11318
11319 status = wmi_unified_cmd_send(wmi_handle, buf,
11320 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053011321 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011322 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011323 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011324 goto error;
11325 }
11326
Govind Singhb53420c2016-03-09 14:32:57 +053011327 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
11328 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011329
11330error:
11331 wmi_buf_free(buf);
11332
Govind Singh67922e82016-04-01 16:48:57 +053011333 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011334}
11335
11336/**
11337 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
11338 * @wmi_handle: wmi handle
11339 * @ap_profile_p: ap profile
11340 * @vdev_id: vdev id
11341 *
11342 * Send WMI_ROAM_AP_PROFILE to firmware
11343 *
11344 * Return: CDF status
11345 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011346static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011347 wmi_ap_profile *ap_profile_p,
11348 uint32_t vdev_id)
11349{
Govind Singha4836fd2016-03-07 16:45:38 +053011350 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011351 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011352 int len;
11353 uint8_t *buf_ptr;
11354 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
11355
11356 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
11357
11358 buf = wmi_buf_alloc(wmi_handle, len);
11359 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011360 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11361 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011362 }
11363
11364 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11365 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
11366 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
11367 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
11368 WMITLV_GET_STRUCT_TLVLEN
11369 (wmi_roam_ap_profile_fixed_param));
11370 /* fill in threshold values */
11371 roam_ap_profile_fp->vdev_id = vdev_id;
11372 roam_ap_profile_fp->id = 0;
11373 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
11374
Govind Singhb53420c2016-03-09 14:32:57 +053011375 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053011376 WMITLV_SET_HDR(buf_ptr,
11377 WMITLV_TAG_STRUC_wmi_ap_profile,
11378 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
11379 status = wmi_unified_cmd_send(wmi_handle, buf,
11380 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053011381 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011382 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011383 status);
Govind Singh67922e82016-04-01 16:48:57 +053011384 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011385 }
11386
Govind Singhb53420c2016-03-09 14:32:57 +053011387 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053011388
Govind Singh67922e82016-04-01 16:48:57 +053011389 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011390}
11391
11392/**
11393 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
11394 * @wmi_handle: wmi handle
11395 * @scan_period: scan period
11396 * @scan_age: scan age
11397 * @vdev_id: vdev id
11398 *
11399 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
11400 *
11401 * Return: CDF status
11402 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011403static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011404 uint32_t scan_period,
11405 uint32_t scan_age,
11406 uint32_t vdev_id)
11407{
Govind Singh67922e82016-04-01 16:48:57 +053011408 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011409 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053011410 int len;
11411 uint8_t *buf_ptr;
11412 wmi_roam_scan_period_fixed_param *scan_period_fp;
11413
11414 /* Send scan period values */
11415 len = sizeof(wmi_roam_scan_period_fixed_param);
11416 buf = wmi_buf_alloc(wmi_handle, len);
11417 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011418 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11419 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011420 }
11421
11422 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11423 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
11424 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
11425 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
11426 WMITLV_GET_STRUCT_TLVLEN
11427 (wmi_roam_scan_period_fixed_param));
11428 /* fill in scan period values */
11429 scan_period_fp->vdev_id = vdev_id;
11430 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
11431 scan_period_fp->roam_scan_age = scan_age;
11432
11433 status = wmi_unified_cmd_send(wmi_handle, buf,
11434 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053011435 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011436 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011437 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011438 goto error;
11439 }
11440
Govind Singhb53420c2016-03-09 14:32:57 +053011441 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011442 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053011443 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011444error:
11445 wmi_buf_free(buf);
11446
Govind Singh67922e82016-04-01 16:48:57 +053011447 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011448}
11449
11450/**
11451 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
11452 * @wmi_handle: wmi handle
11453 * @chan_count: channel count
11454 * @chan_list: channel list
11455 * @list_type: list type
11456 * @vdev_id: vdev id
11457 *
11458 * Set roam offload channel list.
11459 *
11460 * Return: CDF status
11461 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011462static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011463 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070011464 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053011465 uint8_t list_type, uint32_t vdev_id)
11466{
Govind Singha4836fd2016-03-07 16:45:38 +053011467 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011468 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011469 int len, list_tlv_len;
11470 int i;
11471 uint8_t *buf_ptr;
11472 wmi_roam_chan_list_fixed_param *chan_list_fp;
11473 A_UINT32 *roam_chan_list_array;
11474
11475 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053011476 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053011477 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053011478 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053011479 }
11480 /* Channel list is a table of 2 TLV's */
11481 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
11482 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
11483 buf = wmi_buf_alloc(wmi_handle, len);
11484 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011485 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11486 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011487 }
11488
11489 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11490 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
11491 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
11492 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
11493 WMITLV_GET_STRUCT_TLVLEN
11494 (wmi_roam_chan_list_fixed_param));
11495 chan_list_fp->vdev_id = vdev_id;
11496 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053011497 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053011498 /* external app is controlling channel list */
11499 chan_list_fp->chan_list_type =
11500 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
11501 } else {
11502 /* umac supplied occupied channel list in LFR */
11503 chan_list_fp->chan_list_type =
11504 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
11505 }
11506
11507 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
11508 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11509 (chan_list_fp->num_chan * sizeof(uint32_t)));
11510 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053011511 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053011512 for (i = 0; ((i < chan_list_fp->num_chan) &&
11513 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
11514 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053011515 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011516 }
11517
11518 status = wmi_unified_cmd_send(wmi_handle, buf,
11519 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053011520 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011521 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011522 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011523 goto error;
11524 }
11525
Govind Singhb53420c2016-03-09 14:32:57 +053011526 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
11527 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011528error:
11529 wmi_buf_free(buf);
11530
Govind Singh67922e82016-04-01 16:48:57 +053011531 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011532}
11533
11534/**
11535 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
11536 * @wmi_handle: wmi handle
11537 * @rssi_change_thresh: RSSI Change threshold
11538 * @bcn_rssi_weight: beacon RSSI weight
11539 * @vdev_id: vdev id
11540 *
11541 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
11542 *
11543 * Return: CDF status
11544 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011545static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011546 uint32_t vdev_id,
11547 int32_t rssi_change_thresh,
11548 uint32_t bcn_rssi_weight,
11549 uint32_t hirssi_delay_btw_scans)
11550{
Govind Singha4836fd2016-03-07 16:45:38 +053011551 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011552 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053011553 int len;
11554 uint8_t *buf_ptr;
11555 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
11556
11557 /* Send rssi change parameters */
11558 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
11559 buf = wmi_buf_alloc(wmi_handle, len);
11560 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011561 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11562 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011563 }
11564
11565 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11566 rssi_change_fp =
11567 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
11568 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
11569 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
11570 WMITLV_GET_STRUCT_TLVLEN
11571 (wmi_roam_scan_rssi_change_threshold_fixed_param));
11572 /* fill in rssi change threshold (hysteresis) values */
11573 rssi_change_fp->vdev_id = vdev_id;
11574 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
11575 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
11576 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
11577
11578 status = wmi_unified_cmd_send(wmi_handle, buf,
11579 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053011580 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011581 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011582 status);
Govind Singha4836fd2016-03-07 16:45:38 +053011583 goto error;
11584 }
11585
Govind Singhb53420c2016-03-09 14:32:57 +053011586 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053011587 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053011588 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
11589 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011590error:
11591 wmi_buf_free(buf);
11592
Govind Singh67922e82016-04-01 16:48:57 +053011593 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053011594}
11595
11596/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
11597 * @wmi_handle: wmi handle.
11598 * @cmd: size of command structure.
11599 * @per_entry_size: per entry size.
11600 *
11601 * This utility function calculates how many hotlist entries can
11602 * fit in one page.
11603 *
11604 * Return: number of entries
11605 */
11606static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
11607 size_t cmd_size,
11608 size_t per_entry_size)
11609{
11610 uint32_t avail_space = 0;
11611 int num_entries = 0;
11612 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
11613
11614 /* Calculate number of hotlist entries that can
11615 * be passed in wma message request.
11616 */
11617 avail_space = max_msg_len - cmd_size;
11618 num_entries = avail_space / per_entry_size;
11619 return num_entries;
11620}
11621
11622/**
11623 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
11624 * @wmi_handle: wmi handle
11625 * @photlist: hotlist command params
11626 * @buf_len: buffer length
11627 *
11628 * This function fills individual elements for hotlist request and
11629 * TLV for bssid entries
11630 *
11631 * Return: CDF Status.
11632 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011633static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011634 struct ext_scan_setbssi_hotlist_params *
11635 photlist, int *buf_len)
11636{
11637 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
11638 wmi_extscan_hotlist_entry *dest_hotlist;
11639 struct ap_threshold_params *src_ap = photlist->ap;
11640 wmi_buf_t buf;
11641 uint8_t *buf_ptr;
11642
11643 int j, index = 0;
11644 int cmd_len = 0;
11645 int num_entries;
11646 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080011647 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053011648 int len = sizeof(*cmd);
11649
11650 len += WMI_TLV_HDR_SIZE;
11651 cmd_len = len;
11652
11653 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
11654 cmd_len,
11655 sizeof(*dest_hotlist));
11656 /* setbssid hotlist expects the bssid list
11657 * to be non zero value
11658 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080011659 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080011660 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053011661 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011662 }
11663
11664 /* Split the hot list entry pages and send multiple command
11665 * requests if the buffer reaches the maximum request size
11666 */
11667 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053011668 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053011669 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
11670 buf = wmi_buf_alloc(wmi_handle, len);
11671 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011672 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
11673 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011674 }
11675 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11676 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
11677 buf_ptr;
11678 WMITLV_SET_HDR(&cmd->tlv_header,
11679 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
11680 WMITLV_GET_STRUCT_TLVLEN
11681 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
11682
11683 /* Multiple requests are sent until the num_entries_in_page
11684 * matches the total_entries
11685 */
11686 cmd->request_id = photlist->requestId;
11687 cmd->vdev_id = photlist->sessionId;
11688 cmd->total_entries = numap;
11689 cmd->mode = 1;
11690 cmd->num_entries_in_page = min_entries;
11691 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
11692 cmd->first_entry_index = index;
11693
Govind Singhb53420c2016-03-09 14:32:57 +053011694 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011695 __func__, cmd->vdev_id, cmd->total_entries,
11696 cmd->num_entries_in_page,
11697 cmd->lost_ap_scan_count);
11698
11699 buf_ptr += sizeof(*cmd);
11700 WMITLV_SET_HDR(buf_ptr,
11701 WMITLV_TAG_ARRAY_STRUC,
11702 min_entries * sizeof(wmi_extscan_hotlist_entry));
11703 dest_hotlist = (wmi_extscan_hotlist_entry *)
11704 (buf_ptr + WMI_TLV_HDR_SIZE);
11705
11706 /* Populate bssid, channel info and rssi
11707 * for the bssid's that are sent as hotlists.
11708 */
11709 for (j = 0; j < min_entries; j++) {
11710 WMITLV_SET_HDR(dest_hotlist,
11711 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
11712 WMITLV_GET_STRUCT_TLVLEN
11713 (wmi_extscan_hotlist_entry));
11714
11715 dest_hotlist->min_rssi = src_ap->low;
11716 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
11717 &dest_hotlist->bssid);
11718
Govind Singhb53420c2016-03-09 14:32:57 +053011719 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053011720 __func__, dest_hotlist->channel,
11721 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053011722 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053011723 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
11724 __func__, dest_hotlist->bssid.mac_addr31to0,
11725 dest_hotlist->bssid.mac_addr47to32);
11726 dest_hotlist++;
11727 src_ap++;
11728 }
11729 buf_ptr += WMI_TLV_HDR_SIZE +
11730 (min_entries * sizeof(wmi_extscan_hotlist_entry));
11731
11732 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11733 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011734 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011735 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011736 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011737 }
11738 index = index + min_entries;
11739 num_entries = numap - min_entries;
11740 len = cmd_len;
11741 }
Govind Singhb53420c2016-03-09 14:32:57 +053011742 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011743}
11744
Govind Singhbca3b1b2016-05-02 17:59:24 +053011745/**
11746 * send_power_dbg_cmd_tlv() - send power debug commands
11747 * @wmi_handle: wmi handle
11748 * @param: wmi power debug parameter
11749 *
11750 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
11751 *
11752 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
11753 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011754static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
11755 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053011756{
11757 wmi_buf_t buf = NULL;
11758 QDF_STATUS status;
11759 int len, args_tlv_len;
11760 uint8_t *buf_ptr;
11761 uint8_t i;
11762 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
11763 uint32_t *cmd_args;
11764
11765 /* Prepare and send power debug cmd parameters */
11766 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
11767 len = sizeof(*cmd) + args_tlv_len;
11768 buf = wmi_buf_alloc(wmi_handle, len);
11769 if (!buf) {
11770 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
11771 return QDF_STATUS_E_NOMEM;
11772 }
11773
11774 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11775 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
11776 WMITLV_SET_HDR(&cmd->tlv_header,
11777 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
11778 WMITLV_GET_STRUCT_TLVLEN
11779 (wmi_pdev_wal_power_debug_cmd_fixed_param));
11780
11781 cmd->pdev_id = param->pdev_id;
11782 cmd->module_id = param->module_id;
11783 cmd->num_args = param->num_args;
11784 buf_ptr += sizeof(*cmd);
11785 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11786 (param->num_args * sizeof(uint32_t)));
11787 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11788 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
11789 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
11790 cmd_args[i] = param->args[i];
11791 WMI_LOGI("%d,", param->args[i]);
11792 }
11793
11794 status = wmi_unified_cmd_send(wmi_handle, buf,
11795 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
11796 if (QDF_IS_STATUS_ERROR(status)) {
11797 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
11798 status);
11799 goto error;
11800 }
11801
11802 return QDF_STATUS_SUCCESS;
11803error:
11804 wmi_buf_free(buf);
11805
11806 return status;
11807}
11808
Govind Singhe7f2f342016-05-23 12:12:52 +053011809/**
11810 * init_cmd_send_tlv() - send initialization cmd to fw
11811 * @wmi_handle: wmi handle
11812 * @param tgt_res_cfg: pointer to target resource configuration
11813 * @param num_mem_chunks: Number of memory chunks
11814 * @param mem_chunks: pointer to target memory chunks
11815 *
11816 * Return: QDF_STATUS_SUCCESS for success or error code
11817 */
11818static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
11819 target_resource_config *tgt_res_cfg, uint8_t num_mem_chunks,
11820 struct wmi_host_mem_chunk *mem_chunks)
11821{
11822 wmi_buf_t buf;
11823 wmi_init_cmd_fixed_param *cmd;
11824 wmi_abi_version my_vers;
11825 int num_whitelist;
11826 uint8_t *buf_ptr;
11827 wmi_resource_config *resource_cfg;
11828 wlan_host_memory_chunk *host_mem_chunks;
11829 uint32_t mem_chunk_len = 0;
11830 uint16_t idx;
11831 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053011832 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053011833
11834 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11835 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11836 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11837 if (!buf) {
11838 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
11839 return QDF_STATUS_E_FAILURE;
11840 }
11841
11842 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11843 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11844 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11845
11846 host_mem_chunks = (wlan_host_memory_chunk *)
11847 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11848 + WMI_TLV_HDR_SIZE);
11849
11850 WMITLV_SET_HDR(&cmd->tlv_header,
11851 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11852 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11853
11854 wmi_copy_resource_config(resource_cfg, tgt_res_cfg);
11855 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11856 WMITLV_TAG_STRUC_wmi_resource_config,
11857 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11858
11859 for (idx = 0; idx < num_mem_chunks; ++idx) {
11860 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11861 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11862 WMITLV_GET_STRUCT_TLVLEN
11863 (wlan_host_memory_chunk));
11864 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11865 host_mem_chunks[idx].size = mem_chunks[idx].len;
11866 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
11867 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
11868 idx, host_mem_chunks[idx].size,
11869 host_mem_chunks[idx].ptr);
11870 }
11871 cmd->num_host_mem_chunks = num_mem_chunks;
11872 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11873 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11874 WMITLV_TAG_ARRAY_STRUC,
11875 (sizeof(wlan_host_memory_chunk) *
11876 num_mem_chunks));
11877
11878 num_whitelist = sizeof(version_whitelist) /
11879 sizeof(wmi_whitelist_version_info);
11880 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11881 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11882 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11883 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11884 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11885 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
11886
Govind Singh87542482016-06-08 19:40:11 +053011887#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011888 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11889 &my_vers,
11890 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
11891 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011892#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053011893 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
11894 __func__,
11895 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11896 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11897 cmd->host_abi_vers.abi_version_ns_0,
11898 cmd->host_abi_vers.abi_version_ns_1,
11899 cmd->host_abi_vers.abi_version_ns_2,
11900 cmd->host_abi_vers.abi_version_ns_3);
11901
11902 /* Save version sent from host -
11903 * Will be used to check ready event
11904 */
Govind Singh87542482016-06-08 19:40:11 +053011905#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011906 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
11907 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011908#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053011909 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
11910 if (QDF_IS_STATUS_ERROR(ret)) {
11911 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
11912 ret);
11913 wmi_buf_free(buf);
11914 }
11915 return ret;
11916
Govind Singhe7f2f342016-05-23 12:12:52 +053011917}
11918
11919/**
11920 * save_service_bitmap_tlv() - save service bitmap
11921 * @wmi_handle: wmi handle
11922 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080011923 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053011924 *
11925 * Return: None
11926 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011927#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011928static
Rajeev Kumar77901472017-02-12 02:12:17 -080011929void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
11930 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053011931{
11932 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11933 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11934
11935 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
11936 param_buf->wmi_service_bitmap,
11937 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080011938
11939 if (bitmap_buf)
11940 qdf_mem_copy(bitmap_buf,
11941 param_buf->wmi_service_bitmap,
11942 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053011943}
11944#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011945static
Rajeev Kumar77901472017-02-12 02:12:17 -080011946void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
11947 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053011948{
Rajeev Kumar77901472017-02-12 02:12:17 -080011949 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11950 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053011951
Rajeev Kumar77901472017-02-12 02:12:17 -080011952 if (bitmap_buf)
11953 qdf_mem_copy(bitmap_buf,
11954 param_buf->wmi_service_bitmap,
11955 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
11956}
Govind Singhe7f2f342016-05-23 12:12:52 +053011957#endif
11958
11959/**
11960 * is_service_enabled_tlv() - Check if service enabled
11961 * @param wmi_handle: wmi handle
11962 * @param service_id: service identifier
11963 *
11964 * Return: 1 enabled, 0 disabled
11965 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053011966#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053011967static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11968 uint32_t service_id)
11969{
11970 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
11971 service_id);
11972}
11973#else
11974static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
11975 uint32_t service_id)
11976{
11977 return false;
11978}
11979#endif
11980
11981/**
11982 * extract_service_ready_tlv() - extract service ready event
11983 * @wmi_handle: wmi handle
11984 * @param evt_buf: pointer to received event buffer
11985 * @param cap: pointer to hold target capability information extracted from even
11986 *
11987 * Return: QDF_STATUS_SUCCESS for success or error code
11988 */
11989static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
11990 void *evt_buf, target_capability_info *cap)
11991{
11992 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11993 wmi_service_ready_event_fixed_param *ev;
11994
11995
11996 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11997
11998 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11999 if (!ev) {
12000 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
12001 return QDF_STATUS_E_FAILURE;
12002 }
12003
12004 cap->phy_capability = ev->phy_capability;
12005 cap->max_frag_entry = ev->max_frag_entry;
12006 cap->num_rf_chains = ev->num_rf_chains;
12007 cap->ht_cap_info = ev->ht_cap_info;
12008 cap->vht_cap_info = ev->vht_cap_info;
12009 cap->vht_supp_mcs = ev->vht_supp_mcs;
12010 cap->hw_min_tx_power = ev->hw_min_tx_power;
12011 cap->hw_max_tx_power = ev->hw_max_tx_power;
12012 cap->sys_cap_info = ev->sys_cap_info;
12013 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
12014 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
12015 cap->max_num_scan_channels = ev->max_num_scan_channels;
12016 cap->max_supported_macs = ev->max_supported_macs;
12017 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
12018 cap->txrx_chainmask = ev->txrx_chainmask;
12019 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
12020 cap->num_msdu_desc = ev->num_msdu_desc;
12021
12022 return QDF_STATUS_SUCCESS;
12023}
12024
12025/**
12026 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
12027 * @wmi_handle: wmi handle
12028 * @param evt_buf: Pointer to event buffer
12029 * @param cap: pointer to hold HAL reg capabilities
12030 *
12031 * Return: QDF_STATUS_SUCCESS for success or error code
12032 */
12033static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
12034 void *evt_buf, TARGET_HAL_REG_CAPABILITIES *cap)
12035{
12036 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Pratik Gandhi33bb7142017-01-05 19:38:41 +053012037 u_int32_t wireless_modes_orig = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053012038
12039 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12040
12041 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
12042 sizeof(uint32_t)),
12043 sizeof(TARGET_HAL_REG_CAPABILITIES));
12044
Pratik Gandhi33bb7142017-01-05 19:38:41 +053012045 /* Convert REGDMN_MODE values sent by target to host internal
12046 * WMI_HOST_REGDMN_MODE values.
12047 *
12048 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
12049 * host currently. Add this in the future if required.
12050 *
12051 * 11AX TODO (Phase II) : 11ax related values are not currently
12052 * advertised separately by FW. As part of phase II regulatory bring-up,
12053 * finalize the advertisement mechanism.
12054 */
12055
12056 wireless_modes_orig = param_buf->hal_reg_capabilities->wireless_modes;
12057 cap->wireless_modes = 0;
12058
12059 if (wireless_modes_orig & REGDMN_MODE_11A)
12060 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
12061
12062 if (wireless_modes_orig & REGDMN_MODE_TURBO)
12063 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
12064
12065 if (wireless_modes_orig & REGDMN_MODE_11B)
12066 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
12067
12068 if (wireless_modes_orig & REGDMN_MODE_PUREG)
12069 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
12070
12071 if (wireless_modes_orig & REGDMN_MODE_11G)
12072 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
12073
12074 if (wireless_modes_orig & REGDMN_MODE_108G)
12075 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
12076
12077 if (wireless_modes_orig & REGDMN_MODE_108A)
12078 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
12079
12080 if (wireless_modes_orig & REGDMN_MODE_XR)
12081 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
12082
12083 if (wireless_modes_orig & REGDMN_MODE_11A_HALF_RATE)
12084 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
12085
12086 if (wireless_modes_orig & REGDMN_MODE_11A_QUARTER_RATE)
12087 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
12088
12089 if (wireless_modes_orig & REGDMN_MODE_11NG_HT20)
12090 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
12091
12092 if (wireless_modes_orig & REGDMN_MODE_11NA_HT20)
12093 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
12094
12095 if (wireless_modes_orig & REGDMN_MODE_11NG_HT40PLUS)
12096 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
12097
12098 if (wireless_modes_orig & REGDMN_MODE_11NG_HT40MINUS)
12099 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
12100
12101 if (wireless_modes_orig & REGDMN_MODE_11NA_HT40PLUS)
12102 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
12103
12104 if (wireless_modes_orig & REGDMN_MODE_11NA_HT40MINUS)
12105 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
12106
12107 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT20)
12108 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
12109
12110 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT40PLUS)
12111 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
12112
12113 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT40MINUS)
12114 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
12115
12116 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT80)
12117 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
12118
12119 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT160)
12120 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
12121
12122 if (wireless_modes_orig & REGDMN_MODE_11AC_VHT80_80)
12123 cap->wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
12124
Govind Singhe7f2f342016-05-23 12:12:52 +053012125 return QDF_STATUS_SUCCESS;
12126}
12127
12128/**
12129 * extract_host_mem_req_tlv() - Extract host memory request event
12130 * @wmi_handle: wmi handle
12131 * @param evt_buf: pointer to event buffer
12132 * @param num_entries: pointer to hold number of entries requested
12133 *
12134 * Return: Number of entries requested
12135 */
12136static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
12137 void *evt_buf, uint8_t *num_entries)
12138{
12139 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12140 wmi_service_ready_event_fixed_param *ev;
12141
12142 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12143
12144 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12145 if (!ev) {
12146 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
12147 return NULL;
12148 }
12149
12150 *num_entries = ev->num_mem_reqs;
12151
12152 return (host_mem_req *)param_buf->mem_reqs;
12153}
12154
12155/**
12156 * save_fw_version_in_service_ready_tlv() - Save fw version in service
12157 * ready function
12158 * @wmi_handle: wmi handle
12159 * @param evt_buf: pointer to event buffer
12160 *
12161 * Return: QDF_STATUS_SUCCESS for success or error code
12162 */
12163static QDF_STATUS
12164save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
12165{
12166 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12167 wmi_service_ready_event_fixed_param *ev;
12168
12169
12170 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12171
12172 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12173 if (!ev) {
12174 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
12175 return QDF_STATUS_E_FAILURE;
12176 }
12177
Govind Singh87542482016-06-08 19:40:11 +053012178#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053012179 /*Save fw version from service ready message */
12180 /*This will be used while sending INIT message */
12181 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
12182 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012183#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053012184 return QDF_STATUS_SUCCESS;
12185}
12186
12187/**
12188 * ready_extract_init_status_tlv() - Extract init status from ready event
12189 * @wmi_handle: wmi handle
12190 * @param evt_buf: Pointer to event buffer
12191 *
12192 * Return: ready status
12193 */
12194static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
12195 void *evt_buf)
12196{
12197 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12198 wmi_ready_event_fixed_param *ev = NULL;
12199
12200
12201 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12202 ev = param_buf->fixed_param;
12203
12204 qdf_print("%s:%d\n", __func__, ev->status);
12205
12206 return ev->status;
12207}
12208
12209/**
12210 * ready_extract_mac_addr_tlv() - extract mac address from ready event
12211 * @wmi_handle: wmi handle
12212 * @param evt_buf: pointer to event buffer
12213 * @param macaddr: Pointer to hold MAC address
12214 *
12215 * Return: QDF_STATUS_SUCCESS for success or error code
12216 */
12217static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
12218 void *evt_buf, uint8_t *macaddr)
12219{
12220 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12221 wmi_ready_event_fixed_param *ev = NULL;
12222
12223
12224 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12225 ev = param_buf->fixed_param;
12226
12227 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
12228
12229 return QDF_STATUS_SUCCESS;
12230}
12231
12232/**
12233 * extract_dbglog_data_len_tlv() - extract debuglog data length
12234 * @wmi_handle: wmi handle
12235 * @param evt_buf: pointer to event buffer
12236 *
12237 * Return: length
12238 */
12239static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080012240 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053012241{
12242 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
12243
12244 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
12245
12246 *len = param_buf->num_bufp;
12247
12248 return param_buf->bufp;
12249}
12250
12251/**
12252 * extract_vdev_start_resp_tlv() - extract vdev start response
12253 * @wmi_handle: wmi handle
12254 * @param evt_buf: pointer to event buffer
12255 * @param vdev_rsp: Pointer to hold vdev response
12256 *
12257 * Return: QDF_STATUS_SUCCESS for success or error code
12258 */
12259static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
12260 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
12261{
12262 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
12263 wmi_vdev_start_response_event_fixed_param *ev;
12264
12265 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
12266 if (!param_buf) {
12267 qdf_print("Invalid start response event buffer\n");
12268 return QDF_STATUS_E_INVAL;
12269 }
12270
12271 ev = param_buf->fixed_param;
12272 if (!ev) {
12273 qdf_print("Invalid start response event buffer\n");
12274 return QDF_STATUS_E_INVAL;
12275 }
12276
12277 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
12278
12279 vdev_rsp->vdev_id = ev->vdev_id;
12280 vdev_rsp->requestor_id = ev->requestor_id;
12281 vdev_rsp->resp_type = ev->resp_type;
12282 vdev_rsp->status = ev->status;
12283 vdev_rsp->chain_mask = ev->chain_mask;
12284 vdev_rsp->smps_mode = ev->smps_mode;
12285 vdev_rsp->mac_id = ev->mac_id;
12286 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
12287 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
12288
12289 return QDF_STATUS_SUCCESS;
12290}
12291
12292/**
12293 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
12294 * @wmi_handle: wmi handle
12295 * @param evt_buf: pointer to event buffer
12296 * @param vdev_map: Pointer to hold vdev map
12297 * @param tbttoffset_list: Pointer to tbtt offset list
12298 *
12299 * Return: QDF_STATUS_SUCCESS for success or error code
12300 */
12301static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
12302 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
12303{
12304 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
12305 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
12306
12307 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
12308 if (!param_buf) {
12309 qdf_print("Invalid tbtt update event buffer\n");
12310 return QDF_STATUS_E_INVAL;
12311 }
12312 tbtt_offset_event = param_buf->fixed_param;
12313
12314 *vdev_map = tbtt_offset_event->vdev_map;
12315 *tbttoffset_list = param_buf->tbttoffset_list;
12316
12317 return QDF_STATUS_SUCCESS;
12318}
12319
12320/**
12321 * extract_mgmt_rx_params_tlv() - extract management rx params from event
12322 * @wmi_handle: wmi handle
12323 * @param evt_buf: pointer to event buffer
12324 * @param hdr: Pointer to hold header
12325 * @param bufp: Pointer to hold pointer to rx param buffer
12326 *
12327 * Return: QDF_STATUS_SUCCESS for success or error code
12328 */
12329static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053012330 void *evt_buf, struct mgmt_rx_event_params *hdr,
12331 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053012332{
12333 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
12334 wmi_mgmt_rx_hdr *ev_hdr = NULL;
12335
12336 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
12337 if (!param_tlvs) {
12338 WMI_LOGE("Get NULL point message from FW");
12339 return QDF_STATUS_E_INVAL;
12340 }
12341
12342 ev_hdr = param_tlvs->hdr;
12343 if (!hdr) {
12344 WMI_LOGE("Rx event is NULL");
12345 return QDF_STATUS_E_INVAL;
12346 }
12347
12348
12349 hdr->channel = ev_hdr->channel;
12350 hdr->snr = ev_hdr->snr;
12351 hdr->rate = ev_hdr->rate;
12352 hdr->phy_mode = ev_hdr->phy_mode;
12353 hdr->buf_len = ev_hdr->buf_len;
12354 hdr->status = ev_hdr->status;
12355 hdr->flags = ev_hdr->flags;
12356 hdr->rssi = ev_hdr->rssi;
12357 hdr->tsf_delta = ev_hdr->tsf_delta;
12358 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
12359
12360 *bufp = param_tlvs->bufp;
12361
12362 return QDF_STATUS_SUCCESS;
12363}
12364
12365/**
12366 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
12367 * @wmi_handle: wmi handle
12368 * @param evt_buf: pointer to event buffer
12369 * @param vdev_id: Pointer to hold vdev identifier
12370 *
12371 * Return: QDF_STATUS_SUCCESS for success or error code
12372 */
12373static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
12374 void *evt_buf, uint32_t *vdev_id)
12375{
12376 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
12377 wmi_vdev_stopped_event_fixed_param *resp_event;
12378
12379 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
12380 if (!param_buf) {
12381 WMI_LOGE("Invalid event buffer");
12382 return QDF_STATUS_E_INVAL;
12383 }
12384 resp_event = param_buf->fixed_param;
12385 *vdev_id = resp_event->vdev_id;
12386
12387 return QDF_STATUS_SUCCESS;
12388}
12389
12390/**
12391 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
12392 * @wmi_handle: wmi handle
12393 * @param evt_buf: pointer to event buffer
12394 * @param param: Pointer to hold roam param
12395 *
12396 * Return: QDF_STATUS_SUCCESS for success or error code
12397 */
12398static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
12399 void *evt_buf, wmi_host_roam_event *param)
12400{
12401 WMI_ROAM_EVENTID_param_tlvs *param_buf;
12402 wmi_roam_event_fixed_param *evt;
12403
12404 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
12405 if (!param_buf) {
12406 WMI_LOGE("Invalid roam event buffer");
12407 return QDF_STATUS_E_INVAL;
12408 }
12409
12410 evt = param_buf->fixed_param;
12411 qdf_mem_zero(param, sizeof(*param));
12412
12413 param->vdev_id = evt->vdev_id;
12414 param->reason = evt->reason;
12415 param->rssi = evt->rssi;
12416
12417 return QDF_STATUS_SUCCESS;
12418}
12419
12420/**
12421 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
12422 * @wmi_handle: wmi handle
12423 * @param evt_buf: pointer to event buffer
12424 * @param param: Pointer to hold vdev scan param
12425 *
12426 * Return: QDF_STATUS_SUCCESS for success or error code
12427 */
12428static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
12429 void *evt_buf, wmi_host_scan_event *param)
12430{
12431 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
12432 wmi_scan_event_fixed_param *evt = NULL;
12433
12434 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
12435 evt = param_buf->fixed_param;
12436
12437 qdf_mem_zero(param, sizeof(*param));
12438 switch (evt->event) {
12439 case WMI_SCAN_EVENT_STARTED:
12440 param->event = WMI_HOST_SCAN_EVENT_STARTED;
12441 break;
12442 case WMI_SCAN_EVENT_COMPLETED:
12443 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
12444 break;
12445 case WMI_SCAN_EVENT_BSS_CHANNEL:
12446 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
12447 break;
12448 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
12449 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
12450 break;
12451 case WMI_SCAN_EVENT_DEQUEUED:
12452 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
12453 break;
12454 case WMI_SCAN_EVENT_PREEMPTED:
12455 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
12456 break;
12457 case WMI_SCAN_EVENT_START_FAILED:
12458 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
12459 break;
12460 case WMI_SCAN_EVENT_RESTARTED:
12461 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
12462 break;
12463 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
12464 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
12465 break;
12466 case WMI_SCAN_EVENT_MAX:
12467 default:
12468 param->event = WMI_HOST_SCAN_EVENT_MAX;
12469 break;
12470 };
12471
12472 switch (evt->reason) {
12473 case WMI_SCAN_REASON_NONE:
12474 param->reason = WMI_HOST_SCAN_REASON_NONE;
12475 break;
12476 case WMI_SCAN_REASON_COMPLETED:
12477 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
12478 break;
12479 case WMI_SCAN_REASON_CANCELLED:
12480 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
12481 break;
12482 case WMI_SCAN_REASON_PREEMPTED:
12483 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
12484 break;
12485 case WMI_SCAN_REASON_TIMEDOUT:
12486 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
12487 break;
12488 case WMI_SCAN_REASON_INTERNAL_FAILURE:
12489 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
12490 break;
12491 case WMI_SCAN_REASON_MAX:
12492 default:
12493 param->reason = WMI_HOST_SCAN_REASON_MAX;
12494 break;
12495 };
12496
12497 param->channel_freq = evt->channel_freq;
12498 param->requestor = evt->requestor;
12499 param->scan_id = evt->scan_id;
12500 param->vdev_id = evt->vdev_id;
12501
12502 return QDF_STATUS_SUCCESS;
12503}
12504
12505/**
12506 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
12507 * @wmi_handle: wmi handle
12508 * @param evt_buf: pointer to event buffer
12509 * @param param: Pointer to hold MGMT TX completion params
12510 *
12511 * Return: QDF_STATUS_SUCCESS for success or error code
12512 */
12513static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
12514 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
12515{
12516 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
12517 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
12518
12519 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
12520 evt_buf;
12521 if (!param_buf) {
12522 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
12523 return QDF_STATUS_E_INVAL;
12524 }
12525 cmpl_params = param_buf->fixed_param;
12526
12527 param->desc_id = cmpl_params->desc_id;
12528 param->status = cmpl_params->status;
12529
12530 return QDF_STATUS_SUCCESS;
12531}
12532
12533/**
12534 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
12535 * @wmi_handle: wmi handle
12536 * @param evt_buf: pointer to event buffer
12537 * @param vdev_map: Pointer to hold vdev map
12538 *
12539 * Return: QDF_STATUS_SUCCESS for success or error code
12540 */
12541static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
12542 void *evt_buf, uint32_t *vdev_map)
12543{
12544 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12545 wmi_host_swba_event_fixed_param *swba_event;
12546
12547 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12548 if (!param_buf) {
12549 WMI_LOGE("Invalid swba event buffer");
12550 return QDF_STATUS_E_INVAL;
12551 }
12552 swba_event = param_buf->fixed_param;
12553 *vdev_map = swba_event->vdev_map;
12554
12555 return QDF_STATUS_SUCCESS;
12556}
12557
12558/**
12559 * extract_swba_tim_info_tlv() - extract swba tim info from event
12560 * @wmi_handle: wmi handle
12561 * @param evt_buf: pointer to event buffer
12562 * @param idx: Index to bcn info
12563 * @param tim_info: Pointer to hold tim info
12564 *
12565 * Return: QDF_STATUS_SUCCESS for success or error code
12566 */
12567static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
12568 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
12569{
12570 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12571 wmi_tim_info *tim_info_ev;
12572
12573 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12574 if (!param_buf) {
12575 WMI_LOGE("Invalid swba event buffer");
12576 return QDF_STATUS_E_INVAL;
12577 }
12578
12579 tim_info_ev = &param_buf->tim_info[idx];
12580
12581 tim_info->tim_len = tim_info_ev->tim_len;
12582 tim_info->tim_mcast = tim_info_ev->tim_mcast;
12583 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
12584 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
12585 tim_info->tim_changed = tim_info_ev->tim_changed;
12586 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
12587
12588 return QDF_STATUS_SUCCESS;
12589}
12590
12591/**
12592 * extract_swba_noa_info_tlv() - extract swba NoA information from event
12593 * @wmi_handle: wmi handle
12594 * @param evt_buf: pointer to event buffer
12595 * @param idx: Index to bcn info
12596 * @param p2p_desc: Pointer to hold p2p NoA info
12597 *
12598 * Return: QDF_STATUS_SUCCESS for success or error code
12599 */
12600static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
12601 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
12602{
12603 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
12604 wmi_p2p_noa_info *p2p_noa_info;
12605 uint8_t i = 0;
12606
12607 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
12608 if (!param_buf) {
12609 WMI_LOGE("Invalid swba event buffer");
12610 return QDF_STATUS_E_INVAL;
12611 }
12612
12613 p2p_noa_info = &param_buf->p2p_noa_info[idx];
12614
12615 p2p_desc->modified = false;
12616 p2p_desc->num_descriptors = 0;
12617 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
12618 p2p_desc->modified = true;
12619 p2p_desc->index =
12620 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
12621 p2p_desc->oppPS =
12622 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
12623 p2p_desc->ctwindow =
12624 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
12625 p2p_desc->num_descriptors =
12626 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
12627 (p2p_noa_info);
12628 for (i = 0; i < p2p_desc->num_descriptors; i++) {
12629 p2p_desc->noa_descriptors[i].type_count =
12630 (uint8_t) p2p_noa_info->noa_descriptors[i].
12631 type_count;
12632 p2p_desc->noa_descriptors[i].duration =
12633 p2p_noa_info->noa_descriptors[i].duration;
12634 p2p_desc->noa_descriptors[i].interval =
12635 p2p_noa_info->noa_descriptors[i].interval;
12636 p2p_desc->noa_descriptors[i].start_time =
12637 p2p_noa_info->noa_descriptors[i].start_time;
12638 }
12639 }
12640
12641 return QDF_STATUS_SUCCESS;
12642}
12643
12644/**
12645 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
12646 * @wmi_handle: wmi handle
12647 * @param evt_buf: pointer to event buffer
12648 * @param ev: Pointer to hold peer param
12649 *
12650 * Return: QDF_STATUS_SUCCESS for success or error code
12651 */
12652static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
12653 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
12654{
12655 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
12656 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
12657
12658 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
12659 kickout_event = param_buf->fixed_param;
12660
12661 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
12662 ev->peer_macaddr);
12663
12664 ev->reason = kickout_event->reason;
12665 ev->rssi = kickout_event->rssi;
12666
12667 return QDF_STATUS_SUCCESS;
12668}
12669
12670/**
12671 * extract_all_stats_counts_tlv() - extract all stats count from event
12672 * @wmi_handle: wmi handle
12673 * @param evt_buf: pointer to event buffer
12674 * @param stats_param: Pointer to hold stats count
12675 *
12676 * Return: QDF_STATUS_SUCCESS for success or error code
12677 */
12678static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
12679 void *evt_buf, wmi_host_stats_event *stats_param)
12680{
12681 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12682 wmi_stats_event_fixed_param *ev;
12683
12684 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12685
12686 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12687 if (!ev) {
12688 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
12689 return QDF_STATUS_E_FAILURE;
12690 }
12691
12692 switch (ev->stats_id) {
12693 case WMI_REQUEST_PEER_STAT:
12694 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
12695 break;
12696
12697 case WMI_REQUEST_AP_STAT:
12698 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
12699 break;
12700
12701 case WMI_REQUEST_PDEV_STAT:
12702 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
12703 break;
12704
12705 case WMI_REQUEST_VDEV_STAT:
12706 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
12707 break;
12708
12709 case WMI_REQUEST_BCNFLT_STAT:
12710 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
12711 break;
12712
12713 case WMI_REQUEST_VDEV_RATE_STAT:
12714 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
12715 break;
12716
12717 default:
12718 stats_param->stats_id = 0;
12719 break;
12720
12721 }
12722
12723 stats_param->num_pdev_stats = ev->num_pdev_stats;
12724 stats_param->num_pdev_ext_stats = 0;
12725 stats_param->num_vdev_stats = ev->num_vdev_stats;
12726 stats_param->num_peer_stats = ev->num_peer_stats;
12727 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
12728 stats_param->num_chan_stats = ev->num_chan_stats;
12729
12730 return QDF_STATUS_SUCCESS;
12731}
12732
12733/**
12734 * extract_pdev_stats_tlv() - extract pdev stats from event
12735 * @wmi_handle: wmi handle
12736 * @param evt_buf: pointer to event buffer
12737 * @param index: Index into pdev stats
12738 * @param pdev_stats: Pointer to hold pdev stats
12739 *
12740 * Return: QDF_STATUS_SUCCESS for success or error code
12741 */
12742static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
12743 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
12744{
12745 return QDF_STATUS_SUCCESS;
12746}
12747
12748/**
12749 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
12750 * @wmi_handle: wmi handle
12751 * @param evt_buf: pointer to event buffer
12752 * @param index: Index into extended pdev stats
12753 * @param pdev_ext_stats: Pointer to hold extended pdev stats
12754 *
12755 * Return: QDF_STATUS_SUCCESS for success or error code
12756 */
12757static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
12758 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
12759{
12760 return QDF_STATUS_SUCCESS;
12761}
12762
12763/**
12764 * extract_vdev_stats_tlv() - extract vdev stats from event
12765 * @wmi_handle: wmi handle
12766 * @param evt_buf: pointer to event buffer
12767 * @param index: Index into vdev stats
12768 * @param vdev_stats: Pointer to hold vdev stats
12769 *
12770 * Return: QDF_STATUS_SUCCESS for success or error code
12771 */
12772static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
12773 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
12774{
12775 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12776 wmi_stats_event_fixed_param *ev_param;
12777 uint8_t *data;
12778
12779 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12780 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12781 data = (uint8_t *) param_buf->data;
12782
12783 if (index < ev_param->num_vdev_stats) {
12784 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
12785 ((ev_param->num_pdev_stats) *
12786 sizeof(wmi_pdev_stats)) +
12787 (index * sizeof(wmi_vdev_stats)));
12788
12789 vdev_stats->vdev_id = ev->vdev_id;
12790 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
12791 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
12792
12793 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
12794 sizeof(ev->tx_frm_cnt));
12795 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
12796 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
12797 ev->multiple_retry_cnt,
12798 sizeof(ev->multiple_retry_cnt));
12799 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
12800 sizeof(ev->fail_cnt));
12801 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
12802 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
12803 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
12804 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
12805 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
12806 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
12807 sizeof(ev->tx_rate_history));
12808 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
12809 sizeof(ev->bcn_rssi_history));
12810
12811 }
12812
12813 return QDF_STATUS_SUCCESS;
12814}
12815
12816/**
12817 * extract_peer_stats_tlv() - extract peer stats from event
12818 * @wmi_handle: wmi handle
12819 * @param evt_buf: pointer to event buffer
12820 * @param index: Index into peer stats
12821 * @param peer_stats: Pointer to hold peer stats
12822 *
12823 * Return: QDF_STATUS_SUCCESS for success or error code
12824 */
12825static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
12826 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
12827{
12828 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12829 wmi_stats_event_fixed_param *ev_param;
12830 uint8_t *data;
12831
12832 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12833 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12834 data = (uint8_t *) param_buf->data;
12835
12836 if (index < ev_param->num_peer_stats) {
12837 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
12838 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12839 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12840 (index * sizeof(wmi_peer_stats)));
12841
12842 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
12843
12844 OS_MEMCPY(&(peer_stats->peer_macaddr),
12845 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
12846
12847 peer_stats->peer_rssi = ev->peer_rssi;
12848 peer_stats->peer_tx_rate = ev->peer_tx_rate;
12849 peer_stats->peer_rx_rate = ev->peer_rx_rate;
12850 }
12851
12852 return QDF_STATUS_SUCCESS;
12853}
12854
12855/**
12856 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
12857 * @wmi_handle: wmi handle
12858 * @param evt_buf: pointer to event buffer
12859 * @param index: Index into bcn fault stats
12860 * @param bcnflt_stats: Pointer to hold bcn fault stats
12861 *
12862 * Return: QDF_STATUS_SUCCESS for success or error code
12863 */
12864static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
12865 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
12866{
12867 return QDF_STATUS_SUCCESS;
12868}
12869
12870/**
12871 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
12872 * @wmi_handle: wmi handle
12873 * @param evt_buf: pointer to event buffer
12874 * @param index: Index into extended peer stats
12875 * @param peer_extd_stats: Pointer to hold extended peer stats
12876 *
12877 * Return: QDF_STATUS_SUCCESS for success or error code
12878 */
12879static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
12880 void *evt_buf, uint32_t index,
12881 wmi_host_peer_extd_stats *peer_extd_stats)
12882{
12883 return QDF_STATUS_SUCCESS;
12884}
12885
12886/**
12887 * extract_chan_stats_tlv() - extract chan stats from event
12888 * @wmi_handle: wmi handle
12889 * @param evt_buf: pointer to event buffer
12890 * @param index: Index into chan stats
12891 * @param vdev_extd_stats: Pointer to hold chan stats
12892 *
12893 * Return: QDF_STATUS_SUCCESS for success or error code
12894 */
12895static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
12896 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
12897{
12898 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
12899 wmi_stats_event_fixed_param *ev_param;
12900 uint8_t *data;
12901
12902 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
12903 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
12904 data = (uint8_t *) param_buf->data;
12905
12906 if (index < ev_param->num_chan_stats) {
12907 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
12908 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
12909 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
12910 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
12911 (index * sizeof(wmi_chan_stats)));
12912
12913
12914 /* Non-TLV doesnt have num_chan_stats */
12915 chan_stats->chan_mhz = ev->chan_mhz;
12916 chan_stats->sampling_period_us = ev->sampling_period_us;
12917 chan_stats->rx_clear_count = ev->rx_clear_count;
12918 chan_stats->tx_duration_us = ev->tx_duration_us;
12919 chan_stats->rx_duration_us = ev->rx_duration_us;
12920 }
12921
12922 return QDF_STATUS_SUCCESS;
12923}
12924
12925/**
12926 * extract_profile_ctx_tlv() - extract profile context from event
12927 * @wmi_handle: wmi handle
12928 * @param evt_buf: pointer to event buffer
12929 * @idx: profile stats index to extract
12930 * @param profile_ctx: Pointer to hold profile context
12931 *
12932 * Return: QDF_STATUS_SUCCESS for success or error code
12933 */
12934static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
12935 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
12936{
12937 return QDF_STATUS_SUCCESS;
12938}
12939
12940/**
12941 * extract_profile_data_tlv() - extract profile data from event
12942 * @wmi_handle: wmi handle
12943 * @param evt_buf: pointer to event buffer
12944 * @param profile_data: Pointer to hold profile data
12945 *
12946 * Return: QDF_STATUS_SUCCESS for success or error code
12947 */
12948static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
12949 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
12950{
12951
12952 return QDF_STATUS_SUCCESS;
12953}
12954
12955/**
12956 * extract_chan_info_event_tlv() - extract chan information from event
12957 * @wmi_handle: wmi handle
12958 * @param evt_buf: pointer to event buffer
12959 * @param chan_info: Pointer to hold chan information
12960 *
12961 * Return: QDF_STATUS_SUCCESS for success or error code
12962 */
12963static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
12964 void *evt_buf, wmi_host_chan_info_event *chan_info)
12965{
12966 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
12967 wmi_chan_info_event_fixed_param *ev;
12968
12969 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
12970
12971 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
12972 if (!ev) {
12973 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
12974 return QDF_STATUS_E_FAILURE;
12975 }
12976
12977 chan_info->err_code = ev->err_code;
12978 chan_info->freq = ev->freq;
12979 chan_info->cmd_flags = ev->cmd_flags;
12980 chan_info->noise_floor = ev->noise_floor;
12981 chan_info->rx_clear_count = ev->rx_clear_count;
12982 chan_info->cycle_count = ev->cycle_count;
12983
12984 return QDF_STATUS_SUCCESS;
12985}
12986
12987/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053012988 * extract_pdev_utf_event_tlv() - extract UTF data info from event
12989 * @wmi_handle: WMI handle
12990 * @param evt_buf: Pointer to event buffer
12991 * @param param: Pointer to hold data
12992 *
12993 * Return : QDF_STATUS_SUCCESS for success or error code
12994 */
12995static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
12996 uint8_t *evt_buf,
12997 struct wmi_host_pdev_utf_event *event)
12998{
12999 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
13000
13001 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
13002 event->data = param_buf->data;
13003 event->datalen = param_buf->num_data;
13004
13005 return QDF_STATUS_SUCCESS;
13006}
13007/**
Govind Singhe7f2f342016-05-23 12:12:52 +053013008 * extract_channel_hopping_event_tlv() - extract channel hopping param
13009 * from event
13010 * @wmi_handle: wmi handle
13011 * @param evt_buf: pointer to event buffer
13012 * @param ch_hopping: Pointer to hold channel hopping param
13013 *
13014 * Return: QDF_STATUS_SUCCESS for success or error code
13015 */
13016static QDF_STATUS extract_channel_hopping_event_tlv(wmi_unified_t wmi_handle,
13017 void *evt_buf, wmi_host_pdev_channel_hopping_event *chan_info)
13018{
13019 return QDF_STATUS_SUCCESS;
13020}
13021
Kiran Venkatappa06520822016-08-10 23:55:40 +053013022/**
13023 * extract_service_ready_ext_tlv() - extract basic extended service ready params
13024 * from event
13025 * @wmi_handle: wmi handle
13026 * @param evt_buf: pointer to event buffer
13027 * @param param: Pointer to hold evt buf
13028 *
13029 * Return: QDF_STATUS_SUCCESS for success or error code
13030 */
13031static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
13032 uint8_t *event, struct wmi_host_service_ext_param *param)
13033{
13034 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
13035 wmi_service_ready_ext_event_fixed_param *ev;
13036 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
13037 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
13038
13039 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
13040 if (!param_buf)
13041 return -EINVAL;
13042
13043 ev = param_buf->fixed_param;
13044 if (!ev)
13045 return -EINVAL;
13046
13047 /* Move this to host based bitmap */
13048 param->default_conc_scan_config_bits =
13049 ev->default_conc_scan_config_bits;
13050 param->default_fw_config_bits = ev->default_fw_config_bits;
13051 param->he_cap_info = ev->he_cap_info;
13052 param->mpdu_density = ev->mpdu_density;
13053 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
13054 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
13055
13056 hw_caps = param_buf->soc_hw_mode_caps;
13057 param->num_hw_modes = hw_caps->num_hw_modes;
13058
13059 reg_caps = param_buf->soc_hal_reg_caps;
13060 param->num_phy = reg_caps->num_phy;
13061
13062 return QDF_STATUS_SUCCESS;
13063}
13064
13065/**
13066 * extract_hw_mode_cap_service_ready_ext_tlv() -
13067 * extract HW mode cap from service ready event
13068 * @wmi_handle: wmi handle
13069 * @param evt_buf: pointer to event buffer
13070 * @param param: Pointer to hold evt buf
13071 * @param hw_mode_idx: hw mode idx should be less than num_mode
13072 *
13073 * Return: QDF_STATUS_SUCCESS for success or error code
13074 */
13075static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
13076 wmi_unified_t wmi_handle,
13077 uint8_t *event, uint8_t hw_mode_idx,
13078 struct wmi_host_hw_mode_caps *param)
13079{
13080 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
13081 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
13082
13083 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
13084 if (!param_buf)
13085 return -EINVAL;
13086
13087 hw_caps = param_buf->soc_hw_mode_caps;
13088 if (hw_mode_idx >= hw_caps->num_hw_modes)
13089 return -EINVAL;
13090
13091 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
13092 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
13093
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053013094 param->hw_mode_config_type =
13095 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
13096
Kiran Venkatappa06520822016-08-10 23:55:40 +053013097 return QDF_STATUS_SUCCESS;
13098}
13099
13100/**
13101 * extract_mac_phy_cap_service_ready_ext_tlv() -
13102 * extract MAC phy cap from service ready event
13103 * @wmi_handle: wmi handle
13104 * @param evt_buf: pointer to event buffer
13105 * @param param: Pointer to hold evt buf
13106 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053013107 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053013108 *
13109 * Return: QDF_STATUS_SUCCESS for success or error code
13110 */
13111static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
13112 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053013113 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Kiran Venkatappa06520822016-08-10 23:55:40 +053013114 struct wmi_host_mac_phy_caps *param)
13115{
13116 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053013117 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053013118 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
13119 uint32_t phy_map;
13120 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053013121
13122 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
13123 if (!param_buf)
13124 return -EINVAL;
13125
13126 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053013127 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
13128 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
13129 break;
13130
13131 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
13132 while (phy_map) {
13133 phy_map >>= 1;
13134 phy_idx++;
13135 }
13136 }
13137
13138 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa06520822016-08-10 23:55:40 +053013139 return -EINVAL;
13140
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053013141 phy_idx += phy_id;
13142 if (phy_idx >= param_buf->num_mac_phy_caps)
13143 return -EINVAL;
13144
13145 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053013146
13147 param->hw_mode_id = mac_phy_caps->hw_mode_id;
13148 param->pdev_id = mac_phy_caps->pdev_id;
13149 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053013150 param->supports_11b =
13151 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
13152 param->supports_11g =
13153 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
13154 param->supports_11a =
13155 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
13156 param->supports_11n =
13157 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
13158 param->supports_11ac =
13159 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
13160 param->supports_11ax =
13161 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053013162
13163 param->supported_bands = mac_phy_caps->supported_bands;
13164 param->ampdu_density = mac_phy_caps->ampdu_density;
13165 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
13166 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
13167 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
13168 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
13169 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
13170 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
13171 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
13172 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
13173 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
13174 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
13175 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
13176 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
13177 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
13178 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
13179 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
13180 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
13181
13182 return QDF_STATUS_SUCCESS;
13183}
13184
13185/**
13186 * extract_reg_cap_service_ready_ext_tlv() -
13187 * extract REG cap from service ready event
13188 * @wmi_handle: wmi handle
13189 * @param evt_buf: pointer to event buffer
13190 * @param param: Pointer to hold evt buf
13191 * @param phy_idx: phy idx should be less than num_mode
13192 *
13193 * Return: QDF_STATUS_SUCCESS for success or error code
13194 */
13195static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
13196 wmi_unified_t wmi_handle,
13197 uint8_t *event, uint8_t phy_idx,
13198 struct WMI_HOST_HAL_REG_CAPABILITIES_EXT *param)
13199{
13200 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
13201 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
13202 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
13203
13204 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
13205 if (!param_buf)
13206 return -EINVAL;
13207
13208 reg_caps = param_buf->soc_hal_reg_caps;
13209 if (phy_idx >= reg_caps->num_phy)
13210 return -EINVAL;
13211
13212 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
13213
13214 param->phy_id = ext_reg_cap->phy_id;
13215 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
13216 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
13217 param->regcap1 = ext_reg_cap->regcap1;
13218 param->regcap2 = ext_reg_cap->regcap2;
13219 param->wireless_modes = ext_reg_cap->wireless_modes;
13220 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
13221 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
13222 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
13223 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
13224
13225 return QDF_STATUS_SUCCESS;
13226}
13227
Kiran Venkatappafea8a802016-12-29 18:09:32 +053013228/**
13229 * extract_dcs_interference_type_tlv() - extract dcs interference type
13230 * from event
13231 * @wmi_handle: wmi handle
13232 * @param evt_buf: pointer to event buffer
13233 * @param param: Pointer to hold dcs interference param
13234 *
13235 * Return: 0 for success or error code
13236 */
13237static QDF_STATUS extract_dcs_interference_type_tlv(
13238 wmi_unified_t wmi_handle,
13239 void *evt_buf, struct wmi_host_dcs_interference_param *param)
13240{
13241 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
13242
13243 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
13244 if (!param_buf)
13245 return -EINVAL;
13246
13247 param->interference_type = param_buf->fixed_param->interference_type;
13248 param->pdev_id = param_buf->fixed_param->pdev_id;
13249
13250 return QDF_STATUS_SUCCESS;
13251}
13252
13253/*
13254 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
13255 * @wmi_handle: wmi handle
13256 * @param evt_buf: pointer to event buffer
13257 * @param cw_int: Pointer to hold cw interference
13258 *
13259 * Return: 0 for success or error code
13260 */
13261static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
13262 void *evt_buf,
13263 wmi_host_ath_dcs_cw_int *cw_int)
13264{
13265 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
13266 wlan_dcs_cw_int *ev;
13267
13268 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
13269 if (!param_buf)
13270 return -EINVAL;
13271
13272 ev = param_buf->cw_int;
13273
13274 cw_int->channel = ev->channel;
13275
13276 return QDF_STATUS_SUCCESS;
13277}
13278
13279/**
13280 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
13281 * @wmi_handle: wmi handle
13282 * @param evt_buf: pointer to event buffer
13283 * @param wlan_stat: Pointer to hold wlan stats
13284 *
13285 * Return: 0 for success or error code
13286 */
13287static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
13288 void *evt_buf,
13289 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
13290{
13291 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
13292 wlan_dcs_im_tgt_stats_t *ev;
13293
13294 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
13295 if (!param_buf)
13296 return -EINVAL;
13297
13298 ev = param_buf->wlan_stat;
13299 wlan_stat->reg_tsf32 = ev->reg_tsf32;
13300 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
13301 wlan_stat->tx_waste_time = ev->tx_waste_time;
13302 wlan_stat->rx_time = ev->rx_time;
13303 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
13304 wlan_stat->mib_stats.listen_time = ev->listen_time;
13305 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
13306 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
13307 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
13308 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
13309 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
13310 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
13311 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
13312 wlan_stat->chan_nf = ev->chan_nf;
13313 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
13314
13315 return QDF_STATUS_SUCCESS;
13316}
13317
Kiran Venkatappac813ec92016-12-29 22:07:14 +053013318#ifdef BIG_ENDIAN_HOST
13319/**
13320 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
13321 * @param data_len - data length
13322 * @param data - pointer to data
13323 *
13324 * Return: QDF_STATUS - success or error status
13325 */
13326static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
13327{
13328 uint8_t *data_aligned = NULL;
13329 int c;
13330 unsigned char *data_unaligned;
13331
13332 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
13333 FIPS_ALIGN));
13334 /* Assigning unaligned space to copy the data */
13335 /* Checking if kmalloc does succesful allocation */
13336 if (data_unaligned == NULL)
13337 return QDF_STATUS_E_FAILURE;
13338
13339 /* Checking if space is alligned */
13340 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13341 /* align the data space */
13342 data_aligned =
13343 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
13344 } else {
13345 data_aligned = (u_int8_t *)data_unaligned;
13346 }
13347
13348 /* memset and copy content from data to data aligned */
13349 OS_MEMSET(data_aligned, 0, data_len);
13350 OS_MEMCPY(data_aligned, data, data_len);
13351 /* Endianness to LE */
13352 for (c = 0; c < data_len/4; c++) {
13353 *((u_int32_t *)data_aligned + c) =
13354 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
13355 }
13356
13357 /* Copy content to event->data */
13358 OS_MEMCPY(data, data_aligned, data_len);
13359
13360 /* clean up allocated space */
13361 qdf_mem_free(data_unaligned);
13362 data_aligned = NULL;
13363 data_unaligned = NULL;
13364
13365 /*************************************************************/
13366
13367 return QDF_STATUS_SUCCESS;
13368}
13369#else
13370/**
13371 * fips_conv_data_be() - DUMMY for LE platform
13372 *
13373 * Return: QDF_STATUS - success
13374 */
13375static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
13376{
13377 return QDF_STATUS_SUCCESS;
13378}
13379#endif
13380
13381/**
13382 * extract_fips_event_data_tlv() - extract fips event data
13383 * @wmi_handle: wmi handle
13384 * @param evt_buf: pointer to event buffer
13385 * @param param: pointer FIPS event params
13386 *
13387 * Return: 0 for success or error code
13388 */
13389static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
13390 void *evt_buf, struct wmi_host_fips_event_param *param)
13391{
13392 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
13393 wmi_pdev_fips_event_fixed_param *event;
13394
13395 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
13396 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
13397
13398 if (fips_conv_data_be(event->data_len, param_buf->data) !=
13399 QDF_STATUS_SUCCESS)
13400 return QDF_STATUS_E_FAILURE;
13401
13402 param->data = (uint32_t *)param_buf->data;
13403 param->data_len = event->data_len;
13404 param->error_status = event->error_status;
13405
13406 return QDF_STATUS_SUCCESS;
13407}
13408
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053013409/*
13410 * extract_peer_delete_response_event_tlv() - extract peer delete response event
13411 * @wmi_handle: wmi handle
13412 * @param evt_buf: pointer to event buffer
13413 * @param vdev_id: Pointer to hold vdev_id
13414 * @param mac_addr: Pointer to hold peer mac address
13415 *
13416 * Return: QDF_STATUS_SUCCESS for success or error code
13417 */
13418static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
13419 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
13420{
13421 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
13422 wmi_peer_delete_resp_event_fixed_param *ev;
13423
13424 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
13425
13426 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
13427 if (!ev) {
13428 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
13429 return QDF_STATUS_E_FAILURE;
13430 }
13431
13432 param->vdev_id = ev->vdev_id;
13433 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
13434 &param->mac_address.bytes[0]);
13435
13436 return QDF_STATUS_SUCCESS;
13437}
13438
Govind Singh06c18392016-06-10 10:33:19 +053013439#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhecf03cd2016-05-12 12:45:51 +053013440static bool is_management_record_tlv(uint32_t cmd_id)
13441{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053013442 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053013443 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053013444
Govind Singhecf03cd2016-05-12 12:45:51 +053013445 return false;
13446}
Govind Singh06c18392016-06-10 10:33:19 +053013447#endif
Govind Singhecf03cd2016-05-12 12:45:51 +053013448
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053013449static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
13450{
13451 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
13452
13453 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
13454
13455 switch (set_cmd->param_id) {
13456 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
13457 case WMI_VDEV_PARAM_DTIM_POLICY:
13458 return HTC_TX_PACKET_TAG_AUTO_PM;
13459 default:
13460 break;
13461 }
13462
13463 return 0;
13464}
13465
13466static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
13467{
13468 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
13469
13470 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
13471
13472 switch (ps_cmd->param) {
13473 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
13474 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
13475 case WMI_STA_PS_ENABLE_QPOWER:
13476 return HTC_TX_PACKET_TAG_AUTO_PM;
13477 default:
13478 break;
13479 }
13480
13481 return 0;
13482}
13483
13484static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
13485 uint32_t cmd_id)
13486{
13487 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
13488 return 0;
13489
13490 switch (cmd_id) {
13491 case WMI_VDEV_SET_PARAM_CMDID:
13492 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
13493 case WMI_STA_POWERSAVE_PARAM_CMDID:
13494 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
13495 default:
13496 break;
13497 }
13498
13499 return 0;
13500}
13501
13502static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
13503{
13504 uint16_t tag = 0;
13505
13506 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
13507 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
13508 __func__);
13509 return tag;
13510 }
13511
13512 if (wmi_handle->tag_crash_inject)
13513 tag = HTC_TX_PACKET_TAG_AUTO_PM;
13514
13515 wmi_handle->tag_crash_inject = false;
13516 return tag;
13517}
13518
13519/**
13520 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
13521 * @wmi_handle: WMI handle
13522 * @buf: WMI buffer
13523 * @cmd_id: WMI command Id
13524 *
13525 * Return htc_tx_tag
13526 */
13527static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
13528 wmi_buf_t buf,
13529 uint32_t cmd_id)
13530{
13531 uint16_t htc_tx_tag = 0;
13532
13533 switch (cmd_id) {
13534 case WMI_WOW_ENABLE_CMDID:
13535 case WMI_PDEV_SUSPEND_CMDID:
13536 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
13537 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
13538 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
13539 case WMI_PDEV_RESUME_CMDID:
13540 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
13541 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
13542#ifdef FEATURE_WLAN_D0WOW
13543 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
13544#endif
13545 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
13546 break;
13547 case WMI_FORCE_FW_HANG_CMDID:
13548 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
13549 break;
13550 case WMI_VDEV_SET_PARAM_CMDID:
13551 case WMI_STA_POWERSAVE_PARAM_CMDID:
13552 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
13553 default:
13554 break;
13555 }
13556
13557 return htc_tx_tag;
13558}
13559
Govind Singh5eb51532016-03-09 11:34:12 +053013560struct wmi_ops tlv_ops = {
13561 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
13562 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
13563 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053013564 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
13565 .send_hidden_ssid_vdev_restart_cmd =
13566 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053013567 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
13568 .send_peer_param_cmd = send_peer_param_cmd_tlv,
13569 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053013570 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053013571 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053013572 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070013573 .send_peer_rx_reorder_queue_setup_cmd =
13574 send_peer_rx_reorder_queue_setup_cmd_tlv,
13575 .send_peer_rx_reorder_queue_remove_cmd =
13576 send_peer_rx_reorder_queue_remove_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053013577 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
13578 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
13579 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
13580 .send_suspend_cmd = send_suspend_cmd_tlv,
13581 .send_resume_cmd = send_resume_cmd_tlv,
13582 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
13583 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
13584 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
13585 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
13586 .send_dbglog_cmd = send_dbglog_cmd_tlv,
13587 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
13588 .send_stats_request_cmd = send_stats_request_cmd_tlv,
13589 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
13590 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013591#ifndef CONFIG_MCL
13592 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
13593#endif
Govind Singh5eb51532016-03-09 11:34:12 +053013594 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
13595 .send_scan_start_cmd = send_scan_start_cmd_tlv,
13596 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
13597 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053013598 .send_mgmt_cmd = send_mgmt_cmd_tlv,
13599 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
13600 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013601 .send_set_sta_uapsd_auto_trig_cmd =
13602 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053013603 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
13604 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
13605 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
13606 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
13607 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053013608 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
13609 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
13610 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
13611 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
13612 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
13613 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
13614 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013615 .send_ocb_start_timing_advert_cmd =
13616 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053013617 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
13618 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
13619 .send_set_mcc_channel_time_latency_cmd =
13620 send_set_mcc_channel_time_latency_cmd_tlv,
13621 .send_set_mcc_channel_time_quota_cmd =
13622 send_set_mcc_channel_time_quota_cmd_tlv,
13623 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
13624 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053013625 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013626 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
13627 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
13628 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013629 .send_probe_rsp_tmpl_send_cmd =
13630 send_probe_rsp_tmpl_send_cmd_tlv,
13631 .send_p2p_go_set_beacon_ie_cmd =
13632 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053013633 .send_setup_install_key_cmd =
13634 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013635 .send_set_gateway_params_cmd =
13636 send_set_gateway_params_cmd_tlv,
13637 .send_set_rssi_monitoring_cmd =
13638 send_set_rssi_monitoring_cmd_tlv,
13639 .send_scan_probe_setoui_cmd =
13640 send_scan_probe_setoui_cmd_tlv,
13641 .send_reset_passpoint_network_list_cmd =
13642 send_reset_passpoint_network_list_cmd_tlv,
13643 .send_set_passpoint_network_list_cmd =
13644 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053013645 .send_roam_scan_offload_rssi_thresh_cmd =
13646 send_roam_scan_offload_rssi_thresh_cmd_tlv,
13647 .send_roam_scan_filter_cmd =
13648 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053013649 .send_set_epno_network_list_cmd =
13650 send_set_epno_network_list_cmd_tlv,
13651 .send_ipa_offload_control_cmd =
13652 send_ipa_offload_control_cmd_tlv,
13653 .send_extscan_get_capabilities_cmd =
13654 send_extscan_get_capabilities_cmd_tlv,
13655 .send_extscan_get_cached_results_cmd =
13656 send_extscan_get_cached_results_cmd_tlv,
13657 .send_extscan_stop_change_monitor_cmd =
13658 send_extscan_stop_change_monitor_cmd_tlv,
13659 .send_extscan_start_change_monitor_cmd =
13660 send_extscan_start_change_monitor_cmd_tlv,
13661 .send_extscan_stop_hotlist_monitor_cmd =
13662 send_extscan_stop_hotlist_monitor_cmd_tlv,
13663 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
13664 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
13665 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
13666 .send_plm_start_cmd = send_plm_start_cmd_tlv,
13667 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013668#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053013669 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013670#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053013671 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
13672 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
13673 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
13674 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
13675 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053013676 .send_snr_request_cmd = send_snr_request_cmd_tlv,
13677 .send_snr_cmd = send_snr_cmd_tlv,
13678 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013679#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053013680 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
13681 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
13682 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
13683 .send_lphb_config_udp_pkt_filter_cmd =
13684 send_lphb_config_udp_pkt_filter_cmd_tlv,
13685 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
13686 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
13687 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Paul Zhangd19abd82017-01-04 16:45:42 +080013688 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013689 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
13690 .send_process_update_edca_param_cmd =
13691 send_process_update_edca_param_cmd_tlv,
13692 .send_roam_scan_offload_mode_cmd =
13693 send_roam_scan_offload_mode_cmd_tlv,
13694 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
13695 .send_roam_scan_offload_ap_profile_cmd =
13696 send_roam_scan_offload_ap_profile_cmd_tlv,
13697#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053013698 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
13699 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013700#ifdef FEATURE_WLAN_RA_FILTERING
Govind Singh20c5dac2016-03-07 15:33:31 +053013701 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053013702#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053013703 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
13704 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
13705 .send_dfs_phyerr_filter_offload_en_cmd =
13706 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053013707 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
13708 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
13709 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
13710 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
13711 .send_del_ts_cmd = send_del_ts_cmd_tlv,
13712 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
13713 .send_add_ts_cmd = send_add_ts_cmd_tlv,
13714 .send_enable_disable_packet_filter_cmd =
13715 send_enable_disable_packet_filter_cmd_tlv,
13716 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
13717 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
13718 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
13719 .send_process_gtk_offload_getinfo_cmd =
13720 send_process_gtk_offload_getinfo_cmd_tlv,
13721 .send_process_add_periodic_tx_ptrn_cmd =
13722 send_process_add_periodic_tx_ptrn_cmd_tlv,
13723 .send_process_del_periodic_tx_ptrn_cmd =
13724 send_process_del_periodic_tx_ptrn_cmd_tlv,
13725 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
13726 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
13727 .send_set_app_type2_params_in_fw_cmd =
13728 send_set_app_type2_params_in_fw_cmd_tlv,
13729 .send_set_auto_shutdown_timer_cmd =
13730 send_set_auto_shutdown_timer_cmd_tlv,
13731 .send_nan_req_cmd = send_nan_req_cmd_tlv,
13732 .send_process_dhcpserver_offload_cmd =
13733 send_process_dhcpserver_offload_cmd_tlv,
13734 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
13735 .send_process_ch_avoid_update_cmd =
13736 send_process_ch_avoid_update_cmd_tlv,
13737 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
13738 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
13739 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
13740 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
13741 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
13742 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053013743#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053013744 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053013745#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053013746 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053013747 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053013748 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053013749 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053013750 .send_set_base_macaddr_indicate_cmd =
13751 send_set_base_macaddr_indicate_cmd_tlv,
13752 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
13753 .send_enable_specific_fw_logs_cmd =
13754 send_enable_specific_fw_logs_cmd_tlv,
13755 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013756 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013757 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013758 .send_pdev_set_dual_mac_config_cmd =
13759 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053013760 .send_enable_arp_ns_offload_cmd =
13761 send_enable_arp_ns_offload_cmd_tlv,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013762 .send_enable_broadcast_filter_cmd =
13763 send_enable_broadcast_filter_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053013764 .send_app_type1_params_in_fw_cmd =
13765 send_app_type1_params_in_fw_cmd_tlv,
13766 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
13767 .send_process_roam_synch_complete_cmd =
13768 send_process_roam_synch_complete_cmd_tlv,
13769 .send_unit_test_cmd = send_unit_test_cmd_tlv,
13770 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
13771 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053013772 .send_roam_scan_offload_scan_period_cmd =
13773 send_roam_scan_offload_scan_period_cmd_tlv,
13774 .send_roam_scan_offload_chan_list_cmd =
13775 send_roam_scan_offload_chan_list_cmd_tlv,
13776 .send_roam_scan_offload_rssi_change_cmd =
13777 send_roam_scan_offload_rssi_change_cmd_tlv,
13778 .send_get_buf_extscan_hotlist_cmd =
13779 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053013780 .send_adapt_dwelltime_params_cmd =
13781 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053013782 .init_cmd_send = init_cmd_send_tlv,
13783 .get_target_cap_from_service_ready = extract_service_ready_tlv,
13784 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
13785 .extract_host_mem_req = extract_host_mem_req_tlv,
13786 .save_service_bitmap = save_service_bitmap_tlv,
13787 .is_service_enabled = is_service_enabled_tlv,
13788 .save_fw_version = save_fw_version_in_service_ready_tlv,
13789 .ready_extract_init_status = ready_extract_init_status_tlv,
13790 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
13791 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
13792 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
13793 .extract_tbttoffset_update_params =
13794 extract_tbttoffset_update_params_tlv,
13795 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
13796 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
13797 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
13798 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
13799 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
13800 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
13801 .extract_swba_tim_info = extract_swba_tim_info_tlv,
13802 .extract_swba_noa_info = extract_swba_noa_info_tlv,
13803 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
13804 .extract_all_stats_count = extract_all_stats_counts_tlv,
13805 .extract_pdev_stats = extract_pdev_stats_tlv,
13806 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
13807 .extract_vdev_stats = extract_vdev_stats_tlv,
13808 .extract_peer_stats = extract_peer_stats_tlv,
13809 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
13810 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
13811 .extract_chan_stats = extract_chan_stats_tlv,
13812 .extract_profile_ctx = extract_profile_ctx_tlv,
13813 .extract_profile_data = extract_profile_data_tlv,
13814 .extract_chan_info_event = extract_chan_info_event_tlv,
13815 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053013816 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053013817 .send_encrypt_decrypt_send_cmd =
13818 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080013819 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053013820 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053013821 .extract_service_ready_ext = extract_service_ready_ext_tlv,
13822 .extract_hw_mode_cap_service_ready_ext =
13823 extract_hw_mode_cap_service_ready_ext_tlv,
13824 .extract_mac_phy_cap_service_ready_ext =
13825 extract_mac_phy_cap_service_ready_ext_tlv,
13826 .extract_reg_cap_service_ready_ext =
13827 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053013828 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053013829 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053013830 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
13831 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
13832 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053013833 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013834 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053013835 .extract_peer_delete_response_event =
13836 extract_peer_delete_response_event_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053013837};
13838
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053013839#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053013840/**
13841 * populate_tlv_service() - populates wmi services
13842 *
13843 * @param wmi_service: Pointer to hold wmi_service
13844 * Return: None
13845 */
13846static void populate_tlv_service(uint32_t *wmi_service)
13847{
13848 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
13849 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
13850 wmi_service[wmi_service_roam_scan_offload] =
13851 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
13852 wmi_service[wmi_service_bcn_miss_offload] =
13853 WMI_SERVICE_BCN_MISS_OFFLOAD;
13854 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
13855 wmi_service[wmi_service_sta_advanced_pwrsave] =
13856 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
13857 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
13858 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
13859 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
13860 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
13861 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
13862 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
13863 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
13864 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
13865 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
13866 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
13867 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
13868 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
13869 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
13870 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
13871 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
13872 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
13873 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
13874 wmi_service[wmi_service_packet_power_save] =
13875 WMI_SERVICE_PACKET_POWER_SAVE;
13876 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
13877 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
13878 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
13879 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
13880 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
13881 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
13882 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
13883 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
13884 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
13885 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
13886 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
13887 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
13888 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
13889 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
13890 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
13891 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
13892 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
13893 wmi_service[wmi_service_mcc_bcn_interval_change] =
13894 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
13895 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
13896 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
13897 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
13898 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
13899 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
13900 wmi_service[wmi_service_lte_ant_share_support] =
13901 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
13902 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
13903 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
13904 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
13905 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
13906 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
13907 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
13908 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
13909 wmi_service[wmi_service_bcn_txrate_override] =
13910 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
13911 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
13912 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
13913 wmi_service[wmi_service_estimate_linkspeed] =
13914 WMI_SERVICE_ESTIMATE_LINKSPEED;
13915 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
13916 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
13917 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
13918 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
13919 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
13920 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
13921 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
13922 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
13923 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
13924 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
13925 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
13926 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
13927 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
13928 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
13929 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
13930 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
13931 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
13932 wmi_service[wmi_service_sap_auth_offload] =
13933 WMI_SERVICE_SAP_AUTH_OFFLOAD;
13934 wmi_service[wmi_service_dual_band_simultaneous_support] =
13935 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
13936 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
13937 wmi_service[wmi_service_ap_arpns_offload] =
13938 WMI_SERVICE_AP_ARPNS_OFFLOAD;
13939 wmi_service[wmi_service_per_band_chainmask_support] =
13940 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
13941 wmi_service[wmi_service_packet_filter_offload] =
13942 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
13943 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
13944 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
13945 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
13946 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
13947
13948 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
13949 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
13950 wmi_service[wmi_service_smart_antenna_sw_support] =
13951 WMI_SERVICE_UNAVAILABLE;
13952 wmi_service[wmi_service_smart_antenna_hw_support] =
13953 WMI_SERVICE_UNAVAILABLE;
13954 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
13955 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
13956 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
13957 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
13958 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
13959 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
13960 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
13961 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
13962 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
13963 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
13964 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
13965
13966 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
13967 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
13968 wmi_service[wmi_service_periodic_chan_stat_support] =
13969 WMI_SERVICE_UNAVAILABLE;
13970 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
13971 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
13972 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
Sathish Kumar699f6b52016-11-10 15:30:22 +053013973 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
Sathish Kumar58a9fb92017-01-19 14:57:37 +053013974 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053013975}
13976
13977/**
13978 * populate_tlv_event_id() - populates wmi event ids
13979 *
13980 * @param event_ids: Pointer to hold event ids
13981 * Return: None
13982 */
13983static void populate_tlv_events_id(uint32_t *event_ids)
13984{
13985 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
13986 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
13987 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
13988 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
13989 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
13990 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
13991 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
13992 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
13993 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
13994 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
13995 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
13996 event_ids[wmi_service_ready_ext_event_id] =
13997 WMI_SERVICE_READY_EXT_EVENTID;
13998 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
13999 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
14000 event_ids[wmi_vdev_install_key_complete_event_id] =
14001 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
14002 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
14003 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
14004
14005 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
14006 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
14007 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
14008 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
14009 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
14010 event_ids[wmi_peer_estimated_linkspeed_event_id] =
14011 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
14012 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053014013 event_ids[wmi_peer_delete_response_event_id] =
14014 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053014015 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
14016 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
14017 event_ids[wmi_tbttoffset_update_event_id] =
14018 WMI_TBTTOFFSET_UPDATE_EVENTID;
14019 event_ids[wmi_offload_bcn_tx_status_event_id] =
14020 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
14021 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
14022 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
14023 event_ids[wmi_mgmt_tx_completion_event_id] =
14024 WMI_MGMT_TX_COMPLETION_EVENTID;
14025
14026 event_ids[wmi_tx_delba_complete_event_id] =
14027 WMI_TX_DELBA_COMPLETE_EVENTID;
14028 event_ids[wmi_tx_addba_complete_event_id] =
14029 WMI_TX_ADDBA_COMPLETE_EVENTID;
14030 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
14031
14032 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
14033
14034 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
14035 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
14036
14037 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
14038
14039 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
14040
14041 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
14042
14043 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
14044 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
14045 event_ids[wmi_do_wow_disable_ack_event_id] =
14046 WMI_D0_WOW_DISABLE_ACK_EVENTID;
14047 event_ids[wmi_wow_initial_wakeup_event_id] =
14048 WMI_WOW_INITIAL_WAKEUP_EVENTID;
14049
14050 event_ids[wmi_rtt_meas_report_event_id] =
14051 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
14052 event_ids[wmi_tsf_meas_report_event_id] =
14053 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
14054 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
14055 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
14056 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
14057 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
14058 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
14059 event_ids[wmi_update_fw_mem_dump_event_id] =
14060 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
14061 event_ids[wmi_diag_event_id_log_supported_event_id] =
14062 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
14063 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
14064 event_ids[wmi_nlo_scan_complete_event_id] =
14065 WMI_NLO_SCAN_COMPLETE_EVENTID;
14066 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
14067 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
14068
14069 event_ids[wmi_gtk_offload_status_event_id] =
14070 WMI_GTK_OFFLOAD_STATUS_EVENTID;
14071 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
14072 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
14073 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
14074
14075 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
14076
14077 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
14078
14079 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
14080 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
14081 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
14082 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
14083 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
14084 event_ids[wmi_wlan_profile_data_event_id] =
14085 WMI_WLAN_PROFILE_DATA_EVENTID;
14086 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
14087 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
14088 event_ids[wmi_vdev_get_keepalive_event_id] =
14089 WMI_VDEV_GET_KEEPALIVE_EVENTID;
14090 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
14091
14092 event_ids[wmi_diag_container_event_id] =
14093 WMI_DIAG_DATA_CONTAINER_EVENTID;
14094
14095 event_ids[wmi_host_auto_shutdown_event_id] =
14096 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
14097
14098 event_ids[wmi_update_whal_mib_stats_event_id] =
14099 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
14100
14101 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
14102 event_ids[wmi_update_vdev_rate_stats_event_id] =
14103 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
14104
14105 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
14106
14107 /** Set OCB Sched Response, deprecated */
14108 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
14109
14110 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
14111 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
14112 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
14113
14114 /* GPIO Event */
14115 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
14116 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
14117
14118 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
14119 event_ids[wmi_rfkill_state_change_event_id] =
14120 WMI_RFKILL_STATE_CHANGE_EVENTID;
14121
14122 /* TDLS Event */
14123 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
14124
14125 event_ids[wmi_batch_scan_enabled_event_id] =
14126 WMI_BATCH_SCAN_ENABLED_EVENTID;
14127 event_ids[wmi_batch_scan_result_event_id] =
14128 WMI_BATCH_SCAN_RESULT_EVENTID;
14129 /* OEM Event */
14130 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
14131 event_ids[wmi_oem_meas_report_event_id] =
14132 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
14133 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
14134
14135 /* NAN Event */
14136 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
14137
14138 /* LPI Event */
14139 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
14140 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
14141 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
14142
14143 /* ExtScan events */
14144 event_ids[wmi_extscan_start_stop_event_id] =
14145 WMI_EXTSCAN_START_STOP_EVENTID;
14146 event_ids[wmi_extscan_operation_event_id] =
14147 WMI_EXTSCAN_OPERATION_EVENTID;
14148 event_ids[wmi_extscan_table_usage_event_id] =
14149 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
14150 event_ids[wmi_extscan_cached_results_event_id] =
14151 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
14152 event_ids[wmi_extscan_wlan_change_results_event_id] =
14153 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
14154 event_ids[wmi_extscan_hotlist_match_event_id] =
14155 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
14156 event_ids[wmi_extscan_capabilities_event_id] =
14157 WMI_EXTSCAN_CAPABILITIES_EVENTID;
14158 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
14159 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
14160
14161 /* mDNS offload events */
14162 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
14163
14164 /* SAP Authentication offload events */
14165 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
14166 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
14167
14168 /** Out-of-context-of-bss (OCB) events */
14169 event_ids[wmi_ocb_set_config_resp_event_id] =
14170 WMI_OCB_SET_CONFIG_RESP_EVENTID;
14171 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
14172 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
14173 event_ids[wmi_dcc_get_stats_resp_event_id] =
14174 WMI_DCC_GET_STATS_RESP_EVENTID;
14175 event_ids[wmi_dcc_update_ndl_resp_event_id] =
14176 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
14177 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
14178 /* System-On-Chip events */
14179 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
14180 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
14181 event_ids[wmi_soc_hw_mode_transition_event_id] =
14182 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
14183 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
14184 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014185 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053014186}
14187
14188/**
14189 * populate_pdev_param_tlv() - populates pdev params
14190 *
14191 * @param pdev_param: Pointer to hold pdev params
14192 * Return: None
14193 */
14194static void populate_pdev_param_tlv(uint32_t *pdev_param)
14195{
14196 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
14197 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
14198 pdev_param[wmi_pdev_param_txpower_limit2g] =
14199 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
14200 pdev_param[wmi_pdev_param_txpower_limit5g] =
14201 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
14202 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
14203 pdev_param[wmi_pdev_param_beacon_gen_mode] =
14204 WMI_PDEV_PARAM_BEACON_GEN_MODE;
14205 pdev_param[wmi_pdev_param_beacon_tx_mode] =
14206 WMI_PDEV_PARAM_BEACON_TX_MODE;
14207 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
14208 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
14209 pdev_param[wmi_pdev_param_protection_mode] =
14210 WMI_PDEV_PARAM_PROTECTION_MODE;
14211 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
14212 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
14213 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
14214 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
14215 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
14216 pdev_param[wmi_pdev_param_sta_kickout_th] =
14217 WMI_PDEV_PARAM_STA_KICKOUT_TH;
14218 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
14219 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
14220 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
14221 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
14222 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
14223 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
14224 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
14225 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
14226 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
14227 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
14228 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
14229 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
14230 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
14231 pdev_param[wmi_pdev_param_ltr_sleep_override] =
14232 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
14233 pdev_param[wmi_pdev_param_ltr_rx_override] =
14234 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
14235 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
14236 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
14237 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
14238 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
14239 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
14240 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
14241 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
14242 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
14243 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
14244 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
14245 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
14246 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
14247 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
14248 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
14249 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
14250 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
14251 pdev_param[wmi_pdev_param_peer_stats_update_period] =
14252 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
14253 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
14254 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
14255 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
14256 pdev_param[wmi_pdev_param_arp_ac_override] =
14257 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
14258 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
14259 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
14260 pdev_param[wmi_pdev_param_ani_poll_period] =
14261 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
14262 pdev_param[wmi_pdev_param_ani_listen_period] =
14263 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
14264 pdev_param[wmi_pdev_param_ani_ofdm_level] =
14265 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
14266 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
14267 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
14268 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
14269 pdev_param[wmi_pdev_param_idle_ps_config] =
14270 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
14271 pdev_param[wmi_pdev_param_power_gating_sleep] =
14272 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
14273 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
14274 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
14275 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
14276 pdev_param[wmi_pdev_param_hw_rfkill_config] =
14277 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
14278 pdev_param[wmi_pdev_param_low_power_rf_enable] =
14279 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
14280 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
14281 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
14282 pdev_param[wmi_pdev_param_power_collapse_enable] =
14283 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
14284 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
14285 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
14286 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
14287 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
14288 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
14289 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
14290 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
14291 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
14292 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
14293 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
14294 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
14295 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
14296 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
14297 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
14298 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
14299 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
14300 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
14301 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
14302 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
14303 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
14304 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
14305 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
14306 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
14307 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
14308 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
14309 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
14310 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
14311 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
14312 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
14313 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
14314 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
14315 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
14316 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
14317 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
14318 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
14319 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
14320 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
14321 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
14322 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
14323 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
14324 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
14325 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
14326 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
14327 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
14328 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
14329 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
14330 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
14331 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
14332 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
14333 WMI_UNAVAILABLE_PARAM;
14334 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
14335 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
14336 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
14337 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
14338 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
14339 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
14340 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
14341 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
14342 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
14343 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
14344 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
14345 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
14346 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
14347 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
14348 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
14349 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
14350 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
14351 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
14352 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
14353 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
14354 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
14355 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
14356 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
14357 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
14358 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
14359 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
14360 WMI_UNAVAILABLE_PARAM;
14361 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
14362 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
14363 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
14364 WMI_UNAVAILABLE_PARAM;
14365 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
14366 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
14367 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
14368 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
14369 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
14370 WMI_UNAVAILABLE_PARAM;
14371 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
14372 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
14373 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053014374 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
14375 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053014376 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
14377}
14378
14379/**
14380 * populate_vdev_param_tlv() - populates vdev params
14381 *
14382 * @param vdev_param: Pointer to hold vdev params
14383 * Return: None
14384 */
14385static void populate_vdev_param_tlv(uint32_t *vdev_param)
14386{
14387 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
14388 vdev_param[wmi_vdev_param_fragmentation_threshold] =
14389 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
14390 vdev_param[wmi_vdev_param_beacon_interval] =
14391 WMI_VDEV_PARAM_BEACON_INTERVAL;
14392 vdev_param[wmi_vdev_param_listen_interval] =
14393 WMI_VDEV_PARAM_LISTEN_INTERVAL;
14394 vdev_param[wmi_vdev_param_multicast_rate] =
14395 WMI_VDEV_PARAM_MULTICAST_RATE;
14396 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
14397 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
14398 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
14399 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
14400 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
14401 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
14402 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
14403 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
14404 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
14405 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
14406 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
14407 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
14408 vdev_param[wmi_vdev_param_bmiss_count_max] =
14409 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
14410 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
14411 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
14412 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
14413 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
14414 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
14415 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
14416 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
14417 vdev_param[wmi_vdev_param_disable_htprotection] =
14418 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
14419 vdev_param[wmi_vdev_param_sta_quickkickout] =
14420 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
14421 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
14422 vdev_param[wmi_vdev_param_protection_mode] =
14423 WMI_VDEV_PARAM_PROTECTION_MODE;
14424 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
14425 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
14426 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
14427 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
14428 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
14429 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
14430 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
14431 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
14432 vdev_param[wmi_vdev_param_bcast_data_rate] =
14433 WMI_VDEV_PARAM_BCAST_DATA_RATE;
14434 vdev_param[wmi_vdev_param_mcast_data_rate] =
14435 WMI_VDEV_PARAM_MCAST_DATA_RATE;
14436 vdev_param[wmi_vdev_param_mcast_indicate] =
14437 WMI_VDEV_PARAM_MCAST_INDICATE;
14438 vdev_param[wmi_vdev_param_dhcp_indicate] =
14439 WMI_VDEV_PARAM_DHCP_INDICATE;
14440 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
14441 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
14442 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
14443 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
14444 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
14445 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
14446 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
14447 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
14448 vdev_param[wmi_vdev_param_ap_enable_nawds] =
14449 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
14450 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
14451 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
14452 vdev_param[wmi_vdev_param_packet_powersave] =
14453 WMI_VDEV_PARAM_PACKET_POWERSAVE;
14454 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
14455 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
14456 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
14457 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
14458 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
14459 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
14460 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
14461 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
14462 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
14463 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
14464 vdev_param[wmi_vdev_param_early_rx_slop_step] =
14465 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
14466 vdev_param[wmi_vdev_param_early_rx_init_slop] =
14467 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
14468 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
14469 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
14470 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
14471 vdev_param[wmi_vdev_param_snr_num_for_cal] =
14472 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
14473 vdev_param[wmi_vdev_param_roam_fw_offload] =
14474 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
14475 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
14476 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
14477 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
14478 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
14479 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
14480 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
14481 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
14482 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
14483 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
14484 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
14485 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
14486 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
14487 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
14488 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
14489 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
14490 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
14491 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
14492 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
14493 vdev_param[wmi_vdev_param_inactivity_cnt] =
14494 WMI_VDEV_PARAM_INACTIVITY_CNT;
14495 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
14496 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
14497 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
14498 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
14499 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
14500 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
14501 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
14502 vdev_param[wmi_vdev_param_rx_leak_window] =
14503 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
14504 vdev_param[wmi_vdev_param_stats_avg_factor] =
14505 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
14506 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
14507 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
14508 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
14509 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
14510 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
14511 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053014512 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
14513 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053014514}
14515#endif
14516
Govind Singh5eb51532016-03-09 11:34:12 +053014517/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +053014518 * wmi_tlv_attach() - Attach TLV APIs
Govind Singh5eb51532016-03-09 11:34:12 +053014519 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053014520 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053014521 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053014522#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014523void wmi_tlv_attach(wmi_unified_t wmi_handle)
14524{
14525 wmi_handle->ops = &tlv_ops;
14526#ifdef WMI_INTERFACE_EVENT_LOGGING
14527 wmi_handle->log_info.buf_offset_command = 2;
14528 wmi_handle->log_info.buf_offset_event = 4;
14529 wmi_handle->log_info.is_management_record =
14530 is_management_record_tlv;
14531#endif
14532 populate_tlv_service(wmi_handle->services);
14533 populate_tlv_events_id(wmi_handle->wmi_events);
14534 populate_pdev_param_tlv(wmi_handle->pdev_param);
14535 populate_vdev_param_tlv(wmi_handle->vdev_param);
14536}
14537#else
Govind Singhe7d9f3e2016-04-15 13:58:27 +053014538void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053014539{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053014540 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053014541#ifdef WMI_INTERFACE_EVENT_LOGGING
14542 wmi_handle->log_info.buf_offset_command = 2;
14543 wmi_handle->log_info.buf_offset_event = 4;
14544 wmi_handle->log_info.is_management_record =
14545 is_management_record_tlv;
14546#endif
Govind Singh5eb51532016-03-09 11:34:12 +053014547}
Govind Singhe7f2f342016-05-23 12:12:52 +053014548#endif