blob: 775123100df5dc1bbb9dc43d5edf3fc103d45b23 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
2 * Copyright (c) 2016 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#include "wmi_unified_tlv.h"
29#include "wmi_unified_api.h"
30#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053031#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053032#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053033#include "wmi_version_whitelist.h"
Govind Singh5eb51532016-03-09 11:34:12 +053034
35/**
36 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
37 * @wmi_handle: wmi handle
38 * @param: pointer to hold vdev create parameter
39 * @macaddr: vdev mac address
40 *
Govind Singhe7f2f342016-05-23 12:12:52 +053041 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053042 */
Govind Singhb53420c2016-03-09 14:32:57 +053043QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053044 uint8_t macaddr[IEEE80211_ADDR_LEN],
45 struct vdev_create_params *param)
46{
47 wmi_vdev_create_cmd_fixed_param *cmd;
48 wmi_buf_t buf;
49 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053050 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070051 int num_bands = 2;
52 uint8_t *buf_ptr;
53 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053054
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070055 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053056 buf = wmi_buf_alloc(wmi_handle, len);
57 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053058 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053059 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053060 }
61 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
62 WMITLV_SET_HDR(&cmd->tlv_header,
63 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
64 WMITLV_GET_STRUCT_TLVLEN
65 (wmi_vdev_create_cmd_fixed_param));
66 cmd->vdev_id = param->if_id;
67 cmd->vdev_type = param->type;
68 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070069 cmd->num_cfg_txrx_streams = num_bands;
Govind Singh4df47142016-04-16 19:24:23 -070070 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +053071 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +053072 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +053073 __func__, param->if_id,
74 macaddr[0], macaddr[1], macaddr[2],
75 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070076 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
77 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
78 (num_bands * sizeof(wmi_vdev_txrx_streams)));
79 buf_ptr += WMI_TLV_HDR_SIZE;
80
Govind Singh224a7312016-06-21 14:33:26 +053081 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070082 param->type, param->subtype,
83 param->nss_2g, param->nss_5g);
84 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
85 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
86 txrx_streams->supported_tx_streams = param->nss_2g;
87 txrx_streams->supported_rx_streams = param->nss_2g;
88 WMITLV_SET_HDR(&txrx_streams->tlv_header,
89 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
90 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
91
92 txrx_streams++;
93 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
94 txrx_streams->supported_tx_streams = param->nss_5g;
95 txrx_streams->supported_rx_streams = param->nss_5g;
96 WMITLV_SET_HDR(&txrx_streams->tlv_header,
97 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
98 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +053099 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530100 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530101 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530102 wmi_buf_free(buf);
103 }
104
105 return ret;
106}
107
108/**
109 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
110 * @wmi_handle: wmi handle
111 * @if_id: vdev id
112 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530113 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530114 */
Govind Singhb53420c2016-03-09 14:32:57 +0530115QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530116 uint8_t if_id)
117{
118 wmi_vdev_delete_cmd_fixed_param *cmd;
119 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530120 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530121
122 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
123 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530124 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530125 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530126 }
127
128 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
129 WMITLV_SET_HDR(&cmd->tlv_header,
130 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
131 WMITLV_GET_STRUCT_TLVLEN
132 (wmi_vdev_delete_cmd_fixed_param));
133 cmd->vdev_id = if_id;
134 ret = wmi_unified_cmd_send(wmi_handle, buf,
135 sizeof(wmi_vdev_delete_cmd_fixed_param),
136 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530137 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530138 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530139 wmi_buf_free(buf);
140 }
Govind Singhb53420c2016-03-09 14:32:57 +0530141 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530142
143 return ret;
144}
145
146/**
147 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
148 * @wmi: wmi handle
149 * @vdev_id: vdev id
150 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530151 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530152 */
Govind Singhb53420c2016-03-09 14:32:57 +0530153QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530154 uint8_t vdev_id)
155{
156 wmi_vdev_stop_cmd_fixed_param *cmd;
157 wmi_buf_t buf;
158 int32_t len = sizeof(*cmd);
159
160 buf = wmi_buf_alloc(wmi, len);
161 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530162 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530163 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530164 }
165 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
166 WMITLV_SET_HDR(&cmd->tlv_header,
167 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
168 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
169 cmd->vdev_id = vdev_id;
170 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530171 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
172 qdf_nbuf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530173 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530174 }
175
176 return 0;
177}
178
179/**
180 * send_vdev_down_cmd_tlv() - send vdev down command to fw
181 * @wmi: wmi handle
182 * @vdev_id: vdev id
183 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530184 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530185 */
Govind Singhb53420c2016-03-09 14:32:57 +0530186QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530187{
188 wmi_vdev_down_cmd_fixed_param *cmd;
189 wmi_buf_t buf;
190 int32_t len = sizeof(*cmd);
191
192 buf = wmi_buf_alloc(wmi, len);
193 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530194 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530195 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530196 }
197 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
198 WMITLV_SET_HDR(&cmd->tlv_header,
199 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
200 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
201 cmd->vdev_id = vdev_id;
202 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530203 WMI_LOGP("%s: Failed to send vdev down", __func__);
204 qdf_nbuf_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
212/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530213 * send_vdev_start_cmd_tlv() - send vdev start request to fw
214 * @wmi_handle: wmi handle
215 * @req: vdev start params
216 *
217 * Return: QDF status
218 */
219QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
220 struct vdev_start_params *req)
221{
222 wmi_vdev_start_request_cmd_fixed_param *cmd;
223 wmi_buf_t buf;
224 wmi_channel *chan;
225 int32_t len, ret;
226 uint8_t *buf_ptr;
227
228 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
229 buf = wmi_buf_alloc(wmi_handle, len);
230 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530231 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530232 return QDF_STATUS_E_NOMEM;
233 }
234 buf_ptr = (uint8_t *) wmi_buf_data(buf);
235 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
236 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
237 WMITLV_SET_HDR(&cmd->tlv_header,
238 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
239 WMITLV_GET_STRUCT_TLVLEN
240 (wmi_vdev_start_request_cmd_fixed_param));
241 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
242 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
243 cmd->vdev_id = req->vdev_id;
244
245 /* Fill channel info */
246 chan->mhz = req->chan_freq;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530247
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530248 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530249
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530250 chan->band_center_freq1 = req->band_center_freq1;
251 chan->band_center_freq2 = req->band_center_freq2;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530252
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530253 if (req->is_half_rate)
254 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
255 else if (req->is_quarter_rate)
256 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
257
258 if (req->is_dfs) {
259 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
260 cmd->disable_hw_ack = req->dis_hw_ack;
261 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530262
263 cmd->beacon_interval = req->beacon_intval;
264 cmd->dtim_period = req->dtim_period;
265 /* FIXME: Find out min, max and regulatory power levels */
266 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
267 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
268
269 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530270 cmd->beacon_interval = req->beacon_intval;
271 cmd->dtim_period = req->dtim_period;
272
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530273 /* Copy the SSID */
274 if (req->ssid.length) {
275 if (req->ssid.length < sizeof(cmd->ssid.ssid))
276 cmd->ssid.ssid_len = req->ssid.length;
277 else
278 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
279 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
280 cmd->ssid.ssid_len);
281 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530282
283 if (req->hidden_ssid)
284 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
285
286 if (req->pmf_enabled)
287 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530288 }
289
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530290 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530291 cmd->preferred_rx_streams = req->preferred_rx_streams;
292 cmd->preferred_tx_streams = req->preferred_tx_streams;
293
294 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
295 sizeof(wmi_channel));
296 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
297 cmd->num_noa_descriptors *
298 sizeof(wmi_p2p_noa_descriptor));
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530299 WMI_LOGA("\n%s: vdev_id %d freq %d chanmode %d is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530300 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
301 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
302 "Tx SS %d, Rx SS %d",
303 __func__, req->vdev_id, chan->mhz, req->chan_mode,
304 req->is_dfs, req->beacon_intval, cmd->dtim_period,
305 chan->band_center_freq1, chan->band_center_freq2,
306 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
307 req->preferred_tx_streams, req->preferred_rx_streams);
308
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530309 if (req->is_restart)
310 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
311 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530312 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530313 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
314 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530315 if (ret) {
316 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530317 qdf_nbuf_free(buf);
318 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530319 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530320
321 return QDF_STATUS_SUCCESS;
322}
323
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530324/**
325 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
326 * @wmi_handle: wmi handle
327 * @restart_params: vdev restart params
328 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530329 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530330 */
331QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
332 struct hidden_ssid_vdev_restart_params *restart_params)
333{
334 wmi_vdev_start_request_cmd_fixed_param *cmd;
335 wmi_buf_t buf;
336 wmi_channel *chan;
337 int32_t len;
338 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530339 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530340
341 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
342 buf = wmi_buf_alloc(wmi_handle, len);
343 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530344 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530345 return QDF_STATUS_E_NOMEM;
346 }
347 buf_ptr = (uint8_t *) wmi_buf_data(buf);
348 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
349 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
350
351 WMITLV_SET_HDR(&cmd->tlv_header,
352 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
353 WMITLV_GET_STRUCT_TLVLEN
354 (wmi_vdev_start_request_cmd_fixed_param));
355
356 WMITLV_SET_HDR(&chan->tlv_header,
357 WMITLV_TAG_STRUC_wmi_channel,
358 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
359
360 cmd->vdev_id = restart_params->session_id;
361 cmd->ssid.ssid_len = restart_params->ssid_len;
362 qdf_mem_copy(cmd->ssid.ssid,
363 restart_params->ssid,
364 cmd->ssid.ssid_len);
365 cmd->flags = restart_params->flags;
366 cmd->requestor_id = restart_params->requestor_id;
367 cmd->disable_hw_ack = restart_params->disable_hw_ack;
368
369 chan->mhz = restart_params->mhz;
370 chan->band_center_freq1 =
371 restart_params->band_center_freq1;
372 chan->band_center_freq2 =
373 restart_params->band_center_freq2;
374 chan->info = restart_params->info;
375 chan->reg_info_1 = restart_params->reg_info_1;
376 chan->reg_info_2 = restart_params->reg_info_2;
377
378 cmd->num_noa_descriptors = 0;
379 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
380 sizeof(wmi_channel));
381 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
382 cmd->num_noa_descriptors *
383 sizeof(wmi_p2p_noa_descriptor));
384
385 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
386 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530387 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530388 wmi_buf_free(buf);
389 return QDF_STATUS_E_FAILURE;
390 }
391 return QDF_STATUS_SUCCESS;
392}
393
394
395/**
Govind Singh5eb51532016-03-09 11:34:12 +0530396 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
397 * @wmi: wmi handle
398 * @peer_addr: peer mac address
399 * @param: pointer to hold peer flush tid parameter
400 *
401 * Return: 0 for sucess or error code
402 */
Govind Singhb53420c2016-03-09 14:32:57 +0530403QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530404 uint8_t peer_addr[IEEE80211_ADDR_LEN],
405 struct peer_flush_params *param)
406{
407 wmi_peer_flush_tids_cmd_fixed_param *cmd;
408 wmi_buf_t buf;
409 int32_t len = sizeof(*cmd);
410
411 buf = wmi_buf_alloc(wmi, len);
412 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530413 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530414 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530415 }
416 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
417 WMITLV_SET_HDR(&cmd->tlv_header,
418 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
419 WMITLV_GET_STRUCT_TLVLEN
420 (wmi_peer_flush_tids_cmd_fixed_param));
421 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
422 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
423 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530424 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530425 peer_addr, param->vdev_id,
426 param->peer_tid_bitmap);
427 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530428 WMI_LOGP("%s: Failed to send flush tid command", __func__);
429 qdf_nbuf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530430 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530431 }
432
433 return 0;
434}
435
436/**
437 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
438 * @wmi: wmi handle
439 * @peer_addr: peer mac addr
440 * @vdev_id: vdev id
441 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530442 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530443 */
Govind Singhb53420c2016-03-09 14:32:57 +0530444QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530445 uint8_t peer_addr[IEEE80211_ADDR_LEN],
446 uint8_t vdev_id)
447{
448 wmi_peer_delete_cmd_fixed_param *cmd;
449 wmi_buf_t buf;
450 int32_t len = sizeof(*cmd);
451 buf = wmi_buf_alloc(wmi, len);
452 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530453 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530454 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530455 }
456 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
457 WMITLV_SET_HDR(&cmd->tlv_header,
458 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
459 WMITLV_GET_STRUCT_TLVLEN
460 (wmi_peer_delete_cmd_fixed_param));
461 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
462 cmd->vdev_id = vdev_id;
463
464 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530465 WMI_LOGP("%s: Failed to send peer delete command", __func__);
466 qdf_nbuf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530467 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530468 }
Govind Singhb53420c2016-03-09 14:32:57 +0530469 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530470
471 return 0;
472}
473
474/**
475 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530476 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530477 * @peer_addr: peer mac address
478 * @param : pointer to hold peer set parameter
479 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530480 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530481 */
Govind Singhb53420c2016-03-09 14:32:57 +0530482QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530483 uint8_t peer_addr[IEEE80211_ADDR_LEN],
484 struct peer_set_params *param)
485{
486 wmi_peer_set_param_cmd_fixed_param *cmd;
487 wmi_buf_t buf;
488 int32_t err;
489
490 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
491 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530492 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530493 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530494 }
495 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
496 WMITLV_SET_HDR(&cmd->tlv_header,
497 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
498 WMITLV_GET_STRUCT_TLVLEN
499 (wmi_peer_set_param_cmd_fixed_param));
500 cmd->vdev_id = param->vdev_id;
501 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
502 cmd->param_id = param->param_id;
503 cmd->param_value = param->param_value;
504 err = wmi_unified_cmd_send(wmi, buf,
505 sizeof(wmi_peer_set_param_cmd_fixed_param),
506 WMI_PEER_SET_PARAM_CMDID);
507 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530508 WMI_LOGE("Failed to send set_param cmd");
509 qdf_mem_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530510 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530511 }
512
513 return 0;
514}
515
516/**
517 * send_vdev_up_cmd_tlv() - send vdev up command in fw
518 * @wmi: wmi handle
519 * @bssid: bssid
520 * @vdev_up_params: pointer to hold vdev up parameter
521 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530522 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530523 */
Govind Singhb53420c2016-03-09 14:32:57 +0530524QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530525 uint8_t bssid[IEEE80211_ADDR_LEN],
526 struct vdev_up_params *params)
527{
528 wmi_vdev_up_cmd_fixed_param *cmd;
529 wmi_buf_t buf;
530 int32_t len = sizeof(*cmd);
531
Govind Singhb53420c2016-03-09 14:32:57 +0530532 WMI_LOGD("%s: VDEV_UP", __func__);
533 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530534 params->vdev_id, params->assoc_id, bssid);
535 buf = wmi_buf_alloc(wmi, len);
536 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530537 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530538 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530539 }
540 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
541 WMITLV_SET_HDR(&cmd->tlv_header,
542 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
543 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
544 cmd->vdev_id = params->vdev_id;
545 cmd->vdev_assoc_id = params->assoc_id;
546 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
547 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530548 WMI_LOGP("%s: Failed to send vdev up command", __func__);
549 qdf_nbuf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530550 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530551 }
552
553 return 0;
554}
555
556/**
557 * send_peer_create_cmd_tlv() - send peer create command to fw
558 * @wmi: wmi handle
559 * @peer_addr: peer mac address
560 * @peer_type: peer type
561 * @vdev_id: vdev id
562 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530563 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530564 */
Govind Singhb53420c2016-03-09 14:32:57 +0530565QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530566 struct peer_create_params *param)
567{
568 wmi_peer_create_cmd_fixed_param *cmd;
569 wmi_buf_t buf;
570 int32_t len = sizeof(*cmd);
571
572 buf = wmi_buf_alloc(wmi, len);
573 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530574 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530575 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530576 }
577 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
578 WMITLV_SET_HDR(&cmd->tlv_header,
579 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
580 WMITLV_GET_STRUCT_TLVLEN
581 (wmi_peer_create_cmd_fixed_param));
582 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
583 cmd->peer_type = param->peer_type;
584 cmd->vdev_id = param->vdev_id;
585
586 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530587 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
588 qdf_nbuf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530589 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530590 }
Govind Singhb53420c2016-03-09 14:32:57 +0530591 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530592 param->vdev_id);
593
594 return 0;
595}
596
597/**
598 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
599 * @wmi_handle: wmi handle
600 * @value: value
601 * @mac_id: mac id to have radio context
602 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530603 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530604 */
Govind Singhb53420c2016-03-09 14:32:57 +0530605QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530606 uint32_t value, uint8_t mac_id)
607{
608 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
609 wmi_buf_t buf;
610 int32_t len = sizeof(*cmd);
611
Govind Singhb53420c2016-03-09 14:32:57 +0530612 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530613
614 buf = wmi_buf_alloc(wmi_handle, len);
615 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530616 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530617 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530618 }
619
620 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
621 WMITLV_SET_HDR(&cmd->tlv_header,
622 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
623 WMITLV_GET_STRUCT_TLVLEN
624 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530625 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530626 cmd->enable = value;
627
628 if (wmi_unified_cmd_send(wmi_handle, buf, len,
629 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530630 WMI_LOGE("Set Green AP PS param Failed val %d", value);
631 qdf_nbuf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530632 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530633 }
634
635 return 0;
636}
637
638/**
639 * send_pdev_utf_cmd_tlv() - send utf command to fw
640 * @wmi_handle: wmi handle
641 * @param: pointer to pdev_utf_params
642 * @mac_id: mac id to have radio context
643 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530644 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530645 */
Govind Singhb53420c2016-03-09 14:32:57 +0530646QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530647send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
648 struct pdev_utf_params *param,
649 uint8_t mac_id)
650{
651 wmi_buf_t buf;
652 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +0530653 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530654 static uint8_t msgref = 1;
655 uint8_t segNumber = 0, segInfo, numSegments;
656 uint16_t chunk_len, total_bytes;
657 uint8_t *bufpos;
658 struct seg_hdr_info segHdrInfo;
659
660 bufpos = param->utf_payload;
661 total_bytes = param->len;
662 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
663 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
664 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
665
666 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
667 numSegments++;
668
669 while (param->len) {
670 if (param->len > MAX_WMI_UTF_LEN)
671 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
672 else
673 chunk_len = param->len;
674
675 buf = wmi_buf_alloc(wmi_handle,
676 (chunk_len + sizeof(segHdrInfo) +
677 WMI_TLV_HDR_SIZE));
678 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530679 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530680 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530681 }
682
683 cmd = (uint8_t *) wmi_buf_data(buf);
684
685 segHdrInfo.len = total_bytes;
686 segHdrInfo.msgref = msgref;
687 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
688 segHdrInfo.segmentInfo = segInfo;
689 segHdrInfo.pad = 0;
690
Govind Singhb53420c2016-03-09 14:32:57 +0530691 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +0530692 " segHdrInfo.segmentInfo = %d",
693 __func__, segHdrInfo.len, segHdrInfo.msgref,
694 segHdrInfo.segmentInfo);
695
Govind Singhb53420c2016-03-09 14:32:57 +0530696 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +0530697 "chunk len %d", __func__, total_bytes, segNumber,
698 numSegments, chunk_len);
699
700 segNumber++;
701
702 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
703 (chunk_len + sizeof(segHdrInfo)));
704 cmd += WMI_TLV_HDR_SIZE;
705 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
706 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
707
708 ret = wmi_unified_cmd_send(wmi_handle, buf,
709 (chunk_len + sizeof(segHdrInfo) +
710 WMI_TLV_HDR_SIZE),
711 WMI_PDEV_UTF_CMDID);
712
Govind Singh67922e82016-04-01 16:48:57 +0530713 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530714 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530715 wmi_buf_free(buf);
716 break;
717 }
718
719 param->len -= chunk_len;
720 bufpos += chunk_len;
721 }
722
723 msgref++;
724
725 return ret;
726}
727
728/**
729 * send_pdev_param_cmd_tlv() - set pdev parameters
730 * @wmi_handle: wmi handle
731 * @param: pointer to pdev parameter
732 * @mac_id: radio context
733 *
734 * Return: 0 on success, errno on failure
735 */
Govind Singhb53420c2016-03-09 14:32:57 +0530736QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530737send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
738 struct pdev_params *param,
739 uint8_t mac_id)
740{
Govind Singh67922e82016-04-01 16:48:57 +0530741 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530742 wmi_pdev_set_param_cmd_fixed_param *cmd;
743 wmi_buf_t buf;
744 uint16_t len = sizeof(*cmd);
745
746 buf = wmi_buf_alloc(wmi_handle, len);
747 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530748 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530749 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530750 }
751 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
752 WMITLV_SET_HDR(&cmd->tlv_header,
753 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
754 WMITLV_GET_STRUCT_TLVLEN
755 (wmi_pdev_set_param_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530756 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530757 cmd->param_id = param->param_id;
758 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +0530759 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530760 param->param_value);
761 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
762 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530763 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530764 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +0530765 wmi_buf_free(buf);
766 }
767 return ret;
768}
769
770/**
771 * send_suspend_cmd_tlv() - WMI suspend function
772 * @param wmi_handle : handle to WMI.
773 * @param param : pointer to hold suspend parameter
774 * @mac_id: radio context
775 *
776 * Return 0 on success and -ve on failure.
777 */
Govind Singhb53420c2016-03-09 14:32:57 +0530778QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530779 struct suspend_params *param,
780 uint8_t mac_id)
781{
782 wmi_pdev_suspend_cmd_fixed_param *cmd;
783 wmi_buf_t wmibuf;
784 uint32_t len = sizeof(*cmd);
785 int32_t ret;
786
787 /*
788 * send the comand to Target to ignore the
789 * PCIE reset so as to ensure that Host and target
790 * states are in sync
791 */
792 wmibuf = wmi_buf_alloc(wmi_handle, len);
793 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +0530794 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530795
796 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
797 WMITLV_SET_HDR(&cmd->tlv_header,
798 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
799 WMITLV_GET_STRUCT_TLVLEN
800 (wmi_pdev_suspend_cmd_fixed_param));
801 if (param->disable_target_intr)
802 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
803 else
804 cmd->suspend_opt = WMI_PDEV_SUSPEND;
805 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
806 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +0530807 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +0530808 qdf_nbuf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +0530809 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530810 }
811
812 return ret;
813}
814
815/**
816 * send_resume_cmd_tlv() - WMI resume function
817 * @param wmi_handle : handle to WMI.
818 * @mac_id: radio context
819 *
820 * Return: 0 on success and -ve on failure.
821 */
Govind Singhb53420c2016-03-09 14:32:57 +0530822QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530823 uint8_t mac_id)
824{
825 wmi_buf_t wmibuf;
826 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +0530827 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530828
829 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
830 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +0530831 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530832 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
833 WMITLV_SET_HDR(&cmd->tlv_header,
834 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
835 WMITLV_GET_STRUCT_TLVLEN
836 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -0700837 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +0530838 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
839 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530840 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530841 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +0530842 wmi_buf_free(wmibuf);
843 }
844
845 return ret;
846}
847
848/**
849 * send_wow_enable_cmd_tlv() - WMI wow enable function
850 * @param wmi_handle : handle to WMI.
851 * @param param : pointer to hold wow enable parameter
852 * @mac_id: radio context
853 *
854 * Return: 0 on success and -ve on failure.
855 */
Govind Singhb53420c2016-03-09 14:32:57 +0530856QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530857 struct wow_cmd_params *param,
858 uint8_t mac_id)
859{
860 wmi_wow_enable_cmd_fixed_param *cmd;
861 wmi_buf_t buf;
862 int32_t len;
863 int32_t ret;
864
865 len = sizeof(wmi_wow_enable_cmd_fixed_param);
866
867 buf = wmi_buf_alloc(wmi_handle, len);
868 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530869 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
870 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530871 }
872 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
873 WMITLV_SET_HDR(&cmd->tlv_header,
874 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
875 WMITLV_GET_STRUCT_TLVLEN
876 (wmi_wow_enable_cmd_fixed_param));
877 cmd->enable = param->enable;
878 if (param->can_suspend_link)
879 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
880 else
881 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
882
Govind Singhb53420c2016-03-09 14:32:57 +0530883 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +0530884 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
885 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
886
887 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
888 WMI_WOW_ENABLE_CMDID);
889 if (ret)
890 wmi_buf_free(buf);
891
892 return ret;
893}
894
895/**
896 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +0530897 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530898 * @peer_addr: peer mac address
899 * @param: pointer to ap_ps parameter structure
900 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530901 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530902 */
Govind Singhb53420c2016-03-09 14:32:57 +0530903QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530904 uint8_t *peer_addr,
905 struct ap_ps_params *param)
906{
907 wmi_ap_ps_peer_cmd_fixed_param *cmd;
908 wmi_buf_t buf;
909 int32_t err;
910
911 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
912 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530913 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530914 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530915 }
916 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
917 WMITLV_SET_HDR(&cmd->tlv_header,
918 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
919 WMITLV_GET_STRUCT_TLVLEN
920 (wmi_ap_ps_peer_cmd_fixed_param));
921 cmd->vdev_id = param->vdev_id;
922 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
923 cmd->param = param->param;
924 cmd->value = param->value;
925 err = wmi_unified_cmd_send(wmi_handle, buf,
926 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
927 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530928 WMI_LOGE("Failed to send set_ap_ps_param cmd");
929 qdf_mem_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530930 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530931 }
932
933 return 0;
934}
935
936/**
937 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +0530938 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530939 * @peer_addr: peer mac address
940 * @param: pointer to sta_ps parameter structure
941 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530942 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530943 */
Govind Singhb53420c2016-03-09 14:32:57 +0530944QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530945 struct sta_ps_params *param)
946{
947 wmi_sta_powersave_param_cmd_fixed_param *cmd;
948 wmi_buf_t buf;
949 int32_t len = sizeof(*cmd);
950
951 buf = wmi_buf_alloc(wmi_handle, len);
952 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530953 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530954 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530955 }
956
957 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
958 WMITLV_SET_HDR(&cmd->tlv_header,
959 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
960 WMITLV_GET_STRUCT_TLVLEN
961 (wmi_sta_powersave_param_cmd_fixed_param));
962 cmd->vdev_id = param->vdev_id;
963 cmd->param = param->param;
964 cmd->value = param->value;
965
966 if (wmi_unified_cmd_send(wmi_handle, buf, len,
967 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530968 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +0530969 param->vdev_id, param->param, param->value);
Govind Singhb53420c2016-03-09 14:32:57 +0530970 qdf_nbuf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530971 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530972 }
973
974 return 0;
975}
976
977/**
978 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +0530979 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530980 * @param: ponirt to crash inject paramter structure
981 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530982 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +0530983 */
Govind Singhb53420c2016-03-09 14:32:57 +0530984QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530985 struct crash_inject *param)
986{
987 int32_t ret = 0;
988 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
989 uint16_t len = sizeof(*cmd);
990 wmi_buf_t buf;
991
992 buf = wmi_buf_alloc(wmi_handle, len);
993 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530994 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530995 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530996 }
997
998 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
999 WMITLV_SET_HDR(&cmd->tlv_header,
1000 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1001 WMITLV_GET_STRUCT_TLVLEN
1002 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1003 cmd->type = param->type;
1004 cmd->delay_time_ms = param->delay_time_ms;
1005
1006 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1007 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301008 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301009 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301010 __func__, ret);
1011 wmi_buf_free(buf);
1012 }
1013
1014 return ret;
1015}
1016
1017/**
1018 * send_dbglog_cmd_tlv() - set debug log level
1019 * @param wmi_handle : handle to WMI.
1020 * @param param : pointer to hold dbglog level parameter
1021 *
1022 * Return: 0 on success and -ve on failure.
1023 */
Govind Singhb53420c2016-03-09 14:32:57 +05301024QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301025send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1026 struct dbglog_params *dbglog_param)
1027{
1028 wmi_buf_t buf;
1029 wmi_debug_log_config_cmd_fixed_param *configmsg;
1030 A_STATUS status = A_OK;
1031 int32_t i;
1032 int32_t len;
1033 int8_t *buf_ptr;
1034 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1035
1036 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1037
1038 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1039 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1040 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1041 buf = wmi_buf_alloc(wmi_handle, len);
1042 if (buf == NULL)
1043 return A_NO_MEMORY;
1044
1045 configmsg =
1046 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1047 buf_ptr = (int8_t *) configmsg;
1048 WMITLV_SET_HDR(&configmsg->tlv_header,
1049 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1050 WMITLV_GET_STRUCT_TLVLEN
1051 (wmi_debug_log_config_cmd_fixed_param));
1052 configmsg->dbg_log_param = dbglog_param->param;
1053 configmsg->value = dbglog_param->val;
1054 /* Filling in the data part of second tlv -- should
1055 * follow first tlv _ WMI_TLV_HDR_SIZE */
1056 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1057 sizeof
1058 (wmi_debug_log_config_cmd_fixed_param)
1059 + WMI_TLV_HDR_SIZE);
1060 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1061 WMITLV_TAG_ARRAY_UINT32,
1062 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1063 if (dbglog_param->module_id_bitmap) {
1064 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1065 module_id_bitmap_array[i] =
1066 dbglog_param->module_id_bitmap[i];
1067 }
1068 }
1069
1070 status = wmi_unified_cmd_send(wmi_handle, buf,
1071 len, WMI_DBGLOG_CFG_CMDID);
1072
1073 if (status != A_OK)
Govind Singhb53420c2016-03-09 14:32:57 +05301074 qdf_nbuf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301075
1076 return status;
1077}
1078
1079/**
1080 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1081 * @param wmi_handle : handle to WMI.
1082 * @param macaddr : MAC address
1083 * @param param : pointer to hold vdev set parameter
1084 *
1085 * Return: 0 on success and -ve on failure.
1086 */
Govind Singhb53420c2016-03-09 14:32:57 +05301087QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301088 struct vdev_set_params *param)
1089{
Govind Singh67922e82016-04-01 16:48:57 +05301090 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301091 wmi_vdev_set_param_cmd_fixed_param *cmd;
1092 wmi_buf_t buf;
1093 uint16_t len = sizeof(*cmd);
1094
1095 buf = wmi_buf_alloc(wmi_handle, len);
1096 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301097 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301098 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301099 }
1100 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1101 WMITLV_SET_HDR(&cmd->tlv_header,
1102 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1103 WMITLV_GET_STRUCT_TLVLEN
1104 (wmi_vdev_set_param_cmd_fixed_param));
1105 cmd->vdev_id = param->if_id;
1106 cmd->param_id = param->param_id;
1107 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301108 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301109 param->if_id, param->param_id, param->param_value);
1110 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1111 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301112 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301113 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301114 wmi_buf_free(buf);
1115 }
1116
1117 return ret;
1118}
1119
1120/**
1121 * send_stats_request_cmd_tlv() - WMI request stats function
1122 * @param wmi_handle : handle to WMI.
1123 * @param macaddr : MAC address
1124 * @param param : pointer to hold stats request parameter
1125 *
1126 * Return: 0 on success and -ve on failure.
1127 */
Govind Singhb53420c2016-03-09 14:32:57 +05301128QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301129 uint8_t macaddr[IEEE80211_ADDR_LEN],
1130 struct stats_request_params *param)
1131{
Govind Singhd3156eb2016-02-26 17:50:39 +05301132 int32_t ret;
1133 wmi_request_stats_cmd_fixed_param *cmd;
1134 wmi_buf_t buf;
1135 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1136
1137 buf = wmi_buf_alloc(wmi_handle, len);
1138 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301139 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1140 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301141 }
1142
1143 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1144 WMITLV_SET_HDR(&cmd->tlv_header,
1145 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1146 WMITLV_GET_STRUCT_TLVLEN
1147 (wmi_request_stats_cmd_fixed_param));
1148 cmd->stats_id = param->stats_id;
1149 cmd->vdev_id = param->vdev_id;
1150 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1151 WMI_REQUEST_STATS_CMDID);
1152 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301153 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301154 wmi_buf_free(buf);
1155 }
1156
1157 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301158}
1159
1160/**
1161 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1162 * @param wmi_handle : handle to WMI.
1163 * @param macaddr : MAC address
1164 * @param param : pointer to hold stats request parameter
1165 *
1166 * Return: 0 on success and -ve on failure.
1167 */
Govind Singhb53420c2016-03-09 14:32:57 +05301168QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301169 uint8_t macaddr[IEEE80211_ADDR_LEN],
1170 struct packet_enable_params *param)
1171{
1172 return 0;
1173}
1174
1175/**
1176 * send_beacon_send_cmd_tlv() - WMI beacon send function
1177 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301178 * @param param : pointer to hold beacon send cmd parameter
1179 *
1180 * Return: 0 on success and -ve on failure.
1181 */
Govind Singhb53420c2016-03-09 14:32:57 +05301182QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301183 struct beacon_params *param)
1184{
Govind Singhd3156eb2016-02-26 17:50:39 +05301185 int32_t ret;
1186 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1187 wmi_bcn_prb_info *bcn_prb_info;
1188 wmi_buf_t wmi_buf;
1189 uint8_t *buf_ptr;
1190 uint32_t wmi_buf_len;
1191
1192 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1193 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1194 param->tmpl_len_aligned;
1195 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1196 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301197 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301198 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301199 }
1200 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1201 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1202 WMITLV_SET_HDR(&cmd->tlv_header,
1203 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1204 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1205 cmd->vdev_id = param->vdev_id;
1206 cmd->tim_ie_offset = param->tim_ie_offset;
1207 cmd->buf_len = param->tmpl_len;
1208 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1209
1210 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1211 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1212 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1213 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1214 bcn_prb_info->caps = 0;
1215 bcn_prb_info->erp = 0;
1216 buf_ptr += sizeof(wmi_bcn_prb_info);
1217
1218 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1219 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301220 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301221
1222 ret = wmi_unified_cmd_send(wmi_handle,
1223 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1224 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301225 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301226 wmi_buf_free(wmi_buf);
1227 }
Govind Singh5eb51532016-03-09 11:34:12 +05301228 return 0;
1229}
1230
1231/**
1232 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1233 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301234 * @param param : pointer to peer assoc parameter
1235 *
1236 * Return: 0 on success and -ve on failure.
1237 */
Govind Singhb53420c2016-03-09 14:32:57 +05301238QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301239 struct peer_assoc_params *param)
1240{
Govind Singhd3156eb2016-02-26 17:50:39 +05301241 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1242 wmi_vht_rate_set *mcs;
1243 wmi_buf_t buf;
1244 int32_t len;
1245 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301246 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301247 uint32_t peer_legacy_rates_align;
1248 uint32_t peer_ht_rates_align;
1249
1250
1251 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1252 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301253
1254 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301255 (peer_legacy_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301256 WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301257 (peer_ht_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301258 sizeof(wmi_vht_rate_set);
1259
1260 buf = wmi_buf_alloc(wmi_handle, len);
1261 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301262 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301263 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301264 }
1265
1266 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1267 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1268 WMITLV_SET_HDR(&cmd->tlv_header,
1269 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1270 WMITLV_GET_STRUCT_TLVLEN
1271 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301272
Govind Singhd3156eb2016-02-26 17:50:39 +05301273 cmd->vdev_id = param->vdev_id;
Govind Singh3419aea2016-03-28 22:02:42 +05301274 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1275 sizeof(param->peer_macaddr));
Govind Singhd3156eb2016-02-26 17:50:39 +05301276 cmd->peer_new_assoc = param->peer_new_assoc;
1277 cmd->peer_associd = param->peer_associd;
1278 cmd->peer_flags = param->peer_flags;
1279 cmd->peer_rate_caps = param->peer_rate_caps;
1280 cmd->peer_caps = param->peer_caps;
1281 cmd->peer_listen_intval = param->peer_listen_intval;
1282 cmd->peer_ht_caps = param->peer_ht_caps;
1283 cmd->peer_max_mpdu = param->peer_max_mpdu;
1284 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301285 cmd->peer_vht_caps = param->peer_vht_caps;
1286 cmd->peer_phymode = param->peer_phymode;
1287
1288 /* Update peer legacy rate information */
1289 buf_ptr += sizeof(*cmd);
1290 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301291 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301292 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301293 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301294 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301295 param->peer_legacy_rates.num_rates);
1296
1297 /* Update peer HT rate information */
Govind Singh3419aea2016-03-28 22:02:42 +05301298 buf_ptr += param->peer_legacy_rates.num_rates;
Govind Singhd3156eb2016-02-26 17:50:39 +05301299 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301300 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301301 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301302 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301303 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301304 param->peer_ht_rates.num_rates);
1305
1306 /* VHT Rates */
Govind Singh3419aea2016-03-28 22:02:42 +05301307 buf_ptr += param->peer_ht_rates.num_rates;
Govind Singhd3156eb2016-02-26 17:50:39 +05301308 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1309 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1310
1311 cmd->peer_nss = param->peer_nss;
1312 mcs = (wmi_vht_rate_set *) buf_ptr;
1313 if (param->vht_capable) {
1314 mcs->rx_max_rate = param->rx_max_rate;
1315 mcs->rx_mcs_set = param->rx_mcs_set;
1316 mcs->tx_max_rate = param->tx_max_rate;
1317 mcs->tx_mcs_set = param->tx_mcs_set;
1318 }
1319
Govind Singhb53420c2016-03-09 14:32:57 +05301320 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301321 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1322 "nss %d phymode %d peer_mpdu_density %d "
1323 "cmd->peer_vht_caps %x", __func__,
1324 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1325 cmd->peer_rate_caps, cmd->peer_caps,
1326 cmd->peer_listen_intval, cmd->peer_ht_caps,
1327 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1328 cmd->peer_mpdu_density,
1329 cmd->peer_vht_caps);
1330
1331 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1332 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301333 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301334 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301335 __func__, ret);
Govind Singhb53420c2016-03-09 14:32:57 +05301336 qdf_nbuf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301337 }
1338
1339 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301340}
1341
1342/**
1343 * send_scan_start_cmd_tlv() - WMI scan start function
1344 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301345 * @param param : pointer to hold scan start cmd parameter
1346 *
1347 * Return: 0 on success and -ve on failure.
1348 */
Govind Singhb53420c2016-03-09 14:32:57 +05301349QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301350 struct scan_start_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05301351{
Govind Singhd3156eb2016-02-26 17:50:39 +05301352 int32_t ret = 0;
1353 int32_t i;
1354 wmi_buf_t wmi_buf;
1355 wmi_start_scan_cmd_fixed_param *cmd;
1356 uint8_t *buf_ptr;
1357 uint32_t *tmp_ptr;
1358 wmi_ssid *ssid = NULL;
1359 wmi_mac_addr *bssid;
1360 int len = sizeof(*cmd);
1361
1362 /* Length TLV placeholder for array of uint32_t */
1363 len += WMI_TLV_HDR_SIZE;
1364 /* calculate the length of buffer required */
1365 if (params->num_chan)
1366 len += params->num_chan * sizeof(uint32_t);
1367
1368 /* Length TLV placeholder for array of wmi_ssid structures */
1369 len += WMI_TLV_HDR_SIZE;
1370 if (params->num_ssids)
1371 len += params->num_ssids * sizeof(wmi_ssid);
1372
1373 /* Length TLV placeholder for array of wmi_mac_addr structures */
1374 len += WMI_TLV_HDR_SIZE;
1375 len += sizeof(wmi_mac_addr);
1376
1377 /* Length TLV placeholder for array of bytes */
1378 len += WMI_TLV_HDR_SIZE;
1379 if (params->ie_len)
1380 len += roundup(params->ie_len, sizeof(uint32_t));
1381
1382 /* Allocate the memory */
1383 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1384 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301385 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301386 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05301387 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05301388 }
1389 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1390 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
1391 WMITLV_SET_HDR(&cmd->tlv_header,
1392 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
1393 WMITLV_GET_STRUCT_TLVLEN
1394 (wmi_start_scan_cmd_fixed_param));
1395
1396 cmd->scan_id = params->scan_id;
1397 cmd->scan_req_id = params->scan_req_id;
1398 cmd->vdev_id = params->vdev_id;
1399 cmd->scan_priority = params->scan_priority;
1400 cmd->notify_scan_events = params->notify_scan_events;
1401 cmd->dwell_time_active = params->dwell_time_active;
1402 cmd->dwell_time_passive = params->dwell_time_passive;
1403 cmd->min_rest_time = params->min_rest_time;
1404 cmd->max_rest_time = params->max_rest_time;
1405 cmd->repeat_probe_time = params->repeat_probe_time;
1406 cmd->probe_spacing_time = params->probe_spacing_time;
1407 cmd->idle_time = params->idle_time;
1408 cmd->max_scan_time = params->max_scan_time;
1409 cmd->probe_delay = params->probe_delay;
1410 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1411 cmd->burst_duration = params->burst_duration;
1412 cmd->num_chan = params->num_chan;
1413 cmd->num_bssid = params->num_bssid;
1414 cmd->num_ssids = params->num_ssids;
1415 cmd->ie_len = params->ie_len;
1416 cmd->n_probes = params->n_probes;
1417 buf_ptr += sizeof(*cmd);
1418 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
1419 for (i = 0; i < params->num_chan; ++i)
1420 tmp_ptr[i] = params->chan_list[i];
1421
1422 WMITLV_SET_HDR(buf_ptr,
1423 WMITLV_TAG_ARRAY_UINT32,
1424 (params->num_chan * sizeof(uint32_t)));
1425 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05301426 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05301427 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05301428 goto error;
1429 }
1430
1431 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1432 (params->num_ssids * sizeof(wmi_ssid)));
1433
1434 if (params->num_ssids) {
1435 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
1436 for (i = 0; i < params->num_ssids; ++i) {
1437 ssid->ssid_len = params->ssid[i].length;
Govind Singhb53420c2016-03-09 14:32:57 +05301438 qdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05301439 params->ssid[i].length);
1440 ssid++;
1441 }
1442 }
1443 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
1444
1445 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
1446 (params->num_bssid * sizeof(wmi_mac_addr)));
1447 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
1448 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
1449 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
1450
1451 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, params->ie_len_with_pad);
1452 if (params->ie_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05301453 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singhd3156eb2016-02-26 17:50:39 +05301454 (uint8_t *) params->ie_base +
1455 (params->uie_fieldOffset), params->ie_len);
1456 }
1457 buf_ptr += WMI_TLV_HDR_SIZE + params->ie_len_with_pad;
1458
1459 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1460 len, WMI_START_SCAN_CMDID);
1461 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301462 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301463 wmi_buf_free(wmi_buf);
1464 }
1465 return ret;
1466error:
Govind Singhb53420c2016-03-09 14:32:57 +05301467 qdf_nbuf_free(wmi_buf);
1468 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301469}
1470
1471/**
1472 * send_scan_stop_cmd_tlv() - WMI scan start function
1473 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301474 * @param param : pointer to hold scan start cmd parameter
1475 *
1476 * Return: 0 on success and -ve on failure.
1477 */
Govind Singhb53420c2016-03-09 14:32:57 +05301478QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301479 struct scan_stop_params *param)
1480{
Govind Singhd3156eb2016-02-26 17:50:39 +05301481 wmi_stop_scan_cmd_fixed_param *cmd;
1482 int ret;
1483 int len = sizeof(*cmd);
1484 wmi_buf_t wmi_buf;
1485
1486 /* Allocate the memory */
1487 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1488 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301489 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05301490 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301491 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301492 goto error;
1493 }
1494
1495 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1496 WMITLV_SET_HDR(&cmd->tlv_header,
1497 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
1498 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
1499 cmd->vdev_id = param->vdev_id;
1500 cmd->requestor = param->requestor;
1501 cmd->scan_id = param->scan_id;
1502 /* stop the scan with the corresponding scan_id */
1503 cmd->req_type = param->req_type;
1504 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
1505 len, WMI_STOP_SCAN_CMDID);
1506 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301507 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301508 wmi_buf_free(wmi_buf);
1509 }
1510
1511error:
1512 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301513}
1514
1515/**
1516 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
1517 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301518 * @param param : pointer to hold scan channel list parameter
1519 *
1520 * Return: 0 on success and -ve on failure.
1521 */
Govind Singhb53420c2016-03-09 14:32:57 +05301522QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301523 struct scan_chan_list_params *chan_list)
1524{
1525 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05301526 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05301527 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301528 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05301529 uint8_t *buf_ptr;
1530 wmi_channel *chan_info, *tchan_info;
1531 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
1532
1533 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
1534 buf = wmi_buf_alloc(wmi_handle, len);
1535 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301536 WMI_LOGE("Failed to allocate memory");
1537 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301538 goto end;
1539 }
1540
1541 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1542 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
1543 WMITLV_SET_HDR(&cmd->tlv_header,
1544 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
1545 WMITLV_GET_STRUCT_TLVLEN
1546 (wmi_scan_chan_list_cmd_fixed_param));
1547
Govind Singhb53420c2016-03-09 14:32:57 +05301548 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301549
1550 cmd->num_scan_chans = chan_list->num_scan_chans;
1551 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
1552 WMITLV_TAG_ARRAY_STRUC,
1553 sizeof(wmi_channel) * chan_list->num_scan_chans);
1554 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
1555 tchan_info = chan_list->chan_info;
1556
1557 for (i = 0; i < chan_list->num_scan_chans; ++i) {
1558 WMITLV_SET_HDR(&chan_info->tlv_header,
1559 WMITLV_TAG_STRUC_wmi_channel,
1560 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
1561 chan_info->mhz = tchan_info->mhz;
1562 chan_info->band_center_freq1 =
1563 tchan_info->band_center_freq1;
1564 chan_info->band_center_freq2 =
1565 tchan_info->band_center_freq2;
1566 chan_info->info = tchan_info->info;
1567 chan_info->reg_info_1 = tchan_info->reg_info_1;
1568 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05301569 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05301570
1571 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
1572 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
1573 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
1574 tchan_info++;
1575 chan_info++;
1576 }
1577
Govind Singh67922e82016-04-01 16:48:57 +05301578 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singhd3156eb2016-02-26 17:50:39 +05301579 WMI_SCAN_CHAN_LIST_CMDID);
1580
Govind Singh67922e82016-04-01 16:48:57 +05301581 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301582 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05301583 wmi_buf_free(buf);
1584 }
Govind Singh67922e82016-04-01 16:48:57 +05301585
Govind Singhd3156eb2016-02-26 17:50:39 +05301586end:
Govind Singhb53420c2016-03-09 14:32:57 +05301587 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05301588}
1589
1590/**
1591 * send_mgmt_cmd_tlv() - WMI scan start function
1592 * @wmi_handle : handle to WMI.
1593 * @param : pointer to hold mgmt cmd parameter
1594 *
1595 * Return: 0 on success and -ve on failure.
1596 */
Govind Singhb53420c2016-03-09 14:32:57 +05301597QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05301598 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05301599{
Govind Singh427ee5a2016-02-26 18:09:36 +05301600 wmi_buf_t buf;
1601 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
1602 int32_t cmd_len;
1603 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05301604 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05301605 uint8_t *bufp;
1606 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
1607 mgmt_tx_dl_frm_len;
1608
1609 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
1610 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
1611
1612 buf = wmi_buf_alloc(wmi_handle, cmd_len);
1613 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301614 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
1615 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05301616 }
1617
1618 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
1619 bufp = (uint8_t *) cmd;
1620 WMITLV_SET_HDR(&cmd->tlv_header,
1621 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
1622 WMITLV_GET_STRUCT_TLVLEN
1623 (wmi_mgmt_tx_send_cmd_fixed_param));
1624
1625 cmd->vdev_id = param->vdev_id;
1626
Govind Singh224a7312016-06-21 14:33:26 +05301627 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05301628 cmd->chanfreq = param->chanfreq;
1629 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
1630 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
1631 sizeof(uint32_t)));
1632 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301633 qdf_mem_copy(bufp, param->pdata, bufp_len);
1634 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
1635 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05301636 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
1637#if defined(HELIUMPLUS_PADDR64)
1638 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
1639#endif
1640 cmd->frame_len = param->frm_len;
1641 cmd->buf_len = bufp_len;
1642
1643 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
1644 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301645 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05301646 goto err1;
1647 }
Govind Singhb53420c2016-03-09 14:32:57 +05301648 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05301649
1650err1:
1651 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05301652 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05301653}
1654
1655/**
1656 * send_modem_power_state_cmd_tlv() - set modem power state to fw
1657 * @wmi_handle: wmi handle
1658 * @param_value: parameter value
1659 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301660 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05301661 */
Govind Singhb53420c2016-03-09 14:32:57 +05301662QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05301663 uint32_t param_value)
1664{
Govind Singh67922e82016-04-01 16:48:57 +05301665 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05301666 wmi_modem_power_state_cmd_param *cmd;
1667 wmi_buf_t buf;
1668 uint16_t len = sizeof(*cmd);
1669
1670 buf = wmi_buf_alloc(wmi_handle, len);
1671 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301672 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301673 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05301674 }
1675 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
1676 WMITLV_SET_HDR(&cmd->tlv_header,
1677 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
1678 WMITLV_GET_STRUCT_TLVLEN
1679 (wmi_modem_power_state_cmd_param));
1680 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301681 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05301682 param_value);
1683 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1684 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301685 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301686 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05301687 wmi_buf_free(buf);
1688 }
Govind Singh67922e82016-04-01 16:48:57 +05301689
Govind Singh427ee5a2016-02-26 18:09:36 +05301690 return ret;
1691}
1692
1693/**
1694 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
1695 * @wmi_handle: wmi handle
1696 * @vdev_id: vdev id
1697 * @val: value
1698 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301699 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05301700 */
Govind Singhb53420c2016-03-09 14:32:57 +05301701QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05301702 uint32_t vdev_id, uint8_t val)
1703{
1704 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
1705 wmi_buf_t buf;
1706 int32_t len = sizeof(*cmd);
1707
Govind Singhb53420c2016-03-09 14:32:57 +05301708 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05301709
1710 buf = wmi_buf_alloc(wmi_handle, len);
1711 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301712 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301713 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05301714 }
1715 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
1716 WMITLV_SET_HDR(&cmd->tlv_header,
1717 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
1718 WMITLV_GET_STRUCT_TLVLEN
1719 (wmi_sta_powersave_mode_cmd_fixed_param));
1720 cmd->vdev_id = vdev_id;
1721 if (val)
1722 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
1723 else
1724 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
1725
1726 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1727 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301728 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05301729 vdev_id, val);
Govind Singhb53420c2016-03-09 14:32:57 +05301730 qdf_nbuf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301731 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05301732 }
Govind Singh5eb51532016-03-09 11:34:12 +05301733 return 0;
1734}
1735
Govind Singh427ee5a2016-02-26 18:09:36 +05301736/**
1737 * send_set_mimops_cmd_tlv() - set MIMO powersave
1738 * @wmi_handle: wmi handle
1739 * @vdev_id: vdev id
1740 * @value: value
1741 *
Govind Singhb53420c2016-03-09 14:32:57 +05301742 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05301743 */
Govind Singhb53420c2016-03-09 14:32:57 +05301744QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05301745 uint8_t vdev_id, int value)
1746{
Govind Singh67922e82016-04-01 16:48:57 +05301747 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05301748 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
1749 wmi_buf_t buf;
1750 uint16_t len = sizeof(*cmd);
1751
1752 buf = wmi_buf_alloc(wmi_handle, len);
1753 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301754 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301755 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05301756 }
1757 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
1758 WMITLV_SET_HDR(&cmd->tlv_header,
1759 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
1760 WMITLV_GET_STRUCT_TLVLEN
1761 (wmi_sta_smps_force_mode_cmd_fixed_param));
1762
1763 cmd->vdev_id = vdev_id;
1764
Houston Hoffmanb5168052016-04-14 02:18:01 -07001765 /* WMI_SMPS_FORCED_MODE values do not directly map
1766 * to SM power save values defined in the specification.
1767 * Make sure to send the right mapping.
1768 */
Govind Singh427ee5a2016-02-26 18:09:36 +05301769 switch (value) {
1770 case 0:
1771 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
1772 break;
1773 case 1:
1774 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
1775 break;
1776 case 2:
1777 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
1778 break;
1779 case 3:
1780 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
1781 break;
1782 default:
Govind Singhb53420c2016-03-09 14:32:57 +05301783 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
1784 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05301785 }
1786
Govind Singhb53420c2016-03-09 14:32:57 +05301787 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05301788
1789 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1790 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301791 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301792 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05301793 wmi_buf_free(buf);
1794 }
1795
1796 return ret;
1797}
1798
1799/**
1800 * send_set_smps_params_cmd_tlv() - set smps params
1801 * @wmi_handle: wmi handle
1802 * @vdev_id: vdev id
1803 * @value: value
1804 *
Govind Singhb53420c2016-03-09 14:32:57 +05301805 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05301806 */
Govind Singhb53420c2016-03-09 14:32:57 +05301807QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05301808 int value)
1809{
Govind Singh67922e82016-04-01 16:48:57 +05301810 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05301811 wmi_sta_smps_param_cmd_fixed_param *cmd;
1812 wmi_buf_t buf;
1813 uint16_t len = sizeof(*cmd);
1814
1815 buf = wmi_buf_alloc(wmi_handle, len);
1816 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301817 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301818 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05301819 }
1820 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
1821 WMITLV_SET_HDR(&cmd->tlv_header,
1822 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
1823 WMITLV_GET_STRUCT_TLVLEN
1824 (wmi_sta_smps_param_cmd_fixed_param));
1825
1826 cmd->vdev_id = vdev_id;
1827 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
1828 cmd->param =
1829 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
1830
Govind Singhb53420c2016-03-09 14:32:57 +05301831 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05301832 cmd->param);
1833
1834 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1835 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301836 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301837 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05301838 wmi_buf_free(buf);
1839 }
1840
1841 return ret;
1842}
1843
1844/**
1845 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
1846 * @wmi_handle: wmi handle
1847 * @noa: p2p power save parameters
1848 *
Govind Singh2edc80f2016-03-01 15:30:53 +05301849 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05301850 */
Govind Singhb53420c2016-03-09 14:32:57 +05301851QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05301852 struct p2p_ps_params *noa)
1853{
1854 wmi_p2p_set_noa_cmd_fixed_param *cmd;
1855 wmi_p2p_noa_descriptor *noa_discriptor;
1856 wmi_buf_t buf;
1857 uint8_t *buf_ptr;
1858 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05301859 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05301860 uint32_t duration;
1861
Govind Singhb53420c2016-03-09 14:32:57 +05301862 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05301863 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
1864 buf = wmi_buf_alloc(wmi_handle, len);
1865 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301866 WMI_LOGE("Failed to allocate memory");
1867 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05301868 goto end;
1869 }
1870
1871 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1872 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
1873 WMITLV_SET_HDR(&cmd->tlv_header,
1874 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
1875 WMITLV_GET_STRUCT_TLVLEN
1876 (wmi_p2p_set_noa_cmd_fixed_param));
1877 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
1878 cmd->vdev_id = noa->session_id;
1879 cmd->enable = (duration) ? true : false;
1880 cmd->num_noa = 1;
1881
1882 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
1883 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
1884 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
1885 sizeof
1886 (wmi_p2p_set_noa_cmd_fixed_param)
1887 + WMI_TLV_HDR_SIZE);
1888 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
1889 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
1890 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
1891 noa_discriptor->type_count = noa->count;
1892 noa_discriptor->duration = duration;
1893 noa_discriptor->interval = noa->interval;
1894 noa_discriptor->start_time = 0;
1895
Govind Singhb53420c2016-03-09 14:32:57 +05301896 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05301897 cmd->vdev_id, noa->count, noa_discriptor->duration,
1898 noa->interval);
1899 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1900 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301901 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301902 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05301903 wmi_buf_free(buf);
1904 }
1905
1906end:
Govind Singhb53420c2016-03-09 14:32:57 +05301907 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05301908 return status;
1909}
1910
1911
1912/**
1913 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
1914 * @wmi_handle: wmi handle
1915 * @noa: p2p opp power save parameters
1916 *
Govind Singh2edc80f2016-03-01 15:30:53 +05301917 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05301918 */
Govind Singhb53420c2016-03-09 14:32:57 +05301919QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05301920 struct p2p_ps_params *oppps)
1921{
1922 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
1923 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05301924 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05301925
Govind Singhb53420c2016-03-09 14:32:57 +05301926 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05301927 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1928 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301929 WMI_LOGE("Failed to allocate memory");
1930 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05301931 goto end;
1932 }
1933
1934 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
1935 WMITLV_SET_HDR(&cmd->tlv_header,
1936 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
1937 WMITLV_GET_STRUCT_TLVLEN
1938 (wmi_p2p_set_oppps_cmd_fixed_param));
1939 cmd->vdev_id = oppps->session_id;
1940 if (oppps->ctwindow)
1941 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
1942
1943 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05301944 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05301945 cmd->vdev_id, oppps->ctwindow);
1946 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
1947 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301948 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301949 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05301950 wmi_buf_free(buf);
1951 }
1952
1953end:
Govind Singhb53420c2016-03-09 14:32:57 +05301954 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05301955 return status;
1956}
1957
1958/**
1959 * send_get_temperature_cmd_tlv() - get pdev temperature req
1960 * @wmi_handle: wmi handle
1961 *
Govind Singhb53420c2016-03-09 14:32:57 +05301962 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05301963 */
Govind Singhb53420c2016-03-09 14:32:57 +05301964QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05301965{
1966 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
1967 wmi_buf_t wmi_buf;
1968 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
1969 uint8_t *buf_ptr;
1970
1971 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05301972 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
1973 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05301974 }
1975
1976 wmi_buf = wmi_buf_alloc(wmi_handle, len);
1977 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301978 WMI_LOGE(FL("wmi_buf_alloc failed"));
1979 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05301980 }
1981
1982 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1983
1984 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
1985 WMITLV_SET_HDR(&cmd->tlv_header,
1986 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
1987 WMITLV_GET_STRUCT_TLVLEN
1988 (wmi_pdev_get_temperature_cmd_fixed_param));
1989
1990 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
1991 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301992 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05301993 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05301994 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05301995 }
Govind Singh2edc80f2016-03-01 15:30:53 +05301996
Govind Singhb53420c2016-03-09 14:32:57 +05301997 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05301998}
1999
2000/**
2001 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
2002 * @wmi_handle: wmi handle
2003 * @vdevid: vdev id
2004 * @peer_addr: peer mac address
2005 * @auto_triggerparam: auto trigger parameters
2006 * @num_ac: number of access category
2007 *
2008 * This function sets the trigger
2009 * uapsd params such as service interval, delay interval
2010 * and suspend interval which will be used by the firmware
2011 * to send trigger frames periodically when there is no
2012 * traffic on the transmit side.
2013 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302014 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302015 */
Govind Singhb53420c2016-03-09 14:32:57 +05302016QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302017 struct sta_uapsd_trig_params *param)
2018{
2019 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302020 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302021 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
2022 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
2023 uint32_t i;
2024 wmi_buf_t buf;
2025 uint8_t *buf_ptr;
2026
2027 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2028 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302029 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302030 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302031 }
2032
2033 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2034 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
2035 WMITLV_SET_HDR(&cmd->tlv_header,
2036 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
2037 WMITLV_GET_STRUCT_TLVLEN
2038 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
2039 cmd->vdev_id = param->vdevid;
2040 cmd->num_ac = param->num_ac;
2041 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
2042
2043 /* TLV indicating array of structures to follow */
2044 buf_ptr += sizeof(*cmd);
2045 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
2046
2047 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302048 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302049
2050 /*
2051 * Update tag and length for uapsd auto trigger params (this will take
2052 * care of updating tag and length if it is not pre-filled by caller).
2053 */
2054 for (i = 0; i < param->num_ac; i++) {
2055 WMITLV_SET_HDR((buf_ptr +
2056 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
2057 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
2058 WMITLV_GET_STRUCT_TLVLEN
2059 (wmi_sta_uapsd_auto_trig_param));
2060 }
2061
2062 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2063 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302064 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302065 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302066 wmi_buf_free(buf);
2067 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05302068
Govind Singh427ee5a2016-02-26 18:09:36 +05302069 return ret;
2070}
2071
Govind Singh2edc80f2016-03-01 15:30:53 +05302072/**
2073 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
2074 * @wmi_handle: pointer to the wmi handle
2075 * @utc: pointer to the UTC time struct
2076 *
2077 * Return: 0 on succes
2078 */
Govind Singhb53420c2016-03-09 14:32:57 +05302079QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302080 struct ocb_utc_param *utc)
2081{
Govind Singh67922e82016-04-01 16:48:57 +05302082 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302083 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
2084 uint8_t *buf_ptr;
2085 uint32_t len, i;
2086 wmi_buf_t buf;
2087
2088 len = sizeof(*cmd);
2089 buf = wmi_buf_alloc(wmi_handle, len);
2090 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302091 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302092 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302093 }
2094
2095 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2096 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
2097 WMITLV_SET_HDR(&cmd->tlv_header,
2098 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
2099 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
2100 cmd->vdev_id = utc->vdev_id;
2101
2102 for (i = 0; i < SIZE_UTC_TIME; i++)
2103 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
2104
2105 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
2106 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
2107
2108 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2109 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302110 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302111 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302112 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302113 }
2114
Govind Singh67922e82016-04-01 16:48:57 +05302115 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302116}
2117
2118/**
2119 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
2120 * frames on a channel
2121 * @wmi_handle: pointer to the wmi handle
2122 * @timing_advert: pointer to the timing advertisement struct
2123 *
2124 * Return: 0 on succes
2125 */
Govind Singhb53420c2016-03-09 14:32:57 +05302126QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302127 struct ocb_timing_advert_param *timing_advert)
2128{
Govind Singh67922e82016-04-01 16:48:57 +05302129 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302130 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
2131 uint8_t *buf_ptr;
2132 uint32_t len, len_template;
2133 wmi_buf_t buf;
2134
2135 len = sizeof(*cmd) +
2136 WMI_TLV_HDR_SIZE;
2137
2138 len_template = timing_advert->template_length;
2139 /* Add padding to the template if needed */
2140 if (len_template % 4 != 0)
2141 len_template += 4 - (len_template % 4);
2142 len += len_template;
2143
2144 buf = wmi_buf_alloc(wmi_handle, len);
2145 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302146 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302147 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302148 }
2149
2150 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2151 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
2152 WMITLV_SET_HDR(&cmd->tlv_header,
2153 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
2154 WMITLV_GET_STRUCT_TLVLEN(
2155 wmi_ocb_start_timing_advert_cmd_fixed_param));
2156 cmd->vdev_id = timing_advert->vdev_id;
2157 cmd->repeat_rate = timing_advert->repeat_rate;
2158 cmd->channel_freq = timing_advert->chan_freq;
2159 cmd->timestamp_offset = timing_advert->timestamp_offset;
2160 cmd->time_value_offset = timing_advert->time_value_offset;
2161 cmd->timing_advert_template_length = timing_advert->template_length;
2162 buf_ptr += sizeof(*cmd);
2163
2164 /* Add the timing advert template */
2165 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2166 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05302167 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05302168 (uint8_t *)timing_advert->template_value,
2169 timing_advert->template_length);
2170
2171 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2172 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302173 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302174 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302175 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302176 }
2177
Govind Singh67922e82016-04-01 16:48:57 +05302178 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302179}
2180
2181/**
2182 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
2183 * on a channel
2184 * @wmi_handle: pointer to the wmi handle
2185 * @timing_advert: pointer to the timing advertisement struct
2186 *
2187 * Return: 0 on succes
2188 */
Govind Singhb53420c2016-03-09 14:32:57 +05302189QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302190 struct ocb_timing_advert_param *timing_advert)
2191{
Govind Singh67922e82016-04-01 16:48:57 +05302192 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302193 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
2194 uint8_t *buf_ptr;
2195 uint32_t len;
2196 wmi_buf_t buf;
2197
2198 len = sizeof(*cmd);
2199 buf = wmi_buf_alloc(wmi_handle, len);
2200 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302201 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302202 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302203 }
2204
2205 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2206 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
2207 WMITLV_SET_HDR(&cmd->tlv_header,
2208 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
2209 WMITLV_GET_STRUCT_TLVLEN(
2210 wmi_ocb_stop_timing_advert_cmd_fixed_param));
2211 cmd->vdev_id = timing_advert->vdev_id;
2212 cmd->channel_freq = timing_advert->chan_freq;
2213
2214 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2215 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302216 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302217 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302218 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302219 }
2220
Govind Singh67922e82016-04-01 16:48:57 +05302221 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302222}
2223
2224/**
2225 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
2226 * @wmi_handle: pointer to the wmi handle
2227 * @request: pointer to the request
2228 *
2229 * Return: 0 on succes
2230 */
Govind Singhb53420c2016-03-09 14:32:57 +05302231QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302232 uint8_t vdev_id)
2233{
Govind Singhb53420c2016-03-09 14:32:57 +05302234 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302235 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
2236 uint8_t *buf_ptr;
2237 wmi_buf_t buf;
2238 int32_t len;
2239
2240 len = sizeof(*cmd);
2241 buf = wmi_buf_alloc(wmi_handle, len);
2242 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302243 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302244 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302245 }
2246 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2247
2248 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302249 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302250 WMITLV_SET_HDR(&cmd->tlv_header,
2251 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
2252 WMITLV_GET_STRUCT_TLVLEN(
2253 wmi_ocb_get_tsf_timer_cmd_fixed_param));
2254 cmd->vdev_id = vdev_id;
2255
2256 /* Send the WMI command */
2257 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2258 WMI_OCB_GET_TSF_TIMER_CMDID);
2259 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05302260 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302261 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302262 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302263 }
2264
Govind Singh67922e82016-04-01 16:48:57 +05302265 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302266}
2267
2268/**
2269 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
2270 * @wmi_handle: pointer to the wmi handle
2271 * @get_stats_param: pointer to the dcc stats
2272 *
2273 * Return: 0 on succes
2274 */
Govind Singhb53420c2016-03-09 14:32:57 +05302275QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302276 struct dcc_get_stats_param *get_stats_param)
2277{
Govind Singh67922e82016-04-01 16:48:57 +05302278 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302279 wmi_dcc_get_stats_cmd_fixed_param *cmd;
2280 wmi_dcc_channel_stats_request *channel_stats_array;
2281 wmi_buf_t buf;
2282 uint8_t *buf_ptr;
2283 uint32_t len;
2284 uint32_t i;
2285
2286 /* Validate the input */
2287 if (get_stats_param->request_array_len !=
2288 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302289 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05302290 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302291 }
2292
2293 /* Allocate memory for the WMI command */
2294 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
2295 get_stats_param->request_array_len;
2296
2297 buf = wmi_buf_alloc(wmi_handle, len);
2298 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302299 WMI_LOGE(FL("wmi_buf_alloc failed"));
2300 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302301 }
2302
2303 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302304 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302305
2306 /* Populate the WMI command */
2307 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
2308 buf_ptr += sizeof(*cmd);
2309
2310 WMITLV_SET_HDR(&cmd->tlv_header,
2311 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
2312 WMITLV_GET_STRUCT_TLVLEN(
2313 wmi_dcc_get_stats_cmd_fixed_param));
2314 cmd->vdev_id = get_stats_param->vdev_id;
2315 cmd->num_channels = get_stats_param->channel_count;
2316
2317 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2318 get_stats_param->request_array_len);
2319 buf_ptr += WMI_TLV_HDR_SIZE;
2320
2321 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302322 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05302323 get_stats_param->request_array_len);
2324 for (i = 0; i < cmd->num_channels; i++)
2325 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
2326 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
2327 WMITLV_GET_STRUCT_TLVLEN(
2328 wmi_dcc_channel_stats_request));
2329
2330 /* Send the WMI command */
2331 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2332 WMI_DCC_GET_STATS_CMDID);
2333
Govind Singh67922e82016-04-01 16:48:57 +05302334 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302335 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05302336 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302337 }
2338
Govind Singh67922e82016-04-01 16:48:57 +05302339 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302340}
2341
2342/**
2343 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
2344 * @wmi_handle: pointer to the wmi handle
2345 * @vdev_id: vdev id
2346 * @dcc_stats_bitmap: dcc status bitmap
2347 *
2348 * Return: 0 on succes
2349 */
Govind Singhb53420c2016-03-09 14:32:57 +05302350QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302351 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
2352{
Govind Singh67922e82016-04-01 16:48:57 +05302353 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302354 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
2355 wmi_buf_t buf;
2356 uint8_t *buf_ptr;
2357 uint32_t len;
2358
2359 /* Allocate memory for the WMI command */
2360 len = sizeof(*cmd);
2361
2362 buf = wmi_buf_alloc(wmi_handle, len);
2363 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302364 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302365 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302366 }
2367
2368 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302369 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302370
2371 /* Populate the WMI command */
2372 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
2373
2374 WMITLV_SET_HDR(&cmd->tlv_header,
2375 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
2376 WMITLV_GET_STRUCT_TLVLEN(
2377 wmi_dcc_clear_stats_cmd_fixed_param));
2378 cmd->vdev_id = vdev_id;
2379 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
2380
2381 /* Send the WMI command */
2382 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2383 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302384 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302385 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05302386 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302387 }
2388
Govind Singh67922e82016-04-01 16:48:57 +05302389 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302390}
2391
2392/**
2393 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
2394 * @wmi_handle: pointer to the wmi handle
2395 * @update_ndl_param: pointer to the request parameters
2396 *
2397 * Return: 0 on success
2398 */
Govind Singhb53420c2016-03-09 14:32:57 +05302399QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302400 struct dcc_update_ndl_param *update_ndl_param)
2401{
Govind Singhb53420c2016-03-09 14:32:57 +05302402 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05302403 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
2404 wmi_dcc_ndl_chan *ndl_chan_array;
2405 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
2406 uint32_t active_state_count;
2407 wmi_buf_t buf;
2408 uint8_t *buf_ptr;
2409 uint32_t len;
2410 uint32_t i;
2411
2412 /* validate the input */
2413 if (update_ndl_param->dcc_ndl_chan_list_len !=
2414 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302415 WMI_LOGE(FL("Invalid parameter"));
2416 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302417 }
2418 active_state_count = 0;
2419 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
2420 for (i = 0; i < update_ndl_param->channel_count; i++)
2421 active_state_count +=
2422 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
2423 if (update_ndl_param->dcc_ndl_active_state_list_len !=
2424 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302425 WMI_LOGE(FL("Invalid parameter"));
2426 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302427 }
2428
2429 /* Allocate memory for the WMI command */
2430 len = sizeof(*cmd) +
2431 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
2432 WMI_TLV_HDR_SIZE +
2433 update_ndl_param->dcc_ndl_active_state_list_len;
2434
2435 buf = wmi_buf_alloc(wmi_handle, len);
2436 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302437 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302438 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302439 }
2440
2441 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302442 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05302443
2444 /* Populate the WMI command */
2445 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
2446 buf_ptr += sizeof(*cmd);
2447
2448 WMITLV_SET_HDR(&cmd->tlv_header,
2449 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
2450 WMITLV_GET_STRUCT_TLVLEN(
2451 wmi_dcc_update_ndl_cmd_fixed_param));
2452 cmd->vdev_id = update_ndl_param->vdev_id;
2453 cmd->num_channel = update_ndl_param->channel_count;
2454
2455 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2456 update_ndl_param->dcc_ndl_chan_list_len);
2457 buf_ptr += WMI_TLV_HDR_SIZE;
2458
2459 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302460 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05302461 update_ndl_param->dcc_ndl_chan_list_len);
2462 for (i = 0; i < cmd->num_channel; i++)
2463 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
2464 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
2465 WMITLV_GET_STRUCT_TLVLEN(
2466 wmi_dcc_ndl_chan));
2467 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
2468
2469 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2470 update_ndl_param->dcc_ndl_active_state_list_len);
2471 buf_ptr += WMI_TLV_HDR_SIZE;
2472
2473 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302474 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05302475 update_ndl_param->dcc_ndl_active_state_list,
2476 update_ndl_param->dcc_ndl_active_state_list_len);
2477 for (i = 0; i < active_state_count; i++) {
2478 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
2479 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
2480 WMITLV_GET_STRUCT_TLVLEN(
2481 wmi_dcc_ndl_active_state_config));
2482 }
2483 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
2484
2485 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05302486 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05302487 WMI_DCC_UPDATE_NDL_CMDID);
2488 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05302489 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302490 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05302491 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302492 }
2493
Govind Singh67922e82016-04-01 16:48:57 +05302494 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05302495}
2496
2497/**
2498 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
2499 * @wmi_handle: pointer to the wmi handle
2500 * @config: the OCB configuration
2501 *
2502 * Return: 0 on success
2503 */
Govind Singhb53420c2016-03-09 14:32:57 +05302504QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05302505 struct ocb_config_param *config, uint32_t *ch_mhz)
2506{
Govind Singh67922e82016-04-01 16:48:57 +05302507 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302508 wmi_ocb_set_config_cmd_fixed_param *cmd;
2509 wmi_channel *chan;
2510 wmi_ocb_channel *ocb_chan;
2511 wmi_qos_parameter *qos_param;
2512 wmi_dcc_ndl_chan *ndl_chan;
2513 wmi_dcc_ndl_active_state_config *ndl_active_config;
2514 wmi_ocb_schedule_element *sched_elem;
2515 uint8_t *buf_ptr;
2516 wmi_buf_t buf;
2517 int32_t len;
2518 int32_t i, j, active_state_count;
2519
2520 /*
2521 * Validate the dcc_ndl_chan_list_len and count the number of active
2522 * states. Validate dcc_ndl_active_state_list_len.
2523 */
2524 active_state_count = 0;
2525 if (config->dcc_ndl_chan_list_len) {
2526 if (!config->dcc_ndl_chan_list ||
2527 config->dcc_ndl_chan_list_len !=
2528 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302529 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05302530 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05302531 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302532 }
2533
2534 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
2535 i < config->channel_count; ++i, ++ndl_chan)
2536 active_state_count +=
2537 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
2538
2539 if (active_state_count) {
2540 if (!config->dcc_ndl_active_state_list ||
2541 config->dcc_ndl_active_state_list_len !=
2542 active_state_count *
2543 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302544 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05302545 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05302546 }
2547 }
2548 }
2549
2550 len = sizeof(*cmd) +
2551 WMI_TLV_HDR_SIZE + config->channel_count *
2552 sizeof(wmi_channel) +
2553 WMI_TLV_HDR_SIZE + config->channel_count *
2554 sizeof(wmi_ocb_channel) +
2555 WMI_TLV_HDR_SIZE + config->channel_count *
2556 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
2557 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
2558 WMI_TLV_HDR_SIZE + active_state_count *
2559 sizeof(wmi_dcc_ndl_active_state_config) +
2560 WMI_TLV_HDR_SIZE + config->schedule_size *
2561 sizeof(wmi_ocb_schedule_element);
2562 buf = wmi_buf_alloc(wmi_handle, len);
2563 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302564 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05302565 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05302566 }
2567
2568 buf_ptr = (uint8_t *)wmi_buf_data(buf);
2569 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
2570 WMITLV_SET_HDR(&cmd->tlv_header,
2571 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
2572 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
2573 cmd->vdev_id = config->session_id;
2574 cmd->channel_count = config->channel_count;
2575 cmd->schedule_size = config->schedule_size;
2576 cmd->flags = config->flags;
2577 buf_ptr += sizeof(*cmd);
2578
2579 /* Add the wmi_channel info */
2580 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2581 config->channel_count*sizeof(wmi_channel));
2582 buf_ptr += WMI_TLV_HDR_SIZE;
2583 for (i = 0; i < config->channel_count; i++) {
2584 chan = (wmi_channel *)buf_ptr;
2585 WMITLV_SET_HDR(&chan->tlv_header,
2586 WMITLV_TAG_STRUC_wmi_channel,
2587 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2588 chan->mhz = config->channels[i].chan_freq;
2589 chan->band_center_freq1 = config->channels[i].chan_freq;
2590 chan->band_center_freq2 = 0;
2591 chan->info = 0;
2592
2593 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
2594 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
2595 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
2596 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
2597 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
2598 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
2599 config->channels[i].antenna_max);
2600
2601 if (config->channels[i].bandwidth < 10)
2602 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
2603 else if (config->channels[i].bandwidth < 20)
2604 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
2605 buf_ptr += sizeof(*chan);
2606 }
2607
2608 /* Add the wmi_ocb_channel info */
2609 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2610 config->channel_count*sizeof(wmi_ocb_channel));
2611 buf_ptr += WMI_TLV_HDR_SIZE;
2612 for (i = 0; i < config->channel_count; i++) {
2613 ocb_chan = (wmi_ocb_channel *)buf_ptr;
2614 WMITLV_SET_HDR(&ocb_chan->tlv_header,
2615 WMITLV_TAG_STRUC_wmi_ocb_channel,
2616 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
2617 ocb_chan->bandwidth = config->channels[i].bandwidth;
2618 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2619 config->channels[i].mac_address.bytes,
2620 &ocb_chan->mac_address);
2621 buf_ptr += sizeof(*ocb_chan);
2622 }
2623
2624 /* Add the wmi_qos_parameter info */
2625 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2626 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
2627 buf_ptr += WMI_TLV_HDR_SIZE;
2628 /* WMI_MAX_NUM_AC parameters for each channel */
2629 for (i = 0; i < config->channel_count; i++) {
2630 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
2631 qos_param = (wmi_qos_parameter *)buf_ptr;
2632 WMITLV_SET_HDR(&qos_param->tlv_header,
2633 WMITLV_TAG_STRUC_wmi_qos_parameter,
2634 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
2635 qos_param->aifsn =
2636 config->channels[i].qos_params[j].aifsn;
2637 qos_param->cwmin =
2638 config->channels[i].qos_params[j].cwmin;
2639 qos_param->cwmax =
2640 config->channels[i].qos_params[j].cwmax;
2641 buf_ptr += sizeof(*qos_param);
2642 }
2643 }
2644
2645 /* Add the wmi_dcc_ndl_chan (per channel) */
2646 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2647 config->dcc_ndl_chan_list_len);
2648 buf_ptr += WMI_TLV_HDR_SIZE;
2649 if (config->dcc_ndl_chan_list_len) {
2650 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302651 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05302652 config->dcc_ndl_chan_list_len);
2653 for (i = 0; i < config->channel_count; i++)
2654 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
2655 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
2656 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
2657 buf_ptr += config->dcc_ndl_chan_list_len;
2658 }
2659
2660 /* Add the wmi_dcc_ndl_active_state_config */
2661 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
2662 sizeof(wmi_dcc_ndl_active_state_config));
2663 buf_ptr += WMI_TLV_HDR_SIZE;
2664 if (active_state_count) {
2665 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05302666 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05302667 config->dcc_ndl_active_state_list,
2668 active_state_count * sizeof(*ndl_active_config));
2669 for (i = 0; i < active_state_count; ++i)
2670 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
2671 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
2672 WMITLV_GET_STRUCT_TLVLEN(
2673 wmi_dcc_ndl_active_state_config));
2674 buf_ptr += active_state_count *
2675 sizeof(*ndl_active_config);
2676 }
2677
2678 /* Add the wmi_ocb_schedule_element info */
2679 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2680 config->schedule_size * sizeof(wmi_ocb_schedule_element));
2681 buf_ptr += WMI_TLV_HDR_SIZE;
2682 for (i = 0; i < config->schedule_size; i++) {
2683 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
2684 WMITLV_SET_HDR(&sched_elem->tlv_header,
2685 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
2686 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
2687 sched_elem->channel_freq = config->schedule[i].chan_freq;
2688 sched_elem->total_duration = config->schedule[i].total_duration;
2689 sched_elem->guard_interval = config->schedule[i].guard_interval;
2690 buf_ptr += sizeof(*sched_elem);
2691 }
2692
2693
2694 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2695 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302696 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302697 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05302698 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05302699 }
2700
Govind Singh67922e82016-04-01 16:48:57 +05302701 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05302702}
Govind Singh17a9cfa2016-03-01 15:54:59 +05302703
2704/**
2705 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
2706 * @wmi_handle: wmi handle
2707 * @mcc_adaptive_scheduler: enable/disable
2708 *
2709 * This function enable/disable mcc adaptive scheduler in fw.
2710 *
Govind Singhb53420c2016-03-09 14:32:57 +05302711 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05302712 */
Govind Singhb53420c2016-03-09 14:32:57 +05302713QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07002714 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
2715 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05302716{
Govind Singh67922e82016-04-01 16:48:57 +05302717 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302718 wmi_buf_t buf = 0;
2719 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
2720 uint16_t len =
2721 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
2722
2723 buf = wmi_buf_alloc(wmi_handle, len);
2724 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302725 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
2726 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302727 }
2728 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
2729 wmi_buf_data(buf);
2730
2731 WMITLV_SET_HDR(&cmd->tlv_header,
2732 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
2733 WMITLV_GET_STRUCT_TLVLEN
2734 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
2735 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07002736 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302737
2738 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2739 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302740 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302741 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05302742 " adaptive scheduler command", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302743 qdf_nbuf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05302744 }
Govind Singh67922e82016-04-01 16:48:57 +05302745
2746 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302747}
2748
2749/**
2750 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
2751 * @wmi: wmi handle
2752 * @mcc_channel: mcc channel
2753 * @mcc_channel_time_latency: MCC channel time latency.
2754 *
2755 * Currently used to set time latency for an MCC vdev/adapter using operating
2756 * channel of it and channel number. The info is provided run time using
2757 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
2758 *
2759 * Return: CDF status
2760 */
Govind Singhb53420c2016-03-09 14:32:57 +05302761QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05302762 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
2763{
Govind Singh67922e82016-04-01 16:48:57 +05302764 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302765 wmi_buf_t buf = 0;
2766 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
2767 uint16_t len = 0;
2768 uint8_t *buf_ptr = NULL;
2769 wmi_resmgr_chan_latency chan_latency;
2770 /* Note: we only support MCC time latency for a single channel */
2771 uint32_t num_channels = 1;
2772 uint32_t chan1_freq = mcc_channel_freq;
2773 uint32_t latency_chan1 = mcc_channel_time_latency;
2774
2775
2776 /* If 0ms latency is provided, then FW will set to a default.
2777 * Otherwise, latency must be at least 30ms.
2778 */
2779 if ((latency_chan1 > 0) &&
2780 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302781 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05302782 "Minimum is 30ms (or 0 to use default value by "
2783 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05302784 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302785 }
2786
2787 /* Set WMI CMD for channel time latency here */
2788 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
2789 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
2790 num_channels * sizeof(wmi_resmgr_chan_latency);
2791 buf = wmi_buf_alloc(wmi_handle, len);
2792 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302793 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2794 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302795 }
2796 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2797 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
2798 wmi_buf_data(buf);
2799 WMITLV_SET_HDR(&cmdTL->tlv_header,
2800 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
2801 WMITLV_GET_STRUCT_TLVLEN
2802 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
2803 cmdTL->num_chans = num_channels;
2804 /* Update channel time latency information for home channel(s) */
2805 buf_ptr += sizeof(*cmdTL);
2806 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2807 num_channels * sizeof(wmi_resmgr_chan_latency));
2808 buf_ptr += WMI_TLV_HDR_SIZE;
2809 chan_latency.chan_mhz = chan1_freq;
2810 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05302811 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05302812 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2813 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302814 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302815 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05302816 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302817 qdf_nbuf_free(buf);
2818 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05302819 }
Govind Singh67922e82016-04-01 16:48:57 +05302820
2821 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302822}
2823
2824/**
2825 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
2826 * @wmi: wmi handle
2827 * @adapter_1_chan_number: adapter 1 channel number
2828 * @adapter_1_quota: adapter 1 quota
2829 * @adapter_2_chan_number: adapter 2 channel number
2830 *
2831 * Return: CDF status
2832 */
Govind Singhb53420c2016-03-09 14:32:57 +05302833QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05302834 uint32_t adapter_1_chan_freq,
2835 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
2836{
Govind Singh67922e82016-04-01 16:48:57 +05302837 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302838 wmi_buf_t buf = 0;
2839 uint16_t len = 0;
2840 uint8_t *buf_ptr = NULL;
2841 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
2842 wmi_resmgr_chan_time_quota chan_quota;
2843 uint32_t quota_chan1 = adapter_1_quota;
2844 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
2845 uint32_t quota_chan2 = 100 - quota_chan1;
2846 /* Note: setting time quota for MCC requires info for 2 channels */
2847 uint32_t num_channels = 2;
2848 uint32_t chan1_freq = adapter_1_chan_freq;
2849 uint32_t chan2_freq = adapter_2_chan_freq;
2850
Govind Singhb53420c2016-03-09 14:32:57 +05302851 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05302852 "freq2:%dMHz, Quota2:%dms", __func__,
2853 chan1_freq, quota_chan1, chan2_freq,
2854 quota_chan2);
2855
2856 /*
2857 * Perform sanity check on time quota values provided.
2858 */
2859 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
2860 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05302861 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05302862 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05302863 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302864 }
2865 /* Set WMI CMD for channel time quota here */
2866 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
2867 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
2868 num_channels * sizeof(wmi_resmgr_chan_time_quota);
2869 buf = wmi_buf_alloc(wmi_handle, len);
2870 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302871 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2872 QDF_ASSERT(0);
2873 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302874 }
2875 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2876 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
2877 wmi_buf_data(buf);
2878 WMITLV_SET_HDR(&cmdTQ->tlv_header,
2879 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
2880 WMITLV_GET_STRUCT_TLVLEN
2881 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
2882 cmdTQ->num_chans = num_channels;
2883
2884 /* Update channel time quota information for home channel(s) */
2885 buf_ptr += sizeof(*cmdTQ);
2886 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2887 num_channels * sizeof(wmi_resmgr_chan_time_quota));
2888 buf_ptr += WMI_TLV_HDR_SIZE;
2889 chan_quota.chan_mhz = chan1_freq;
2890 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05302891 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05302892 /* Construct channel and quota record for the 2nd MCC mode. */
2893 buf_ptr += sizeof(chan_quota);
2894 chan_quota.chan_mhz = chan2_freq;
2895 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05302896 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05302897
2898 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2899 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302900 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302901 WMI_LOGE("Failed to send MCC Channel Time Quota command");
2902 qdf_nbuf_free(buf);
2903 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05302904 }
Govind Singh67922e82016-04-01 16:48:57 +05302905
2906 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302907}
2908
2909/**
2910 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
2911 * @wmi_handle: Pointer to wmi handle
2912 * @thermal_info: Thermal command information
2913 *
2914 * This function sends the thermal management command
2915 * to the firmware
2916 *
Govind Singhb53420c2016-03-09 14:32:57 +05302917 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05302918 */
Govind Singhb53420c2016-03-09 14:32:57 +05302919QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05302920 struct thermal_cmd_params *thermal_info)
2921{
2922 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
2923 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05302924 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302925 uint32_t len = 0;
2926
2927 len = sizeof(*cmd);
2928
2929 buf = wmi_buf_alloc(wmi_handle, len);
2930 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302931 WMI_LOGE("Failed to allocate buffer to send set key cmd");
2932 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302933 }
2934
2935 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
2936
2937 WMITLV_SET_HDR(&cmd->tlv_header,
2938 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
2939 WMITLV_GET_STRUCT_TLVLEN
2940 (wmi_thermal_mgmt_cmd_fixed_param));
2941
2942 cmd->lower_thresh_degreeC = thermal_info->min_temp;
2943 cmd->upper_thresh_degreeC = thermal_info->max_temp;
2944 cmd->enable = thermal_info->thermal_enable;
2945
Govind Singhb53420c2016-03-09 14:32:57 +05302946 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05302947 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
2948
2949 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2950 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302951 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302952 qdf_nbuf_free(buf);
2953 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05302954 }
2955
Govind Singh67922e82016-04-01 16:48:57 +05302956 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302957}
2958
2959
2960/**
2961 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05302962 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05302963 * @wmi_lro_cmd: Pointer to LRO configuration parameters
2964 *
2965 * This function sends down the LRO configuration parameters to
2966 * the firmware to enable LRO, sets the TCP flags and sets the
2967 * seed values for the toeplitz hash generation
2968 *
Govind Singhb53420c2016-03-09 14:32:57 +05302969 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05302970 */
Govind Singhb53420c2016-03-09 14:32:57 +05302971QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05302972 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
2973{
2974 wmi_lro_info_cmd_fixed_param *cmd;
2975 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302976 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302977
2978
2979 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2980 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302981 WMI_LOGE("Failed to allocate buffer to send set key cmd");
2982 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05302983 }
2984
2985 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
2986
2987 WMITLV_SET_HDR(&cmd->tlv_header,
2988 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
2989 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
2990
2991 cmd->lro_enable = wmi_lro_cmd->lro_enable;
2992 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
2993 wmi_lro_cmd->tcp_flag);
2994 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
2995 wmi_lro_cmd->tcp_flag_mask);
2996 cmd->toeplitz_hash_ipv4_0_3 =
2997 wmi_lro_cmd->toeplitz_hash_ipv4[0];
2998 cmd->toeplitz_hash_ipv4_4_7 =
2999 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3000 cmd->toeplitz_hash_ipv4_8_11 =
3001 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3002 cmd->toeplitz_hash_ipv4_12_15 =
3003 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3004 cmd->toeplitz_hash_ipv4_16 =
3005 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3006
3007 cmd->toeplitz_hash_ipv6_0_3 =
3008 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3009 cmd->toeplitz_hash_ipv6_4_7 =
3010 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3011 cmd->toeplitz_hash_ipv6_8_11 =
3012 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3013 cmd->toeplitz_hash_ipv6_12_15 =
3014 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3015 cmd->toeplitz_hash_ipv6_16_19 =
3016 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3017 cmd->toeplitz_hash_ipv6_20_23 =
3018 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3019 cmd->toeplitz_hash_ipv6_24_27 =
3020 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3021 cmd->toeplitz_hash_ipv6_28_31 =
3022 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3023 cmd->toeplitz_hash_ipv6_32_35 =
3024 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3025 cmd->toeplitz_hash_ipv6_36_39 =
3026 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3027 cmd->toeplitz_hash_ipv6_40 =
3028 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3029
Govind Singhb53420c2016-03-09 14:32:57 +05303030 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303031 cmd->lro_enable, cmd->tcp_flag_u32);
3032
3033 status = wmi_unified_cmd_send(wmi_handle, buf,
3034 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303035 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303036 qdf_nbuf_free(buf);
3037 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303038 }
3039
Govind Singh67922e82016-04-01 16:48:57 +05303040 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303041}
3042
Govind Singh4eacd2b2016-03-07 14:24:22 +05303043/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303044 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3045 * @wmi_handle: Pointer to wmi handle
3046 * @rate_report_params: Pointer to peer rate report parameters
3047 *
3048 *
3049 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3050 */
3051QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
3052 struct wmi_peer_rate_report_params *rate_report_params)
3053{
3054 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3055 wmi_buf_t buf = NULL;
3056 QDF_STATUS status = 0;
3057 uint32_t len = 0;
3058 uint32_t i, j;
3059
3060 len = sizeof(*cmd);
3061
3062 buf = wmi_buf_alloc(wmi_handle, len);
3063 if (!buf) {
3064 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
3065 return QDF_STATUS_E_FAILURE;
3066 }
3067
3068 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3069 wmi_buf_data(buf);
3070
3071 WMITLV_SET_HDR(
3072 &cmd->tlv_header,
3073 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3074 WMITLV_GET_STRUCT_TLVLEN(
3075 wmi_peer_set_rate_report_condition_fixed_param));
3076
3077 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3078 cmd->report_backoff_time = rate_report_params->backoff_time;
3079 cmd->report_timer_period = rate_report_params->timer_period;
3080 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
3081 cmd->cond_per_phy[i].val_cond_flags =
3082 rate_report_params->report_per_phy[i].cond_flags;
3083 cmd->cond_per_phy[i].rate_delta.min_delta =
3084 rate_report_params->report_per_phy[i].delta.delta_min;
3085 cmd->cond_per_phy[i].rate_delta.percentage =
3086 rate_report_params->report_per_phy[i].delta.percent;
3087 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3088 cmd->cond_per_phy[i].rate_threshold[j] =
3089 rate_report_params->report_per_phy[i].
3090 report_rate_threshold[j];
3091 }
3092 }
3093
3094 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
3095 cmd->enable_rate_report,
3096 cmd->report_backoff_time, cmd->report_timer_period);
3097
3098 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3099 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3100 if (QDF_IS_STATUS_ERROR(status)) {
3101 qdf_nbuf_free(buf);
3102 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3103 __func__);
3104 }
3105 return status;
3106}
3107
3108/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303109 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3110 * @wmi_handle: wmi handle
3111 * @param: bcn ll cmd parameter
3112 *
Govind Singhb53420c2016-03-09 14:32:57 +05303113 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303114 */
Govind Singhb53420c2016-03-09 14:32:57 +05303115QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303116 wmi_bcn_send_from_host_cmd_fixed_param *param)
3117{
3118 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3119 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303120 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303121
3122 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3123 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303124 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3125 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303126 }
3127
3128 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3129 WMITLV_SET_HDR(&cmd->tlv_header,
3130 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3131 WMITLV_GET_STRUCT_TLVLEN
3132 (wmi_bcn_send_from_host_cmd_fixed_param));
3133 cmd->vdev_id = param->vdev_id;
3134 cmd->data_len = param->data_len;
3135 cmd->frame_ctrl = param->frame_ctrl;
3136 cmd->frag_ptr = param->frag_ptr;
3137 cmd->dtim_flag = param->dtim_flag;
3138
3139 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3140 WMI_PDEV_SEND_BCN_CMDID);
3141
Govind Singh67922e82016-04-01 16:48:57 +05303142 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303143 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303144 wmi_buf_free(wmi_buf);
3145 }
3146
3147 return ret;
3148}
3149
3150/**
3151 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
3152 * @wmi_handle: wmi handle
3153 * @vdev_id: vdev id
3154 * @max_retries: max retries
3155 * @retry_interval: retry interval
3156 * This function sets sta query related parameters in fw.
3157 *
Govind Singhb53420c2016-03-09 14:32:57 +05303158 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303159 */
3160
Govind Singhb53420c2016-03-09 14:32:57 +05303161QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303162 uint8_t vdev_id, uint32_t max_retries,
3163 uint32_t retry_interval)
3164{
3165 wmi_buf_t buf;
3166 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
3167 int len;
3168
3169 len = sizeof(*cmd);
3170 buf = wmi_buf_alloc(wmi_handle, len);
3171 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303172 WMI_LOGE(FL("wmi_buf_alloc failed"));
3173 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303174 }
3175
3176 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
3177 WMITLV_SET_HDR(&cmd->tlv_header,
3178 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
3179 WMITLV_GET_STRUCT_TLVLEN
3180 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
3181
3182
3183 cmd->vdev_id = vdev_id;
3184 cmd->sa_query_max_retry_count = max_retries;
3185 cmd->sa_query_retry_interval = retry_interval;
3186
Govind Singhb53420c2016-03-09 14:32:57 +05303187 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303188 vdev_id, retry_interval, max_retries);
3189
3190 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3191 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303192 WMI_LOGE(FL("Failed to offload STA SA Query"));
3193 qdf_nbuf_free(buf);
3194 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303195 }
3196
Govind Singhb53420c2016-03-09 14:32:57 +05303197 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303198 return 0;
3199}
3200
3201/**
3202 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
3203 * @wmi_handle: wmi handle
3204 * @params: sta keep alive parameter
3205 *
3206 * This function sets keep alive related parameters in fw.
3207 *
3208 * Return: CDF status
3209 */
Govind Singhb53420c2016-03-09 14:32:57 +05303210QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303211 struct sta_params *params)
3212{
3213 wmi_buf_t buf;
3214 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
3215 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
3216 uint8_t *buf_ptr;
3217 int len;
Govind Singh67922e82016-04-01 16:48:57 +05303218 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303219
Govind Singhb53420c2016-03-09 14:32:57 +05303220 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303221
Govind Singh4eacd2b2016-03-07 14:24:22 +05303222 len = sizeof(*cmd) + sizeof(*arp_rsp);
3223 buf = wmi_buf_alloc(wmi_handle, len);
3224 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303225 WMI_LOGE("wmi_buf_alloc failed");
3226 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303227 }
3228
3229 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
3230 buf_ptr = (uint8_t *) cmd;
3231 WMITLV_SET_HDR(&cmd->tlv_header,
3232 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
3233 WMITLV_GET_STRUCT_TLVLEN
3234 (WMI_STA_KEEPALIVE_CMD_fixed_param));
3235 cmd->interval = params->timeperiod;
3236 cmd->enable = (params->timeperiod) ? 1 : 0;
3237 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05303238 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303239 params->timeperiod, params->method);
3240 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
3241 WMITLV_SET_HDR(&arp_rsp->tlv_header,
3242 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
3243 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
3244
3245 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
3246 if ((NULL == params->hostv4addr) ||
3247 (NULL == params->destv4addr) ||
3248 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303249 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05303250 "destv4addr:%p destmac:%p ", __func__,
3251 params->hostv4addr, params->destv4addr, params->destmac);
Govind Singhb53420c2016-03-09 14:32:57 +05303252 qdf_nbuf_free(buf);
3253 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303254 }
3255 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05303256 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303257 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05303258 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303259 WMI_IPV4_ADDR_LEN);
3260 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
3261 } else {
3262 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
3263 }
3264
Govind Singh67922e82016-04-01 16:48:57 +05303265 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3266 WMI_STA_KEEPALIVE_CMDID);
3267 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303268 WMI_LOGE("Failed to set KeepAlive");
3269 qdf_nbuf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303270 }
3271
Govind Singhb53420c2016-03-09 14:32:57 +05303272 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303273 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303274}
3275
3276/**
3277 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
3278 * @wmi_handle: wmi handle
3279 * @if_id: vdev id
3280 * @gtx_info: GTX config params
3281 *
3282 * This function set GTX related params in firmware.
3283 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303284 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303285 */
Govind Singhb53420c2016-03-09 14:32:57 +05303286QDF_STATUS send_vdev_set_gtx_cfg_cmd_tlv(wmi_unified_t wmi_handle, uint32_t if_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303287 struct wmi_gtx_config *gtx_info)
3288{
3289 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
3290 wmi_buf_t buf;
3291 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
3292 buf = wmi_buf_alloc(wmi_handle, len);
3293 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303294 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303295 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303296 }
3297 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
3298 WMITLV_SET_HDR(&cmd->tlv_header,
3299 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
3300 WMITLV_GET_STRUCT_TLVLEN
3301 (wmi_vdev_set_gtx_params_cmd_fixed_param));
3302 cmd->vdev_id = if_id;
3303
3304 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
3305 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
3306 cmd->userGtxMask = gtx_info->gtx_usrcfg;
3307 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
3308 cmd->gtxPERMargin = gtx_info->gtx_margin;
3309 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
3310 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
3311 cmd->gtxBWMask = gtx_info->gtx_bwmask;
3312
Govind Singhb53420c2016-03-09 14:32:57 +05303313 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05303314 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
3315 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
3316 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
3317 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
3318
3319 return wmi_unified_cmd_send(wmi_handle, buf, len,
3320 WMI_VDEV_SET_GTX_PARAMS_CMDID);
3321}
3322
3323/**
3324 * send_process_update_edca_param_cmd_tlv() - update EDCA params
3325 * @wmi_handle: wmi handle
3326 * @edca_params: edca parameters
3327 *
3328 * This function updates EDCA parameters to the target
3329 *
3330 * Return: CDF Status
3331 */
Govind Singhb53420c2016-03-09 14:32:57 +05303332QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303333 uint8_t vdev_id,
3334 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
3335{
3336 uint8_t *buf_ptr;
3337 wmi_buf_t buf;
3338 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
3339 wmi_wmm_vparams *wmm_param, *twmm_param;
3340 int len = sizeof(*cmd);
3341 int ac;
3342
3343 buf = wmi_buf_alloc(wmi_handle, len);
3344
3345 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303346 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3347 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303348 }
3349
3350 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3351 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
3352 WMITLV_SET_HDR(&cmd->tlv_header,
3353 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3354 WMITLV_GET_STRUCT_TLVLEN
3355 (wmi_vdev_set_wmm_params_cmd_fixed_param));
3356 cmd->vdev_id = vdev_id;
3357
3358 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
3359 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
3360 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
3361 WMITLV_SET_HDR(&wmm_param->tlv_header,
3362 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3363 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
3364 wmm_param->cwmin = twmm_param->cwmin;
3365 wmm_param->cwmax = twmm_param->cwmax;
3366 wmm_param->aifs = twmm_param->aifs;
3367 wmm_param->txoplimit = twmm_param->txoplimit;
3368 wmm_param->acm = twmm_param->acm;
3369 wmm_param->no_ack = twmm_param->no_ack;
3370 }
3371
3372 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3373 WMI_VDEV_SET_WMM_PARAMS_CMDID))
3374 goto fail;
3375
Govind Singhb53420c2016-03-09 14:32:57 +05303376 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303377
3378fail:
3379 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303380 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
3381 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303382}
3383
3384/**
3385 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
3386 * @wmi_handle: wmi handle
3387 * @vdev_id: vdev id
3388 * @probe_rsp_info: probe response info
3389 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303390 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303391 */
Govind Singhb53420c2016-03-09 14:32:57 +05303392QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303393 uint8_t vdev_id,
3394 struct wmi_probe_resp_params *probe_rsp_info,
3395 uint8_t *frm)
3396{
3397 wmi_prb_tmpl_cmd_fixed_param *cmd;
3398 wmi_bcn_prb_info *bcn_prb_info;
3399 wmi_buf_t wmi_buf;
3400 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
3401 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05303402 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303403
Govind Singhb53420c2016-03-09 14:32:57 +05303404 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303405
3406 tmpl_len = probe_rsp_info->probeRespTemplateLen;
3407 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
3408
3409 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
3410 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
3411 tmpl_len_aligned;
3412
3413 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05303414 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303415 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05303416 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303417 }
3418
3419 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3420 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303421 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303422 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303423 }
3424
3425 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3426
3427 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
3428 WMITLV_SET_HDR(&cmd->tlv_header,
3429 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
3430 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
3431 cmd->vdev_id = vdev_id;
3432 cmd->buf_len = tmpl_len;
3433 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
3434
3435 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
3436 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
3437 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
3438 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
3439 bcn_prb_info->caps = 0;
3440 bcn_prb_info->erp = 0;
3441 buf_ptr += sizeof(wmi_bcn_prb_info);
3442
3443 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
3444 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303445 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303446
3447 ret = wmi_unified_cmd_send(wmi_handle,
3448 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303449 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303450 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303451 wmi_buf_free(wmi_buf);
3452 }
3453
3454 return ret;
3455}
3456
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303457#ifdef FEATURE_WLAN_WAPI
3458#define WPI_IV_LEN 16
3459
3460/**
3461 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
3462 *
3463 * @dest_tx: destination address of tsc key counter
3464 * @src_tx: source address of tsc key counter
3465 * @dest_rx: destination address of rsc key counter
3466 * @src_rx: source address of rsc key counter
3467 *
3468 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
3469 *
3470 * Return: None
3471 *
3472 */
3473static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
3474 uint8_t *dest_rx, uint8_t *src_rx)
3475{
3476 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
3477 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
3478}
3479#else
3480static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
3481 uint8_t *dest_rx, uint8_t *src_rx)
3482{
3483 return;
3484}
3485#endif
3486
3487/**
3488 * send_setup_install_key_cmd_tlv() - set key parameters
3489 * @wmi_handle: wmi handle
3490 * @key_params: key parameters
3491 *
3492 * This function fills structure from information
3493 * passed in key_params.
3494 *
3495 * Return: QDF_STATUS_SUCCESS - success
3496 * QDF_STATUS_E_FAILURE - failure
3497 * QDF_STATUS_E_NOMEM - not able to allocate buffer
3498 */
3499QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
3500 struct set_key_params *key_params)
3501{
3502 wmi_vdev_install_key_cmd_fixed_param *cmd;
3503 wmi_buf_t buf;
3504 uint8_t *buf_ptr;
3505 uint32_t len;
3506 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05303507 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303508
3509 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
3510 WMI_TLV_HDR_SIZE;
3511
3512 buf = wmi_buf_alloc(wmi_handle, len);
3513 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05303514 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303515 return QDF_STATUS_E_NOMEM;
3516 }
3517
3518 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3519 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
3520 WMITLV_SET_HDR(&cmd->tlv_header,
3521 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
3522 WMITLV_GET_STRUCT_TLVLEN
3523 (wmi_vdev_install_key_cmd_fixed_param));
3524 cmd->vdev_id = key_params->vdev_id;
3525 cmd->key_ix = key_params->key_idx;
3526 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
3527 cmd->key_flags |= key_params->key_flags;
3528 cmd->key_cipher = key_params->key_cipher;
3529 if ((key_params->key_txmic_len) &&
3530 (key_params->key_rxmic_len)) {
3531 cmd->key_txmic_len = key_params->key_txmic_len;
3532 cmd->key_rxmic_len = key_params->key_rxmic_len;
3533 }
3534
3535 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
3536 key_params->tx_iv,
3537 cmd->wpi_key_rsc_counter,
3538 key_params->rx_iv);
3539
3540 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
3541 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3542 roundup(key_params->key_len, sizeof(uint32_t)));
3543 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
3544 qdf_mem_copy((void *)key_data,
3545 (const void *)key_params->key_data, key_params->key_len);
3546 cmd->key_len = key_params->key_len;
3547
3548 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3549 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303550 if (QDF_IS_STATUS_ERROR(status))
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303551 qdf_nbuf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303552
Govind Singh67922e82016-04-01 16:48:57 +05303553 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303554}
3555
3556
Govind Singh4eacd2b2016-03-07 14:24:22 +05303557/**
3558 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
3559 * @wmi_handle: wmi handle
3560 * @vdev_id: vdev id
3561 * @p2p_ie: p2p IE
3562 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303563 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303564 */
Govind Singhb53420c2016-03-09 14:32:57 +05303565QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303566 A_UINT32 vdev_id, uint8_t *p2p_ie)
3567{
Govind Singh67922e82016-04-01 16:48:57 +05303568 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303569 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
3570 wmi_buf_t wmi_buf;
3571 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
3572 uint8_t *buf_ptr;
3573
3574 ie_len = (uint32_t) (p2p_ie[1] + 2);
3575
3576 /* More than one P2P IE may be included in a single frame.
3577 If multiple P2P IEs are present, the complete P2P attribute
3578 data consists of the concatenation of the P2P Attribute
3579 fields of the P2P IEs. The P2P Attributes field of each
3580 P2P IE may be any length up to the maximum (251 octets).
3581 In this case host sends one P2P IE to firmware so the length
3582 should not exceed more than 251 bytes
3583 */
3584 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05303585 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05303586 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303587 }
3588
3589 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
3590
3591 wmi_buf_len =
3592 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
3593 WMI_TLV_HDR_SIZE;
3594
3595 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3596 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303597 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303598 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303599 }
3600
3601 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3602
3603 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
3604 WMITLV_SET_HDR(&cmd->tlv_header,
3605 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
3606 WMITLV_GET_STRUCT_TLVLEN
3607 (wmi_p2p_go_set_beacon_ie_fixed_param));
3608 cmd->vdev_id = vdev_id;
3609 cmd->ie_buf_len = ie_len;
3610
3611 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
3612 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
3613 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303614 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303615
Govind Singhb53420c2016-03-09 14:32:57 +05303616 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303617
3618 ret = wmi_unified_cmd_send(wmi_handle,
3619 wmi_buf, wmi_buf_len,
3620 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05303621 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303622 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303623 wmi_buf_free(wmi_buf);
3624 }
3625
Govind Singhb53420c2016-03-09 14:32:57 +05303626 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303627 return ret;
3628}
3629
3630/**
3631 * send_set_gateway_params_cmd_tlv() - set gateway parameters
3632 * @wmi_handle: wmi handle
3633 * @req: gateway parameter update request structure
3634 *
3635 * This function reads the incoming @req and fill in the destination
3636 * WMI structure and sends down the gateway configs down to the firmware
3637 *
Govind Singhb53420c2016-03-09 14:32:57 +05303638 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05303639 */
Govind Singhb53420c2016-03-09 14:32:57 +05303640QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303641 struct gateway_update_req_param *req)
3642{
3643 wmi_roam_subnet_change_config_fixed_param *cmd;
3644 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303645 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303646 int len = sizeof(*cmd);
3647
3648 buf = wmi_buf_alloc(wmi_handle, len);
3649 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303650 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
3651 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303652 }
3653
3654 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
3655 WMITLV_SET_HDR(&cmd->tlv_header,
3656 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
3657 WMITLV_GET_STRUCT_TLVLEN(
3658 wmi_roam_subnet_change_config_fixed_param));
3659
3660 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05303661 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
3662 QDF_IPV4_ADDR_SIZE);
3663 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
3664 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303665 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
3666 &cmd->inet_gw_mac_addr);
3667 cmd->max_retries = req->max_retries;
3668 cmd->timeout = req->timeout;
3669 cmd->num_skip_subnet_change_detection_bssid_list = 0;
3670 cmd->flag = 0;
3671 if (req->ipv4_addr_type)
3672 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
3673
3674 if (req->ipv6_addr_type)
3675 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
3676
3677 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3678 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303679 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303680 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05303681 ret);
3682 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303683 }
3684
Govind Singh67922e82016-04-01 16:48:57 +05303685 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303686}
3687
3688/**
3689 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
3690 * @wmi_handle: wmi handle
3691 * @req: rssi monitoring request structure
3692 *
3693 * This function reads the incoming @req and fill in the destination
3694 * WMI structure and send down the rssi monitoring configs down to the firmware
3695 *
3696 * Return: 0 on success; error number otherwise
3697 */
Govind Singhb53420c2016-03-09 14:32:57 +05303698QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303699 struct rssi_monitor_param *req)
3700{
3701 wmi_rssi_breach_monitor_config_fixed_param *cmd;
3702 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303703 QDF_STATUS ret;
3704 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303705
3706 buf = wmi_buf_alloc(wmi_handle, len);
3707 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303708 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
3709 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303710 }
3711
3712 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
3713 WMITLV_SET_HDR(&cmd->tlv_header,
3714 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
3715 WMITLV_GET_STRUCT_TLVLEN(
3716 wmi_rssi_breach_monitor_config_fixed_param));
3717
3718 cmd->vdev_id = req->session_id;
3719 cmd->request_id = req->request_id;
3720 cmd->lo_rssi_reenable_hysteresis = 0;
3721 cmd->hi_rssi_reenable_histeresis = 0;
3722 cmd->min_report_interval = 0;
3723 cmd->max_num_report = 1;
3724 if (req->control) {
3725 /* enable one threshold for each min/max */
3726 cmd->enabled_bitmap = 0x09;
3727 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
3728 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
3729 } else {
3730 cmd->enabled_bitmap = 0;
3731 cmd->low_rssi_breach_threshold[0] = 0;
3732 cmd->hi_rssi_breach_threshold[0] = 0;
3733 }
3734
3735 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3736 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303737 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303738 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303739 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303740 }
3741
Govind Singhb53420c2016-03-09 14:32:57 +05303742 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05303743 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303744}
3745
3746/**
3747 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
3748 * @wmi_handle: wmi handle
3749 * @psetoui: OUI parameters
3750 *
3751 * set scan probe OUI parameters in firmware
3752 *
3753 * Return: CDF status
3754 */
Govind Singhb53420c2016-03-09 14:32:57 +05303755QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303756 struct scan_mac_oui *psetoui)
3757{
3758 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
3759 wmi_buf_t wmi_buf;
3760 uint32_t len;
3761 uint8_t *buf_ptr;
3762 uint32_t *oui_buf;
3763
3764 len = sizeof(*cmd);
3765 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3766 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303767 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3768 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303769 }
3770 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3771 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
3772 WMITLV_SET_HDR(&cmd->tlv_header,
3773 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
3774 WMITLV_GET_STRUCT_TLVLEN
3775 (wmi_scan_prob_req_oui_cmd_fixed_param));
3776
3777 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05303778 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303779 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
3780 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05303781 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303782 cmd->prob_req_oui);
3783
3784 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3785 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303786 WMI_LOGE("%s: failed to send command", __func__);
3787 qdf_nbuf_free(wmi_buf);
3788 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303789 }
Govind Singhb53420c2016-03-09 14:32:57 +05303790 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303791}
3792
3793/**
3794 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
3795 * @wmi_handle: wmi handle
3796 * @req: passpoint network request structure
3797 *
3798 * This function sends down WMI command with network id set to wildcard id.
3799 * firmware shall clear all the config entries
3800 *
Govind Singhb53420c2016-03-09 14:32:57 +05303801 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05303802 */
Govind Singhb53420c2016-03-09 14:32:57 +05303803QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303804 struct wifi_passpoint_req_param *req)
3805{
3806 wmi_passpoint_config_cmd_fixed_param *cmd;
3807 wmi_buf_t buf;
3808 uint32_t len;
3809 int ret;
3810
3811 len = sizeof(*cmd);
3812 buf = wmi_buf_alloc(wmi_handle, len);
3813 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303814 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
3815 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303816 }
3817
3818 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
3819
3820 WMITLV_SET_HDR(&cmd->tlv_header,
3821 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
3822 WMITLV_GET_STRUCT_TLVLEN(
3823 wmi_passpoint_config_cmd_fixed_param));
3824 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
3825
3826 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3827 WMI_PASSPOINT_LIST_CONFIG_CMDID);
3828 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05303829 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05303830 __func__);
3831 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303832 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303833 }
3834
Govind Singhb53420c2016-03-09 14:32:57 +05303835 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303836}
3837
3838/**
3839 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
3840 * @wmi_handle: wmi handle
3841 * @req: passpoint network request structure
3842 *
3843 * This function reads the incoming @req and fill in the destination
3844 * WMI structure and send down the passpoint configs down to the firmware
3845 *
Govind Singhb53420c2016-03-09 14:32:57 +05303846 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05303847 */
Govind Singhb53420c2016-03-09 14:32:57 +05303848QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303849 struct wifi_passpoint_req_param *req)
3850{
3851 wmi_passpoint_config_cmd_fixed_param *cmd;
3852 u_int8_t i, j, *bytes;
3853 wmi_buf_t buf;
3854 uint32_t len;
3855 int ret;
3856
3857 len = sizeof(*cmd);
3858 for (i = 0; i < req->num_networks; i++) {
3859 buf = wmi_buf_alloc(wmi_handle, len);
3860 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303861 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
3862 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303863 }
3864
3865 cmd = (wmi_passpoint_config_cmd_fixed_param *)
3866 wmi_buf_data(buf);
3867
3868 WMITLV_SET_HDR(&cmd->tlv_header,
3869 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
3870 WMITLV_GET_STRUCT_TLVLEN(
3871 wmi_passpoint_config_cmd_fixed_param));
3872 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05303873 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
3874 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303875 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05303876 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303877 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
3878 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05303879 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05303880 j, bytes[0], bytes[1], bytes[2], bytes[3],
3881 bytes[4], bytes[5], bytes[6], bytes[7]);
3882
Govind Singhb53420c2016-03-09 14:32:57 +05303883 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05303884 &req->networks[i].roaming_consortium_ids[j],
3885 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
3886 }
Govind Singhb53420c2016-03-09 14:32:57 +05303887 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303888 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05303889 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303890 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
3891
3892 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3893 WMI_PASSPOINT_LIST_CONFIG_CMDID);
3894 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05303895 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05303896 __func__);
3897 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303898 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303899 }
3900 }
3901
Govind Singhb53420c2016-03-09 14:32:57 +05303902 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303903}
3904
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05303905/**
3906 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
3907 * @wmi_handle: wmi handle
3908 * @scan_cmd_fp: start scan command ptr
3909 * @roam_req: roam request param
3910 *
3911 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
3912 * of WMI_ROAM_SCAN_MODE.
3913 *
3914 * Return: QDF status
3915 */
3916QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
3917 wmi_start_scan_cmd_fixed_param *
3918 scan_cmd_fp,
3919 struct roam_offload_scan_params *roam_req)
3920{
3921 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303922 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05303923 int len;
3924 uint8_t *buf_ptr;
3925 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05303926
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05303927#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3928 int auth_mode = roam_req->auth_mode;
3929 wmi_roam_offload_tlv_param *roam_offload_params;
3930 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
3931 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
3932 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
3933#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3934 /* Need to create a buf with roam_scan command at
3935 * front and piggyback with scan command */
3936 len = sizeof(wmi_roam_scan_mode_fixed_param) +
3937#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3938 (2 * WMI_TLV_HDR_SIZE) +
3939#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3940 sizeof(wmi_start_scan_cmd_fixed_param);
3941#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3942 if (roam_req->is_roam_req_valid &&
3943 roam_req->roam_offload_enabled) {
3944 len += sizeof(wmi_roam_offload_tlv_param);
3945 len += WMI_TLV_HDR_SIZE;
3946 if ((auth_mode != WMI_AUTH_NONE) &&
3947 ((auth_mode != WMI_AUTH_OPEN) ||
3948 (auth_mode == WMI_AUTH_OPEN &&
3949 roam_req->mdid.mdie_present) ||
3950 roam_req->is_ese_assoc)) {
3951 len += WMI_TLV_HDR_SIZE;
3952 if (roam_req->is_ese_assoc)
3953 len +=
3954 sizeof(wmi_roam_ese_offload_tlv_param);
3955 else if (auth_mode == WMI_AUTH_FT_RSNA ||
3956 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
3957 (auth_mode == WMI_AUTH_OPEN &&
3958 roam_req->mdid.mdie_present))
3959 len +=
3960 sizeof(wmi_roam_11r_offload_tlv_param);
3961 else
3962 len +=
3963 sizeof(wmi_roam_11i_offload_tlv_param);
3964 } else {
3965 len += WMI_TLV_HDR_SIZE;
3966 }
3967 } else {
3968 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05303969 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05303970 __func__, roam_req->roam_offload_enabled);
3971 else
Govind Singhe7f2f342016-05-23 12:12:52 +05303972 WMI_LOGD("%s : roam_req is NULL", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05303973 len += (2 * WMI_TLV_HDR_SIZE);
3974 }
3975 if (roam_req->is_roam_req_valid &&
3976 roam_req->roam_offload_enabled) {
3977 roam_req->mode = roam_req->mode |
3978 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
3979 }
3980#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3981
3982 buf = wmi_buf_alloc(wmi_handle, len);
3983 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05303984 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05303985 return QDF_STATUS_E_NOMEM;
3986 }
3987
3988 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3989 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
3990 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
3991 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
3992 WMITLV_GET_STRUCT_TLVLEN
3993 (wmi_roam_scan_mode_fixed_param));
3994
3995 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
3996 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
3997 /* Fill in scan parameters suitable for roaming scan */
3998 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
3999 qdf_mem_copy(buf_ptr, scan_cmd_fp,
4000 sizeof(wmi_start_scan_cmd_fixed_param));
4001 /* Ensure there is no additional IEs */
4002 scan_cmd_fp->ie_len = 0;
4003 WMITLV_SET_HDR(buf_ptr,
4004 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
4005 WMITLV_GET_STRUCT_TLVLEN
4006 (wmi_start_scan_cmd_fixed_param));
4007#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4008 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
4009 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
4010 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4011 sizeof(wmi_roam_offload_tlv_param));
4012 buf_ptr += WMI_TLV_HDR_SIZE;
4013 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
4014 WMITLV_SET_HDR(buf_ptr,
4015 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
4016 WMITLV_GET_STRUCT_TLVLEN
4017 (wmi_roam_offload_tlv_param));
4018 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
4019 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
4020 roam_offload_params->select_5g_margin =
4021 roam_req->select_5ghz_margin;
4022 roam_offload_params->reassoc_failure_timeout =
4023 roam_req->reassoc_failure_timeout;
4024
4025 /* Fill the capabilities */
4026 roam_offload_params->capability =
4027 roam_req->roam_offload_params.capability;
4028 roam_offload_params->ht_caps_info =
4029 roam_req->roam_offload_params.ht_caps_info;
4030 roam_offload_params->ampdu_param =
4031 roam_req->roam_offload_params.ampdu_param;
4032 roam_offload_params->ht_ext_cap =
4033 roam_req->roam_offload_params.ht_ext_cap;
4034 roam_offload_params->ht_txbf =
4035 roam_req->roam_offload_params.ht_txbf;
4036 roam_offload_params->asel_cap =
4037 roam_req->roam_offload_params.asel_cap;
4038 roam_offload_params->qos_caps =
4039 roam_req->roam_offload_params.qos_caps;
4040 roam_offload_params->wmm_caps =
4041 roam_req->roam_offload_params.wmm_caps;
4042 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
4043 (uint8_t *)roam_req->roam_offload_params.mcsset,
4044 ROAM_OFFLOAD_NUM_MCS_SET);
4045
4046 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
4047 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
4048 * they are filled in the same order.Depending on the
4049 * authentication type, the other mode TLV's are nullified
4050 * and only headers are filled.*/
4051 if ((auth_mode != WMI_AUTH_NONE) &&
4052 ((auth_mode != WMI_AUTH_OPEN) ||
4053 (auth_mode == WMI_AUTH_OPEN
4054 && roam_req->mdid.mdie_present) ||
4055 roam_req->is_ese_assoc)) {
4056 if (roam_req->is_ese_assoc) {
4057 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4058 WMITLV_GET_STRUCT_TLVLEN(0));
4059 buf_ptr += WMI_TLV_HDR_SIZE;
4060 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4061 WMITLV_GET_STRUCT_TLVLEN(0));
4062 buf_ptr += WMI_TLV_HDR_SIZE;
4063 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4064 sizeof(wmi_roam_ese_offload_tlv_param));
4065 buf_ptr += WMI_TLV_HDR_SIZE;
4066 roam_offload_ese =
4067 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
4068 qdf_mem_copy(roam_offload_ese->krk,
4069 roam_req->krk,
4070 sizeof(roam_req->krk));
4071 qdf_mem_copy(roam_offload_ese->btk,
4072 roam_req->btk,
4073 sizeof(roam_req->btk));
4074 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
4075 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
4076 WMITLV_GET_STRUCT_TLVLEN
4077 (wmi_roam_ese_offload_tlv_param));
4078 buf_ptr +=
4079 sizeof(wmi_roam_ese_offload_tlv_param);
4080 } else if (auth_mode == WMI_AUTH_FT_RSNA
4081 || auth_mode == WMI_AUTH_FT_RSNA_PSK
4082 || (auth_mode == WMI_AUTH_OPEN
4083 && roam_req->mdid.mdie_present)) {
4084 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4085 0);
4086 buf_ptr += WMI_TLV_HDR_SIZE;
4087 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4088 sizeof(wmi_roam_11r_offload_tlv_param));
4089 buf_ptr += WMI_TLV_HDR_SIZE;
4090 roam_offload_11r =
4091 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
4092 roam_offload_11r->r0kh_id_len =
4093 roam_req->rokh_id_length;
4094 qdf_mem_copy(roam_offload_11r->r0kh_id,
4095 roam_req->rokh_id,
4096 roam_offload_11r->r0kh_id_len);
4097 qdf_mem_copy(roam_offload_11r->psk_msk,
4098 roam_req->psk_pmk,
4099 sizeof(roam_req->psk_pmk));
4100 roam_offload_11r->psk_msk_len =
4101 roam_req->pmk_len;
4102 roam_offload_11r->mdie_present =
4103 roam_req->mdid.mdie_present;
4104 roam_offload_11r->mdid =
4105 roam_req->mdid.mobility_domain;
4106 if (auth_mode == WMI_AUTH_OPEN) {
4107 /* If FT-Open ensure pmk length
4108 and r0khid len are zero */
4109 roam_offload_11r->r0kh_id_len = 0;
4110 roam_offload_11r->psk_msk_len = 0;
4111 }
4112 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
4113 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
4114 WMITLV_GET_STRUCT_TLVLEN
4115 (wmi_roam_11r_offload_tlv_param));
4116 buf_ptr +=
4117 sizeof(wmi_roam_11r_offload_tlv_param);
4118 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4119 WMITLV_GET_STRUCT_TLVLEN(0));
4120 buf_ptr += WMI_TLV_HDR_SIZE;
4121 } else {
4122 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4123 sizeof(wmi_roam_11i_offload_tlv_param));
4124 buf_ptr += WMI_TLV_HDR_SIZE;
4125 roam_offload_11i =
4126 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
4127 if (roam_req->roam_key_mgmt_offload_enabled) {
4128 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
4129 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304130 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304131 } else {
4132 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
4133 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05304134 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304135 }
4136
4137 qdf_mem_copy(roam_offload_11i->pmk,
4138 roam_req->psk_pmk,
4139 sizeof(roam_req->psk_pmk));
4140 roam_offload_11i->pmk_len = roam_req->pmk_len;
4141 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
4142 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
4143 WMITLV_GET_STRUCT_TLVLEN
4144 (wmi_roam_11i_offload_tlv_param));
4145 buf_ptr +=
4146 sizeof(wmi_roam_11i_offload_tlv_param);
4147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4148 0);
4149 buf_ptr += WMI_TLV_HDR_SIZE;
4150 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4151 0);
4152 buf_ptr += WMI_TLV_HDR_SIZE;
4153 }
4154 } else {
4155 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4156 WMITLV_GET_STRUCT_TLVLEN(0));
4157 buf_ptr += WMI_TLV_HDR_SIZE;
4158 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4159 WMITLV_GET_STRUCT_TLVLEN(0));
4160 buf_ptr += WMI_TLV_HDR_SIZE;
4161 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4162 WMITLV_GET_STRUCT_TLVLEN(0));
4163 }
4164 } else {
4165 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4166 WMITLV_GET_STRUCT_TLVLEN(0));
4167 buf_ptr += WMI_TLV_HDR_SIZE;
4168 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4169 WMITLV_GET_STRUCT_TLVLEN(0));
4170 buf_ptr += WMI_TLV_HDR_SIZE;
4171 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4172 WMITLV_GET_STRUCT_TLVLEN(0));
4173 buf_ptr += WMI_TLV_HDR_SIZE;
4174 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4175 WMITLV_GET_STRUCT_TLVLEN(0));
4176 }
4177#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4178 status = wmi_unified_cmd_send(wmi_handle, buf,
4179 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05304180 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304181 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304182 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
4183 status);
4184 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304185 }
4186
Govind Singh67922e82016-04-01 16:48:57 +05304187 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304188}
4189
4190
4191/**
4192 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
4193 * rssi threashold
4194 * @wmi_handle: wmi handle
4195 * @roam_req: Roaming request buffer
4196 *
4197 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
4198 *
4199 * Return: QDF status
4200 */
4201QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
4202 struct roam_offload_scan_rssi_params *roam_req)
4203{
4204 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304205 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304206 int len;
4207 uint8_t *buf_ptr;
4208 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
4209 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
4210 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05304211 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304212
4213 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4214 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
4215 len += sizeof(wmi_roam_scan_extended_threshold_param);
4216 len += WMI_TLV_HDR_SIZE;
4217 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05304218 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
4219 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304220 buf = wmi_buf_alloc(wmi_handle, len);
4221 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304222 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304223 return QDF_STATUS_E_NOMEM;
4224 }
4225
4226 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4227 rssi_threshold_fp =
4228 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
4229 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
4230 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
4231 WMITLV_GET_STRUCT_TLVLEN
4232 (wmi_roam_scan_rssi_threshold_fixed_param));
4233 /* fill in threshold values */
4234 rssi_threshold_fp->vdev_id = roam_req->session_id;
4235 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
4236 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
4237 rssi_threshold_fp->hirssi_scan_max_count =
4238 roam_req->hi_rssi_scan_max_count;
4239 rssi_threshold_fp->hirssi_scan_delta =
4240 roam_req->hi_rssi_scan_rssi_delta;
4241 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
4242
4243 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
4244 WMITLV_SET_HDR(buf_ptr,
4245 WMITLV_TAG_ARRAY_STRUC,
4246 sizeof(wmi_roam_scan_extended_threshold_param));
4247 buf_ptr += WMI_TLV_HDR_SIZE;
4248 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
4249
4250 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
4251 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
4252 ext_thresholds->boost_threshold_5g =
4253 roam_req->boost_threshold_5g;
4254
4255 ext_thresholds->boost_algorithm_5g =
4256 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4257 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
4258 ext_thresholds->penalty_algorithm_5g =
4259 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
4260 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
4261 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
4262 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
4263 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
4264
4265 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
4266 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
4267 WMITLV_GET_STRUCT_TLVLEN
4268 (wmi_roam_scan_extended_threshold_param));
4269 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
4270 WMITLV_SET_HDR(buf_ptr,
4271 WMITLV_TAG_ARRAY_STRUC,
4272 sizeof(wmi_roam_earlystop_rssi_thres_param));
4273 buf_ptr += WMI_TLV_HDR_SIZE;
4274 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
4275 early_stop_thresholds->roam_earlystop_thres_min =
4276 roam_req->roam_earlystop_thres_min;
4277 early_stop_thresholds->roam_earlystop_thres_max =
4278 roam_req->roam_earlystop_thres_max;
4279 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
4280 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
4281 WMITLV_GET_STRUCT_TLVLEN
4282 (wmi_roam_earlystop_rssi_thres_param));
4283
Gupta, Kapil7e652922016-04-12 15:02:00 +05304284 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
4285 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4286 sizeof(wmi_roam_dense_thres_param));
4287 buf_ptr += WMI_TLV_HDR_SIZE;
4288 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
4289 dense_thresholds->roam_dense_rssi_thres_offset =
4290 roam_req->dense_rssi_thresh_offset;
4291 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
4292 dense_thresholds->roam_dense_traffic_thres =
4293 roam_req->traffic_threshold;
4294 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
4295 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
4296 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
4297 WMITLV_GET_STRUCT_TLVLEN
4298 (wmi_roam_dense_thres_param));
4299
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304300 status = wmi_unified_cmd_send(wmi_handle, buf,
4301 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05304302 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304303 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304304 status);
4305 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304306 }
4307
Govind Singh67922e82016-04-01 16:48:57 +05304308 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304309}
4310
4311/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05304312 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
4313 * configuration params
4314 * @wma_handle: wma handler
4315 * @dwelltime_params: pointer to dwelltime_params
4316 *
4317 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
4318 */
4319QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
4320 struct wmi_adaptive_dwelltime_params *dwelltime_params)
4321{
4322 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
4323 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
4324 wmi_buf_t buf;
4325 uint8_t *buf_ptr;
4326 int32_t err;
4327 int len;
4328
4329 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
4330 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
4331 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
4332 buf = wmi_buf_alloc(wmi_handle, len);
4333 if (!buf) {
4334 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
4335 __func__);
4336 return QDF_STATUS_E_NOMEM;
4337 }
4338 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4339 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
4340 WMITLV_SET_HDR(&dwell_param->tlv_header,
4341 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
4342 WMITLV_GET_STRUCT_TLVLEN
4343 (wmi_scan_adaptive_dwell_config_fixed_param));
4344
4345 dwell_param->enable = dwelltime_params->is_enabled;
4346 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
4347 WMITLV_SET_HDR(buf_ptr,
4348 WMITLV_TAG_ARRAY_STRUC,
4349 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
4350 buf_ptr += WMI_TLV_HDR_SIZE;
4351
4352 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
4353 WMITLV_SET_HDR(&cmd->tlv_header,
4354 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
4355 WMITLV_GET_STRUCT_TLVLEN(
4356 wmi_scan_adaptive_dwell_parameters_tlv));
4357
4358 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
4359 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
4360 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
4361 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
4362 err = wmi_unified_cmd_send(wmi_handle, buf,
4363 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
4364 if (err) {
4365 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
4366 wmi_buf_free(buf);
4367 return QDF_STATUS_E_FAILURE;
4368 }
4369
4370 return QDF_STATUS_SUCCESS;
4371}
4372
4373
4374/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304375 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
4376 * @wmi_handle: wmi handle
4377 * @roam_req: Request which contains the filters
4378 *
4379 * There are filters such as whitelist, blacklist and preferred
4380 * list that need to be applied to the scan results to form the
4381 * probable candidates for roaming.
4382 *
4383 * Return: Return success upon succesfully passing the
4384 * parameters to the firmware, otherwise failure.
4385 */
4386QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
4387 struct roam_scan_filter_params *roam_req)
4388{
4389 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304390 QDF_STATUS status;
4391 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304392 uint32_t len;
4393 uint8_t *buf_ptr;
4394 wmi_roam_filter_fixed_param *roam_filter;
4395 uint8_t *bssid_src_ptr = NULL;
4396 wmi_mac_addr *bssid_dst_ptr = NULL;
4397 wmi_ssid *ssid_ptr = NULL;
4398 uint32_t *bssid_preferred_factor_ptr = NULL;
4399
4400 len = sizeof(wmi_roam_filter_fixed_param);
4401 len += WMI_TLV_HDR_SIZE;
4402 len += roam_req->len;
4403
4404 buf = wmi_buf_alloc(wmi_handle, len);
4405 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304406 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304407 return QDF_STATUS_E_NOMEM;
4408 }
4409
4410 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
4411 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
4412 WMITLV_SET_HDR(&roam_filter->tlv_header,
4413 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
4414 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
4415 /* fill in fixed values */
4416 roam_filter->vdev_id = roam_req->session_id;
4417 roam_filter->flags = 0;
4418 roam_filter->op_bitmap = roam_req->op_bitmap;
4419 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
4420 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
4421 roam_filter->num_bssid_preferred_list =
4422 roam_req->num_bssid_preferred_list;
4423 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
4424
4425 WMITLV_SET_HDR((buf_ptr),
4426 WMITLV_TAG_ARRAY_FIXED_STRUC,
4427 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
4428 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
4429 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
4430 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
4431 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
4432 bssid_src_ptr += ATH_MAC_LEN;
4433 bssid_dst_ptr++;
4434 }
4435 buf_ptr += WMI_TLV_HDR_SIZE +
4436 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
4437 WMITLV_SET_HDR((buf_ptr),
4438 WMITLV_TAG_ARRAY_FIXED_STRUC,
4439 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
4440 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
4441 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
4442 qdf_mem_copy(&ssid_ptr->ssid,
4443 &roam_req->ssid_allowed_list[i].mac_ssid,
4444 roam_req->ssid_allowed_list[i].length);
4445 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
4446 ssid_ptr++;
4447 }
4448 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
4449 sizeof(wmi_ssid));
4450 WMITLV_SET_HDR((buf_ptr),
4451 WMITLV_TAG_ARRAY_FIXED_STRUC,
4452 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
4453 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
4454 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
4455 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
4456 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
4457 (wmi_mac_addr *)bssid_dst_ptr);
4458 bssid_src_ptr += ATH_MAC_LEN;
4459 bssid_dst_ptr++;
4460 }
4461 buf_ptr += WMI_TLV_HDR_SIZE +
4462 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
4463 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
4464 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
4465 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
4466 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
4467 *bssid_preferred_factor_ptr =
4468 roam_req->bssid_favored_factor[i];
4469 bssid_preferred_factor_ptr++;
4470 }
4471 buf_ptr += WMI_TLV_HDR_SIZE +
4472 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
4473
4474 status = wmi_unified_cmd_send(wmi_handle, buf,
4475 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304476 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304477 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304478 status);
4479 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304480 }
Govind Singh67922e82016-04-01 16:48:57 +05304481
4482 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05304483}
4484
Govind Singh4eacd2b2016-03-07 14:24:22 +05304485/** send_set_epno_network_list_cmd_tlv() - set epno network list
4486 * @wmi_handle: wmi handle
4487 * @req: epno config params request structure
4488 *
4489 * This function reads the incoming epno config request structure
4490 * and constructs the WMI message to the firmware.
4491 *
4492 * Returns: 0 on success, error number otherwise
4493 */
Govind Singhb53420c2016-03-09 14:32:57 +05304494QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304495 struct wifi_enhanched_pno_params *req)
4496{
4497 wmi_nlo_config_cmd_fixed_param *cmd;
4498 nlo_configured_parameters *nlo_list;
4499 u_int8_t i, *buf_ptr;
4500 wmi_buf_t buf;
4501 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05304502 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304503
4504 /* TLV place holder for array of structures
4505 * nlo_configured_parameters(nlo_list) */
4506 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4507 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05304508 QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304509 len += WMI_TLV_HDR_SIZE; /* TLV for channel_list */
4510 len += WMI_TLV_HDR_SIZE; /* TLV for channel prediction cfg*/
4511
4512 buf = wmi_buf_alloc(wmi_handle, len);
4513 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304514 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4515 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304516 }
4517
4518 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
4519
4520 buf_ptr = (u_int8_t *) cmd;
4521 WMITLV_SET_HDR(&cmd->tlv_header,
4522 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
4523 WMITLV_GET_STRUCT_TLVLEN(
4524 wmi_nlo_config_cmd_fixed_param));
4525 cmd->vdev_id = req->session_id;
4526 cmd->flags = WMI_NLO_CONFIG_ENLO;
4527
4528 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
4529
Govind Singhb53420c2016-03-09 14:32:57 +05304530 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
4531 WMI_LOGD("SSID count: %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304532 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4533 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
4534 buf_ptr += WMI_TLV_HDR_SIZE;
4535
4536 nlo_list = (nlo_configured_parameters *) buf_ptr;
4537 for (i = 0; i < cmd->no_of_ssids; i++) {
4538 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
4539 WMITLV_TAG_ARRAY_BYTE,
4540 WMITLV_GET_STRUCT_TLVLEN(nlo_configured_parameters));
4541 /* Copy ssid and it's length */
4542 nlo_list[i].ssid.valid = true;
4543 nlo_list[i].ssid.ssid.ssid_len = req->networks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05304544 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304545 req->networks[i].ssid.mac_ssid,
4546 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05304547 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304548 nlo_list[i].ssid.ssid.ssid_len,
4549 (char *) nlo_list[i].ssid.ssid.ssid,
4550 nlo_list[i].ssid.ssid.ssid_len);
4551
4552 /* Copy rssi threshold */
4553 nlo_list[i].rssi_cond.valid = true;
4554 nlo_list[i].rssi_cond.rssi =
4555 req->networks[i].rssi_threshold;
Govind Singhb53420c2016-03-09 14:32:57 +05304556 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304557 nlo_list[i].rssi_cond.rssi);
4558
4559 /* Copy pno flags */
4560 nlo_list[i].bcast_nw_type.valid = true;
4561 nlo_list[i].bcast_nw_type.bcast_nw_type =
4562 req->networks[i].flags;
Govind Singhb53420c2016-03-09 14:32:57 +05304563 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304564 nlo_list[i].bcast_nw_type.bcast_nw_type);
4565
4566 /* Copy auth bit field */
4567 nlo_list[i].auth_type.valid = true;
4568 nlo_list[i].auth_type.auth_type =
4569 req->networks[i].auth_bit_field;
Govind Singhb53420c2016-03-09 14:32:57 +05304570 WMI_LOGD("Auth bit field (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304571 nlo_list[i].auth_type.auth_type);
4572 }
4573
4574 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
4575 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
4576 buf_ptr += WMI_TLV_HDR_SIZE;
4577
4578 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
4579 buf_ptr += WMI_TLV_HDR_SIZE;
4580 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4581 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304582 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304583 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304584 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304585 }
4586
Govind Singhb53420c2016-03-09 14:32:57 +05304587 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304588 req->session_id);
4589
Govind Singh67922e82016-04-01 16:48:57 +05304590 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304591}
4592
4593/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
4594 * @wmi_handle: wmi handle
4595 * @ipa_offload: ipa offload control parameter
4596 *
4597 * Returns: 0 on success, error number otherwise
4598 */
Govind Singhb53420c2016-03-09 14:32:57 +05304599QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304600 struct ipa_offload_control_params *ipa_offload)
4601{
4602 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
4603 wmi_buf_t wmi_buf;
4604 uint32_t len;
4605 u_int8_t *buf_ptr;
4606
4607 len = sizeof(*cmd);
4608 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4609 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304610 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
4611 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304612 }
4613
Govind Singhb53420c2016-03-09 14:32:57 +05304614 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304615 ipa_offload->offload_type, ipa_offload->enable);
4616
4617 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
4618
4619 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
4620 WMITLV_SET_HDR(&cmd->tlv_header,
4621 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
4622 WMITLV_GET_STRUCT_TLVLEN(
4623 wmi_ipa_offload_enable_disable_cmd_fixed_param));
4624
4625 cmd->offload_type = ipa_offload->offload_type;
4626 cmd->vdev_id = ipa_offload->vdev_id;
4627 cmd->enable = ipa_offload->enable;
4628
4629 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4630 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304631 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304632 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304633 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304634 }
4635
Govind Singhb53420c2016-03-09 14:32:57 +05304636 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304637}
4638
4639/**
4640 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
4641 * @wmi_handle: wmi handle
4642 * @pgetcapab: get capabilities params
4643 *
4644 * This function send request to fw to get extscan capabilities.
4645 *
4646 * Return: CDF status
4647 */
Govind Singhb53420c2016-03-09 14:32:57 +05304648QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304649 struct extscan_capabilities_params *pgetcapab)
4650{
4651 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
4652 wmi_buf_t wmi_buf;
4653 uint32_t len;
4654 uint8_t *buf_ptr;
4655
4656 len = sizeof(*cmd);
4657 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4658 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304659 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4660 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304661 }
4662 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4663
4664 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
4665 WMITLV_SET_HDR(&cmd->tlv_header,
4666 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
4667 WMITLV_GET_STRUCT_TLVLEN
4668 (wmi_extscan_get_capabilities_cmd_fixed_param));
4669
4670 cmd->request_id = pgetcapab->request_id;
4671
4672 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4673 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304674 WMI_LOGE("%s: failed to command", __func__);
4675 qdf_nbuf_free(wmi_buf);
4676 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304677 }
Govind Singhb53420c2016-03-09 14:32:57 +05304678 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304679}
4680
4681/**
4682 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
4683 * @wmi_handle: wmi handle
4684 * @pcached_results: cached results parameters
4685 *
4686 * This function send request to fw to get cached results.
4687 *
4688 * Return: CDF status
4689 */
Govind Singhb53420c2016-03-09 14:32:57 +05304690QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304691 struct extscan_cached_result_params *pcached_results)
4692{
4693 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
4694 wmi_buf_t wmi_buf;
4695 uint32_t len;
4696 uint8_t *buf_ptr;
4697
4698 len = sizeof(*cmd);
4699 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4700 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304701 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4702 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304703 }
4704 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4705
4706 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
4707 WMITLV_SET_HDR(&cmd->tlv_header,
4708 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
4709 WMITLV_GET_STRUCT_TLVLEN
4710 (wmi_extscan_get_cached_results_cmd_fixed_param));
4711
4712 cmd->request_id = pcached_results->request_id;
4713 cmd->vdev_id = pcached_results->session_id;
4714 cmd->control_flags = pcached_results->flush;
4715
4716 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4717 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304718 WMI_LOGE("%s: failed to command", __func__);
4719 qdf_nbuf_free(wmi_buf);
4720 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304721 }
Govind Singhb53420c2016-03-09 14:32:57 +05304722 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304723}
4724
4725/**
4726 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
4727 * @wmi_handle: wmi handle
4728 * @reset_req: Reset change request params
4729 *
4730 * This function sends stop change monitor request to fw.
4731 *
4732 * Return: CDF status
4733 */
Govind Singhb53420c2016-03-09 14:32:57 +05304734QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304735 struct extscan_capabilities_reset_params *reset_req)
4736{
4737 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
4738 wmi_buf_t wmi_buf;
4739 uint32_t len;
4740 uint8_t *buf_ptr;
4741 int change_list = 0;
4742
4743 len = sizeof(*cmd);
4744
4745 /* reset significant change tlv is set to 0 */
4746 len += WMI_TLV_HDR_SIZE;
4747 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
4748 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4749 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304750 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4751 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304752 }
4753 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4754
4755 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
4756 buf_ptr;
4757 WMITLV_SET_HDR(&cmd->tlv_header,
4758 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
4759 WMITLV_GET_STRUCT_TLVLEN
4760 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
4761
4762 cmd->request_id = reset_req->request_id;
4763 cmd->vdev_id = reset_req->session_id;
4764 cmd->mode = 0;
4765
4766 buf_ptr += sizeof(*cmd);
4767 WMITLV_SET_HDR(buf_ptr,
4768 WMITLV_TAG_ARRAY_STRUC,
4769 change_list *
4770 sizeof(wmi_extscan_wlan_change_bssid_param));
4771 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
4772 sizeof
4773 (wmi_extscan_wlan_change_bssid_param));
4774
4775 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4776 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304777 WMI_LOGE("%s: failed to command", __func__);
4778 qdf_nbuf_free(wmi_buf);
4779 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304780 }
Govind Singhb53420c2016-03-09 14:32:57 +05304781 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304782}
4783
4784/**
4785 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
4786 * @wmi_handle: wmi handle
4787 * @psigchange: change monitor request params
4788 * @buf: wmi buffer
4789 * @buf_len: buffer length
4790 *
4791 * This function fills elements of change monitor request buffer.
4792 *
4793 * Return: CDF status
4794 */
Govind Singhb53420c2016-03-09 14:32:57 +05304795static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304796 struct extscan_set_sig_changereq_params
4797 *psigchange, wmi_buf_t *buf, int *buf_len)
4798{
4799 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
4800 wmi_extscan_wlan_change_bssid_param *dest_chglist;
4801 uint8_t *buf_ptr;
4802 int j;
4803 int len = sizeof(*cmd);
4804 int numap = psigchange->num_ap;
4805 struct ap_threshold_params *src_ap = psigchange->ap;
4806
4807 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +05304808 WMI_LOGE("%s: Invalid number of bssid's", __func__);
4809 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304810 }
4811 len += WMI_TLV_HDR_SIZE;
4812 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
4813
4814 *buf = wmi_buf_alloc(wmi_handle, len);
4815 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304816 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304817 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05304818 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304819 }
4820 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
4821 cmd =
4822 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
4823 buf_ptr;
4824 WMITLV_SET_HDR(&cmd->tlv_header,
4825 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
4826 WMITLV_GET_STRUCT_TLVLEN
4827 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
4828
4829 cmd->request_id = psigchange->request_id;
4830 cmd->vdev_id = psigchange->session_id;
4831 cmd->total_entries = numap;
4832 cmd->mode = 1;
4833 cmd->num_entries_in_page = numap;
4834 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
4835 cmd->max_rssi_samples = psigchange->rssi_sample_size;
4836 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
4837 cmd->max_out_of_range_count = psigchange->min_breaching;
4838
4839 buf_ptr += sizeof(*cmd);
4840 WMITLV_SET_HDR(buf_ptr,
4841 WMITLV_TAG_ARRAY_STRUC,
4842 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
4843 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
4844 (buf_ptr + WMI_TLV_HDR_SIZE);
4845
4846 for (j = 0; j < numap; j++) {
4847 WMITLV_SET_HDR(dest_chglist,
4848 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
4849 WMITLV_GET_STRUCT_TLVLEN
4850 (wmi_extscan_wlan_change_bssid_param));
4851
4852 dest_chglist->lower_rssi_limit = src_ap->low;
4853 dest_chglist->upper_rssi_limit = src_ap->high;
4854 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
4855 &dest_chglist->bssid);
4856
Govind Singhb53420c2016-03-09 14:32:57 +05304857 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304858 dest_chglist->lower_rssi_limit);
4859 dest_chglist++;
4860 src_ap++;
4861 }
4862 buf_ptr += WMI_TLV_HDR_SIZE +
4863 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
4864 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05304865 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304866}
4867
4868/**
4869 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
4870 * @wmi_handle: wmi handle
4871 * @psigchange: change monitor request params
4872 *
4873 * This function sends start change monitor request to fw.
4874 *
4875 * Return: CDF status
4876 */
Govind Singhb53420c2016-03-09 14:32:57 +05304877QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304878 struct extscan_set_sig_changereq_params *
4879 psigchange)
4880{
Govind Singhb53420c2016-03-09 14:32:57 +05304881 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304882 wmi_buf_t buf;
4883 int len;
4884
4885
Govind Singhb53420c2016-03-09 14:32:57 +05304886 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304887 psigchange, &buf,
4888 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05304889 if (qdf_status != QDF_STATUS_SUCCESS) {
4890 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304891 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05304892 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304893 }
4894 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304895 WMI_LOGE("%s: Failed to get buffer", __func__);
4896 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304897 }
4898 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4899 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304900 WMI_LOGE("%s: failed to send command", __func__);
4901 qdf_nbuf_free(buf);
4902 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304903 }
Govind Singhb53420c2016-03-09 14:32:57 +05304904 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304905}
4906
4907/**
4908 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
4909 * @wmi_handle: wmi handle
4910 * @photlist_reset: hotlist reset params
4911 *
4912 * This function configures hotlist monitor to stop in fw.
4913 *
4914 * Return: CDF status
4915 */
Govind Singhb53420c2016-03-09 14:32:57 +05304916QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304917 struct extscan_bssid_hotlist_reset_params *photlist_reset)
4918{
4919 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
4920 wmi_buf_t wmi_buf;
4921 uint32_t len;
4922 uint8_t *buf_ptr;
4923 int hotlist_entries = 0;
4924
4925 len = sizeof(*cmd);
4926
4927 /* reset bssid hotlist with tlv set to 0 */
4928 len += WMI_TLV_HDR_SIZE;
4929 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
4930
4931 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4932 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304933 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4934 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304935 }
4936
4937 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4938 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
4939 buf_ptr;
4940 WMITLV_SET_HDR(&cmd->tlv_header,
4941 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
4942 WMITLV_GET_STRUCT_TLVLEN
4943 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
4944
4945 cmd->request_id = photlist_reset->request_id;
4946 cmd->vdev_id = photlist_reset->session_id;
4947 cmd->mode = 0;
4948
4949 buf_ptr += sizeof(*cmd);
4950 WMITLV_SET_HDR(buf_ptr,
4951 WMITLV_TAG_ARRAY_STRUC,
4952 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
4953 buf_ptr += WMI_TLV_HDR_SIZE +
4954 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
4955
4956 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4957 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304958 WMI_LOGE("%s: failed to command", __func__);
4959 qdf_nbuf_free(wmi_buf);
4960 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304961 }
Govind Singhb53420c2016-03-09 14:32:57 +05304962 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304963}
4964
4965/**
4966 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
4967 * @wmi_handle: wmi handle
4968 * @pstopcmd: stop scan command request params
4969 *
4970 * This function sends stop extscan request to fw.
4971 *
4972 * Return: CDF Status.
4973 */
Govind Singhb53420c2016-03-09 14:32:57 +05304974QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304975 struct extscan_stop_req_params *pstopcmd)
4976{
4977 wmi_extscan_stop_cmd_fixed_param *cmd;
4978 wmi_buf_t wmi_buf;
4979 uint32_t len;
4980 uint8_t *buf_ptr;
4981
4982 len = sizeof(*cmd);
4983 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4984 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304985 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4986 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304987 }
4988 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4989 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
4990 WMITLV_SET_HDR(&cmd->tlv_header,
4991 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
4992 WMITLV_GET_STRUCT_TLVLEN
4993 (wmi_extscan_stop_cmd_fixed_param));
4994
4995 cmd->request_id = pstopcmd->request_id;
4996 cmd->vdev_id = pstopcmd->session_id;
4997
4998 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4999 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305000 WMI_LOGE("%s: failed to command", __func__);
5001 qdf_nbuf_free(wmi_buf);
5002 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305003 }
5004
Govind Singhb53420c2016-03-09 14:32:57 +05305005 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305006}
5007
5008/**
5009 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
5010 * @wmi_handle: wmi handle
5011 * @pstart: scan command request params
5012 * @buf: event buffer
5013 * @buf_len: length of buffer
5014 *
5015 * This function fills individual elements of extscan request and
5016 * TLV for buckets, channel list.
5017 *
5018 * Return: CDF Status.
5019 */
Govind Singhb53420c2016-03-09 14:32:57 +05305020QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305021 struct wifi_scan_cmd_req_params *pstart,
5022 wmi_buf_t *buf, int *buf_len)
5023{
5024 wmi_extscan_start_cmd_fixed_param *cmd;
5025 wmi_extscan_bucket *dest_blist;
5026 wmi_extscan_bucket_channel *dest_clist;
5027 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
5028 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
5029 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
5030
5031 uint8_t *buf_ptr;
5032 int i, k, count = 0;
5033 int len = sizeof(*cmd);
5034 int nbuckets = pstart->numBuckets;
5035 int nchannels = 0;
5036
5037 /* These TLV's are are NULL by default */
5038 uint32_t ie_len_with_pad = 0;
5039 int num_ssid = 0;
5040 int num_bssid = 0;
5041 int ie_len = 0;
5042
5043 uint32_t base_period = pstart->basePeriod;
5044
5045 /* TLV placeholder for ssid_list (NULL) */
5046 len += WMI_TLV_HDR_SIZE;
5047 len += num_ssid * sizeof(wmi_ssid);
5048
5049 /* TLV placeholder for bssid_list (NULL) */
5050 len += WMI_TLV_HDR_SIZE;
5051 len += num_bssid * sizeof(wmi_mac_addr);
5052
5053 /* TLV placeholder for ie_data (NULL) */
5054 len += WMI_TLV_HDR_SIZE;
5055 len += ie_len * sizeof(uint32_t);
5056
5057 /* TLV placeholder for bucket */
5058 len += WMI_TLV_HDR_SIZE;
5059 len += nbuckets * sizeof(wmi_extscan_bucket);
5060
5061 /* TLV channel placeholder */
5062 len += WMI_TLV_HDR_SIZE;
5063 for (i = 0; i < nbuckets; i++) {
5064 nchannels += src_bucket->numChannels;
5065 src_bucket++;
5066 }
5067
Govind Singhb53420c2016-03-09 14:32:57 +05305068 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305069 __func__, nbuckets, nchannels);
5070 len += nchannels * sizeof(wmi_extscan_bucket_channel);
5071 /* Allocate the memory */
5072 *buf = wmi_buf_alloc(wmi_handle, len);
5073 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305074 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05305075 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305076 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305077 }
5078 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
5079 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
5080 WMITLV_SET_HDR(&cmd->tlv_header,
5081 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
5082 WMITLV_GET_STRUCT_TLVLEN
5083 (wmi_extscan_start_cmd_fixed_param));
5084
5085 cmd->request_id = pstart->requestId;
5086 cmd->vdev_id = pstart->sessionId;
5087 cmd->base_period = pstart->basePeriod;
5088 cmd->num_buckets = nbuckets;
5089 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05305090 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305091 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05305092 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305093 cmd->configuration_flags);
5094
Govind Singhb53420c2016-03-09 14:32:57 +05305095 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
5096 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305097 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5098
5099 /* The max dwell time is retrieved from the first channel
5100 * of the first bucket and kept common for all channels.
5101 */
5102 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
5103 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
5104 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
5105 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
5106 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
5107 cmd->max_table_usage = pstart->report_threshold_percent;
5108 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
5109
5110 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05305111 WMI_SCAN_NPROBES_DEFAULT;
5112 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305113 cmd->probe_delay = 0;
5114 cmd->probe_spacing_time = 0;
5115 cmd->idle_time = 0;
Govind Singhb53420c2016-03-09 14:32:57 +05305116 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305117 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
5118 WMI_SCAN_ADD_CCK_RATES |
5119 WMI_SCAN_ADD_OFDM_RATES |
5120 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
5121 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05305122 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
5123 pstart->extscan_adaptive_dwell_mode);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305124 cmd->scan_priority = WMI_SCAN_PRIORITY_HIGH;
5125 cmd->num_ssids = 0;
5126 cmd->num_bssid = 0;
5127 cmd->ie_len = 0;
5128 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
5129 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
5130
5131 buf_ptr += sizeof(*cmd);
5132 WMITLV_SET_HDR(buf_ptr,
5133 WMITLV_TAG_ARRAY_FIXED_STRUC,
5134 num_ssid * sizeof(wmi_ssid));
5135 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
5136
5137 WMITLV_SET_HDR(buf_ptr,
5138 WMITLV_TAG_ARRAY_FIXED_STRUC,
5139 num_bssid * sizeof(wmi_mac_addr));
5140 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
5141
5142 ie_len_with_pad = 0;
5143 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5144 ie_len_with_pad);
5145 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
5146
5147 WMITLV_SET_HDR(buf_ptr,
5148 WMITLV_TAG_ARRAY_STRUC,
5149 nbuckets * sizeof(wmi_extscan_bucket));
5150 dest_blist = (wmi_extscan_bucket *)
5151 (buf_ptr + WMI_TLV_HDR_SIZE);
5152 src_bucket = pstart->buckets;
5153
5154 /* Retrieve scanning information from each bucket and
5155 * channels and send it to the target
5156 */
5157 for (i = 0; i < nbuckets; i++) {
5158 WMITLV_SET_HDR(dest_blist,
5159 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
5160 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
5161
5162 dest_blist->bucket_id = src_bucket->bucket;
5163 dest_blist->base_period_multiplier =
5164 src_bucket->period / base_period;
5165 dest_blist->min_period = src_bucket->period;
5166 dest_blist->max_period = src_bucket->max_period;
5167 dest_blist->exp_backoff = src_bucket->exponent;
5168 dest_blist->exp_max_step_count = src_bucket->step_count;
5169 dest_blist->channel_band = src_bucket->band;
5170 dest_blist->num_channels = src_bucket->numChannels;
5171 dest_blist->notify_extscan_events = 0;
5172
5173 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
5174 dest_blist->notify_extscan_events =
5175 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT;
5176
5177 if (src_bucket->reportEvents &
5178 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
5179 dest_blist->forwarding_flags =
5180 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
5181 dest_blist->notify_extscan_events |=
5182 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
5183 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
5184 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
5185 } else {
5186 dest_blist->forwarding_flags =
5187 WMI_EXTSCAN_NO_FORWARDING;
5188 }
5189
5190 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
5191 dest_blist->configuration_flags = 0;
5192 else
5193 dest_blist->configuration_flags =
5194 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
5195
Govind Singhb53420c2016-03-09 14:32:57 +05305196 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305197 __func__, dest_blist->notify_extscan_events,
5198 dest_blist->configuration_flags,
5199 dest_blist->forwarding_flags);
5200
5201 dest_blist->min_dwell_time_active =
5202 src_bucket->min_dwell_time_active;
5203 dest_blist->max_dwell_time_active =
5204 src_bucket->max_dwell_time_active;
5205 dest_blist->min_dwell_time_passive =
5206 src_bucket->min_dwell_time_passive;
5207 dest_blist->max_dwell_time_passive =
5208 src_bucket->max_dwell_time_passive;
5209 src_channel = src_bucket->channels;
5210
5211 /* save the channel info to later populate
5212 * the channel TLV
5213 */
5214 for (k = 0; k < src_bucket->numChannels; k++) {
5215 save_channel[count++].channel = src_channel->channel;
5216 src_channel++;
5217 }
5218 dest_blist++;
5219 src_bucket++;
5220 }
5221 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
5222 WMITLV_SET_HDR(buf_ptr,
5223 WMITLV_TAG_ARRAY_STRUC,
5224 nchannels * sizeof(wmi_extscan_bucket_channel));
5225 dest_clist = (wmi_extscan_bucket_channel *)
5226 (buf_ptr + WMI_TLV_HDR_SIZE);
5227
5228 /* Active or passive scan is based on the bucket dwell time
5229 * and channel specific active,passive scans are not
5230 * supported yet
5231 */
5232 for (i = 0; i < nchannels; i++) {
5233 WMITLV_SET_HDR(dest_clist,
5234 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
5235 WMITLV_GET_STRUCT_TLVLEN
5236 (wmi_extscan_bucket_channel));
5237 dest_clist->channel = save_channel[i].channel;
5238 dest_clist++;
5239 }
5240 buf_ptr += WMI_TLV_HDR_SIZE +
5241 (nchannels * sizeof(wmi_extscan_bucket_channel));
5242 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05305243 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305244}
5245
5246/**
5247 * send_start_extscan_cmd_tlv() - start extscan command to fw.
5248 * @wmi_handle: wmi handle
5249 * @pstart: scan command request params
5250 *
5251 * This function sends start extscan request to fw.
5252 *
5253 * Return: CDF Status.
5254 */
Govind Singhb53420c2016-03-09 14:32:57 +05305255QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305256 struct wifi_scan_cmd_req_params *pstart)
5257{
Govind Singhb53420c2016-03-09 14:32:57 +05305258 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305259 wmi_buf_t buf;
5260 int len;
5261
5262 /* Fill individual elements of extscan request and
5263 * TLV for buckets, channel list.
5264 */
Govind Singhb53420c2016-03-09 14:32:57 +05305265 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305266 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05305267 if (qdf_status != QDF_STATUS_SUCCESS) {
5268 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
5269 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305270 }
5271 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305272 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05305273 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05305274 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305275 }
5276 if (wmi_unified_cmd_send(wmi_handle, buf,
5277 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305278 WMI_LOGE("%s: failed to send command", __func__);
5279 qdf_nbuf_free(buf);
5280 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305281 }
5282
Govind Singhb53420c2016-03-09 14:32:57 +05305283 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305284}
5285
5286/**
5287 * send_plm_stop_cmd_tlv() - plm stop request
5288 * @wmi_handle: wmi handle
5289 * @plm: plm request parameters
5290 *
5291 * This function request FW to stop PLM.
5292 *
5293 * Return: CDF status
5294 */
Govind Singhb53420c2016-03-09 14:32:57 +05305295QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305296 const struct plm_req_params *plm)
5297{
5298 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
5299 int32_t len;
5300 wmi_buf_t buf;
5301 uint8_t *buf_ptr;
5302 int ret;
5303
5304 len = sizeof(*cmd);
5305 buf = wmi_buf_alloc(wmi_handle, len);
5306 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305307 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5308 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305309 }
5310
5311 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
5312
5313 buf_ptr = (uint8_t *) cmd;
5314
5315 WMITLV_SET_HDR(&cmd->tlv_header,
5316 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
5317 WMITLV_GET_STRUCT_TLVLEN
5318 (wmi_vdev_plmreq_stop_cmd_fixed_param));
5319
5320 cmd->vdev_id = plm->session_id;
5321
5322 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05305323 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305324
5325 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5326 WMI_VDEV_PLMREQ_STOP_CMDID);
5327 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305328 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305329 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305330 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305331 }
5332
Govind Singhb53420c2016-03-09 14:32:57 +05305333 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305334}
5335
5336/**
5337 * send_plm_start_cmd_tlv() - plm start request
5338 * @wmi_handle: wmi handle
5339 * @plm: plm request parameters
5340 *
5341 * This function request FW to start PLM.
5342 *
5343 * Return: CDF status
5344 */
Govind Singhb53420c2016-03-09 14:32:57 +05305345QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305346 const struct plm_req_params *plm,
5347 uint32_t *gchannel_list)
5348{
5349 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
5350 uint32_t *channel_list;
5351 int32_t len;
5352 wmi_buf_t buf;
5353 uint8_t *buf_ptr;
5354 uint8_t count;
5355 int ret;
5356
5357 /* TLV place holder for channel_list */
5358 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5359 len += sizeof(uint32_t) * plm->plm_num_ch;
5360
5361 buf = wmi_buf_alloc(wmi_handle, len);
5362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305363 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5364 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305365 }
5366 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
5367
5368 buf_ptr = (uint8_t *) cmd;
5369
5370 WMITLV_SET_HDR(&cmd->tlv_header,
5371 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
5372 WMITLV_GET_STRUCT_TLVLEN
5373 (wmi_vdev_plmreq_start_cmd_fixed_param));
5374
5375 cmd->vdev_id = plm->session_id;
5376
5377 cmd->meas_token = plm->meas_token;
5378 cmd->dialog_token = plm->diag_token;
5379 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05305380 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305381 cmd->off_duration = plm->meas_duration;
5382 cmd->burst_cycle = plm->burst_len;
5383 cmd->tx_power = plm->desired_tx_pwr;
5384 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
5385 cmd->num_chans = plm->plm_num_ch;
5386
5387 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
5388
Govind Singhb53420c2016-03-09 14:32:57 +05305389 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
5390 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
5391 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
5392 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
5393 WMI_LOGD("off_duration: %d", cmd->off_duration);
5394 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
5395 WMI_LOGD("tx_power: %d", cmd->tx_power);
5396 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305397
5398 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5399 (cmd->num_chans * sizeof(uint32_t)));
5400
5401 buf_ptr += WMI_TLV_HDR_SIZE;
5402 if (cmd->num_chans) {
5403 channel_list = (uint32_t *) buf_ptr;
5404 for (count = 0; count < cmd->num_chans; count++) {
5405 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05305406 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305407 channel_list[count] =
5408 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05305409 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305410 }
5411 buf_ptr += cmd->num_chans * sizeof(uint32_t);
5412 }
5413
5414 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5415 WMI_VDEV_PLMREQ_START_CMDID);
5416 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305417 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305418 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305419 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305420 }
5421
Govind Singhb53420c2016-03-09 14:32:57 +05305422 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305423}
5424
5425/**
5426 * send_pno_stop_cmd_tlv() - PNO stop request
5427 * @wmi_handle: wmi handle
5428 * @vdev_id: vdev id
5429 *
5430 * This function request FW to stop ongoing PNO operation.
5431 *
5432 * Return: CDF status
5433 */
Govind Singhb53420c2016-03-09 14:32:57 +05305434QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305435{
5436 wmi_nlo_config_cmd_fixed_param *cmd;
5437 int32_t len = sizeof(*cmd);
5438 wmi_buf_t buf;
5439 uint8_t *buf_ptr;
5440 int ret;
5441
5442 /*
5443 * TLV place holder for array of structures nlo_configured_parameters
5444 * TLV place holder for array of uint32_t channel_list
5445 * TLV place holder for chnl prediction cfg
5446 */
5447 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
5448 buf = wmi_buf_alloc(wmi_handle, len);
5449 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305450 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5451 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305452 }
5453
5454 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5455 buf_ptr = (uint8_t *) cmd;
5456
5457 WMITLV_SET_HDR(&cmd->tlv_header,
5458 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5459 WMITLV_GET_STRUCT_TLVLEN
5460 (wmi_nlo_config_cmd_fixed_param));
5461
5462 cmd->vdev_id = vdev_id;
5463 cmd->flags = WMI_NLO_CONFIG_STOP;
5464 buf_ptr += sizeof(*cmd);
5465
5466 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5467 buf_ptr += WMI_TLV_HDR_SIZE;
5468
5469 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5470 buf_ptr += WMI_TLV_HDR_SIZE;
5471
5472 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5473 buf_ptr += WMI_TLV_HDR_SIZE;
5474
5475
5476 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5477 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
5478 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305479 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305480 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305481 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305482 }
5483
Govind Singhb53420c2016-03-09 14:32:57 +05305484 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305485}
5486
5487/**
Govind Singhccb0c272016-04-01 16:30:08 +05305488 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
5489 * @buf_ptr: Buffer passed by upper layers
5490 * @pno: Buffer to be sent to the firmware
5491 *
5492 * Copy the PNO Channel prediction configuration parameters
5493 * passed by the upper layers to a WMI format TLV and send it
5494 * down to the firmware.
5495 *
5496 * Return: None
5497 */
5498static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
5499 struct pno_scan_req_params *pno)
5500{
5501 nlo_channel_prediction_cfg *channel_prediction_cfg =
5502 (nlo_channel_prediction_cfg *) buf_ptr;
5503 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
5504 WMITLV_TAG_ARRAY_BYTE,
5505 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
5506 channel_prediction_cfg->enable = pno->pno_channel_prediction;
5507 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
5508 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
5509 channel_prediction_cfg->full_scan_period_ms =
5510 pno->channel_prediction_full_scan;
5511 buf_ptr += sizeof(nlo_channel_prediction_cfg);
5512 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
5513 channel_prediction_cfg->enable,
5514 channel_prediction_cfg->top_k_num,
5515 channel_prediction_cfg->stationary_threshold,
5516 channel_prediction_cfg->full_scan_period_ms);
5517}
5518
5519/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05305520 * send_pno_start_cmd_tlv() - PNO start request
5521 * @wmi_handle: wmi handle
5522 * @pno: PNO request
5523 *
5524 * This function request FW to start PNO request.
5525 * Request: CDF status
5526 */
Govind Singhb53420c2016-03-09 14:32:57 +05305527QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305528 struct pno_scan_req_params *pno,
5529 uint32_t *gchannel_freq_list)
5530{
5531 wmi_nlo_config_cmd_fixed_param *cmd;
5532 nlo_configured_parameters *nlo_list;
5533 uint32_t *channel_list;
5534 int32_t len;
5535 wmi_buf_t buf;
5536 uint8_t *buf_ptr;
5537 uint8_t i;
5538 int ret;
5539
5540 /*
5541 * TLV place holder for array nlo_configured_parameters(nlo_list)
5542 * TLV place holder for array of uint32_t channel_list
5543 * TLV place holder for chnnl prediction cfg
5544 */
5545 len = sizeof(*cmd) +
5546 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
5547
Govind Singhb53420c2016-03-09 14:32:57 +05305548 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305549 WMI_NLO_MAX_CHAN);
5550 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05305551 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305552 len += sizeof(nlo_channel_prediction_cfg);
5553
5554 buf = wmi_buf_alloc(wmi_handle, len);
5555 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305556 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5557 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305558 }
5559
5560 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5561
5562 buf_ptr = (uint8_t *) cmd;
5563 WMITLV_SET_HDR(&cmd->tlv_header,
5564 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5565 WMITLV_GET_STRUCT_TLVLEN
5566 (wmi_nlo_config_cmd_fixed_param));
5567 cmd->vdev_id = pno->sessionId;
5568 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
5569
Gupta, Kapil2e685982016-04-25 19:14:19 +05305570 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
5571 pno->pnoscan_adaptive_dwell_mode);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305572 /* Current FW does not support min-max range for dwell time */
5573 cmd->active_dwell_time = pno->active_max_time;
5574 cmd->passive_dwell_time = pno->passive_max_time;
5575
5576 /* Copy scan interval */
5577 cmd->fast_scan_period = pno->fast_scan_period;
5578 cmd->slow_scan_period = pno->slow_scan_period;
5579 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05305580 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305581 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05305582 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305583
5584 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5585
Govind Singhb53420c2016-03-09 14:32:57 +05305586 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
5587 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305588 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5589 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5590 buf_ptr += WMI_TLV_HDR_SIZE;
5591
5592 nlo_list = (nlo_configured_parameters *) buf_ptr;
5593 for (i = 0; i < cmd->no_of_ssids; i++) {
5594 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5595 WMITLV_TAG_ARRAY_BYTE,
5596 WMITLV_GET_STRUCT_TLVLEN
5597 (nlo_configured_parameters));
5598 /* Copy ssid and it's length */
5599 nlo_list[i].ssid.valid = true;
5600 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05305601 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305602 pno->aNetworks[i].ssid.mac_ssid,
5603 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05305604 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305605 nlo_list[i].ssid.ssid.ssid_len,
5606 (char *)nlo_list[i].ssid.ssid.ssid,
5607 nlo_list[i].ssid.ssid.ssid_len);
5608
5609 /* Copy rssi threshold */
5610 if (pno->aNetworks[i].rssiThreshold &&
5611 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
5612 nlo_list[i].rssi_cond.valid = true;
5613 nlo_list[i].rssi_cond.rssi =
5614 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05305615 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305616 nlo_list[i].rssi_cond.rssi);
5617 }
5618 nlo_list[i].bcast_nw_type.valid = true;
5619 nlo_list[i].bcast_nw_type.bcast_nw_type =
5620 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05305621 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305622 nlo_list[i].bcast_nw_type.bcast_nw_type);
5623 }
5624 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5625
5626 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05305627 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305628 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05305629 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305630 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5631 (cmd->num_of_channels * sizeof(uint32_t)));
5632 buf_ptr += WMI_TLV_HDR_SIZE;
5633
5634 channel_list = (uint32_t *) buf_ptr;
5635 for (i = 0; i < cmd->num_of_channels; i++) {
5636 channel_list[i] = pno->aNetworks[0].aChannels[i];
5637
5638 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
5639 channel_list[i] = gchannel_freq_list[i];
5640
Govind Singhb53420c2016-03-09 14:32:57 +05305641 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305642 }
5643 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
5644 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5645 sizeof(nlo_channel_prediction_cfg));
5646 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05305647 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305648 buf_ptr += WMI_TLV_HDR_SIZE;
5649 /** TODO: Discrete firmware doesn't have command/option to configure
5650 * App IE which comes from wpa_supplicant as of part PNO start request.
5651 */
5652 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5653 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
5654 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305655 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305656 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305657 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305658 }
5659
Govind Singhb53420c2016-03-09 14:32:57 +05305660 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305661}
5662
5663/* send_set_ric_req_cmd_tlv() - set ric request element
5664 * @wmi_handle: wmi handle
5665 * @msg: message
5666 * @is_add_ts: is addts required
5667 *
5668 * This function sets ric request element for 11r roaming.
5669 *
5670 * Return: CDF status
5671 */
Govind Singhb53420c2016-03-09 14:32:57 +05305672QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305673 void *msg, uint8_t is_add_ts)
5674{
5675 wmi_ric_request_fixed_param *cmd;
5676 wmi_ric_tspec *tspec_param;
5677 wmi_buf_t buf;
5678 uint8_t *buf_ptr;
5679 struct mac_tspec_ie *ptspecIE;
5680 int32_t len = sizeof(wmi_ric_request_fixed_param) +
5681 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
5682
5683 buf = wmi_buf_alloc(wmi_handle, len);
5684 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305685 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5686 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305687 }
5688
5689 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5690
5691 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
5692 WMITLV_SET_HDR(&cmd->tlv_header,
5693 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
5694 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
5695 if (is_add_ts)
5696 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
5697 else
5698 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
5699 cmd->num_ric_request = 1;
5700 cmd->is_add_ric = is_add_ts;
5701
5702 buf_ptr += sizeof(wmi_ric_request_fixed_param);
5703 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
5704
5705 buf_ptr += WMI_TLV_HDR_SIZE;
5706 tspec_param = (wmi_ric_tspec *) buf_ptr;
5707 WMITLV_SET_HDR(&tspec_param->tlv_header,
5708 WMITLV_TAG_STRUC_wmi_ric_tspec,
5709 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
5710
5711 if (is_add_ts)
5712 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
5713 else
5714 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
5715
5716 /* Fill the tsinfo in the format expected by firmware */
5717#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singhb53420c2016-03-09 14:32:57 +05305718 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305719 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
5720#else
Govind Singhb53420c2016-03-09 14:32:57 +05305721 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305722 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
5723#endif /* ANI_LITTLE_BIT_ENDIAN */
5724
5725 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
5726 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
5727 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
5728 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
5729 tspec_param->inactivity_interval = ptspecIE->inactInterval;
5730 tspec_param->suspension_interval = ptspecIE->suspendInterval;
5731 tspec_param->svc_start_time = ptspecIE->svcStartTime;
5732 tspec_param->min_data_rate = ptspecIE->minDataRate;
5733 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
5734 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
5735 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
5736 tspec_param->delay_bound = ptspecIE->delayBound;
5737 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
5738 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
5739 tspec_param->medium_time = 0;
5740
Govind Singhb53420c2016-03-09 14:32:57 +05305741 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305742
5743 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5744 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305745 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305746 __func__);
5747 if (is_add_ts)
5748 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05305749 QDF_STATUS_E_FAILURE;
5750 qdf_nbuf_free(buf);
5751 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305752 }
5753
Govind Singhb53420c2016-03-09 14:32:57 +05305754 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305755}
5756
5757/**
5758 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
5759 * @wmi_handle: wmi handle
5760 * @clear_req: ll stats clear request command params
5761 *
Govind Singhb53420c2016-03-09 14:32:57 +05305762 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305763 */
Govind Singhb53420c2016-03-09 14:32:57 +05305764QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305765 const struct ll_stats_clear_params *clear_req,
5766 uint8_t addr[IEEE80211_ADDR_LEN])
5767{
5768 wmi_clear_link_stats_cmd_fixed_param *cmd;
5769 int32_t len;
5770 wmi_buf_t buf;
5771 uint8_t *buf_ptr;
5772 int ret;
5773
5774 len = sizeof(*cmd);
5775 buf = wmi_buf_alloc(wmi_handle, len);
5776
5777 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305778 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5779 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305780 }
5781
5782 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305783 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305784 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
5785
5786 WMITLV_SET_HDR(&cmd->tlv_header,
5787 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
5788 WMITLV_GET_STRUCT_TLVLEN
5789 (wmi_clear_link_stats_cmd_fixed_param));
5790
5791 cmd->stop_stats_collection_req = clear_req->stop_req;
5792 cmd->vdev_id = clear_req->sta_id;
5793 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
5794
5795 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
5796 &cmd->peer_macaddr);
5797
Govind Singhb53420c2016-03-09 14:32:57 +05305798 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
5799 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
5800 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
5801 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
5802 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305803 cmd->peer_macaddr); */
5804
5805 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5806 WMI_CLEAR_LINK_STATS_CMDID);
5807 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305808 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305809 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305810 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305811 }
5812
Govind Singhb53420c2016-03-09 14:32:57 +05305813 WMI_LOGD("Clear Link Layer Stats request sent successfully");
5814 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305815}
5816
5817/**
5818 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
5819 * @wmi_handle: wmi handle
5820 * @setReq: ll stats set request command params
5821 *
Govind Singhb53420c2016-03-09 14:32:57 +05305822 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305823 */
Govind Singhb53420c2016-03-09 14:32:57 +05305824QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305825 const struct ll_stats_set_params *set_req)
5826{
5827 wmi_start_link_stats_cmd_fixed_param *cmd;
5828 int32_t len;
5829 wmi_buf_t buf;
5830 uint8_t *buf_ptr;
5831 int ret;
5832
5833 len = sizeof(*cmd);
5834 buf = wmi_buf_alloc(wmi_handle, len);
5835
5836 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305837 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5838 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305839 }
5840
5841 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305842 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305843 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
5844
5845 WMITLV_SET_HDR(&cmd->tlv_header,
5846 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
5847 WMITLV_GET_STRUCT_TLVLEN
5848 (wmi_start_link_stats_cmd_fixed_param));
5849
5850 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
5851 cmd->aggressive_statistics_gathering =
5852 set_req->aggressive_statistics_gathering;
5853
Govind Singhb53420c2016-03-09 14:32:57 +05305854 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
5855 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
5856 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305857
5858 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5859 WMI_START_LINK_STATS_CMDID);
5860 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305861 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305862 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305863 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305864 }
5865
Govind Singhb53420c2016-03-09 14:32:57 +05305866 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305867}
5868
5869/**
5870 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
5871 * @wmi_handle:wmi handle
5872 * @get_req:ll stats get request command params
5873 * @addr: mac address
5874 *
Govind Singhb53420c2016-03-09 14:32:57 +05305875 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305876 */
Govind Singhb53420c2016-03-09 14:32:57 +05305877QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305878 const struct ll_stats_get_params *get_req,
5879 uint8_t addr[IEEE80211_ADDR_LEN])
5880{
5881 wmi_request_link_stats_cmd_fixed_param *cmd;
5882 int32_t len;
5883 wmi_buf_t buf;
5884 uint8_t *buf_ptr;
5885 int ret;
5886
5887 len = sizeof(*cmd);
5888 buf = wmi_buf_alloc(wmi_handle, len);
5889
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05305890 if (!buf) {
5891 WMI_LOGE("%s: buf allocation failed", __func__);
5892 return QDF_STATUS_E_NOMEM;
5893 }
5894
Govind Singh4eacd2b2016-03-07 14:24:22 +05305895 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305896 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305897 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
5898
5899 WMITLV_SET_HDR(&cmd->tlv_header,
5900 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
5901 WMITLV_GET_STRUCT_TLVLEN
5902 (wmi_request_link_stats_cmd_fixed_param));
5903
5904 cmd->request_id = get_req->req_id;
5905 cmd->stats_type = get_req->param_id_mask;
5906 cmd->vdev_id = get_req->sta_id;
5907
5908 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
5909 &cmd->peer_macaddr);
5910
Govind Singhb53420c2016-03-09 14:32:57 +05305911 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
5912 WMI_LOGD("Request ID : %d", cmd->request_id);
5913 WMI_LOGD("Stats Type : %d", cmd->stats_type);
5914 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
5915 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305916
5917 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5918 WMI_REQUEST_LINK_STATS_CMDID);
5919 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305920 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305921 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305922 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305923 }
5924
Govind Singhb53420c2016-03-09 14:32:57 +05305925 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305926}
5927
5928/**
5929 * send_get_stats_cmd_tlv() - get stats request
5930 * @wmi_handle: wmi handle
5931 * @get_stats_param: stats params
5932 * @addr: mac address
5933 *
5934 * Return: CDF status
5935 */
Govind Singhb53420c2016-03-09 14:32:57 +05305936QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305937 struct pe_stats_req *get_stats_param,
5938 uint8_t addr[IEEE80211_ADDR_LEN])
5939{
5940 wmi_buf_t buf;
5941 wmi_request_stats_cmd_fixed_param *cmd;
5942 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
5943
5944 buf = wmi_buf_alloc(wmi_handle, len);
5945 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305946 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
5947 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305948 }
5949
5950
5951 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
5952 WMITLV_SET_HDR(&cmd->tlv_header,
5953 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
5954 WMITLV_GET_STRUCT_TLVLEN
5955 (wmi_request_stats_cmd_fixed_param));
5956 cmd->stats_id =
5957 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
5958 WMI_REQUEST_VDEV_STAT;
5959 cmd->vdev_id = get_stats_param->session_id;
5960 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05305961 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305962 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5963 WMI_REQUEST_STATS_CMDID)) {
5964
Govind Singhb53420c2016-03-09 14:32:57 +05305965 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305966 __func__);
5967 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305968 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305969 }
5970
Govind Singhb53420c2016-03-09 14:32:57 +05305971 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305972
5973}
5974
Govind Singh20c5dac2016-03-07 15:33:31 +05305975/**
5976 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
5977 * @wmi_handle: wmi handle
5978 * @rssi_req: get RSSI request
5979 *
5980 * Return: CDF status
5981 */
Govind Singhb53420c2016-03-09 14:32:57 +05305982QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05305983{
5984 wmi_buf_t buf;
5985 wmi_request_stats_cmd_fixed_param *cmd;
5986 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
5987
5988 buf = wmi_buf_alloc(wmi_handle, len);
5989 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305990 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5991 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305992 }
5993
5994 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
5995 WMITLV_SET_HDR(&cmd->tlv_header,
5996 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
5997 WMITLV_GET_STRUCT_TLVLEN
5998 (wmi_request_stats_cmd_fixed_param));
5999 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6000 if (wmi_unified_cmd_send
6001 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306002 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306003 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306004 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306005 }
6006
Govind Singhb53420c2016-03-09 14:32:57 +05306007 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306008}
6009
6010/**
6011 * send_snr_cmd_tlv() - get RSSI from fw
6012 * @wmi_handle: wmi handle
6013 * @vdev_id: vdev id
6014 *
6015 * Return: CDF status
6016 */
Govind Singhb53420c2016-03-09 14:32:57 +05306017QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05306018{
6019 wmi_buf_t buf;
6020 wmi_request_stats_cmd_fixed_param *cmd;
6021 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6022
6023 buf = wmi_buf_alloc(wmi_handle, len);
6024 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306025 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6026 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306027 }
6028
6029 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6030 cmd->vdev_id = vdev_id;
6031
6032 WMITLV_SET_HDR(&cmd->tlv_header,
6033 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6034 WMITLV_GET_STRUCT_TLVLEN
6035 (wmi_request_stats_cmd_fixed_param));
6036 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
6037 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6038 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306039 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306040 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306041 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306042 }
6043
Govind Singhb53420c2016-03-09 14:32:57 +05306044 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306045}
6046
6047/**
6048 * send_link_status_req_cmd_tlv() - process link status request from UMAC
6049 * @wmi_handle: wmi handle
6050 * @link_status: get link params
6051 *
6052 * Return: CDF status
6053 */
Govind Singhb53420c2016-03-09 14:32:57 +05306054QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306055 struct link_status_params *link_status)
6056{
6057 wmi_buf_t buf;
6058 wmi_request_stats_cmd_fixed_param *cmd;
6059 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
6060
6061 buf = wmi_buf_alloc(wmi_handle, len);
6062 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306063 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6064 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306065 }
6066
6067 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
6068 WMITLV_SET_HDR(&cmd->tlv_header,
6069 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
6070 WMITLV_GET_STRUCT_TLVLEN
6071 (wmi_request_stats_cmd_fixed_param));
6072 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
6073 cmd->vdev_id = link_status->session_id;
6074 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6075 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306076 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05306077 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306078 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306079 }
6080
Govind Singhb53420c2016-03-09 14:32:57 +05306081 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306082}
6083
6084#ifdef FEATURE_WLAN_LPHB
6085
6086/**
6087 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
6088 * @wmi_handle: wmi handle
6089 * @lphb_conf_req: configuration info
6090 *
6091 * Return: CDF status
6092 */
Govind Singhb53420c2016-03-09 14:32:57 +05306093QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306094 wmi_hb_set_enable_cmd_fixed_param *params)
6095{
Govind Singh67922e82016-04-01 16:48:57 +05306096 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306097 wmi_buf_t buf = NULL;
6098 uint8_t *buf_ptr;
6099 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
6100 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
6101
6102
6103 buf = wmi_buf_alloc(wmi_handle, len);
6104 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306105 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6106 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306107 }
6108
6109 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6110 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
6111 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
6112 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
6113 WMITLV_GET_STRUCT_TLVLEN
6114 (wmi_hb_set_enable_cmd_fixed_param));
6115
6116 /* fill in values */
6117 hb_enable_fp->vdev_id = params->session;
6118 hb_enable_fp->enable = params->enable;
6119 hb_enable_fp->item = params->item;
6120 hb_enable_fp->session = params->session;
6121
6122 status = wmi_unified_cmd_send(wmi_handle, buf,
6123 len, WMI_HB_SET_ENABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306124 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306125 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_ENABLE returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306126 status);
Govind Singh67922e82016-04-01 16:48:57 +05306127 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306128 }
6129
Govind Singh67922e82016-04-01 16:48:57 +05306130 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306131}
6132
6133/**
6134 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
6135 * @wmi_handle: wmi handle
6136 * @lphb_conf_req: lphb config request
6137 *
6138 * Return: CDF status
6139 */
Govind Singhb53420c2016-03-09 14:32:57 +05306140QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306141 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
6142{
Govind Singh67922e82016-04-01 16:48:57 +05306143 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306144 wmi_buf_t buf = NULL;
6145 uint8_t *buf_ptr;
6146 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
6147 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
6148
6149 buf = wmi_buf_alloc(wmi_handle, len);
6150 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306151 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6152 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306153 }
6154
6155 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6156 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
6157 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
6158 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
6159 WMITLV_GET_STRUCT_TLVLEN
6160 (wmi_hb_set_tcp_params_cmd_fixed_param));
6161
6162 /* fill in values */
6163 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
6164 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
6165 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
6166 hb_tcp_params_fp->seq = lphb_conf_req->seq;
6167 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
6168 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
6169 hb_tcp_params_fp->interval = lphb_conf_req->interval;
6170 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
6171 hb_tcp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05306172 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05306173 &lphb_conf_req->gateway_mac,
6174 sizeof(hb_tcp_params_fp->gateway_mac));
6175
6176 status = wmi_unified_cmd_send(wmi_handle, buf,
6177 len, WMI_HB_SET_TCP_PARAMS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306178 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306179 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306180 status);
Govind Singh20c5dac2016-03-07 15:33:31 +05306181 }
6182
Govind Singh67922e82016-04-01 16:48:57 +05306183 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306184}
6185
6186/**
6187 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
6188 * @wmi_handle: wmi handle
6189 * @lphb_conf_req: lphb config request
6190 *
6191 * Return: CDF status
6192 */
Govind Singhb53420c2016-03-09 14:32:57 +05306193QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306194 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
6195{
Govind Singh67922e82016-04-01 16:48:57 +05306196 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306197 wmi_buf_t buf = NULL;
6198 uint8_t *buf_ptr;
6199 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
6200 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
6201
6202 buf = wmi_buf_alloc(wmi_handle, len);
6203 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306204 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6205 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306206 }
6207
6208 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6209 hb_tcp_filter_fp =
6210 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
6211 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
6212 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
6213 WMITLV_GET_STRUCT_TLVLEN
6214 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
6215
6216 /* fill in values */
6217 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
6218 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
6219 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
6220 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
6221 memcpy((void *)&hb_tcp_filter_fp->filter,
6222 (void *)&g_hb_tcp_filter_fp->filter,
6223 WMI_WLAN_HB_MAX_FILTER_SIZE);
6224
6225 status = wmi_unified_cmd_send(wmi_handle, buf,
6226 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306227 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306228 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306229 status);
Govind Singh20c5dac2016-03-07 15:33:31 +05306230 }
6231
Govind Singh67922e82016-04-01 16:48:57 +05306232 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306233}
6234
6235/**
6236 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
6237 * @wmi_handle: wmi handle
6238 * @lphb_conf_req: lphb config request
6239 *
6240 * Return: CDF status
6241 */
Govind Singhb53420c2016-03-09 14:32:57 +05306242QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306243 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
6244{
Govind Singh67922e82016-04-01 16:48:57 +05306245 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306246 wmi_buf_t buf = NULL;
6247 uint8_t *buf_ptr;
6248 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
6249 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
6250
6251 buf = wmi_buf_alloc(wmi_handle, len);
6252 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306253 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6254 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306255 }
6256
6257 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6258 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
6259 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
6260 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
6261 WMITLV_GET_STRUCT_TLVLEN
6262 (wmi_hb_set_udp_params_cmd_fixed_param));
6263
6264 /* fill in values */
6265 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
6266 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
6267 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
6268 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
6269 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
6270 hb_udp_params_fp->interval = lphb_conf_req->interval;
6271 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
6272 hb_udp_params_fp->session = lphb_conf_req->session;
Govind Singhb53420c2016-03-09 14:32:57 +05306273 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
Govind Singh20c5dac2016-03-07 15:33:31 +05306274 &lphb_conf_req->gateway_mac,
6275 sizeof(lphb_conf_req->gateway_mac));
6276
6277 status = wmi_unified_cmd_send(wmi_handle, buf,
6278 len, WMI_HB_SET_UDP_PARAMS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306279 if (QDF_IS_STATUS_ERROR(status))
Govind Singhb53420c2016-03-09 14:32:57 +05306280 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306281 status);
Govind Singh20c5dac2016-03-07 15:33:31 +05306282
Govind Singh67922e82016-04-01 16:48:57 +05306283 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306284}
6285
6286/**
6287 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
6288 * @wmi_handle: wmi handle
6289 * @lphb_conf_req: lphb config request
6290 *
6291 * Return: CDF status
6292 */
Govind Singhb53420c2016-03-09 14:32:57 +05306293QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306294 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
6295{
Govind Singh67922e82016-04-01 16:48:57 +05306296 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306297 wmi_buf_t buf = NULL;
6298 uint8_t *buf_ptr;
6299 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
6300 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
6301
6302 buf = wmi_buf_alloc(wmi_handle, len);
6303 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306304 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6305 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306306 }
6307
6308 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6309 hb_udp_filter_fp =
6310 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
6311 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
6312 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
6313 WMITLV_GET_STRUCT_TLVLEN
6314 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
6315
6316 /* fill in values */
6317 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
6318 hb_udp_filter_fp->length = lphb_conf_req->length;
6319 hb_udp_filter_fp->offset = lphb_conf_req->offset;
6320 hb_udp_filter_fp->session = lphb_conf_req->session;
6321 memcpy((void *)&hb_udp_filter_fp->filter,
6322 (void *)&lphb_conf_req->filter,
6323 WMI_WLAN_HB_MAX_FILTER_SIZE);
6324
6325 status = wmi_unified_cmd_send(wmi_handle, buf,
6326 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306327 if (QDF_IS_STATUS_ERROR(status))
Govind Singhb53420c2016-03-09 14:32:57 +05306328 WMI_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306329 status);
Govind Singh20c5dac2016-03-07 15:33:31 +05306330
Govind Singh67922e82016-04-01 16:48:57 +05306331 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306332}
6333#endif /* FEATURE_WLAN_LPHB */
6334
6335/**
6336 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
6337 * @wmi_handle: wmi handle
6338 * @ta_dhcp_ind: DHCP indication parameter
6339 *
6340 * Return: CDF Status
6341 */
Govind Singhb53420c2016-03-09 14:32:57 +05306342QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306343 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
6344{
Govind Singh67922e82016-04-01 16:48:57 +05306345 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306346 wmi_buf_t buf = NULL;
6347 uint8_t *buf_ptr;
6348 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
6349 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
6350
6351
6352 buf = wmi_buf_alloc(wmi_handle, len);
6353 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306354 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6355 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306356 }
6357
6358 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6359 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
6360 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
6361 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
6362 WMITLV_GET_STRUCT_TLVLEN
6363 (wmi_peer_set_param_cmd_fixed_param));
6364
6365 /* fill in values */
6366 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
6367 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
6368 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05306369 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05306370 &ta_dhcp_ind->peer_macaddr,
6371 sizeof(ta_dhcp_ind->peer_macaddr));
6372
6373 status = wmi_unified_cmd_send(wmi_handle, buf,
6374 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306375 if (QDF_IS_STATUS_ERROR(status))
Govind Singhb53420c2016-03-09 14:32:57 +05306376 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05306377 " returned Error %d", __func__, status);
Govind Singh20c5dac2016-03-07 15:33:31 +05306378
Govind Singh67922e82016-04-01 16:48:57 +05306379 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05306380}
6381
6382/**
6383 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
6384 * @wmi_handle: wmi handle
6385 * @pLinkSpeed: link speed info
6386 *
6387 * Return: CDF status
6388 */
Govind Singhb53420c2016-03-09 14:32:57 +05306389QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306390 wmi_mac_addr peer_macaddr)
6391{
6392 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
6393 wmi_buf_t wmi_buf;
6394 uint32_t len;
6395 uint8_t *buf_ptr;
6396
6397 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
6398 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6399 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306400 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6401 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306402 }
6403 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6404
6405 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
6406 WMITLV_SET_HDR(&cmd->tlv_header,
6407 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
6408 WMITLV_GET_STRUCT_TLVLEN
6409 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
6410
6411 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05306412 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05306413 &peer_macaddr,
6414 sizeof(peer_macaddr));
6415
6416
6417 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6418 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306419 WMI_LOGE("%s: failed to send link speed command", __func__);
6420 qdf_nbuf_free(wmi_buf);
6421 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306422 }
Govind Singhb53420c2016-03-09 14:32:57 +05306423 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306424}
6425
6426/**
6427 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
6428 * @wmi_handle: wmi handler
6429 * @egap_params: pointer to egap_params
6430 *
6431 * Return: 0 for success, otherwise appropriate error code
6432 */
Govind Singhb53420c2016-03-09 14:32:57 +05306433QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306434 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
6435{
6436 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
6437 wmi_buf_t buf;
6438 int32_t err;
6439
6440 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
6441 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306442 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
6443 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306444 }
6445 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
6446 WMITLV_SET_HDR(&cmd->tlv_header,
6447 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
6448 WMITLV_GET_STRUCT_TLVLEN(
6449 wmi_ap_ps_egap_param_cmd_fixed_param));
6450
6451 cmd->enable = egap_params->enable;
6452 cmd->inactivity_time = egap_params->inactivity_time;
6453 cmd->wait_time = egap_params->wait_time;
6454 cmd->flags = egap_params->flags;
6455 err = wmi_unified_cmd_send(wmi_handle, buf,
6456 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
6457 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05306458 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05306459 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306460 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306461 }
6462
Govind Singhb53420c2016-03-09 14:32:57 +05306463 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306464}
6465
6466/**
6467 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
6468 * @wmi_handl: wmi handle
6469 * @cmd: Profiling command index
6470 * @value1: parameter1 value
6471 * @value2: parameter2 value
6472 *
Govind Singhe7f2f342016-05-23 12:12:52 +05306473 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05306474 */
Govind Singhb53420c2016-03-09 14:32:57 +05306475QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306476 uint32_t cmd, uint32_t value1, uint32_t value2)
6477{
6478 wmi_buf_t buf;
6479 int32_t len = 0;
6480 int ret;
6481 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
6482 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
6483 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
6484 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
6485
6486 switch (cmd) {
6487 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
6488 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
6489 buf = wmi_buf_alloc(wmi_handle, len);
6490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306491 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306492 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306493 }
6494 prof_trig_cmd =
6495 (wmi_wlan_profile_trigger_cmd_fixed_param *)
6496 wmi_buf_data(buf);
6497 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
6498 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
6499 WMITLV_GET_STRUCT_TLVLEN
6500 (wmi_wlan_profile_trigger_cmd_fixed_param));
6501 prof_trig_cmd->enable = value1;
6502 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6503 WMI_WLAN_PROFILE_TRIGGER_CMDID);
6504 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306505 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306506 value1);
Govind Singhb53420c2016-03-09 14:32:57 +05306507 qdf_nbuf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306508 return ret;
6509 }
6510 break;
6511
6512 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
6513 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
6514 buf = wmi_buf_alloc(wmi_handle, len);
6515 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306516 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306517 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306518 }
6519 profile_getdata_cmd =
6520 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
6521 wmi_buf_data(buf);
6522 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
6523 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
6524 WMITLV_GET_STRUCT_TLVLEN
6525 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
6526 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6527 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
6528 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306529 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306530 value1, value2);
Govind Singhb53420c2016-03-09 14:32:57 +05306531 qdf_nbuf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306532 return ret;
6533 }
6534 break;
6535
6536 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
6537 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
6538 buf = wmi_buf_alloc(wmi_handle, len);
6539 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306540 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306541 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306542 }
6543 hist_intvl_cmd =
6544 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
6545 wmi_buf_data(buf);
6546 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
6547 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
6548 WMITLV_GET_STRUCT_TLVLEN
6549 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
6550 hist_intvl_cmd->profile_id = value1;
6551 hist_intvl_cmd->value = value2;
6552 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6553 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
6554 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306555 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306556 value1, value2);
Govind Singhb53420c2016-03-09 14:32:57 +05306557 qdf_nbuf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306558 return ret;
6559 }
6560 break;
6561
6562 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
6563 len =
6564 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
6565 buf = wmi_buf_alloc(wmi_handle, len);
6566 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306567 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306568 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306569 }
6570 profile_enable_cmd =
6571 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
6572 wmi_buf_data(buf);
6573 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
6574 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
6575 WMITLV_GET_STRUCT_TLVLEN
6576 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
6577 profile_enable_cmd->profile_id = value1;
6578 profile_enable_cmd->enable = value2;
6579 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6580 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
6581 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306582 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306583 value1, value2);
Govind Singhb53420c2016-03-09 14:32:57 +05306584 qdf_nbuf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306585 return ret;
6586 }
6587 break;
6588
6589 default:
Govind Singhb53420c2016-03-09 14:32:57 +05306590 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05306591 break;
6592 }
6593
6594 return 0;
6595}
6596
6597#ifdef FEATURE_WLAN_RA_FILTERING
6598/**
6599 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
6600 * @wmi_handle: wmi handle
6601 * @vdev_id: vdev id
6602 *
6603 * Return: CDF status
6604 */
Govind Singhb53420c2016-03-09 14:32:57 +05306605QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306606 uint8_t vdev_id, uint8_t default_pattern,
6607 uint16_t rate_limit_interval)
6608{
6609
6610 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
6611 wmi_buf_t buf;
6612 uint8_t *buf_ptr;
6613 int32_t len;
6614 int ret;
6615
6616 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
6617 WMI_TLV_HDR_SIZE +
6618 0 * sizeof(WOW_BITMAP_PATTERN_T) +
6619 WMI_TLV_HDR_SIZE +
6620 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
6621 WMI_TLV_HDR_SIZE +
6622 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
6623 WMI_TLV_HDR_SIZE +
6624 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
6625 WMI_TLV_HDR_SIZE +
6626 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
6627
6628 buf = wmi_buf_alloc(wmi_handle, len);
6629 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306630 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6631 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306632 }
6633
6634 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
6635 buf_ptr = (uint8_t *) cmd;
6636
6637 WMITLV_SET_HDR(&cmd->tlv_header,
6638 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
6639 WMITLV_GET_STRUCT_TLVLEN
6640 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
6641 cmd->vdev_id = vdev_id;
6642 cmd->pattern_id = default_pattern,
6643 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
6644 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
6645
6646 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
6647 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6648 buf_ptr += WMI_TLV_HDR_SIZE;
6649
6650 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
6651 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6652 buf_ptr += WMI_TLV_HDR_SIZE;
6653
6654 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
6655 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6656 buf_ptr += WMI_TLV_HDR_SIZE;
6657
6658 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
6659 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6660 buf_ptr += WMI_TLV_HDR_SIZE;
6661
6662 /* Fill TLV for pattern_info_timeout but no data. */
6663 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6664 buf_ptr += WMI_TLV_HDR_SIZE;
6665
6666 /* Fill TLV for ra_ratelimit_interval. */
6667 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
6668 buf_ptr += WMI_TLV_HDR_SIZE;
6669
6670 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
6671
Govind Singhb53420c2016-03-09 14:32:57 +05306672 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05306673 rate_limit_interval, vdev_id);
6674
6675 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6676 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
6677 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306678 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05306679 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306680 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306681 }
6682
Govind Singhb53420c2016-03-09 14:32:57 +05306683 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306684
6685}
6686#endif /* FEATURE_WLAN_RA_FILTERING */
6687
6688/**
6689 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
6690 * @wmi_handle: wmi handle
6691 * @vdev_id: vdev id
6692 *
Govind Singhe7f2f342016-05-23 12:12:52 +05306693 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05306694 */
Govind Singhb53420c2016-03-09 14:32:57 +05306695QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05306696{
6697 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
6698 wmi_buf_t buf;
6699 int32_t len = sizeof(*cmd);
6700
Govind Singhb53420c2016-03-09 14:32:57 +05306701 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05306702 buf = wmi_buf_alloc(wmi_handle, len);
6703 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306704 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306705 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306706 }
6707 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
6708 wmi_buf_data(buf);
6709 WMITLV_SET_HDR(&cmd->tlv_header,
6710 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
6711 WMITLV_GET_STRUCT_TLVLEN
6712 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
6713 cmd->vdev_id = vdev_id;
6714 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
6715 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6716 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306717 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05306718 __func__);
6719 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05306720 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306721 }
6722
6723 return 0;
6724}
6725
6726/**
6727 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
6728 * @wmi_handle: wmi handle
6729 * @vdev_id: vdev id
6730 *
Govind Singhe7f2f342016-05-23 12:12:52 +05306731 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05306732 */
Govind Singhb53420c2016-03-09 14:32:57 +05306733QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306734 uint8_t vdev_id)
6735{
6736 wmi_csa_offload_enable_cmd_fixed_param *cmd;
6737 wmi_buf_t buf;
6738 int32_t len = sizeof(*cmd);
6739
Govind Singhb53420c2016-03-09 14:32:57 +05306740 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05306741 buf = wmi_buf_alloc(wmi_handle, len);
6742 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306743 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306744 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306745 }
6746 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
6747 WMITLV_SET_HDR(&cmd->tlv_header,
6748 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
6749 WMITLV_GET_STRUCT_TLVLEN
6750 (wmi_csa_offload_enable_cmd_fixed_param));
6751 cmd->vdev_id = vdev_id;
6752 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
6753 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6754 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306755 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05306756 __func__);
6757 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05306758 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306759 }
6760
6761 return 0;
6762}
6763
6764/**
6765 * send_start_oem_data_cmd_tlv() - start OEM data request to target
6766 * @wmi_handle: wmi handle
6767 * @startOemDataReq: start request params
6768 *
6769 * Return: CDF status
6770 */
Govind Singhb53420c2016-03-09 14:32:57 +05306771QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306772 uint8_t data_len,
6773 uint8_t *data)
6774{
6775 wmi_buf_t buf;
6776 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05306777 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05306778
6779 buf = wmi_buf_alloc(wmi_handle,
6780 (data_len + WMI_TLV_HDR_SIZE));
6781 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306782 WMI_LOGE(FL("wmi_buf_alloc failed"));
6783 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306784 }
6785
6786 cmd = (uint8_t *) wmi_buf_data(buf);
6787
6788 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
6789 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05306790 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05306791 data_len);
6792
Govind Singhb53420c2016-03-09 14:32:57 +05306793 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05306794 data_len);
6795
6796 ret = wmi_unified_cmd_send(wmi_handle, buf,
6797 (data_len +
6798 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
6799
Govind Singh67922e82016-04-01 16:48:57 +05306800 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306801 WMI_LOGE(FL(":wmi cmd send failed"));
6802 qdf_nbuf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05306803 }
6804
Govind Singh67922e82016-04-01 16:48:57 +05306805 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05306806}
6807
6808/**
6809 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
6810 * @wmi_handle: wmi handle
6811 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
6812 *
6813 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
6814 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
6815 * to firmware based on phyerr filtering
6816 * offload status.
6817 *
6818 * Return: 1 success, 0 failure
6819 */
Govind Singhb53420c2016-03-09 14:32:57 +05306820QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05306821send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
6822 bool dfs_phyerr_filter_offload)
6823{
6824 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
6825 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
6826 wmi_buf_t buf;
6827 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05306828 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05306829
6830
6831 if (dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05306832 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05306833 __func__);
6834 len = sizeof(*disable_phyerr_offload_cmd);
6835 buf = wmi_buf_alloc(wmi_handle, len);
6836 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306837 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05306838 return 0;
6839 }
6840 disable_phyerr_offload_cmd =
6841 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
6842 wmi_buf_data(buf);
6843
6844 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
6845 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
6846 WMITLV_GET_STRUCT_TLVLEN
6847 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
6848
6849 /*
6850 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
6851 * to the firmware to disable the phyerror
6852 * filtering offload.
6853 */
6854 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6855 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306856 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306857 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306858 __func__, ret);
6859 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306860 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306861 }
Govind Singhb53420c2016-03-09 14:32:57 +05306862 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05306863 __func__);
6864 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05306865 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05306866 __func__);
6867
6868 len = sizeof(*enable_phyerr_offload_cmd);
6869 buf = wmi_buf_alloc(wmi_handle, len);
6870 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306871 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
6872 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306873 }
6874
6875 enable_phyerr_offload_cmd =
6876 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
6877 wmi_buf_data(buf);
6878
6879 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
6880 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
6881 WMITLV_GET_STRUCT_TLVLEN
6882 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
6883
6884 /*
6885 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
6886 * to the firmware to enable the phyerror
6887 * filtering offload.
6888 */
6889 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6890 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
6891
Govind Singh67922e82016-04-01 16:48:57 +05306892 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306893 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05306894 __func__, ret);
6895 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306896 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306897 }
Govind Singhb53420c2016-03-09 14:32:57 +05306898 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05306899 __func__);
6900 }
6901
Govind Singhb53420c2016-03-09 14:32:57 +05306902 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306903}
6904
6905#if !defined(REMOVE_PKT_LOG)
6906/**
6907 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
6908 * @wmi_handle: wmi handle
6909 * @pktlog_event: pktlog event
6910 * @cmd_id: pktlog cmd id
6911 *
6912 * Return: CDF status
6913 */
Govind Singhb53420c2016-03-09 14:32:57 +05306914QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306915 WMI_PKTLOG_EVENT pktlog_event,
6916 WMI_CMD_ID cmd_id)
6917{
6918 WMI_PKTLOG_EVENT PKTLOG_EVENT;
6919 WMI_CMD_ID CMD_ID;
6920 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
6921 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
6922 int len = 0;
6923 wmi_buf_t buf;
6924
6925 PKTLOG_EVENT = pktlog_event;
6926 CMD_ID = cmd_id;
6927
6928 switch (CMD_ID) {
6929 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
6930 len = sizeof(*cmd);
6931 buf = wmi_buf_alloc(wmi_handle, len);
6932 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306933 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
6934 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306935 }
6936 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
6937 wmi_buf_data(buf);
6938 WMITLV_SET_HDR(&cmd->tlv_header,
6939 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
6940 WMITLV_GET_STRUCT_TLVLEN
6941 (wmi_pdev_pktlog_enable_cmd_fixed_param));
6942 cmd->evlist = PKTLOG_EVENT;
Govind Singh4df47142016-04-16 19:24:23 -07006943 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05306944 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6945 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306946 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05306947 goto wmi_send_failed;
6948 }
6949 break;
6950 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
6951 len = sizeof(*disable_cmd);
6952 buf = wmi_buf_alloc(wmi_handle, len);
6953 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306954 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
6955 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05306956 }
6957 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
6958 wmi_buf_data(buf);
6959 WMITLV_SET_HDR(&disable_cmd->tlv_header,
6960 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
6961 WMITLV_GET_STRUCT_TLVLEN
6962 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07006963 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05306964 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6965 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306966 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05306967 goto wmi_send_failed;
6968 }
6969 break;
6970 default:
Govind Singhb53420c2016-03-09 14:32:57 +05306971 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05306972 break;
6973 }
6974
Govind Singhb53420c2016-03-09 14:32:57 +05306975 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05306976
6977wmi_send_failed:
6978 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306979 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05306980}
6981#endif /* REMOVE_PKT_LOG */
6982
6983/**
6984 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
6985 * @wmi_handle: wmi handle
6986 * @vdev_id: vdev id
6987 * @bitmap: Event bitmap
6988 * @enable: enable/disable
6989 *
6990 * Return: CDF status
6991 */
Govind Singhb53420c2016-03-09 14:32:57 +05306992QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05306993 uint32_t vdev_id,
6994 uint32_t bitmap,
6995 bool enable)
6996{
6997 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
6998 uint16_t len;
6999 wmi_buf_t buf;
7000 int ret;
7001
7002 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
7003 buf = wmi_buf_alloc(wmi_handle, len);
7004 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307005 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7006 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307007 }
7008 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
7009 WMITLV_SET_HDR(&cmd->tlv_header,
7010 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
7011 WMITLV_GET_STRUCT_TLVLEN
7012 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
7013 cmd->vdev_id = vdev_id;
7014 cmd->is_add = enable;
7015 cmd->event_bitmap = bitmap;
7016
7017 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7018 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
7019 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307020 WMI_LOGE("Failed to config wow wakeup event");
Govind Singh20c5dac2016-03-07 15:33:31 +05307021 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307022 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307023 }
7024
Govind Singhb53420c2016-03-09 14:32:57 +05307025 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
Govind Singh20c5dac2016-03-07 15:33:31 +05307026 enable ? "enabled" : "disabled");
7027
Govind Singhb53420c2016-03-09 14:32:57 +05307028 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307029}
7030
7031/**
7032 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
7033 * @wmi_handle: wmi handle
7034 * @vdev_id: vdev id
7035 * @ptrn_id: pattern id
7036 * @ptrn: pattern
7037 * @ptrn_len: pattern length
7038 * @ptrn_offset: pattern offset
7039 * @mask: mask
7040 * @mask_len: mask length
7041 * @user: true for user configured pattern and false for default pattern
7042 * @default_patterns: default patterns
7043 *
7044 * Return: CDF status
7045 */
Govind Singhb53420c2016-03-09 14:32:57 +05307046QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307047 uint8_t vdev_id, uint8_t ptrn_id,
7048 const uint8_t *ptrn, uint8_t ptrn_len,
7049 uint8_t ptrn_offset, const uint8_t *mask,
7050 uint8_t mask_len, bool user,
7051 uint8_t default_patterns)
7052{
7053 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
7054 WOW_BITMAP_PATTERN_T *bitmap_pattern;
7055 wmi_buf_t buf;
7056 uint8_t *buf_ptr;
7057 int32_t len;
7058 int ret;
7059
7060
7061 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
7062 WMI_TLV_HDR_SIZE +
7063 1 * sizeof(WOW_BITMAP_PATTERN_T) +
7064 WMI_TLV_HDR_SIZE +
7065 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
7066 WMI_TLV_HDR_SIZE +
7067 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
7068 WMI_TLV_HDR_SIZE +
7069 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
7070 WMI_TLV_HDR_SIZE +
7071 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
7072
7073 buf = wmi_buf_alloc(wmi_handle, len);
7074 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307075 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7076 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307077 }
7078
7079 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7080 buf_ptr = (uint8_t *) cmd;
7081
7082 WMITLV_SET_HDR(&cmd->tlv_header,
7083 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
7084 WMITLV_GET_STRUCT_TLVLEN
7085 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
7086 cmd->vdev_id = vdev_id;
7087 cmd->pattern_id = ptrn_id;
7088
7089 cmd->pattern_type = WOW_BITMAP_PATTERN;
7090 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
7091
7092 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7093 sizeof(WOW_BITMAP_PATTERN_T));
7094 buf_ptr += WMI_TLV_HDR_SIZE;
7095 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
7096
7097 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
7098 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
7099 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
7100
Govind Singhb53420c2016-03-09 14:32:57 +05307101 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
7102 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05307103
7104 bitmap_pattern->pattern_offset = ptrn_offset;
7105 bitmap_pattern->pattern_len = ptrn_len;
7106
7107 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
7108 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
7109
7110 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
7111 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
7112
7113 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
7114 bitmap_pattern->pattern_id = ptrn_id;
7115
Govind Singhb53420c2016-03-09 14:32:57 +05307116 WMI_LOGI("vdev id : %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307117 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
7118 bitmap_pattern->pattern_offset, user);
7119
Govind Singhb53420c2016-03-09 14:32:57 +05307120 WMI_LOGI("Pattern : ");
7121 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307122 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
7123
Govind Singhb53420c2016-03-09 14:32:57 +05307124 WMI_LOGI("Mask : ");
7125 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh20c5dac2016-03-07 15:33:31 +05307126 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
7127
7128 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
7129
7130 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
7131 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7132 buf_ptr += WMI_TLV_HDR_SIZE;
7133
7134 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
7135 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7136 buf_ptr += WMI_TLV_HDR_SIZE;
7137
7138 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
7139 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7140 buf_ptr += WMI_TLV_HDR_SIZE;
7141
7142 /* Fill TLV for pattern_info_timeout but no data. */
7143 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7144 buf_ptr += WMI_TLV_HDR_SIZE;
7145
7146 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
7147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
7148 buf_ptr += WMI_TLV_HDR_SIZE;
7149 *(A_UINT32 *) buf_ptr = 0;
7150
7151 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7152 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
7153 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307154 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307155 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307156 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307157 }
7158
Govind Singhb53420c2016-03-09 14:32:57 +05307159 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307160}
7161
7162/**
7163 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
7164 * @wmi_handle: wmi handle
7165 * @ptrn_id: pattern id
7166 * @vdev_id: vdev id
7167 *
7168 * Return: CDF status
7169 */
Govind Singhb53420c2016-03-09 14:32:57 +05307170QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle, uint8_t ptrn_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307171 uint8_t vdev_id)
7172{
7173 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
7174 wmi_buf_t buf;
7175 int32_t len;
7176 int ret;
7177
7178 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
7179
7180
7181 buf = wmi_buf_alloc(wmi_handle, len);
7182 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307183 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7184 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307185 }
7186
7187 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7188
7189 WMITLV_SET_HDR(&cmd->tlv_header,
7190 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
7191 WMITLV_GET_STRUCT_TLVLEN(
7192 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
7193 cmd->vdev_id = vdev_id;
7194 cmd->pattern_id = ptrn_id;
7195 cmd->pattern_type = WOW_BITMAP_PATTERN;
7196
Govind Singhb53420c2016-03-09 14:32:57 +05307197 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05307198 cmd->pattern_id, vdev_id);
7199
7200 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7201 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
7202 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307203 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307204 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307205 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307206 }
7207
Govind Singhb53420c2016-03-09 14:32:57 +05307208 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307209}
7210
7211/**
7212 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
7213 * @wmi_handle: wmi handle
7214 *
7215 * Sends host wakeup indication to FW. On receiving this indication,
7216 * FW will come out of WOW.
7217 *
7218 * Return: CDF status
7219 */
Govind Singhb53420c2016-03-09 14:32:57 +05307220QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307221{
7222 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
7223 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05307224 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307225 int32_t len;
7226 int ret;
7227
7228 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
7229
7230 buf = wmi_buf_alloc(wmi_handle, len);
7231 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307232 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7233 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307234 }
7235
7236 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
7237 wmi_buf_data(buf);
7238 WMITLV_SET_HDR(&cmd->tlv_header,
7239 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
7240 WMITLV_GET_STRUCT_TLVLEN
7241 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
7242
7243
7244 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7245 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
7246 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307247 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307248 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307249 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307250 }
7251
Govind Singhb53420c2016-03-09 14:32:57 +05307252 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307253}
7254
7255/**
7256 * send_del_ts_cmd_tlv() - send DELTS request to fw
7257 * @wmi_handle: wmi handle
7258 * @msg: delts params
7259 *
7260 * Return: CDF status
7261 */
Govind Singhb53420c2016-03-09 14:32:57 +05307262QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307263 uint8_t ac)
7264{
7265 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
7266 wmi_buf_t buf;
7267 int32_t len = sizeof(*cmd);
7268
7269 buf = wmi_buf_alloc(wmi_handle, len);
7270 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307271 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7272 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307273 }
7274 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
7275 WMITLV_SET_HDR(&cmd->tlv_header,
7276 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
7277 WMITLV_GET_STRUCT_TLVLEN
7278 (wmi_vdev_wmm_delts_cmd_fixed_param));
7279 cmd->vdev_id = vdev_id;
7280 cmd->ac = ac;
7281
Govind Singhb53420c2016-03-09 14:32:57 +05307282 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307283 cmd->vdev_id, cmd->ac, __func__, __LINE__);
7284 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7285 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307286 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
7287 qdf_nbuf_free(buf);
7288 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307289 }
7290
Govind Singhb53420c2016-03-09 14:32:57 +05307291 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307292}
7293
7294/**
7295 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
7296 * @wmi_handle: handle to wmi
7297 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
7298 *
Govind Singhb53420c2016-03-09 14:32:57 +05307299 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05307300 * ADD_TS requestes to firmware in loop for all the ACs with
7301 * active flow.
7302 *
7303 * Return: CDF status
7304 */
Govind Singhb53420c2016-03-09 14:32:57 +05307305QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307306 struct aggr_add_ts_param *aggr_qos_rsp_msg)
7307{
7308 int i = 0;
7309 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
7310 wmi_buf_t buf;
7311 int32_t len = sizeof(*cmd);
7312
7313 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
7314 /* if flow in this AC is active */
7315 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
7316 /*
7317 * as per implementation of wma_add_ts_req() we
7318 * are not waiting any response from firmware so
7319 * apart from sending ADDTS to firmware just send
7320 * success to upper layers
7321 */
Govind Singhb53420c2016-03-09 14:32:57 +05307322 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307323
7324 buf = wmi_buf_alloc(wmi_handle, len);
7325 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307326 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7327 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307328 }
7329 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
7330 wmi_buf_data(buf);
7331 WMITLV_SET_HDR(&cmd->tlv_header,
7332 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
7333 WMITLV_GET_STRUCT_TLVLEN
7334 (wmi_vdev_wmm_addts_cmd_fixed_param));
7335 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
7336 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05307337 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05307338 traffic.userPrio);
7339 cmd->medium_time_us =
7340 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
7341 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05307342 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307343 __func__, __LINE__, cmd->vdev_id, cmd->ac,
7344 cmd->medium_time_us, cmd->downgrade_type);
7345 if (wmi_unified_cmd_send
7346 (wmi_handle, buf, len,
7347 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307348 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307349 __func__);
7350 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05307351 QDF_STATUS_E_FAILURE;
7352 qdf_nbuf_free(buf);
7353 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307354 }
7355 }
7356 }
7357
Govind Singhb53420c2016-03-09 14:32:57 +05307358 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307359}
7360
7361/**
7362 * send_add_ts_cmd_tlv() - send ADDTS request to fw
7363 * @wmi_handle: wmi handle
7364 * @msg: ADDTS params
7365 *
7366 * Return: CDF status
7367 */
Govind Singhb53420c2016-03-09 14:32:57 +05307368QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307369 struct add_ts_param *msg)
7370{
7371 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
7372 wmi_buf_t buf;
7373 int32_t len = sizeof(*cmd);
7374
Govind Singhb53420c2016-03-09 14:32:57 +05307375 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307376
7377 buf = wmi_buf_alloc(wmi_handle, len);
7378 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307379 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7380 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307381 }
7382 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
7383 WMITLV_SET_HDR(&cmd->tlv_header,
7384 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
7385 WMITLV_GET_STRUCT_TLVLEN
7386 (wmi_vdev_wmm_addts_cmd_fixed_param));
7387 cmd->vdev_id = msg->sme_session_id;
7388 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
7389 cmd->medium_time_us = msg->tspec.mediumTime * 32;
7390 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05307391 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307392 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
7393 cmd->downgrade_type, __func__, __LINE__);
7394 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7395 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307396 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
7397 msg->status = QDF_STATUS_E_FAILURE;
7398 qdf_nbuf_free(buf);
7399 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307400 }
7401
Govind Singhb53420c2016-03-09 14:32:57 +05307402 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307403}
7404
7405/**
7406 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
7407 * @wmi_handle: wmi handle
7408 * @vdev_id: vdev id
7409 * @enable: Flag to enable/disable packet filter
7410 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307411 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307412 */
Govind Singhb53420c2016-03-09 14:32:57 +05307413QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307414 uint8_t vdev_id, bool enable)
7415{
7416 int32_t len;
7417 int ret = 0;
7418 wmi_buf_t buf;
7419 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
7420
7421 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
7422
7423 buf = wmi_buf_alloc(wmi_handle, len);
7424 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307425 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307426 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307427 }
7428
7429 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
7430 WMITLV_SET_HDR(&cmd->tlv_header,
7431 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
7432 WMITLV_GET_STRUCT_TLVLEN(
7433 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
7434
7435 cmd->vdev_id = vdev_id;
7436 if (enable)
7437 cmd->enable = PACKET_FILTER_SET_ENABLE;
7438 else
7439 cmd->enable = PACKET_FILTER_SET_DISABLE;
7440
Govind Singhb53420c2016-03-09 14:32:57 +05307441 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307442 __func__, cmd->enable, vdev_id);
7443
7444 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7445 WMI_PACKET_FILTER_ENABLE_CMDID);
7446 if (ret)
Govind Singhb53420c2016-03-09 14:32:57 +05307447 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307448
7449 return ret;
7450}
7451
7452/**
7453 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
7454 * @wmi_handle: wmi handle
7455 * @vdev_id: vdev id
7456 * @rcv_filter_param: Packet filter parameters
7457 * @filter_id: Filter id
7458 * @enable: Flag to add/delete packet filter configuration
7459 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307460 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307461 */
Govind Singhb53420c2016-03-09 14:32:57 +05307462QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307463 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
7464 uint8_t filter_id, bool enable)
7465{
7466 int len, i;
7467 int err = 0;
7468 wmi_buf_t buf;
7469 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
7470
7471
7472 /* allocate the memory */
7473 len = sizeof(*cmd);
7474 buf = wmi_buf_alloc(wmi_handle, len);
7475 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307476 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05307477 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307478 }
7479
7480 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
7481 WMITLV_SET_HDR(&cmd->tlv_header,
7482 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
7483 WMITLV_GET_STRUCT_TLVLEN
7484 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
7485
7486 cmd->vdev_id = vdev_id;
7487 cmd->filter_id = filter_id;
7488 if (enable)
7489 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
7490 else
7491 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
7492
7493 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05307494 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05307495 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
7496 rcv_filter_param->numFieldParams);
7497 cmd->filter_type = rcv_filter_param->filterType;
7498 cmd->coalesce_time = rcv_filter_param->coalesceTime;
7499
7500 for (i = 0; i < cmd->num_params; i++) {
7501 cmd->paramsData[i].proto_type =
7502 rcv_filter_param->paramsData[i].protocolLayer;
7503 cmd->paramsData[i].cmp_type =
7504 rcv_filter_param->paramsData[i].cmpFlag;
7505 cmd->paramsData[i].data_length =
7506 rcv_filter_param->paramsData[i].dataLength;
7507 cmd->paramsData[i].data_offset =
7508 rcv_filter_param->paramsData[i].dataOffset;
7509 memcpy(&cmd->paramsData[i].compareData,
7510 rcv_filter_param->paramsData[i].compareData,
7511 sizeof(cmd->paramsData[i].compareData));
7512 memcpy(&cmd->paramsData[i].dataMask,
7513 rcv_filter_param->paramsData[i].dataMask,
7514 sizeof(cmd->paramsData[i].dataMask));
7515 }
7516 }
7517
Govind Singhb53420c2016-03-09 14:32:57 +05307518 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307519 cmd->filter_action, cmd->filter_id, cmd->num_params);
7520 /* send the command along with data */
7521 err = wmi_unified_cmd_send(wmi_handle, buf, len,
7522 WMI_PACKET_FILTER_CONFIG_CMDID);
7523 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307524 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307525 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307526 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307527 }
7528
7529
7530 return 0;
7531}
7532
7533/**
7534 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
7535 * @wmi_handle: wmi handle
7536 * @vdev_id: vdev id
7537 * @multicastAddr: mcast address
7538 * @clearList: clear list flag
7539 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307540 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307541 */
Govind Singhb53420c2016-03-09 14:32:57 +05307542QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307543 uint8_t vdev_id,
Govind Singhb53420c2016-03-09 14:32:57 +05307544 struct qdf_mac_addr multicast_addr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307545 bool clearList)
7546{
7547 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
7548 wmi_buf_t buf;
7549 int err;
7550
7551 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7552 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307553 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05307554 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307555 }
7556
7557 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307558 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05307559
7560 WMITLV_SET_HDR(&cmd->tlv_header,
7561 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
7562 WMITLV_GET_STRUCT_TLVLEN
7563 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
7564 cmd->action =
7565 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
7566 cmd->vdev_id = vdev_id;
7567 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
7568 err = wmi_unified_cmd_send(wmi_handle, buf,
7569 sizeof(*cmd),
7570 WMI_SET_MCASTBCAST_FILTER_CMDID);
7571 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307572 WMI_LOGE("Failed to send set_param cmd");
7573 qdf_mem_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307574 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307575 }
Govind Singhb53420c2016-03-09 14:32:57 +05307576 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307577 cmd->action, vdev_id, clearList);
Govind Singh224a7312016-06-21 14:33:26 +05307578 WMI_LOGD("MCBC MAC Addr: %pM", multicast_addr.bytes);
Govind Singh20c5dac2016-03-07 15:33:31 +05307579
7580 return 0;
7581}
7582
7583/**
7584 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
7585 * @wmi_handle: wmi handle
7586 * @vdev_id: vdev id
7587 * @params: GTK offload parameters
7588 *
7589 * Return: CDF status
7590 */
Govind Singhb53420c2016-03-09 14:32:57 +05307591QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307592 struct gtk_offload_params *params,
7593 bool enable_offload,
7594 uint32_t gtk_offload_opcode)
7595{
7596 int len;
7597 wmi_buf_t buf;
7598 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05307599 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307600
Govind Singhb53420c2016-03-09 14:32:57 +05307601 WMI_LOGD("%s Enter", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307602
7603 len = sizeof(*cmd);
7604
7605 /* alloc wmi buffer */
7606 buf = wmi_buf_alloc(wmi_handle, len);
7607 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307608 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
7609 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307610 goto out;
7611 }
7612
7613 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
7614 WMITLV_SET_HDR(&cmd->tlv_header,
7615 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
7616 WMITLV_GET_STRUCT_TLVLEN
7617 (WMI_GTK_OFFLOAD_CMD_fixed_param));
7618
7619 cmd->vdev_id = vdev_id;
7620
7621 /* Request target to enable GTK offload */
Siddarth Poddar9500f2e2016-04-01 17:45:06 +05307622 if (enable_offload == WMI_GTK_OFFLOAD_ENABLE) {
Govind Singh20c5dac2016-03-07 15:33:31 +05307623 cmd->flags = gtk_offload_opcode;
7624
7625 /* Copy the keys and replay counter */
Govind Singhb53420c2016-03-09 14:32:57 +05307626 qdf_mem_copy(cmd->KCK, params->aKCK, WMI_GTK_OFFLOAD_KCK_BYTES);
7627 qdf_mem_copy(cmd->KEK, params->aKEK, WMI_GTK_OFFLOAD_KEK_BYTES);
7628 qdf_mem_copy(cmd->replay_counter, &params->ullKeyReplayCounter,
Govind Singh20c5dac2016-03-07 15:33:31 +05307629 GTK_REPLAY_COUNTER_BYTES);
7630 } else {
7631 cmd->flags = gtk_offload_opcode;
7632 }
7633
7634 /* send the wmi command */
7635 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7636 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307637 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
Govind Singh20c5dac2016-03-07 15:33:31 +05307638 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307639 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307640 }
7641
Govind Singhb53420c2016-03-09 14:32:57 +05307642 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
Govind Singh20c5dac2016-03-07 15:33:31 +05307643out:
Govind Singhb53420c2016-03-09 14:32:57 +05307644 WMI_LOGD("%s Exit", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307645 return status;
7646}
7647
7648/**
7649 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
7650 * @wmi_handle: wmi handle
7651 * @params: GTK offload params
7652 *
7653 * Return: CDF status
7654 */
Govind Singhb53420c2016-03-09 14:32:57 +05307655QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307656 uint8_t vdev_id,
7657 uint64_t offload_req_opcode)
7658{
7659 int len;
7660 wmi_buf_t buf;
7661 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Govind Singhb53420c2016-03-09 14:32:57 +05307662 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307663
7664 len = sizeof(*cmd);
7665
7666 /* alloc wmi buffer */
7667 buf = wmi_buf_alloc(wmi_handle, len);
7668 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307669 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
7670 status = QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307671 goto out;
7672 }
7673
7674 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
7675 WMITLV_SET_HDR(&cmd->tlv_header,
7676 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
7677 WMITLV_GET_STRUCT_TLVLEN
7678 (WMI_GTK_OFFLOAD_CMD_fixed_param));
7679
7680 /* Request for GTK offload status */
7681 cmd->flags = offload_req_opcode;
7682 cmd->vdev_id = vdev_id;
7683
7684 /* send the wmi command */
7685 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7686 WMI_GTK_OFFLOAD_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307687 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
Govind Singh20c5dac2016-03-07 15:33:31 +05307688 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307689 status = QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307690 }
7691
7692out:
7693 return status;
7694}
7695
7696/**
7697 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
7698 * @wmi_handle: wmi handle
7699 * @pAddPeriodicTxPtrnParams: tx ptrn params
7700 *
7701 * Retrun: CDF status
7702 */
Govind Singhb53420c2016-03-09 14:32:57 +05307703QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307704 struct periodic_tx_pattern *
7705 pAddPeriodicTxPtrnParams,
7706 uint8_t vdev_id)
7707{
7708 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
7709 wmi_buf_t wmi_buf;
7710 uint32_t len;
7711 uint8_t *buf_ptr;
7712 uint32_t ptrn_len, ptrn_len_aligned;
7713 int j;
7714
7715 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
7716 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
7717 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
7718 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
7719
7720 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7721 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307722 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7723 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307724 }
7725
7726 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7727
7728 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
7729 WMITLV_SET_HDR(&cmd->tlv_header,
7730 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
7731 WMITLV_GET_STRUCT_TLVLEN
7732 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
7733
7734 /* Pass the pattern id to delete for the corresponding vdev id */
7735 cmd->vdev_id = vdev_id;
7736 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
7737 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
7738 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
7739
7740 /* Pattern info */
7741 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
7742 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
7743 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307744 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05307745 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05307746 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05307747
Govind Singhb53420c2016-03-09 14:32:57 +05307748 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307749 __func__, cmd->pattern_id, cmd->vdev_id);
7750
7751 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7752 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307753 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307754 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307755 qdf_nbuf_free(wmi_buf);
7756 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307757 }
Govind Singhb53420c2016-03-09 14:32:57 +05307758 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307759}
7760
7761/**
7762 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
7763 * @wmi_handle: wmi handle
7764 * @vdev_id: vdev id
7765 * @pattern_id: pattern id
7766 *
7767 * Retrun: CDF status
7768 */
Govind Singhb53420c2016-03-09 14:32:57 +05307769QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307770 uint8_t vdev_id,
7771 uint8_t pattern_id)
7772{
7773 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
7774 wmi_buf_t wmi_buf;
7775 uint32_t len =
7776 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
7777
7778 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7779 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307780 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7781 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307782 }
7783
7784 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
7785 wmi_buf_data(wmi_buf);
7786 WMITLV_SET_HDR(&cmd->tlv_header,
7787 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
7788 WMITLV_GET_STRUCT_TLVLEN
7789 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
7790
7791 /* Pass the pattern id to delete for the corresponding vdev id */
7792 cmd->vdev_id = vdev_id;
7793 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05307794 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307795 __func__, cmd->pattern_id, cmd->vdev_id);
7796
7797 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7798 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307799 WMI_LOGE("%s: failed to send del pattern command", __func__);
7800 qdf_nbuf_free(wmi_buf);
7801 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307802 }
Govind Singhb53420c2016-03-09 14:32:57 +05307803 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307804}
7805
7806/**
7807 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
7808 * @wmi_handle: wmi handle
7809 * @preq: stats ext params
7810 *
7811 * Return: CDF status
7812 */
Govind Singhb53420c2016-03-09 14:32:57 +05307813QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307814 struct stats_ext_params *preq)
7815{
Govind Singh67922e82016-04-01 16:48:57 +05307816 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307817 wmi_req_stats_ext_cmd_fixed_param *cmd;
7818 wmi_buf_t buf;
7819 uint16_t len;
7820 uint8_t *buf_ptr;
7821
7822 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
7823
7824 buf = wmi_buf_alloc(wmi_handle, len);
7825 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307826 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307827 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307828 }
7829
7830 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7831 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
7832
7833 WMITLV_SET_HDR(&cmd->tlv_header,
7834 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
7835 WMITLV_GET_STRUCT_TLVLEN
7836 (wmi_req_stats_ext_cmd_fixed_param));
7837 cmd->vdev_id = preq->vdev_id;
7838 cmd->data_len = preq->request_data_len;
7839
Govind Singhb53420c2016-03-09 14:32:57 +05307840 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05307841 __func__, preq->request_data_len, preq->vdev_id);
7842
7843 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
7844 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
7845
7846 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307847 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05307848
7849 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7850 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307851 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307852 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05307853 ret);
7854 wmi_buf_free(buf);
7855 }
7856
7857 return ret;
7858}
7859
7860/**
7861 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
7862 * @wmi_handle: wmi handle
7863 * @params: ext wow params
7864 *
7865 * Return:0 for success or error code
7866 */
Govind Singhb53420c2016-03-09 14:32:57 +05307867QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307868 struct ext_wow_params *params)
7869{
7870 wmi_extwow_enable_cmd_fixed_param *cmd;
7871 wmi_buf_t buf;
7872 int32_t len;
7873 int ret;
7874
7875 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
7876 buf = wmi_buf_alloc(wmi_handle, len);
7877 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307878 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7879 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307880 }
7881
7882 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
7883
7884 WMITLV_SET_HDR(&cmd->tlv_header,
7885 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
7886 WMITLV_GET_STRUCT_TLVLEN
7887 (wmi_extwow_enable_cmd_fixed_param));
7888
7889 cmd->vdev_id = params->vdev_id;
7890 cmd->type = params->type;
7891 cmd->wakeup_pin_num = params->wakeup_pin_num;
7892
Govind Singhb53420c2016-03-09 14:32:57 +05307893 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05307894 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
7895
7896 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7897 WMI_EXTWOW_ENABLE_CMDID);
7898 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307899 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307900 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307901 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307902 }
7903
Govind Singhb53420c2016-03-09 14:32:57 +05307904 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307905
7906}
7907
7908/**
7909 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
7910 * @wmi_handle: wmi handle
7911 * @app_type1_params: app type1 params
7912 *
7913 * Return: CDF status
7914 */
Govind Singhb53420c2016-03-09 14:32:57 +05307915QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307916 struct app_type1_params *app_type1_params)
7917{
7918 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
7919 wmi_buf_t buf;
7920 int32_t len;
7921 int ret;
7922
7923 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
7924 buf = wmi_buf_alloc(wmi_handle, len);
7925 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307926 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7927 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307928 }
7929
7930 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
7931 wmi_buf_data(buf);
7932
7933 WMITLV_SET_HDR(&cmd->tlv_header,
7934 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
7935 WMITLV_GET_STRUCT_TLVLEN
7936 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
7937
7938 cmd->vdev_id = app_type1_params->vdev_id;
7939 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
7940 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05307941 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05307942 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05307943 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05307944 cmd->passwd_len = app_type1_params->pass_length;
7945
Govind Singhb53420c2016-03-09 14:32:57 +05307946 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05307947 "identification_id %.8s id_length %u "
7948 "password %.16s pass_length %u",
7949 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
7950 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
7951
7952 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7953 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
7954 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307955 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307956 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307957 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307958 }
7959
Govind Singhb53420c2016-03-09 14:32:57 +05307960 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307961}
7962
7963/**
7964 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
7965 * @wmi_handle: wmi handle
7966 * @appType2Params: app type2 params
7967 *
7968 * Return: CDF status
7969 */
Govind Singhb53420c2016-03-09 14:32:57 +05307970QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307971 struct app_type2_params *appType2Params)
7972{
7973 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
7974 wmi_buf_t buf;
7975 int32_t len;
7976 int ret;
7977
7978 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
7979 buf = wmi_buf_alloc(wmi_handle, len);
7980 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307981 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7982 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307983 }
7984
7985 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
7986 wmi_buf_data(buf);
7987
7988 WMITLV_SET_HDR(&cmd->tlv_header,
7989 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
7990 WMITLV_GET_STRUCT_TLVLEN
7991 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
7992
7993 cmd->vdev_id = appType2Params->vdev_id;
7994
Govind Singhb53420c2016-03-09 14:32:57 +05307995 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05307996 cmd->rc4_key_len = appType2Params->rc4_key_len;
7997
7998 cmd->ip_id = appType2Params->ip_id;
7999 cmd->ip_device_ip = appType2Params->ip_device_ip;
8000 cmd->ip_server_ip = appType2Params->ip_server_ip;
8001
8002 cmd->tcp_src_port = appType2Params->tcp_src_port;
8003 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8004 cmd->tcp_seq = appType2Params->tcp_seq;
8005 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8006
8007 cmd->keepalive_init = appType2Params->keepalive_init;
8008 cmd->keepalive_min = appType2Params->keepalive_min;
8009 cmd->keepalive_max = appType2Params->keepalive_max;
8010 cmd->keepalive_inc = appType2Params->keepalive_inc;
8011
8012 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8013 &cmd->gateway_mac);
8014 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8015 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8016
Govind Singhb53420c2016-03-09 14:32:57 +05308017 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308018 "rc4_key %.16s rc4_key_len %u "
8019 "ip_id %x ip_device_ip %x ip_server_ip %x "
8020 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8021 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8022 "keepalive_max %u keepalive_inc %u "
8023 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8024 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8025 cmd->rc4_key, cmd->rc4_key_len,
8026 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8027 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8028 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8029 cmd->keepalive_max, cmd->keepalive_inc,
8030 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8031
8032 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8033 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8034 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308035 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308036 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308037 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308038 }
8039
Govind Singhb53420c2016-03-09 14:32:57 +05308040 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308041
8042}
8043
8044/**
8045 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8046 * @wmi_handle: wmi handle
8047 * @timer_val: auto shutdown timer value
8048 *
8049 * Return: CDF status
8050 */
Govind Singhb53420c2016-03-09 14:32:57 +05308051QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308052 uint32_t timer_val)
8053{
Govind Singh67922e82016-04-01 16:48:57 +05308054 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308055 wmi_buf_t buf = NULL;
8056 uint8_t *buf_ptr;
8057 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8058 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8059
Govind Singhb53420c2016-03-09 14:32:57 +05308060 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308061 __func__, timer_val);
8062
8063 buf = wmi_buf_alloc(wmi_handle, len);
8064 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308065 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8066 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308067 }
8068
8069 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8070 wmi_auto_sh_cmd =
8071 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8072 wmi_auto_sh_cmd->timer_value = timer_val;
8073
8074 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8075 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8076 WMITLV_GET_STRUCT_TLVLEN
8077 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8078
8079 status = wmi_unified_cmd_send(wmi_handle, buf,
8080 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308081 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308082 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308083 __func__, status);
8084 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308085 }
8086
Govind Singh67922e82016-04-01 16:48:57 +05308087 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308088}
8089
8090/**
8091 * send_nan_req_cmd_tlv() - to send nan request to target
8092 * @wmi_handle: wmi handle
8093 * @nan_req: request data which will be non-null
8094 *
8095 * Return: CDF status
8096 */
Govind Singhb53420c2016-03-09 14:32:57 +05308097QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308098 struct nan_req_params *nan_req)
8099{
Govind Singh67922e82016-04-01 16:48:57 +05308100 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308101 wmi_nan_cmd_param *cmd;
8102 wmi_buf_t buf;
8103 uint16_t len = sizeof(*cmd);
8104 uint16_t nan_data_len, nan_data_len_aligned;
8105 uint8_t *buf_ptr;
8106
8107 /*
8108 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8109 * +------------+----------+-----------------------+--------------+
8110 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8111 * +------------+----------+-----------------------+--------------+
8112 */
8113 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308114 WMI_LOGE("%s:nan req is not valid", __func__);
8115 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308116 }
8117 nan_data_len = nan_req->request_data_len;
8118 nan_data_len_aligned = roundup(nan_req->request_data_len,
8119 sizeof(uint32_t));
8120 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8121 buf = wmi_buf_alloc(wmi_handle, len);
8122 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308123 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8124 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308125 }
8126 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8127 cmd = (wmi_nan_cmd_param *) buf_ptr;
8128 WMITLV_SET_HDR(&cmd->tlv_header,
8129 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8130 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8131 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308132 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308133 __func__, nan_req->request_data_len);
8134 buf_ptr += sizeof(wmi_nan_cmd_param);
8135 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8136 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308137 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308138
8139 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8140 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308141 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308142 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308143 __func__, ret);
8144 wmi_buf_free(buf);
8145 }
8146
8147 return ret;
8148}
8149
8150/**
8151 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8152 * @wmi_handle: wmi handle
8153 * @pDhcpSrvOffloadInfo: DHCP server offload info
8154 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308155 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308156 */
Govind Singhb53420c2016-03-09 14:32:57 +05308157QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308158 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8159{
8160 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8161 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308162 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308163
8164 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8165 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308166 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308167 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308168 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308169 }
8170
8171 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308172 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308173
8174 WMITLV_SET_HDR(&cmd->tlv_header,
8175 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8176 WMITLV_GET_STRUCT_TLVLEN
8177 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8178 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8179 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8180 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8181 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8182 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308183 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308184 sizeof(*cmd),
8185 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308186 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308187 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308188 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308189 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308190 }
Govind Singhb53420c2016-03-09 14:32:57 +05308191 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308192 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308193
8194 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308195}
8196
8197/**
8198 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8199 * @wmi_handle: wmi handle
8200 * @flashing: flashing request
8201 *
8202 * Return: CDF status
8203 */
Govind Singhb53420c2016-03-09 14:32:57 +05308204QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308205 struct flashing_req_params *flashing)
8206{
8207 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308208 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308209 wmi_buf_t buf;
8210 uint8_t *buf_ptr;
8211 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8212
8213 buf = wmi_buf_alloc(wmi_handle, len);
8214 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308215 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308216 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308217 }
8218 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8219 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8220 WMITLV_SET_HDR(&cmd->tlv_header,
8221 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8222 WMITLV_GET_STRUCT_TLVLEN
8223 (wmi_set_led_flashing_cmd_fixed_param));
8224 cmd->pattern_id = flashing->pattern_id;
8225 cmd->led_x0 = flashing->led_x0;
8226 cmd->led_x1 = flashing->led_x1;
8227
8228 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8229 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308230 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308231 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308232 " returned Error %d", __func__, status);
Govind Singh20c5dac2016-03-07 15:33:31 +05308233 }
Govind Singh67922e82016-04-01 16:48:57 +05308234
8235 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308236}
8237
8238/**
8239 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8240 * @wmi_handle: wmi handle
8241 * @ch_avoid_update_req: channel avoid update params
8242 *
8243 * Return: CDF status
8244 */
Govind Singhb53420c2016-03-09 14:32:57 +05308245QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308246{
Govind Singh67922e82016-04-01 16:48:57 +05308247 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308248 wmi_buf_t buf = NULL;
8249 uint8_t *buf_ptr;
8250 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
8251 int len = sizeof(wmi_chan_avoid_update_cmd_param);
8252
8253
8254 buf = wmi_buf_alloc(wmi_handle, len);
8255 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308256 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8257 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308258 }
8259
8260 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8261 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
8262 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
8263 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
8264 WMITLV_GET_STRUCT_TLVLEN
8265 (wmi_chan_avoid_update_cmd_param));
8266
8267 status = wmi_unified_cmd_send(wmi_handle, buf,
8268 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308269 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308270 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05308271 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
8272 " returned Error %d", status);
8273 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308274 }
8275
Govind Singh67922e82016-04-01 16:48:57 +05308276 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308277}
8278
8279/**
8280 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
8281 * @wmi_handle: wmi handle
8282 * @reg_dmn: reg domain
8283 * @regdmn2G: 2G reg domain
8284 * @regdmn5G: 5G reg domain
8285 * @ctl2G: 2G test limit
8286 * @ctl5G: 5G test limit
8287 *
8288 * Return: none
8289 */
Govind Singhb53420c2016-03-09 14:32:57 +05308290QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308291 uint32_t reg_dmn, uint16_t regdmn2G,
8292 uint16_t regdmn5G, int8_t ctl2G,
8293 int8_t ctl5G)
8294{
8295 wmi_buf_t buf;
8296 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8297 int32_t len = sizeof(*cmd);
8298
8299
8300 buf = wmi_buf_alloc(wmi_handle, len);
8301 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308302 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8303 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308304 }
8305 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8306 WMITLV_SET_HDR(&cmd->tlv_header,
8307 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8308 WMITLV_GET_STRUCT_TLVLEN
8309 (wmi_pdev_set_regdomain_cmd_fixed_param));
8310 cmd->reg_domain = reg_dmn;
8311 cmd->reg_domain_2G = regdmn2G;
8312 cmd->reg_domain_5G = regdmn5G;
8313 cmd->conformance_test_limit_2G = ctl2G;
8314 cmd->conformance_test_limit_5G = ctl5G;
8315
8316 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8317 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308318 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308319 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05308320 qdf_nbuf_free(buf);
8321 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308322 }
8323
Govind Singhb53420c2016-03-09 14:32:57 +05308324 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308325}
8326
8327
8328/**
8329 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
8330 * @wmi_handle: wmi handle
8331 * @chan_switch_params: Pointer to tdls channel switch parameter structure
8332 *
8333 * This function sets tdls off channel mode
8334 *
8335 * Return: 0 on success; Negative errno otherwise
8336 */
Govind Singhb53420c2016-03-09 14:32:57 +05308337QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308338 struct tdls_channel_switch_params *chan_switch_params)
8339{
8340 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
8341 wmi_buf_t wmi_buf;
8342 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
8343
8344 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8345 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308346 WMI_LOGE(FL("wmi_buf_alloc failed"));
8347 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308348 }
8349 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
8350 wmi_buf_data(wmi_buf);
8351 WMITLV_SET_HDR(&cmd->tlv_header,
8352 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
8353 WMITLV_GET_STRUCT_TLVLEN(
8354 wmi_tdls_set_offchan_mode_cmd_fixed_param));
8355
8356 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
8357 &cmd->peer_macaddr);
8358 cmd->vdev_id = chan_switch_params->vdev_id;
8359 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
8360 cmd->is_peer_responder = chan_switch_params->is_responder;
8361 cmd->offchan_num = chan_switch_params->tdls_off_ch;
8362 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
8363 cmd->offchan_oper_class = chan_switch_params->oper_class;
8364
Govind Singhb53420c2016-03-09 14:32:57 +05308365 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308366 cmd->peer_macaddr.mac_addr31to0,
8367 cmd->peer_macaddr.mac_addr47to32);
8368
Govind Singhb53420c2016-03-09 14:32:57 +05308369 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05308370 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
8371 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
8372 ),
8373 cmd->vdev_id,
8374 cmd->offchan_mode,
8375 cmd->offchan_num,
8376 cmd->offchan_bw_bitmap,
8377 cmd->is_peer_responder,
8378 cmd->offchan_oper_class);
8379
8380 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8381 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308382 WMI_LOGP(FL("failed to send tdls off chan command"));
8383 qdf_nbuf_free(wmi_buf);
8384 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308385 }
8386
8387
Govind Singhb53420c2016-03-09 14:32:57 +05308388 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308389}
8390
8391/**
8392 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
8393 * @wmi_handle: wmi handle
8394 * @pwmaTdlsparams: TDLS params
8395 *
8396 * Return: 0 for sucess or error code
8397 */
Govind Singhb53420c2016-03-09 14:32:57 +05308398QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308399 void *tdls_param, uint8_t tdls_state)
8400{
8401 wmi_tdls_set_state_cmd_fixed_param *cmd;
8402 wmi_buf_t wmi_buf;
8403
8404 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
8405 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
8406
8407 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8408 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308409 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
8410 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308411 }
8412 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
8413 WMITLV_SET_HDR(&cmd->tlv_header,
8414 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
8415 WMITLV_GET_STRUCT_TLVLEN
8416 (wmi_tdls_set_state_cmd_fixed_param));
8417 cmd->vdev_id = wmi_tdls->vdev_id;
8418 cmd->state = tdls_state;
8419 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
8420 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
8421 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
8422 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
8423 cmd->rssi_delta = wmi_tdls->rssi_delta;
8424 cmd->tdls_options = wmi_tdls->tdls_options;
8425 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
8426 cmd->tdls_peer_traffic_response_timeout_ms =
8427 wmi_tdls->peer_traffic_response_timeout;
8428 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
8429 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
8430 cmd->tdls_puapsd_rx_frame_threshold =
8431 wmi_tdls->puapsd_rx_frame_threshold;
8432 cmd->teardown_notification_ms =
8433 wmi_tdls->teardown_notification_ms;
8434 cmd->tdls_peer_kickout_threshold =
8435 wmi_tdls->tdls_peer_kickout_threshold;
8436
Govind Singhb53420c2016-03-09 14:32:57 +05308437 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05308438 "notification_interval_ms: %d, "
8439 "tx_discovery_threshold: %d, "
8440 "tx_teardown_threshold: %d, "
8441 "rssi_teardown_threshold: %d, "
8442 "rssi_delta: %d, "
8443 "tdls_options: 0x%x, "
8444 "tdls_peer_traffic_ind_window: %d, "
8445 "tdls_peer_traffic_response_timeout: %d, "
8446 "tdls_puapsd_mask: 0x%x, "
8447 "tdls_puapsd_inactivity_time: %d, "
8448 "tdls_puapsd_rx_frame_threshold: %d, "
8449 "teardown_notification_ms: %d, "
8450 "tdls_peer_kickout_threshold: %d",
8451 __func__, tdls_state, cmd->state,
8452 cmd->notification_interval_ms,
8453 cmd->tx_discovery_threshold,
8454 cmd->tx_teardown_threshold,
8455 cmd->rssi_teardown_threshold,
8456 cmd->rssi_delta,
8457 cmd->tdls_options,
8458 cmd->tdls_peer_traffic_ind_window,
8459 cmd->tdls_peer_traffic_response_timeout_ms,
8460 cmd->tdls_puapsd_mask,
8461 cmd->tdls_puapsd_inactivity_time_ms,
8462 cmd->tdls_puapsd_rx_frame_threshold,
8463 cmd->teardown_notification_ms,
8464 cmd->tdls_peer_kickout_threshold);
8465
8466 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8467 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308468 WMI_LOGP("%s: failed to send tdls set state command", __func__);
8469 qdf_nbuf_free(wmi_buf);
8470 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308471 }
Govind Singhb53420c2016-03-09 14:32:57 +05308472 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308473
Govind Singhb53420c2016-03-09 14:32:57 +05308474 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308475}
8476
8477/**
8478 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
8479 * @wmi_handle: wmi handle
8480 * @peerStateParams: TDLS peer state params
8481 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308482 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308483 */
Govind Singhb53420c2016-03-09 14:32:57 +05308484QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308485 struct tdls_peer_state_params *peerStateParams,
8486 uint32_t *ch_mhz)
8487{
8488 wmi_tdls_peer_update_cmd_fixed_param *cmd;
8489 wmi_tdls_peer_capabilities *peer_cap;
8490 wmi_channel *chan_info;
8491 wmi_buf_t wmi_buf;
8492 uint8_t *buf_ptr;
8493 uint32_t i;
8494 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
8495 sizeof(wmi_tdls_peer_capabilities);
8496
8497
8498 len += WMI_TLV_HDR_SIZE +
8499 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
8500
8501 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8502 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308503 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8504 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308505 }
8506
8507 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8508 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
8509 WMITLV_SET_HDR(&cmd->tlv_header,
8510 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
8511 WMITLV_GET_STRUCT_TLVLEN
8512 (wmi_tdls_peer_update_cmd_fixed_param));
8513
8514 cmd->vdev_id = peerStateParams->vdevId;
8515 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
8516 &cmd->peer_macaddr);
8517
8518
8519 cmd->peer_state = peerStateParams->peerState;
8520
Govind Singhb53420c2016-03-09 14:32:57 +05308521 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05308522 "peer_macaddr.mac_addr31to0: 0x%x, "
8523 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
8524 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
8525 cmd->peer_macaddr.mac_addr31to0,
8526 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
8527
8528 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
8529 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
8530 WMITLV_SET_HDR(&peer_cap->tlv_header,
8531 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
8532 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
8533
8534 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
8535 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
8536 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
8537 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
8538 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
8539 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
8540 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
8541 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
8542
8543 /* Ack and More Data Ack are sent as 0, so no need to set
8544 * but fill SP
8545 */
8546 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
8547 peerStateParams->peerCap.peerMaxSp);
8548
8549 peer_cap->buff_sta_support =
8550 peerStateParams->peerCap.peerBuffStaSupport;
8551 peer_cap->off_chan_support =
8552 peerStateParams->peerCap.peerOffChanSupport;
8553 peer_cap->peer_curr_operclass =
8554 peerStateParams->peerCap.peerCurrOperClass;
8555 /* self curr operclass is not being used and so pass op class for
8556 * preferred off chan in it.
8557 */
8558 peer_cap->self_curr_operclass =
8559 peerStateParams->peerCap.opClassForPrefOffChan;
8560 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
8561 peer_cap->peer_operclass_len =
8562 peerStateParams->peerCap.peerOperClassLen;
8563
Govind Singhb53420c2016-03-09 14:32:57 +05308564 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308565 __func__, peer_cap->peer_operclass_len);
8566 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
8567 peer_cap->peer_operclass[i] =
8568 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05308569 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308570 __func__, i, peer_cap->peer_operclass[i]);
8571 }
8572
8573 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
8574 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
8575 peer_cap->pref_offchan_bw =
8576 peerStateParams->peerCap.prefOffChanBandwidth;
8577
Govind Singhb53420c2016-03-09 14:32:57 +05308578 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05308579 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
8580 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
8581 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
8582 " %d, pref_offchan_bw: %d",
8583 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
8584 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
8585 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
8586 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
8587 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
8588
8589 /* next fill variable size array of peer chan info */
8590 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
8591 WMITLV_SET_HDR(buf_ptr,
8592 WMITLV_TAG_ARRAY_STRUC,
8593 sizeof(wmi_channel) *
8594 peerStateParams->peerCap.peerChanLen);
8595 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
8596
8597 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
8598 WMITLV_SET_HDR(&chan_info->tlv_header,
8599 WMITLV_TAG_STRUC_wmi_channel,
8600 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
8601 chan_info->mhz = ch_mhz[i];
8602 chan_info->band_center_freq1 = chan_info->mhz;
8603 chan_info->band_center_freq2 = 0;
8604
Govind Singhb53420c2016-03-09 14:32:57 +05308605 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05308606
8607 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
8608 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05308609 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05308610 peerStateParams->peerCap.peerChan[i].chanId,
8611 peerStateParams->peerCap.peerChan[i].dfsSet);
8612 }
8613
8614 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
8615 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
8616 else
8617 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
8618
8619 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
8620 peerStateParams->peerCap.
8621 peerChan[i].pwr);
8622
8623 WMI_SET_CHANNEL_REG_POWER(chan_info,
8624 peerStateParams->peerCap.peerChan[i].
8625 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05308626 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05308627 peerStateParams->peerCap.peerChan[i].pwr);
8628
8629 chan_info++;
8630 }
8631
8632 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8633 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308634 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308635 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05308636 qdf_nbuf_free(wmi_buf);
8637 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308638 }
8639
8640
Govind Singhb53420c2016-03-09 14:32:57 +05308641 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308642}
8643
8644/*
8645 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
8646 * firmware
8647 * @wmi_handle: Pointer to wmi handle
8648 * @mem_dump_req: Pointer for mem_dump_req
8649 *
8650 * This function sends memory dump request to firmware
8651 *
Govind Singhb53420c2016-03-09 14:32:57 +05308652 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05308653 *
8654 */
Govind Singhb53420c2016-03-09 14:32:57 +05308655QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308656 struct fw_dump_req_param *mem_dump_req)
8657{
8658 wmi_get_fw_mem_dump_fixed_param *cmd;
8659 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05308660 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05308661 int32_t len;
8662 wmi_buf_t buf;
8663 u_int8_t *buf_ptr;
8664 int ret, loop;
8665
8666 /*
8667 * len = sizeof(fixed param) that includes tlv header +
8668 * tlv header for array of struc +
8669 * sizeof (each struct)
8670 */
8671 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
8672 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
8673 buf = wmi_buf_alloc(wmi_handle, len);
8674
8675 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308676 WMI_LOGE(FL("Failed allocate wmi buffer"));
8677 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308678 }
8679
8680 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308681 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308682 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
8683
8684 WMITLV_SET_HDR(&cmd->tlv_header,
8685 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
8686 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
8687
8688 cmd->request_id = mem_dump_req->request_id;
8689 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
8690
8691 /* TLV indicating array of structures to follow */
8692 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
8693 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8694 sizeof(wmi_fw_mem_dump) *
8695 cmd->num_fw_mem_dump_segs);
8696
8697 buf_ptr += WMI_TLV_HDR_SIZE;
8698 dump_params = (wmi_fw_mem_dump *) buf_ptr;
8699
Govind Singhb53420c2016-03-09 14:32:57 +05308700 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308701 mem_dump_req->request_id, mem_dump_req->num_seg);
8702 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05308703 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05308704 ((uint8_t *)(mem_dump_req->segment) +
8705 loop * sizeof(*seg_req));
8706 WMITLV_SET_HDR(&dump_params->tlv_header,
8707 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
8708 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
8709 dump_params->seg_id = seg_req->seg_id;
8710 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
8711 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
8712 dump_params->seg_length = seg_req->seg_length;
8713 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
8714 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05308715 WMI_LOGI(FL("seg_number:%d"), loop);
8716 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308717 dump_params->seg_id, dump_params->seg_start_addr_lo,
8718 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05308719 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308720 dump_params->seg_length, dump_params->dest_addr_lo,
8721 dump_params->dest_addr_hi);
8722 dump_params++;
8723 }
8724
8725 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8726 WMI_GET_FW_MEM_DUMP_CMDID);
8727 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308728 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05308729 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308730 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308731 }
8732
Govind Singhb53420c2016-03-09 14:32:57 +05308733 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
8734 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308735}
8736
8737/*
8738 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
8739 * @wmi_handle: Pointer to WMi handle
8740 * @ie_data: Pointer for ie data
8741 *
8742 * This function sends IE information to firmware
8743 *
Govind Singhb53420c2016-03-09 14:32:57 +05308744 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05308745 *
8746 */
Govind Singhb53420c2016-03-09 14:32:57 +05308747QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308748 struct vdev_ie_info_param *ie_info)
8749{
8750 wmi_vdev_set_ie_cmd_fixed_param *cmd;
8751 wmi_buf_t buf;
8752 uint8_t *buf_ptr;
8753 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05308754 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308755
8756
8757 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
8758 /* Allocate memory for the WMI command */
8759 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
8760
8761 buf = wmi_buf_alloc(wmi_handle, len);
8762 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308763 WMI_LOGE(FL("wmi_buf_alloc failed"));
8764 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308765 }
8766
8767 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308768 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308769
8770 /* Populate the WMI command */
8771 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
8772
8773 WMITLV_SET_HDR(&cmd->tlv_header,
8774 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
8775 WMITLV_GET_STRUCT_TLVLEN(
8776 wmi_vdev_set_ie_cmd_fixed_param));
8777 cmd->vdev_id = ie_info->vdev_id;
8778 cmd->ie_id = ie_info->ie_id;
8779 cmd->ie_len = ie_info->length;
8780
Govind Singhb53420c2016-03-09 14:32:57 +05308781 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308782 ie_info->length, ie_info->vdev_id);
8783
8784 buf_ptr += sizeof(*cmd);
8785 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
8786 buf_ptr += WMI_TLV_HDR_SIZE;
8787
Govind Singhb53420c2016-03-09 14:32:57 +05308788 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308789
8790 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8791 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308792 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308793 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05308794 wmi_buf_free(buf);
8795 }
8796
8797 return ret;
8798}
8799
Govind Singh9ddd5162016-03-07 16:30:32 +05308800
8801void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05308802 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05308803{
Govind Singhe7f2f342016-05-23 12:12:52 +05308804 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05308805 resource_cfg->num_peers = tgt_res_cfg->num_peers;
8806 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
8807 resource_cfg->num_offload_reorder_buffs =
8808 tgt_res_cfg->num_offload_reorder_buffs;
8809 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
8810 resource_cfg->num_tids = tgt_res_cfg->num_tids;
8811 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
8812 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
8813 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
8814 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
8815 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
8816 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
8817 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
8818 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
8819 resource_cfg->scan_max_pending_req =
8820 tgt_res_cfg->scan_max_pending_req;
8821 resource_cfg->bmiss_offload_max_vdev =
8822 tgt_res_cfg->bmiss_offload_max_vdev;
8823 resource_cfg->roam_offload_max_vdev =
8824 tgt_res_cfg->roam_offload_max_vdev;
8825 resource_cfg->roam_offload_max_ap_profiles =
8826 tgt_res_cfg->roam_offload_max_ap_profiles;
8827 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
8828 resource_cfg->num_mcast_table_elems =
8829 tgt_res_cfg->num_mcast_table_elems;
8830 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
8831 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
8832 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
8833 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
8834 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
8835 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
8836 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
8837 resource_cfg->vow_config = tgt_res_cfg->vow_config;
8838 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
8839 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
8840 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
8841 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
8842 resource_cfg->num_tdls_conn_table_entries =
8843 tgt_res_cfg->num_tdls_conn_table_entries;
8844 resource_cfg->beacon_tx_offload_max_vdev =
8845 tgt_res_cfg->beacon_tx_offload_max_vdev;
8846 resource_cfg->num_multicast_filter_entries =
8847 tgt_res_cfg->num_multicast_filter_entries;
8848 resource_cfg->num_wow_filters =
8849 tgt_res_cfg->num_wow_filters;
8850 resource_cfg->num_keep_alive_pattern =
8851 tgt_res_cfg->num_keep_alive_pattern;
8852 resource_cfg->keep_alive_pattern_size =
8853 tgt_res_cfg->keep_alive_pattern_size;
8854 resource_cfg->max_tdls_concurrent_sleep_sta =
8855 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
8856 resource_cfg->max_tdls_concurrent_buffer_sta =
8857 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
8858 resource_cfg->wmi_send_separate =
8859 tgt_res_cfg->wmi_send_separate;
8860 resource_cfg->num_ocb_vdevs =
8861 tgt_res_cfg->num_ocb_vdevs;
8862 resource_cfg->num_ocb_channels =
8863 tgt_res_cfg->num_ocb_channels;
8864 resource_cfg->num_ocb_schedules =
8865 tgt_res_cfg->num_ocb_schedules;
8866
8867}
8868
8869/**
8870 * send_init_cmd_tlv() - wmi init command
8871 * @wmi_handle: pointer to wmi handle
8872 * @res_cfg: resource config
8873 * @num_mem_chunks: no of mem chunck
8874 * @mem_chunk: pointer to mem chunck structure
8875 *
8876 * This function sends IE information to firmware
8877 *
Govind Singhb53420c2016-03-09 14:32:57 +05308878 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05308879 *
8880 */
Govind Singhb53420c2016-03-09 14:32:57 +05308881QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05308882 wmi_resource_config *tgt_res_cfg,
8883 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
8884 bool action)
8885{
8886 wmi_buf_t buf;
8887 wmi_init_cmd_fixed_param *cmd;
8888 wmi_abi_version my_vers;
8889 int num_whitelist;
8890 uint8_t *buf_ptr;
8891 wmi_resource_config *resource_cfg;
8892 wlan_host_memory_chunk *host_mem_chunks;
8893 uint32_t mem_chunk_len = 0;
8894 uint16_t idx;
8895 int len;
8896 int ret;
8897
8898 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
8899 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
8900 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
8901 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308902 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
8903 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05308904 }
8905
8906 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8907 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
8908 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
8909
8910 host_mem_chunks = (wlan_host_memory_chunk *)
8911 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
8912 + WMI_TLV_HDR_SIZE);
8913
8914 WMITLV_SET_HDR(&cmd->tlv_header,
8915 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
8916 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
8917
Govind Singhb53420c2016-03-09 14:32:57 +05308918 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +05308919 WMITLV_SET_HDR(&resource_cfg->tlv_header,
8920 WMITLV_TAG_STRUC_wmi_resource_config,
8921 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
8922
8923 for (idx = 0; idx < num_mem_chunks; ++idx) {
8924 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
8925 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
8926 WMITLV_GET_STRUCT_TLVLEN
8927 (wlan_host_memory_chunk));
8928 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
8929 host_mem_chunks[idx].size = mem_chunks[idx].len;
8930 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308931 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +05308932 idx, host_mem_chunks[idx].size,
8933 host_mem_chunks[idx].ptr);
8934 }
8935 cmd->num_host_mem_chunks = num_mem_chunks;
8936 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
8937 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
8938 WMITLV_TAG_ARRAY_STRUC,
8939 (sizeof(wlan_host_memory_chunk) *
8940 num_mem_chunks));
8941
8942 num_whitelist = sizeof(version_whitelist) /
8943 sizeof(wmi_whitelist_version_info);
8944 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
8945 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
8946 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
8947 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
8948 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
8949 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
8950
8951 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
8952 &my_vers,
8953 &wmi_handle->fw_abi_version,
8954 &cmd->host_abi_vers);
8955
Govind Singhb53420c2016-03-09 14:32:57 +05308956 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05308957 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
8958 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
8959 cmd->host_abi_vers.abi_version_ns_0,
8960 cmd->host_abi_vers.abi_version_ns_1,
8961 cmd->host_abi_vers.abi_version_ns_2,
8962 cmd->host_abi_vers.abi_version_ns_3);
8963
8964 /* Save version sent from host -
8965 * Will be used to check ready event
8966 */
Govind Singhb53420c2016-03-09 14:32:57 +05308967 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05308968 sizeof(wmi_abi_version));
8969
8970 if (action) {
8971 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8972 WMI_INIT_CMDID);
8973 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308974 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +05308975 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308976 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05308977 }
8978 } else {
8979 wmi_handle->saved_wmi_init_cmd.buf = buf;
8980 wmi_handle->saved_wmi_init_cmd.buf_len = len;
8981 }
8982
Govind Singhb53420c2016-03-09 14:32:57 +05308983 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05308984
8985}
8986
8987/**
8988 * send_saved_init_cmd_tlv() - wmi init command
8989 * @wmi_handle: pointer to wmi handle
8990 *
8991 * This function sends IE information to firmware
8992 *
Govind Singhb53420c2016-03-09 14:32:57 +05308993 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05308994 *
8995 */
Govind Singhb53420c2016-03-09 14:32:57 +05308996QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +05308997{
8998 int status;
8999
9000 if (!wmi_handle->saved_wmi_init_cmd.buf ||
9001 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +05309002 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
9003 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309004 }
9005 status = wmi_unified_cmd_send(wmi_handle,
9006 wmi_handle->saved_wmi_init_cmd.buf,
9007 wmi_handle->saved_wmi_init_cmd.buf_len,
9008 WMI_INIT_CMDID);
9009 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +05309010 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +05309011 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309012 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309013 }
9014 wmi_handle->saved_wmi_init_cmd.buf = NULL;
9015 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
9016
Govind Singhb53420c2016-03-09 14:32:57 +05309017 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309018}
9019
Govind Singhb53420c2016-03-09 14:32:57 +05309020QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05309021{
9022 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
9023 wmi_service_ready_event_fixed_param *ev;
9024
9025
9026 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
9027
9028 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
9029 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05309030 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309031
9032 /*Save fw version from service ready message */
9033 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05309034 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309035 sizeof(wmi_handle->fw_abi_version));
9036
Govind Singhb53420c2016-03-09 14:32:57 +05309037 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309038}
9039
9040/**
9041 * wmi_unified_save_fw_version_cmd() - save fw version
9042 * @wmi_handle: pointer to wmi handle
9043 * @res_cfg: resource config
9044 * @num_mem_chunks: no of mem chunck
9045 * @mem_chunk: pointer to mem chunck structure
9046 *
9047 * This function sends IE information to firmware
9048 *
Govind Singhb53420c2016-03-09 14:32:57 +05309049 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05309050 *
9051 */
Govind Singhb53420c2016-03-09 14:32:57 +05309052QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05309053 void *evt_buf)
9054{
9055 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
9056 wmi_ready_event_fixed_param *ev = NULL;
9057
9058 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
9059 ev = param_buf->fixed_param;
9060
9061 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
9062 &ev->fw_abi_vers)) {
9063 /*
9064 * Error: Our host version and the given firmware version
9065 * are incompatible.
9066 **/
Govind Singhb53420c2016-03-09 14:32:57 +05309067 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +05309068 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
9069 __func__,
9070 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
9071 abi_version_0),
9072 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
9073 abi_version_0),
9074 wmi_handle->final_abi_vers.abi_version_ns_0,
9075 wmi_handle->final_abi_vers.abi_version_ns_1,
9076 wmi_handle->final_abi_vers.abi_version_ns_2,
9077 wmi_handle->final_abi_vers.abi_version_ns_3,
9078 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
9079 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
9080 ev->fw_abi_vers.abi_version_ns_0,
9081 ev->fw_abi_vers.abi_version_ns_1,
9082 ev->fw_abi_vers.abi_version_ns_2,
9083 ev->fw_abi_vers.abi_version_ns_3);
9084
Govind Singhb53420c2016-03-09 14:32:57 +05309085 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05309086 }
Govind Singhb53420c2016-03-09 14:32:57 +05309087 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309088 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +05309089 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05309090 sizeof(wmi_abi_version));
9091
9092
Govind Singhb53420c2016-03-09 14:32:57 +05309093 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05309094}
Govind Singha4836fd2016-03-07 16:45:38 +05309095
9096/**
9097 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
9098 * @wmi_handle: wmi handle
9099 * @custom_addr: base mac address
9100 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309101 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +05309102 */
Govind Singhb53420c2016-03-09 14:32:57 +05309103QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309104 uint8_t *custom_addr)
9105{
9106 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
9107 wmi_buf_t buf;
9108 int err;
9109
9110 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9111 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309112 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309113 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309114 }
9115
9116 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309117 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +05309118
9119 WMITLV_SET_HDR(&cmd->tlv_header,
9120 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
9121 WMITLV_GET_STRUCT_TLVLEN
9122 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
9123 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -07009124 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +05309125 err = wmi_unified_cmd_send(wmi_handle, buf,
9126 sizeof(*cmd),
9127 WMI_PDEV_SET_BASE_MACADDR_CMDID);
9128 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05309129 WMI_LOGE("Failed to send set_base_macaddr cmd");
9130 qdf_mem_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309131 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309132 }
9133
9134 return 0;
9135}
9136
9137/**
9138 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
9139 * @handle: wmi handle
9140 * @event: Event received from FW
9141 * @len: Length of the event
9142 *
9143 * Enables the low frequency events and disables the high frequency
9144 * events. Bit 17 indicates if the event if low/high frequency.
9145 * 1 - high frequency, 0 - low frequency
9146 *
9147 * Return: 0 on successfully enabling/disabling the events
9148 */
Govind Singhb53420c2016-03-09 14:32:57 +05309149QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309150 uint8_t *event,
9151 uint32_t len)
9152{
9153 uint32_t num_of_diag_events_logs;
9154 wmi_diag_event_log_config_fixed_param *cmd;
9155 wmi_buf_t buf;
9156 uint8_t *buf_ptr;
9157 uint32_t *cmd_args, *evt_args;
9158 uint32_t buf_len, i;
9159
9160 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
9161 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
9162
Govind Singhb53420c2016-03-09 14:32:57 +05309163 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +05309164
9165 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
9166 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309167 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +05309168 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309169 }
9170 wmi_event = param_buf->fixed_param;
9171 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
9172 evt_args = param_buf->diag_events_logs_list;
9173 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +05309174 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309175 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +05309176 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309177 }
9178
Govind Singhb53420c2016-03-09 14:32:57 +05309179 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05309180 __func__, num_of_diag_events_logs);
9181
9182 /* Free any previous allocation */
9183 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +05309184 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309185
9186 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +05309187 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +05309188 sizeof(uint32_t));
9189 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +05309190 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +05309191 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309192 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309193 }
9194 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
9195
9196 /* Prepare the send buffer */
9197 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
9198 (num_of_diag_events_logs * sizeof(uint32_t));
9199
9200 buf = wmi_buf_alloc(wmi_handle, buf_len);
9201 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309202 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9203 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05309204 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05309205 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309206 }
9207
9208 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
9209 buf_ptr = (uint8_t *) cmd;
9210
9211 WMITLV_SET_HDR(&cmd->tlv_header,
9212 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
9213 WMITLV_GET_STRUCT_TLVLEN(
9214 wmi_diag_event_log_config_fixed_param));
9215
9216 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
9217
9218 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
9219
9220 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9221 (num_of_diag_events_logs * sizeof(uint32_t)));
9222
9223 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
9224
9225 /* Populate the events */
9226 for (i = 0; i < num_of_diag_events_logs; i++) {
9227 /* Low freq (0) - Enable (1) the event
9228 * High freq (1) - Disable (0) the event
9229 */
9230 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
9231 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
9232 /* Set the event ID */
9233 WMI_DIAG_ID_SET(cmd_args[i],
9234 WMI_DIAG_ID_GET(evt_args[i]));
9235 /* Set the type */
9236 WMI_DIAG_TYPE_SET(cmd_args[i],
9237 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +05309238 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +05309239 wmi_handle->events_logs_list[i] = evt_args[i];
9240 }
9241
9242 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
9243 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309244 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +05309245 __func__);
9246 wmi_buf_free(buf);
9247 /* Not clearing events_logs_list, though wmi cmd failed.
9248 * Host can still have this list
9249 */
Govind Singh67922e82016-04-01 16:48:57 +05309250 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309251 }
9252
9253 return 0;
9254}
9255
9256/**
9257 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
9258 * @wmi_handle: wmi handle
9259 * @start_log: Start logging related parameters
9260 *
9261 * Send the command to the FW based on which specific logging of diag
9262 * event/log id can be started/stopped
9263 *
9264 * Return: None
9265 */
Govind Singhb53420c2016-03-09 14:32:57 +05309266QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309267 struct wmi_wifi_start_log *start_log)
9268{
9269 wmi_diag_event_log_config_fixed_param *cmd;
9270 wmi_buf_t buf;
9271 uint8_t *buf_ptr;
9272 uint32_t len, count, log_level, i;
9273 uint32_t *cmd_args;
9274 uint32_t total_len;
9275 count = 0;
9276
9277 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +05309278 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +05309279 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309280 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309281 }
9282 /* total_len stores the number of events where BITS 17 and 18 are set.
9283 * i.e., events of high frequency (17) and for extended debugging (18)
9284 */
9285 total_len = 0;
9286 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
9287 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
9288 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
9289 total_len++;
9290 }
9291
9292 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
9293 (total_len * sizeof(uint32_t));
9294
9295 buf = wmi_buf_alloc(wmi_handle, len);
9296 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309297 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309298 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309299 }
9300 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
9301 buf_ptr = (uint8_t *) cmd;
9302
9303 WMITLV_SET_HDR(&cmd->tlv_header,
9304 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
9305 WMITLV_GET_STRUCT_TLVLEN(
9306 wmi_diag_event_log_config_fixed_param));
9307
9308 cmd->num_of_diag_events_logs = total_len;
9309
9310 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
9311
9312 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9313 (total_len * sizeof(uint32_t)));
9314
9315 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
9316
Govind Singh224a7312016-06-21 14:33:26 +05309317 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +05309318 log_level = 1;
9319 else
9320 log_level = 0;
9321
Govind Singhb53420c2016-03-09 14:32:57 +05309322 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +05309323 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
9324 uint32_t val = wmi_handle->events_logs_list[i];
9325 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
9326 (WMI_DIAG_EXT_FEATURE_GET(val))) {
9327
9328 WMI_DIAG_ID_SET(cmd_args[count],
9329 WMI_DIAG_ID_GET(val));
9330 WMI_DIAG_TYPE_SET(cmd_args[count],
9331 WMI_DIAG_TYPE_GET(val));
9332 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
9333 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +05309334 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +05309335 count++;
9336 }
9337 }
9338
9339 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9340 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309341 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +05309342 __func__);
9343 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309344 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309345 }
9346
Govind Singhb53420c2016-03-09 14:32:57 +05309347 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309348}
9349
9350/**
9351 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
9352 * @wmi_handle: WMI handle
9353 *
9354 * This function is used to send the flush command to the FW,
9355 * that will flush the fw logs that are residue in the FW
9356 *
9357 * Return: None
9358 */
Govind Singhb53420c2016-03-09 14:32:57 +05309359QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +05309360{
9361 wmi_debug_mesg_flush_fixed_param *cmd;
9362 wmi_buf_t buf;
9363 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +05309364 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +05309365
9366 buf = wmi_buf_alloc(wmi_handle, len);
9367 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309368 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309369 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309370 }
9371
9372 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
9373 WMITLV_SET_HDR(&cmd->tlv_header,
9374 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
9375 WMITLV_GET_STRUCT_TLVLEN(
9376 wmi_debug_mesg_flush_fixed_param));
9377 cmd->reserved0 = 0;
9378
9379 ret = wmi_unified_cmd_send(wmi_handle,
9380 buf,
9381 len,
9382 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309383 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309384 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +05309385 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309386 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05309387 }
Govind Singhb53420c2016-03-09 14:32:57 +05309388 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +05309389
Govind Singh67922e82016-04-01 16:48:57 +05309390 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +05309391}
9392
9393/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309394 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +05309395 * @wmi_handle: wmi handle
9396 * @msg: PCL structure containing the PCL and the number of channels
9397 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309398 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +05309399 * firmware. The DBS Manager is the consumer of this information in the WLAN
9400 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
9401 * to migrate to a new channel without host driver involvement. An example of
9402 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
9403 * manage the channel selection without firmware involvement.
9404 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309405 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
9406 * channel list. The weights corresponds to the channels sent in
9407 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
9408 * weightage compared to the non PCL channels.
9409 *
Govind Singha4836fd2016-03-07 16:45:38 +05309410 * Return: Success if the cmd is sent successfully to the firmware
9411 */
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309412QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
9413 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +05309414{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309415 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +05309416 wmi_buf_t buf;
9417 uint8_t *buf_ptr;
9418 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309419 uint32_t chan_len;
9420
9421 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +05309422
9423 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309424 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +05309425
9426 buf = wmi_buf_alloc(wmi_handle, len);
9427 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309428 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9429 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309430 }
9431
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309432 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +05309433 buf_ptr = (uint8_t *) cmd;
9434 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309435 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
9436 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +05309437
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309438 cmd->pdev_id = WMI_PDEV_ID_SOC;
9439 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +05309440 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309441
9442 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +05309443 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309444 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +05309445 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309446 for (i = 0; i < chan_len ; i++) {
9447 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +05309448 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309449 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +05309450 }
9451 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +05309452 WMI_PDEV_SET_PCL_CMDID)) {
9453 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05309454 qdf_nbuf_free(buf);
9455 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309456 }
Govind Singhb53420c2016-03-09 14:32:57 +05309457 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309458}
9459
9460/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +05309461 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +05309462 * @wmi_handle: wmi handle
9463 * @msg: Structure containing the following parameters
9464 *
9465 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
9466 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
9467 *
9468 * Provides notification to the WLAN firmware that host driver is requesting a
9469 * HardWare (HW) Mode change. This command is needed to support iHelium in the
9470 * configurations that include the Dual Band Simultaneous (DBS) feature.
9471 *
9472 * Return: Success if the cmd is sent successfully to the firmware
9473 */
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +05309474QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309475 uint32_t hw_mode_index)
9476{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +05309477 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +05309478 wmi_buf_t buf;
9479 uint32_t len;
9480
9481 len = sizeof(*cmd);
9482
9483 buf = wmi_buf_alloc(wmi_handle, len);
9484 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309485 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9486 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309487 }
9488
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +05309489 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +05309490 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +05309491 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
9492 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
9493
9494 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +05309495 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +05309496 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +05309497
9498 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +05309499 WMI_PDEV_SET_HW_MODE_CMDID)) {
9500 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +05309501 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05309502 qdf_nbuf_free(buf);
9503 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309504 }
9505
Govind Singhb53420c2016-03-09 14:32:57 +05309506 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309507}
9508
9509/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +05309510 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +05309511 * @wmi_handle: wmi handle
9512 * @msg: Dual MAC config parameters
9513 *
9514 * Configures WLAN firmware with the dual MAC features
9515 *
Govind Singhb53420c2016-03-09 14:32:57 +05309516 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +05309517 */
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +05309518QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309519 struct wmi_dual_mac_config *msg)
9520{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +05309521 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +05309522 wmi_buf_t buf;
9523 uint32_t len;
9524
9525 len = sizeof(*cmd);
9526
9527 buf = wmi_buf_alloc(wmi_handle, len);
9528 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309529 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9530 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309531 }
9532
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +05309533 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +05309534 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +05309535 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +05309536 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +05309537 wmi_pdev_set_mac_config_cmd_fixed_param));
9538
9539 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +05309540 cmd->concurrent_scan_config_bits = msg->scan_config;
9541 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +05309542 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +05309543 __func__, msg->scan_config, msg->fw_mode_config);
9544
9545 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +05309546 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
9547 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +05309548 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05309549 qdf_nbuf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +05309550 }
Govind Singhb53420c2016-03-09 14:32:57 +05309551 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309552}
9553
9554/**
9555 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
9556 * @wma: wmi handle
9557 * @tpSirHostOffloadReq: offload request
9558 * @arp_only: flag
9559 *
9560 * To configure ARP NS off load data to firmware
9561 * when target goes to wow mode.
9562 *
9563 * Return: CDF Status
9564 */
Govind Singhb53420c2016-03-09 14:32:57 +05309565QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309566 struct host_offload_req_param *param, bool arp_only,
9567 uint8_t vdev_id)
9568{
9569 int32_t i;
9570 int32_t res;
9571 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
9572 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
9573 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
9574 A_UINT8 *buf_ptr;
9575 wmi_buf_t buf;
9576 int32_t len;
9577 uint32_t count = 0, num_ns_ext_tuples = 0;
9578
9579
9580 if (!arp_only)
9581 count = param->num_ns_offload_count;
9582 /*
9583 * TLV place holder size for array of NS tuples
9584 * TLV place holder size for array of ARP tuples
9585 */
9586 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) + WMI_TLV_HDR_SIZE +
9587 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) + WMI_TLV_HDR_SIZE +
9588 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
9589
9590 /*
9591 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
9592 * extra length for extended NS offload tuples which follows ARP offload
9593 * tuples. Host needs to fill this structure in following format:
9594 * 2 NS ofload tuples
9595 * 2 ARP offload tuples
9596 * N numbers of extended NS offload tuples if HDD has given more than
9597 * 2 NS offload addresses
9598 */
9599 if (!arp_only && count > WMI_MAX_NS_OFFLOADS) {
9600 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
9601 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples *
9602 sizeof(WMI_NS_OFFLOAD_TUPLE);
9603 }
9604
9605 buf = wmi_buf_alloc(wmi_handle, len);
9606 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309607 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05309608 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309609 }
9610
9611 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
9612 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
9613 WMITLV_SET_HDR(&cmd->tlv_header,
9614 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
9615 WMITLV_GET_STRUCT_TLVLEN
9616 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
9617 cmd->flags = 0;
9618 cmd->vdev_id = vdev_id;
9619 if (!arp_only)
9620 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
9621
Govind Singhb53420c2016-03-09 14:32:57 +05309622 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +05309623
9624 /* Have copy of arp info to send along with NS, Since FW expects
9625 * both ARP and NS info in single cmd */
9626 if (arp_only)
Govind Singhb53420c2016-03-09 14:32:57 +05309627 qdf_mem_copy(&wmi_handle->arp_info, param,
Govind Singh17c39b02016-03-28 22:07:13 +05309628 sizeof(struct host_offload_req_param));
Govind Singha4836fd2016-03-07 16:45:38 +05309629
9630 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
9631 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9632 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
9633 buf_ptr += WMI_TLV_HDR_SIZE;
9634 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
9635 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *) buf_ptr;
9636 WMITLV_SET_HDR(&ns_tuple->tlv_header,
9637 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
9638 (sizeof(WMI_NS_OFFLOAD_TUPLE) -
9639 WMI_TLV_HDR_SIZE));
9640
9641 /* Fill data only for NS offload in the first ARP tuple for LA */
9642 if (!arp_only &&
Govind Singh224a7312016-06-21 14:33:26 +05309643 ((param->enableOrDisable & WMI_OFFLOAD_ENABLE))) {
Govind Singha4836fd2016-03-07 16:45:38 +05309644 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
9645
9646#ifdef WLAN_NS_OFFLOAD
9647 /*Copy the target/solicitation/remote ip addr */
9648 if (param->nsOffloadInfo.
9649 targetIPv6AddrValid[i])
9650 A_MEMCPY(&ns_tuple->target_ipaddr[0],
9651 &param->nsOffloadInfo.
9652 targetIPv6Addr[i],
9653 sizeof(WMI_IPV6_ADDR));
9654 A_MEMCPY(&ns_tuple->solicitation_ipaddr,
9655 &param->nsOffloadInfo.
9656 selfIPv6Addr[i], sizeof(WMI_IPV6_ADDR));
Govind Singhb53420c2016-03-09 14:32:57 +05309657 WMI_LOGD("NS solicitedIp: %pI6, targetIp: %pI6",
Govind Singha4836fd2016-03-07 16:45:38 +05309658 &param->nsOffloadInfo.selfIPv6Addr[i],
9659 &param->nsOffloadInfo.
9660 targetIPv6Addr[i]);
9661
9662 /* target MAC is optional, check if it is valid,
9663 * if this is not valid, the target will use the known
9664 * local MAC address rather than the tuple
9665 */
9666 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->
9667 nsOffloadInfo.self_macaddr.bytes,
9668 &ns_tuple->target_mac);
9669#endif /* WLAN_NS_OFFLOAD */
9670 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
9671 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
9672 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
9673 }
9674 }
9675 buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
9676 }
9677
9678 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9679 (WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE)));
9680 buf_ptr += WMI_TLV_HDR_SIZE;
9681 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
9682 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *) buf_ptr;
9683 WMITLV_SET_HDR(&arp_tuple->tlv_header,
9684 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
9685 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
9686
9687 /* Fill data for ARP and NS in the first tupple for LA */
Govind Singh224a7312016-06-21 14:33:26 +05309688 if ((wmi_handle->arp_info.enableOrDisable & WMI_OFFLOAD_ENABLE)
Govind Singha4836fd2016-03-07 16:45:38 +05309689 && (i == 0)) {
9690 /*Copy the target ip addr and flags */
9691 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
9692 A_MEMCPY(&arp_tuple->target_ipaddr,
9693 wmi_handle->arp_info.params.hostIpv4Addr,
Govind Singh224a7312016-06-21 14:33:26 +05309694 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05309695 WMI_LOGD("ARPOffload IP4 address: %pI4",
Govind Singha4836fd2016-03-07 16:45:38 +05309696 wmi_handle->arp_info.params.hostIpv4Addr);
9697 }
9698 buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
9699 }
9700
9701 /* Populate extended NS offload tuples */
9702 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9703 (num_ns_ext_tuples*sizeof(WMI_NS_OFFLOAD_TUPLE)));
9704 buf_ptr += WMI_TLV_HDR_SIZE;
9705
9706 if (num_ns_ext_tuples) {
9707 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
9708 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)buf_ptr;
9709 WMITLV_SET_HDR(&ns_tuple->tlv_header,
9710 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
9711 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
9712
9713 /* Fill data only for NS offload in the first ARP tuple for LA */
9714 if (!arp_only &&
Govind Singh224a7312016-06-21 14:33:26 +05309715 ((param->enableOrDisable &
9716 WMI_OFFLOAD_ENABLE))) {
Govind Singha4836fd2016-03-07 16:45:38 +05309717 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
9718#ifdef WLAN_NS_OFFLOAD
9719 /*Copy the target/solicitation/remote ip addr */
9720 if (param->nsOffloadInfo.targetIPv6AddrValid[i])
9721 A_MEMCPY(&ns_tuple->target_ipaddr[0],
9722 &param->nsOffloadInfo.targetIPv6Addr[i],
9723 sizeof(WMI_IPV6_ADDR));
9724 A_MEMCPY(&ns_tuple->solicitation_ipaddr,
9725 &param->nsOffloadInfo.selfIPv6Addr[i],
9726 sizeof(WMI_IPV6_ADDR));
Govind Singhb53420c2016-03-09 14:32:57 +05309727 WMI_LOGD("Index %d NS solicitedIp: %pI6, targetIp: %pI6", i,
Govind Singha4836fd2016-03-07 16:45:38 +05309728 &param->nsOffloadInfo.selfIPv6Addr[i],
9729 &param->nsOffloadInfo.targetIPv6Addr[i]);
9730
9731 /* target MAC is optional, check if it is valid, if this is not valid,
9732 * the target will use the known local MAC address rather than the tuple */
9733 WMI_CHAR_ARRAY_TO_MAC_ADDR(
9734 param->nsOffloadInfo.self_macaddr.bytes,
9735 &ns_tuple->target_mac);
9736#endif
9737 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
9738 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
9739 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
9740 }
9741 }
9742 buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
9743 }
9744 }
9745
9746 res = wmi_unified_cmd_send(wmi_handle, buf, len,
9747 WMI_SET_ARP_NS_OFFLOAD_CMDID);
9748 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +05309749 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +05309750 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309751 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309752 }
9753
Govind Singhb53420c2016-03-09 14:32:57 +05309754 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309755}
9756
9757/**
9758 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
9759 * @wmi_handle: wmi handle
9760 * @request: SSID hotlist set request
9761 *
Govind Singhb53420c2016-03-09 14:32:57 +05309762 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +05309763 */
Govind Singhb53420c2016-03-09 14:32:57 +05309764QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +05309765send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
9766 struct ssid_hotlist_request_params *request)
9767{
9768 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
9769 wmi_buf_t wmi_buf;
9770 uint32_t len;
9771 uint32_t array_size;
9772 uint8_t *buf_ptr;
9773
9774 /* length of fixed portion */
9775 len = sizeof(*cmd);
9776
9777 /* length of variable portion */
9778 array_size =
9779 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
9780 len += WMI_TLV_HDR_SIZE + array_size;
9781
9782 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9783 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309784 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9785 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309786 }
9787
9788 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9789 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
9790 buf_ptr;
9791 WMITLV_SET_HDR
9792 (&cmd->tlv_header,
9793 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
9794 WMITLV_GET_STRUCT_TLVLEN
9795 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
9796
9797 cmd->request_id = request->request_id;
9798 cmd->requestor_id = 0;
9799 cmd->vdev_id = request->session_id;
9800 cmd->table_id = 0;
9801 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
9802 cmd->total_entries = request->ssid_count;
9803 cmd->num_entries_in_page = request->ssid_count;
9804 cmd->first_entry_index = 0;
9805
9806 buf_ptr += sizeof(*cmd);
9807 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
9808
9809 if (request->ssid_count) {
9810 wmi_extscan_hotlist_ssid_entry *entry;
9811 int i;
9812
9813 buf_ptr += WMI_TLV_HDR_SIZE;
9814 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
9815 for (i = 0; i < request->ssid_count; i++) {
9816 WMITLV_SET_HDR
9817 (entry,
9818 WMITLV_TAG_ARRAY_STRUC,
9819 WMITLV_GET_STRUCT_TLVLEN
9820 (wmi_extscan_hotlist_ssid_entry));
9821 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05309822 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +05309823 request->ssids[i].ssid.mac_ssid,
9824 request->ssids[i].ssid.length);
9825 entry->band = request->ssids[i].band;
9826 entry->min_rssi = request->ssids[i].rssi_low;
9827 entry->max_rssi = request->ssids[i].rssi_high;
9828 entry++;
9829 }
9830 cmd->mode = WMI_EXTSCAN_MODE_START;
9831 } else {
9832 cmd->mode = WMI_EXTSCAN_MODE_STOP;
9833 }
9834
9835 if (wmi_unified_cmd_send
9836 (wmi_handle, wmi_buf, len,
9837 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309838 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +05309839 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309840 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309841 }
9842
Govind Singhb53420c2016-03-09 14:32:57 +05309843 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309844}
9845
9846/**
9847 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
9848 * @wmi_handle: wmi handle
9849 * @vdev_id: vdev id
9850 *
9851 * This function sends roam synch complete event to fw.
9852 *
9853 * Return: CDF STATUS
9854 */
Govind Singhb53420c2016-03-09 14:32:57 +05309855QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309856 uint8_t vdev_id)
9857{
9858 wmi_roam_synch_complete_fixed_param *cmd;
9859 wmi_buf_t wmi_buf;
9860 uint8_t *buf_ptr;
9861 uint16_t len;
9862 len = sizeof(wmi_roam_synch_complete_fixed_param);
9863
9864 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9865 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309866 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9867 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309868 }
9869 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
9870 buf_ptr = (uint8_t *) cmd;
9871 WMITLV_SET_HDR(&cmd->tlv_header,
9872 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
9873 WMITLV_GET_STRUCT_TLVLEN
9874 (wmi_roam_synch_complete_fixed_param));
9875 cmd->vdev_id = vdev_id;
9876 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9877 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309878 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +05309879 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05309880 qdf_nbuf_free(wmi_buf);
9881 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309882 }
9883
Govind Singhb53420c2016-03-09 14:32:57 +05309884 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309885}
9886
9887/**
9888 * send_unit_test_cmd_tlv() - send unit test command to fw.
9889 * @wmi_handle: wmi handle
9890 * @wmi_utest: unit test command
9891 *
9892 * This function send unit test command to fw.
9893 *
9894 * Return: CDF STATUS
9895 */
Govind Singhb53420c2016-03-09 14:32:57 +05309896QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309897 struct wmi_unit_test_cmd *wmi_utest)
9898{
9899 wmi_unit_test_cmd_fixed_param *cmd;
9900 wmi_buf_t wmi_buf;
9901 uint8_t *buf_ptr;
9902 int i;
9903 uint16_t len, args_tlv_len;
9904 A_UINT32 *unit_test_cmd_args;
9905
9906 args_tlv_len =
9907 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
9908 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
9909
9910 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9911 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309912 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9913 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309914 }
9915
9916 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9917 buf_ptr = (uint8_t *) cmd;
9918 WMITLV_SET_HDR(&cmd->tlv_header,
9919 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
9920 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
9921 cmd->vdev_id = wmi_utest->vdev_id;
9922 cmd->module_id = wmi_utest->module_id;
9923 cmd->num_args = wmi_utest->num_args;
9924 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
9925 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9926 (wmi_utest->num_args * sizeof(uint32_t)));
9927 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +05309928 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +05309929 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
9930 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309931 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +05309932 }
9933 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9934 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309935 WMI_LOGP("%s: failed to send unit test command", __func__);
9936 qdf_nbuf_free(wmi_buf);
9937 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05309938 }
9939
Govind Singhb53420c2016-03-09 14:32:57 +05309940 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05309941}
9942
9943/**
9944 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
9945 * @wmi_handle: wma handle
9946 * @roaminvoke: roam invoke command
9947 *
9948 * Send roam invoke command to fw for fastreassoc.
9949 *
9950 * Return: CDF STATUS
9951 */
Govind Singhb53420c2016-03-09 14:32:57 +05309952QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05309953 struct wmi_roam_invoke_cmd *roaminvoke,
9954 uint32_t ch_hz)
9955{
9956 wmi_roam_invoke_cmd_fixed_param *cmd;
9957 wmi_buf_t wmi_buf;
9958 u_int8_t *buf_ptr;
9959 u_int16_t len, args_tlv_len;
9960 A_UINT32 *channel_list;
9961 wmi_mac_addr *bssid_list;
9962
9963 /* Host sends only one channel and one bssid */
9964 args_tlv_len = 2 * WMI_TLV_HDR_SIZE + sizeof(A_UINT32) +
9965 sizeof(wmi_mac_addr);
9966 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
9967 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9968 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309969 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9970 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05309971 }
9972
9973 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
9974 buf_ptr = (u_int8_t *) cmd;
9975 WMITLV_SET_HDR(&cmd->tlv_header,
9976 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
9977 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
9978 cmd->vdev_id = roaminvoke->vdev_id;
9979 cmd->flags = 0;
9980 cmd->roam_scan_mode = 0;
9981 cmd->roam_ap_sel_mode = 0;
9982 cmd->roam_delay = 0;
9983 cmd->num_chan = 1;
9984 cmd->num_bssid = 1;
9985 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
9986 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9987 (sizeof(u_int32_t)));
9988 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
9989 *channel_list = ch_hz;
9990 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
9991 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
9992 (sizeof(wmi_mac_addr)));
9993 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
9994 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
9995 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9996 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309997 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +05309998 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309999 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010000 }
10001
Govind Singhb53420c2016-03-09 14:32:57 +053010002 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010003}
10004
10005/**
10006 * send_roam_scan_offload_cmd_tlv() - set roam offload command
10007 * @wmi_handle: wmi handle
10008 * @command: command
10009 * @vdev_id: vdev id
10010 *
10011 * This function set roam offload command to fw.
10012 *
10013 * Return: CDF status
10014 */
Govind Singhb53420c2016-03-09 14:32:57 +053010015QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010016 uint32_t command, uint32_t vdev_id)
10017{
Govind Singh67922e82016-04-01 16:48:57 +053010018 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010019 wmi_roam_scan_cmd_fixed_param *cmd_fp;
10020 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053010021 int len;
10022 uint8_t *buf_ptr;
10023
10024 len = sizeof(wmi_roam_scan_cmd_fixed_param);
10025 buf = wmi_buf_alloc(wmi_handle, len);
10026 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010027 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10028 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010029 }
10030
10031 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10032
10033 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
10034 WMITLV_SET_HDR(&cmd_fp->tlv_header,
10035 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
10036 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
10037 cmd_fp->vdev_id = vdev_id;
10038 cmd_fp->command_arg = command;
10039
10040 status = wmi_unified_cmd_send(wmi_handle, buf,
10041 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053010042 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010043 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010044 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010045 goto error;
10046 }
10047
Govind Singhb53420c2016-03-09 14:32:57 +053010048 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
10049 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010050
10051error:
10052 wmi_buf_free(buf);
10053
Govind Singh67922e82016-04-01 16:48:57 +053010054 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010055}
10056
10057/**
10058 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
10059 * @wmi_handle: wmi handle
10060 * @ap_profile_p: ap profile
10061 * @vdev_id: vdev id
10062 *
10063 * Send WMI_ROAM_AP_PROFILE to firmware
10064 *
10065 * Return: CDF status
10066 */
Govind Singhb53420c2016-03-09 14:32:57 +053010067QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010068 wmi_ap_profile *ap_profile_p,
10069 uint32_t vdev_id)
10070{
Govind Singha4836fd2016-03-07 16:45:38 +053010071 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010072 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010073 int len;
10074 uint8_t *buf_ptr;
10075 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
10076
10077 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
10078
10079 buf = wmi_buf_alloc(wmi_handle, len);
10080 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010081 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10082 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010083 }
10084
10085 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10086 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
10087 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
10088 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
10089 WMITLV_GET_STRUCT_TLVLEN
10090 (wmi_roam_ap_profile_fixed_param));
10091 /* fill in threshold values */
10092 roam_ap_profile_fp->vdev_id = vdev_id;
10093 roam_ap_profile_fp->id = 0;
10094 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
10095
Govind Singhb53420c2016-03-09 14:32:57 +053010096 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053010097 WMITLV_SET_HDR(buf_ptr,
10098 WMITLV_TAG_STRUC_wmi_ap_profile,
10099 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
10100 status = wmi_unified_cmd_send(wmi_handle, buf,
10101 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053010102 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010103 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010104 status);
Govind Singh67922e82016-04-01 16:48:57 +053010105 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053010106 }
10107
Govind Singhb53420c2016-03-09 14:32:57 +053010108 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053010109
Govind Singh67922e82016-04-01 16:48:57 +053010110 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010111}
10112
10113/**
10114 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
10115 * @wmi_handle: wmi handle
10116 * @scan_period: scan period
10117 * @scan_age: scan age
10118 * @vdev_id: vdev id
10119 *
10120 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
10121 *
10122 * Return: CDF status
10123 */
Govind Singhb53420c2016-03-09 14:32:57 +053010124QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010125 uint32_t scan_period,
10126 uint32_t scan_age,
10127 uint32_t vdev_id)
10128{
Govind Singh67922e82016-04-01 16:48:57 +053010129 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010130 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053010131 int len;
10132 uint8_t *buf_ptr;
10133 wmi_roam_scan_period_fixed_param *scan_period_fp;
10134
10135 /* Send scan period values */
10136 len = sizeof(wmi_roam_scan_period_fixed_param);
10137 buf = wmi_buf_alloc(wmi_handle, len);
10138 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010139 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10140 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010141 }
10142
10143 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10144 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
10145 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
10146 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
10147 WMITLV_GET_STRUCT_TLVLEN
10148 (wmi_roam_scan_period_fixed_param));
10149 /* fill in scan period values */
10150 scan_period_fp->vdev_id = vdev_id;
10151 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
10152 scan_period_fp->roam_scan_age = scan_age;
10153
10154 status = wmi_unified_cmd_send(wmi_handle, buf,
10155 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053010156 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010157 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010158 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010159 goto error;
10160 }
10161
Govind Singhb53420c2016-03-09 14:32:57 +053010162 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010163 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053010164 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010165error:
10166 wmi_buf_free(buf);
10167
Govind Singh67922e82016-04-01 16:48:57 +053010168 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010169}
10170
10171/**
10172 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
10173 * @wmi_handle: wmi handle
10174 * @chan_count: channel count
10175 * @chan_list: channel list
10176 * @list_type: list type
10177 * @vdev_id: vdev id
10178 *
10179 * Set roam offload channel list.
10180 *
10181 * Return: CDF status
10182 */
Govind Singhb53420c2016-03-09 14:32:57 +053010183QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010184 uint8_t chan_count,
10185 uint8_t *chan_list,
10186 uint8_t list_type, uint32_t vdev_id)
10187{
Govind Singha4836fd2016-03-07 16:45:38 +053010188 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010189 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010190 int len, list_tlv_len;
10191 int i;
10192 uint8_t *buf_ptr;
10193 wmi_roam_chan_list_fixed_param *chan_list_fp;
10194 A_UINT32 *roam_chan_list_array;
10195
10196 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053010197 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053010198 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053010199 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053010200 }
10201 /* Channel list is a table of 2 TLV's */
10202 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
10203 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
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__);
10207 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010208 }
10209
10210 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10211 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
10212 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
10213 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
10214 WMITLV_GET_STRUCT_TLVLEN
10215 (wmi_roam_chan_list_fixed_param));
10216 chan_list_fp->vdev_id = vdev_id;
10217 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053010218 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053010219 /* external app is controlling channel list */
10220 chan_list_fp->chan_list_type =
10221 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
10222 } else {
10223 /* umac supplied occupied channel list in LFR */
10224 chan_list_fp->chan_list_type =
10225 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
10226 }
10227
10228 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
10229 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10230 (chan_list_fp->num_chan * sizeof(uint32_t)));
10231 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053010232 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053010233 for (i = 0; ((i < chan_list_fp->num_chan) &&
10234 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
10235 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010236 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053010237 }
10238
10239 status = wmi_unified_cmd_send(wmi_handle, buf,
10240 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053010241 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010242 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010243 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010244 goto error;
10245 }
10246
Govind Singhb53420c2016-03-09 14:32:57 +053010247 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
10248 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010249error:
10250 wmi_buf_free(buf);
10251
Govind Singh67922e82016-04-01 16:48:57 +053010252 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010253}
10254
10255/**
10256 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
10257 * @wmi_handle: wmi handle
10258 * @rssi_change_thresh: RSSI Change threshold
10259 * @bcn_rssi_weight: beacon RSSI weight
10260 * @vdev_id: vdev id
10261 *
10262 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
10263 *
10264 * Return: CDF status
10265 */
Govind Singhb53420c2016-03-09 14:32:57 +053010266QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010267 uint32_t vdev_id,
10268 int32_t rssi_change_thresh,
10269 uint32_t bcn_rssi_weight,
10270 uint32_t hirssi_delay_btw_scans)
10271{
Govind Singha4836fd2016-03-07 16:45:38 +053010272 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053010273 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053010274 int len;
10275 uint8_t *buf_ptr;
10276 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
10277
10278 /* Send rssi change parameters */
10279 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
10280 buf = wmi_buf_alloc(wmi_handle, len);
10281 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010282 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10283 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010284 }
10285
10286 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10287 rssi_change_fp =
10288 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
10289 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
10290 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
10291 WMITLV_GET_STRUCT_TLVLEN
10292 (wmi_roam_scan_rssi_change_threshold_fixed_param));
10293 /* fill in rssi change threshold (hysteresis) values */
10294 rssi_change_fp->vdev_id = vdev_id;
10295 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
10296 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
10297 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
10298
10299 status = wmi_unified_cmd_send(wmi_handle, buf,
10300 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053010301 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010302 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010303 status);
Govind Singha4836fd2016-03-07 16:45:38 +053010304 goto error;
10305 }
10306
Govind Singhb53420c2016-03-09 14:32:57 +053010307 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053010308 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053010309 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
10310 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010311error:
10312 wmi_buf_free(buf);
10313
Govind Singh67922e82016-04-01 16:48:57 +053010314 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053010315}
10316
10317/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
10318 * @wmi_handle: wmi handle.
10319 * @cmd: size of command structure.
10320 * @per_entry_size: per entry size.
10321 *
10322 * This utility function calculates how many hotlist entries can
10323 * fit in one page.
10324 *
10325 * Return: number of entries
10326 */
10327static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
10328 size_t cmd_size,
10329 size_t per_entry_size)
10330{
10331 uint32_t avail_space = 0;
10332 int num_entries = 0;
10333 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
10334
10335 /* Calculate number of hotlist entries that can
10336 * be passed in wma message request.
10337 */
10338 avail_space = max_msg_len - cmd_size;
10339 num_entries = avail_space / per_entry_size;
10340 return num_entries;
10341}
10342
10343/**
10344 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
10345 * @wmi_handle: wmi handle
10346 * @photlist: hotlist command params
10347 * @buf_len: buffer length
10348 *
10349 * This function fills individual elements for hotlist request and
10350 * TLV for bssid entries
10351 *
10352 * Return: CDF Status.
10353 */
Govind Singhb53420c2016-03-09 14:32:57 +053010354QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010355 struct ext_scan_setbssi_hotlist_params *
10356 photlist, int *buf_len)
10357{
10358 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
10359 wmi_extscan_hotlist_entry *dest_hotlist;
10360 struct ap_threshold_params *src_ap = photlist->ap;
10361 wmi_buf_t buf;
10362 uint8_t *buf_ptr;
10363
10364 int j, index = 0;
10365 int cmd_len = 0;
10366 int num_entries;
10367 int min_entries = 0;
10368 int numap = photlist->numAp;
10369 int len = sizeof(*cmd);
10370
10371 len += WMI_TLV_HDR_SIZE;
10372 cmd_len = len;
10373
10374 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
10375 cmd_len,
10376 sizeof(*dest_hotlist));
10377 /* setbssid hotlist expects the bssid list
10378 * to be non zero value
10379 */
10380 if (!numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053010381 WMI_LOGE("%s: Invalid number of bssid's", __func__);
10382 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010383 }
10384
10385 /* Split the hot list entry pages and send multiple command
10386 * requests if the buffer reaches the maximum request size
10387 */
10388 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053010389 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053010390 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
10391 buf = wmi_buf_alloc(wmi_handle, len);
10392 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010393 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10394 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010395 }
10396 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10397 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
10398 buf_ptr;
10399 WMITLV_SET_HDR(&cmd->tlv_header,
10400 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
10401 WMITLV_GET_STRUCT_TLVLEN
10402 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
10403
10404 /* Multiple requests are sent until the num_entries_in_page
10405 * matches the total_entries
10406 */
10407 cmd->request_id = photlist->requestId;
10408 cmd->vdev_id = photlist->sessionId;
10409 cmd->total_entries = numap;
10410 cmd->mode = 1;
10411 cmd->num_entries_in_page = min_entries;
10412 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
10413 cmd->first_entry_index = index;
10414
Govind Singhb53420c2016-03-09 14:32:57 +053010415 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010416 __func__, cmd->vdev_id, cmd->total_entries,
10417 cmd->num_entries_in_page,
10418 cmd->lost_ap_scan_count);
10419
10420 buf_ptr += sizeof(*cmd);
10421 WMITLV_SET_HDR(buf_ptr,
10422 WMITLV_TAG_ARRAY_STRUC,
10423 min_entries * sizeof(wmi_extscan_hotlist_entry));
10424 dest_hotlist = (wmi_extscan_hotlist_entry *)
10425 (buf_ptr + WMI_TLV_HDR_SIZE);
10426
10427 /* Populate bssid, channel info and rssi
10428 * for the bssid's that are sent as hotlists.
10429 */
10430 for (j = 0; j < min_entries; j++) {
10431 WMITLV_SET_HDR(dest_hotlist,
10432 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
10433 WMITLV_GET_STRUCT_TLVLEN
10434 (wmi_extscan_hotlist_entry));
10435
10436 dest_hotlist->min_rssi = src_ap->low;
10437 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
10438 &dest_hotlist->bssid);
10439
Govind Singhb53420c2016-03-09 14:32:57 +053010440 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053010441 __func__, dest_hotlist->channel,
10442 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053010443 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053010444 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
10445 __func__, dest_hotlist->bssid.mac_addr31to0,
10446 dest_hotlist->bssid.mac_addr47to32);
10447 dest_hotlist++;
10448 src_ap++;
10449 }
10450 buf_ptr += WMI_TLV_HDR_SIZE +
10451 (min_entries * sizeof(wmi_extscan_hotlist_entry));
10452
10453 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10454 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010455 WMI_LOGE("%s: failed to send command", __func__);
10456 qdf_nbuf_free(buf);
10457 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010458 }
10459 index = index + min_entries;
10460 num_entries = numap - min_entries;
10461 len = cmd_len;
10462 }
Govind Singhb53420c2016-03-09 14:32:57 +053010463 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053010464}
10465
Govind Singhbca3b1b2016-05-02 17:59:24 +053010466/**
10467 * send_power_dbg_cmd_tlv() - send power debug commands
10468 * @wmi_handle: wmi handle
10469 * @param: wmi power debug parameter
10470 *
10471 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
10472 *
10473 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
10474 */
10475QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
10476 struct wmi_power_dbg_params *param)
10477{
10478 wmi_buf_t buf = NULL;
10479 QDF_STATUS status;
10480 int len, args_tlv_len;
10481 uint8_t *buf_ptr;
10482 uint8_t i;
10483 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
10484 uint32_t *cmd_args;
10485
10486 /* Prepare and send power debug cmd parameters */
10487 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
10488 len = sizeof(*cmd) + args_tlv_len;
10489 buf = wmi_buf_alloc(wmi_handle, len);
10490 if (!buf) {
10491 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10492 return QDF_STATUS_E_NOMEM;
10493 }
10494
10495 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10496 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
10497 WMITLV_SET_HDR(&cmd->tlv_header,
10498 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
10499 WMITLV_GET_STRUCT_TLVLEN
10500 (wmi_pdev_wal_power_debug_cmd_fixed_param));
10501
10502 cmd->pdev_id = param->pdev_id;
10503 cmd->module_id = param->module_id;
10504 cmd->num_args = param->num_args;
10505 buf_ptr += sizeof(*cmd);
10506 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10507 (param->num_args * sizeof(uint32_t)));
10508 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
10509 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
10510 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
10511 cmd_args[i] = param->args[i];
10512 WMI_LOGI("%d,", param->args[i]);
10513 }
10514
10515 status = wmi_unified_cmd_send(wmi_handle, buf,
10516 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
10517 if (QDF_IS_STATUS_ERROR(status)) {
10518 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
10519 status);
10520 goto error;
10521 }
10522
10523 return QDF_STATUS_SUCCESS;
10524error:
10525 wmi_buf_free(buf);
10526
10527 return status;
10528}
10529
Govind Singhe7f2f342016-05-23 12:12:52 +053010530/**
10531 * init_cmd_send_tlv() - send initialization cmd to fw
10532 * @wmi_handle: wmi handle
10533 * @param tgt_res_cfg: pointer to target resource configuration
10534 * @param num_mem_chunks: Number of memory chunks
10535 * @param mem_chunks: pointer to target memory chunks
10536 *
10537 * Return: QDF_STATUS_SUCCESS for success or error code
10538 */
10539static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
10540 target_resource_config *tgt_res_cfg, uint8_t num_mem_chunks,
10541 struct wmi_host_mem_chunk *mem_chunks)
10542{
10543 wmi_buf_t buf;
10544 wmi_init_cmd_fixed_param *cmd;
10545 wmi_abi_version my_vers;
10546 int num_whitelist;
10547 uint8_t *buf_ptr;
10548 wmi_resource_config *resource_cfg;
10549 wlan_host_memory_chunk *host_mem_chunks;
10550 uint32_t mem_chunk_len = 0;
10551 uint16_t idx;
10552 int len;
10553
10554 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
10555 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
10556 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
10557 if (!buf) {
10558 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
10559 return QDF_STATUS_E_FAILURE;
10560 }
10561
10562 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10563 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
10564 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
10565
10566 host_mem_chunks = (wlan_host_memory_chunk *)
10567 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
10568 + WMI_TLV_HDR_SIZE);
10569
10570 WMITLV_SET_HDR(&cmd->tlv_header,
10571 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
10572 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
10573
10574 wmi_copy_resource_config(resource_cfg, tgt_res_cfg);
10575 WMITLV_SET_HDR(&resource_cfg->tlv_header,
10576 WMITLV_TAG_STRUC_wmi_resource_config,
10577 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
10578
10579 for (idx = 0; idx < num_mem_chunks; ++idx) {
10580 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
10581 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
10582 WMITLV_GET_STRUCT_TLVLEN
10583 (wlan_host_memory_chunk));
10584 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
10585 host_mem_chunks[idx].size = mem_chunks[idx].len;
10586 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
10587 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
10588 idx, host_mem_chunks[idx].size,
10589 host_mem_chunks[idx].ptr);
10590 }
10591 cmd->num_host_mem_chunks = num_mem_chunks;
10592 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
10593 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
10594 WMITLV_TAG_ARRAY_STRUC,
10595 (sizeof(wlan_host_memory_chunk) *
10596 num_mem_chunks));
10597
10598 num_whitelist = sizeof(version_whitelist) /
10599 sizeof(wmi_whitelist_version_info);
10600 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
10601 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
10602 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
10603 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
10604 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
10605 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
10606
10607 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
10608 &my_vers,
10609 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
10610 &cmd->host_abi_vers);
10611
10612 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
10613 __func__,
10614 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
10615 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
10616 cmd->host_abi_vers.abi_version_ns_0,
10617 cmd->host_abi_vers.abi_version_ns_1,
10618 cmd->host_abi_vers.abi_version_ns_2,
10619 cmd->host_abi_vers.abi_version_ns_3);
10620
10621 /* Save version sent from host -
10622 * Will be used to check ready event
10623 */
10624 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
10625 sizeof(wmi_abi_version));
10626
10627 return wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
10628}
10629
10630/**
10631 * save_service_bitmap_tlv() - save service bitmap
10632 * @wmi_handle: wmi handle
10633 * @param evt_buf: pointer to event buffer
10634 *
10635 * Return: None
10636 */
10637#ifdef WMI_TLV_AND_NON_TLV_SUPPORT
10638void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
10639{
10640 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
10641 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
10642
10643 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
10644 param_buf->wmi_service_bitmap,
10645 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
10646}
10647#else
10648void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf)
10649{
10650 return;
10651}
10652
10653#endif
10654
10655/**
10656 * is_service_enabled_tlv() - Check if service enabled
10657 * @param wmi_handle: wmi handle
10658 * @param service_id: service identifier
10659 *
10660 * Return: 1 enabled, 0 disabled
10661 */
10662#ifdef WMI_TLV_AND_NON_TLV_SUPPORT
10663static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
10664 uint32_t service_id)
10665{
10666 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
10667 service_id);
10668}
10669#else
10670static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
10671 uint32_t service_id)
10672{
10673 return false;
10674}
10675#endif
10676
10677/**
10678 * extract_service_ready_tlv() - extract service ready event
10679 * @wmi_handle: wmi handle
10680 * @param evt_buf: pointer to received event buffer
10681 * @param cap: pointer to hold target capability information extracted from even
10682 *
10683 * Return: QDF_STATUS_SUCCESS for success or error code
10684 */
10685static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
10686 void *evt_buf, target_capability_info *cap)
10687{
10688 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
10689 wmi_service_ready_event_fixed_param *ev;
10690
10691
10692 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
10693
10694 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
10695 if (!ev) {
10696 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
10697 return QDF_STATUS_E_FAILURE;
10698 }
10699
10700 cap->phy_capability = ev->phy_capability;
10701 cap->max_frag_entry = ev->max_frag_entry;
10702 cap->num_rf_chains = ev->num_rf_chains;
10703 cap->ht_cap_info = ev->ht_cap_info;
10704 cap->vht_cap_info = ev->vht_cap_info;
10705 cap->vht_supp_mcs = ev->vht_supp_mcs;
10706 cap->hw_min_tx_power = ev->hw_min_tx_power;
10707 cap->hw_max_tx_power = ev->hw_max_tx_power;
10708 cap->sys_cap_info = ev->sys_cap_info;
10709 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
10710 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
10711 cap->max_num_scan_channels = ev->max_num_scan_channels;
10712 cap->max_supported_macs = ev->max_supported_macs;
10713 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
10714 cap->txrx_chainmask = ev->txrx_chainmask;
10715 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
10716 cap->num_msdu_desc = ev->num_msdu_desc;
10717
10718 return QDF_STATUS_SUCCESS;
10719}
10720
10721/**
10722 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
10723 * @wmi_handle: wmi handle
10724 * @param evt_buf: Pointer to event buffer
10725 * @param cap: pointer to hold HAL reg capabilities
10726 *
10727 * Return: QDF_STATUS_SUCCESS for success or error code
10728 */
10729static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
10730 void *evt_buf, TARGET_HAL_REG_CAPABILITIES *cap)
10731{
10732 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
10733
10734 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
10735
10736 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
10737 sizeof(uint32_t)),
10738 sizeof(TARGET_HAL_REG_CAPABILITIES));
10739
10740 return QDF_STATUS_SUCCESS;
10741}
10742
10743/**
10744 * extract_host_mem_req_tlv() - Extract host memory request event
10745 * @wmi_handle: wmi handle
10746 * @param evt_buf: pointer to event buffer
10747 * @param num_entries: pointer to hold number of entries requested
10748 *
10749 * Return: Number of entries requested
10750 */
10751static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
10752 void *evt_buf, uint8_t *num_entries)
10753{
10754 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
10755 wmi_service_ready_event_fixed_param *ev;
10756
10757 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
10758
10759 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
10760 if (!ev) {
10761 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
10762 return NULL;
10763 }
10764
10765 *num_entries = ev->num_mem_reqs;
10766
10767 return (host_mem_req *)param_buf->mem_reqs;
10768}
10769
10770/**
10771 * save_fw_version_in_service_ready_tlv() - Save fw version in service
10772 * ready function
10773 * @wmi_handle: wmi handle
10774 * @param evt_buf: pointer to event buffer
10775 *
10776 * Return: QDF_STATUS_SUCCESS for success or error code
10777 */
10778static QDF_STATUS
10779save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
10780{
10781 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
10782 wmi_service_ready_event_fixed_param *ev;
10783
10784
10785 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
10786
10787 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
10788 if (!ev) {
10789 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
10790 return QDF_STATUS_E_FAILURE;
10791 }
10792
10793 /*Save fw version from service ready message */
10794 /*This will be used while sending INIT message */
10795 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
10796 sizeof(wmi_handle->fw_abi_version));
10797
10798 return QDF_STATUS_SUCCESS;
10799}
10800
10801/**
10802 * ready_extract_init_status_tlv() - Extract init status from ready event
10803 * @wmi_handle: wmi handle
10804 * @param evt_buf: Pointer to event buffer
10805 *
10806 * Return: ready status
10807 */
10808static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
10809 void *evt_buf)
10810{
10811 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
10812 wmi_ready_event_fixed_param *ev = NULL;
10813
10814
10815 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
10816 ev = param_buf->fixed_param;
10817
10818 qdf_print("%s:%d\n", __func__, ev->status);
10819
10820 return ev->status;
10821}
10822
10823/**
10824 * ready_extract_mac_addr_tlv() - extract mac address from ready event
10825 * @wmi_handle: wmi handle
10826 * @param evt_buf: pointer to event buffer
10827 * @param macaddr: Pointer to hold MAC address
10828 *
10829 * Return: QDF_STATUS_SUCCESS for success or error code
10830 */
10831static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
10832 void *evt_buf, uint8_t *macaddr)
10833{
10834 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
10835 wmi_ready_event_fixed_param *ev = NULL;
10836
10837
10838 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
10839 ev = param_buf->fixed_param;
10840
10841 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
10842
10843 return QDF_STATUS_SUCCESS;
10844}
10845
10846/**
10847 * extract_dbglog_data_len_tlv() - extract debuglog data length
10848 * @wmi_handle: wmi handle
10849 * @param evt_buf: pointer to event buffer
10850 *
10851 * Return: length
10852 */
10853static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
10854 void *evt_buf, uint16_t *len)
10855{
10856 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
10857
10858 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
10859
10860 *len = param_buf->num_bufp;
10861
10862 return param_buf->bufp;
10863}
10864
10865/**
10866 * extract_vdev_start_resp_tlv() - extract vdev start response
10867 * @wmi_handle: wmi handle
10868 * @param evt_buf: pointer to event buffer
10869 * @param vdev_rsp: Pointer to hold vdev response
10870 *
10871 * Return: QDF_STATUS_SUCCESS for success or error code
10872 */
10873static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
10874 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
10875{
10876 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
10877 wmi_vdev_start_response_event_fixed_param *ev;
10878
10879 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
10880 if (!param_buf) {
10881 qdf_print("Invalid start response event buffer\n");
10882 return QDF_STATUS_E_INVAL;
10883 }
10884
10885 ev = param_buf->fixed_param;
10886 if (!ev) {
10887 qdf_print("Invalid start response event buffer\n");
10888 return QDF_STATUS_E_INVAL;
10889 }
10890
10891 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
10892
10893 vdev_rsp->vdev_id = ev->vdev_id;
10894 vdev_rsp->requestor_id = ev->requestor_id;
10895 vdev_rsp->resp_type = ev->resp_type;
10896 vdev_rsp->status = ev->status;
10897 vdev_rsp->chain_mask = ev->chain_mask;
10898 vdev_rsp->smps_mode = ev->smps_mode;
10899 vdev_rsp->mac_id = ev->mac_id;
10900 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
10901 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
10902
10903 return QDF_STATUS_SUCCESS;
10904}
10905
10906/**
10907 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
10908 * @wmi_handle: wmi handle
10909 * @param evt_buf: pointer to event buffer
10910 * @param vdev_map: Pointer to hold vdev map
10911 * @param tbttoffset_list: Pointer to tbtt offset list
10912 *
10913 * Return: QDF_STATUS_SUCCESS for success or error code
10914 */
10915static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
10916 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
10917{
10918 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
10919 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
10920
10921 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
10922 if (!param_buf) {
10923 qdf_print("Invalid tbtt update event buffer\n");
10924 return QDF_STATUS_E_INVAL;
10925 }
10926 tbtt_offset_event = param_buf->fixed_param;
10927
10928 *vdev_map = tbtt_offset_event->vdev_map;
10929 *tbttoffset_list = param_buf->tbttoffset_list;
10930
10931 return QDF_STATUS_SUCCESS;
10932}
10933
10934/**
10935 * extract_mgmt_rx_params_tlv() - extract management rx params from event
10936 * @wmi_handle: wmi handle
10937 * @param evt_buf: pointer to event buffer
10938 * @param hdr: Pointer to hold header
10939 * @param bufp: Pointer to hold pointer to rx param buffer
10940 *
10941 * Return: QDF_STATUS_SUCCESS for success or error code
10942 */
10943static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
10944 void *evt_buf, wmi_host_mgmt_rx_hdr *hdr, uint8_t **bufp)
10945{
10946 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
10947 wmi_mgmt_rx_hdr *ev_hdr = NULL;
10948
10949 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
10950 if (!param_tlvs) {
10951 WMI_LOGE("Get NULL point message from FW");
10952 return QDF_STATUS_E_INVAL;
10953 }
10954
10955 ev_hdr = param_tlvs->hdr;
10956 if (!hdr) {
10957 WMI_LOGE("Rx event is NULL");
10958 return QDF_STATUS_E_INVAL;
10959 }
10960
10961
10962 hdr->channel = ev_hdr->channel;
10963 hdr->snr = ev_hdr->snr;
10964 hdr->rate = ev_hdr->rate;
10965 hdr->phy_mode = ev_hdr->phy_mode;
10966 hdr->buf_len = ev_hdr->buf_len;
10967 hdr->status = ev_hdr->status;
10968 hdr->flags = ev_hdr->flags;
10969 hdr->rssi = ev_hdr->rssi;
10970 hdr->tsf_delta = ev_hdr->tsf_delta;
10971 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
10972
10973 *bufp = param_tlvs->bufp;
10974
10975 return QDF_STATUS_SUCCESS;
10976}
10977
10978/**
10979 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
10980 * @wmi_handle: wmi handle
10981 * @param evt_buf: pointer to event buffer
10982 * @param vdev_id: Pointer to hold vdev identifier
10983 *
10984 * Return: QDF_STATUS_SUCCESS for success or error code
10985 */
10986static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
10987 void *evt_buf, uint32_t *vdev_id)
10988{
10989 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
10990 wmi_vdev_stopped_event_fixed_param *resp_event;
10991
10992 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
10993 if (!param_buf) {
10994 WMI_LOGE("Invalid event buffer");
10995 return QDF_STATUS_E_INVAL;
10996 }
10997 resp_event = param_buf->fixed_param;
10998 *vdev_id = resp_event->vdev_id;
10999
11000 return QDF_STATUS_SUCCESS;
11001}
11002
11003/**
11004 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
11005 * @wmi_handle: wmi handle
11006 * @param evt_buf: pointer to event buffer
11007 * @param param: Pointer to hold roam param
11008 *
11009 * Return: QDF_STATUS_SUCCESS for success or error code
11010 */
11011static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
11012 void *evt_buf, wmi_host_roam_event *param)
11013{
11014 WMI_ROAM_EVENTID_param_tlvs *param_buf;
11015 wmi_roam_event_fixed_param *evt;
11016
11017 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
11018 if (!param_buf) {
11019 WMI_LOGE("Invalid roam event buffer");
11020 return QDF_STATUS_E_INVAL;
11021 }
11022
11023 evt = param_buf->fixed_param;
11024 qdf_mem_zero(param, sizeof(*param));
11025
11026 param->vdev_id = evt->vdev_id;
11027 param->reason = evt->reason;
11028 param->rssi = evt->rssi;
11029
11030 return QDF_STATUS_SUCCESS;
11031}
11032
11033/**
11034 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
11035 * @wmi_handle: wmi handle
11036 * @param evt_buf: pointer to event buffer
11037 * @param param: Pointer to hold vdev scan param
11038 *
11039 * Return: QDF_STATUS_SUCCESS for success or error code
11040 */
11041static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
11042 void *evt_buf, wmi_host_scan_event *param)
11043{
11044 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
11045 wmi_scan_event_fixed_param *evt = NULL;
11046
11047 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
11048 evt = param_buf->fixed_param;
11049
11050 qdf_mem_zero(param, sizeof(*param));
11051 switch (evt->event) {
11052 case WMI_SCAN_EVENT_STARTED:
11053 param->event = WMI_HOST_SCAN_EVENT_STARTED;
11054 break;
11055 case WMI_SCAN_EVENT_COMPLETED:
11056 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
11057 break;
11058 case WMI_SCAN_EVENT_BSS_CHANNEL:
11059 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
11060 break;
11061 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
11062 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
11063 break;
11064 case WMI_SCAN_EVENT_DEQUEUED:
11065 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
11066 break;
11067 case WMI_SCAN_EVENT_PREEMPTED:
11068 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
11069 break;
11070 case WMI_SCAN_EVENT_START_FAILED:
11071 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
11072 break;
11073 case WMI_SCAN_EVENT_RESTARTED:
11074 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
11075 break;
11076 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
11077 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
11078 break;
11079 case WMI_SCAN_EVENT_MAX:
11080 default:
11081 param->event = WMI_HOST_SCAN_EVENT_MAX;
11082 break;
11083 };
11084
11085 switch (evt->reason) {
11086 case WMI_SCAN_REASON_NONE:
11087 param->reason = WMI_HOST_SCAN_REASON_NONE;
11088 break;
11089 case WMI_SCAN_REASON_COMPLETED:
11090 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
11091 break;
11092 case WMI_SCAN_REASON_CANCELLED:
11093 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
11094 break;
11095 case WMI_SCAN_REASON_PREEMPTED:
11096 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
11097 break;
11098 case WMI_SCAN_REASON_TIMEDOUT:
11099 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
11100 break;
11101 case WMI_SCAN_REASON_INTERNAL_FAILURE:
11102 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
11103 break;
11104 case WMI_SCAN_REASON_MAX:
11105 default:
11106 param->reason = WMI_HOST_SCAN_REASON_MAX;
11107 break;
11108 };
11109
11110 param->channel_freq = evt->channel_freq;
11111 param->requestor = evt->requestor;
11112 param->scan_id = evt->scan_id;
11113 param->vdev_id = evt->vdev_id;
11114
11115 return QDF_STATUS_SUCCESS;
11116}
11117
11118/**
11119 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
11120 * @wmi_handle: wmi handle
11121 * @param evt_buf: pointer to event buffer
11122 * @param param: Pointer to hold MGMT TX completion params
11123 *
11124 * Return: QDF_STATUS_SUCCESS for success or error code
11125 */
11126static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
11127 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
11128{
11129 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
11130 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
11131
11132 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
11133 evt_buf;
11134 if (!param_buf) {
11135 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
11136 return QDF_STATUS_E_INVAL;
11137 }
11138 cmpl_params = param_buf->fixed_param;
11139
11140 param->desc_id = cmpl_params->desc_id;
11141 param->status = cmpl_params->status;
11142
11143 return QDF_STATUS_SUCCESS;
11144}
11145
11146/**
11147 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
11148 * @wmi_handle: wmi handle
11149 * @param evt_buf: pointer to event buffer
11150 * @param vdev_map: Pointer to hold vdev map
11151 *
11152 * Return: QDF_STATUS_SUCCESS for success or error code
11153 */
11154static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
11155 void *evt_buf, uint32_t *vdev_map)
11156{
11157 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
11158 wmi_host_swba_event_fixed_param *swba_event;
11159
11160 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
11161 if (!param_buf) {
11162 WMI_LOGE("Invalid swba event buffer");
11163 return QDF_STATUS_E_INVAL;
11164 }
11165 swba_event = param_buf->fixed_param;
11166 *vdev_map = swba_event->vdev_map;
11167
11168 return QDF_STATUS_SUCCESS;
11169}
11170
11171/**
11172 * extract_swba_tim_info_tlv() - extract swba tim info from event
11173 * @wmi_handle: wmi handle
11174 * @param evt_buf: pointer to event buffer
11175 * @param idx: Index to bcn info
11176 * @param tim_info: Pointer to hold tim info
11177 *
11178 * Return: QDF_STATUS_SUCCESS for success or error code
11179 */
11180static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
11181 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
11182{
11183 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
11184 wmi_tim_info *tim_info_ev;
11185
11186 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
11187 if (!param_buf) {
11188 WMI_LOGE("Invalid swba event buffer");
11189 return QDF_STATUS_E_INVAL;
11190 }
11191
11192 tim_info_ev = &param_buf->tim_info[idx];
11193
11194 tim_info->tim_len = tim_info_ev->tim_len;
11195 tim_info->tim_mcast = tim_info_ev->tim_mcast;
11196 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
11197 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
11198 tim_info->tim_changed = tim_info_ev->tim_changed;
11199 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
11200
11201 return QDF_STATUS_SUCCESS;
11202}
11203
11204/**
11205 * extract_swba_noa_info_tlv() - extract swba NoA information from event
11206 * @wmi_handle: wmi handle
11207 * @param evt_buf: pointer to event buffer
11208 * @param idx: Index to bcn info
11209 * @param p2p_desc: Pointer to hold p2p NoA info
11210 *
11211 * Return: QDF_STATUS_SUCCESS for success or error code
11212 */
11213static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
11214 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
11215{
11216 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
11217 wmi_p2p_noa_info *p2p_noa_info;
11218 uint8_t i = 0;
11219
11220 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
11221 if (!param_buf) {
11222 WMI_LOGE("Invalid swba event buffer");
11223 return QDF_STATUS_E_INVAL;
11224 }
11225
11226 p2p_noa_info = &param_buf->p2p_noa_info[idx];
11227
11228 p2p_desc->modified = false;
11229 p2p_desc->num_descriptors = 0;
11230 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
11231 p2p_desc->modified = true;
11232 p2p_desc->index =
11233 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
11234 p2p_desc->oppPS =
11235 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
11236 p2p_desc->ctwindow =
11237 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
11238 p2p_desc->num_descriptors =
11239 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
11240 (p2p_noa_info);
11241 for (i = 0; i < p2p_desc->num_descriptors; i++) {
11242 p2p_desc->noa_descriptors[i].type_count =
11243 (uint8_t) p2p_noa_info->noa_descriptors[i].
11244 type_count;
11245 p2p_desc->noa_descriptors[i].duration =
11246 p2p_noa_info->noa_descriptors[i].duration;
11247 p2p_desc->noa_descriptors[i].interval =
11248 p2p_noa_info->noa_descriptors[i].interval;
11249 p2p_desc->noa_descriptors[i].start_time =
11250 p2p_noa_info->noa_descriptors[i].start_time;
11251 }
11252 }
11253
11254 return QDF_STATUS_SUCCESS;
11255}
11256
11257/**
11258 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
11259 * @wmi_handle: wmi handle
11260 * @param evt_buf: pointer to event buffer
11261 * @param ev: Pointer to hold peer param
11262 *
11263 * Return: QDF_STATUS_SUCCESS for success or error code
11264 */
11265static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
11266 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
11267{
11268 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
11269 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
11270
11271 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
11272 kickout_event = param_buf->fixed_param;
11273
11274 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
11275 ev->peer_macaddr);
11276
11277 ev->reason = kickout_event->reason;
11278 ev->rssi = kickout_event->rssi;
11279
11280 return QDF_STATUS_SUCCESS;
11281}
11282
11283/**
11284 * extract_all_stats_counts_tlv() - extract all stats count from event
11285 * @wmi_handle: wmi handle
11286 * @param evt_buf: pointer to event buffer
11287 * @param stats_param: Pointer to hold stats count
11288 *
11289 * Return: QDF_STATUS_SUCCESS for success or error code
11290 */
11291static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
11292 void *evt_buf, wmi_host_stats_event *stats_param)
11293{
11294 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
11295 wmi_stats_event_fixed_param *ev;
11296
11297 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
11298
11299 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
11300 if (!ev) {
11301 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
11302 return QDF_STATUS_E_FAILURE;
11303 }
11304
11305 switch (ev->stats_id) {
11306 case WMI_REQUEST_PEER_STAT:
11307 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
11308 break;
11309
11310 case WMI_REQUEST_AP_STAT:
11311 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
11312 break;
11313
11314 case WMI_REQUEST_PDEV_STAT:
11315 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
11316 break;
11317
11318 case WMI_REQUEST_VDEV_STAT:
11319 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
11320 break;
11321
11322 case WMI_REQUEST_BCNFLT_STAT:
11323 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
11324 break;
11325
11326 case WMI_REQUEST_VDEV_RATE_STAT:
11327 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
11328 break;
11329
11330 default:
11331 stats_param->stats_id = 0;
11332 break;
11333
11334 }
11335
11336 stats_param->num_pdev_stats = ev->num_pdev_stats;
11337 stats_param->num_pdev_ext_stats = 0;
11338 stats_param->num_vdev_stats = ev->num_vdev_stats;
11339 stats_param->num_peer_stats = ev->num_peer_stats;
11340 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
11341 stats_param->num_chan_stats = ev->num_chan_stats;
11342
11343 return QDF_STATUS_SUCCESS;
11344}
11345
11346/**
11347 * extract_pdev_stats_tlv() - extract pdev stats from event
11348 * @wmi_handle: wmi handle
11349 * @param evt_buf: pointer to event buffer
11350 * @param index: Index into pdev stats
11351 * @param pdev_stats: Pointer to hold pdev stats
11352 *
11353 * Return: QDF_STATUS_SUCCESS for success or error code
11354 */
11355static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
11356 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
11357{
11358 return QDF_STATUS_SUCCESS;
11359}
11360
11361/**
11362 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
11363 * @wmi_handle: wmi handle
11364 * @param evt_buf: pointer to event buffer
11365 * @param index: Index into extended pdev stats
11366 * @param pdev_ext_stats: Pointer to hold extended pdev stats
11367 *
11368 * Return: QDF_STATUS_SUCCESS for success or error code
11369 */
11370static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
11371 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
11372{
11373 return QDF_STATUS_SUCCESS;
11374}
11375
11376/**
11377 * extract_vdev_stats_tlv() - extract vdev stats from event
11378 * @wmi_handle: wmi handle
11379 * @param evt_buf: pointer to event buffer
11380 * @param index: Index into vdev stats
11381 * @param vdev_stats: Pointer to hold vdev stats
11382 *
11383 * Return: QDF_STATUS_SUCCESS for success or error code
11384 */
11385static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
11386 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
11387{
11388 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
11389 wmi_stats_event_fixed_param *ev_param;
11390 uint8_t *data;
11391
11392 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
11393 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
11394 data = (uint8_t *) param_buf->data;
11395
11396 if (index < ev_param->num_vdev_stats) {
11397 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
11398 ((ev_param->num_pdev_stats) *
11399 sizeof(wmi_pdev_stats)) +
11400 (index * sizeof(wmi_vdev_stats)));
11401
11402 vdev_stats->vdev_id = ev->vdev_id;
11403 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
11404 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
11405
11406 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
11407 sizeof(ev->tx_frm_cnt));
11408 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
11409 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
11410 ev->multiple_retry_cnt,
11411 sizeof(ev->multiple_retry_cnt));
11412 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
11413 sizeof(ev->fail_cnt));
11414 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
11415 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
11416 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
11417 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
11418 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
11419 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
11420 sizeof(ev->tx_rate_history));
11421 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
11422 sizeof(ev->bcn_rssi_history));
11423
11424 }
11425
11426 return QDF_STATUS_SUCCESS;
11427}
11428
11429/**
11430 * extract_peer_stats_tlv() - extract peer stats from event
11431 * @wmi_handle: wmi handle
11432 * @param evt_buf: pointer to event buffer
11433 * @param index: Index into peer stats
11434 * @param peer_stats: Pointer to hold peer stats
11435 *
11436 * Return: QDF_STATUS_SUCCESS for success or error code
11437 */
11438static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
11439 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
11440{
11441 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
11442 wmi_stats_event_fixed_param *ev_param;
11443 uint8_t *data;
11444
11445 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
11446 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
11447 data = (uint8_t *) param_buf->data;
11448
11449 if (index < ev_param->num_peer_stats) {
11450 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
11451 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
11452 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
11453 (index * sizeof(wmi_peer_stats)));
11454
11455 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
11456
11457 OS_MEMCPY(&(peer_stats->peer_macaddr),
11458 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
11459
11460 peer_stats->peer_rssi = ev->peer_rssi;
11461 peer_stats->peer_tx_rate = ev->peer_tx_rate;
11462 peer_stats->peer_rx_rate = ev->peer_rx_rate;
11463 }
11464
11465 return QDF_STATUS_SUCCESS;
11466}
11467
11468/**
11469 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
11470 * @wmi_handle: wmi handle
11471 * @param evt_buf: pointer to event buffer
11472 * @param index: Index into bcn fault stats
11473 * @param bcnflt_stats: Pointer to hold bcn fault stats
11474 *
11475 * Return: QDF_STATUS_SUCCESS for success or error code
11476 */
11477static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
11478 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
11479{
11480 return QDF_STATUS_SUCCESS;
11481}
11482
11483/**
11484 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
11485 * @wmi_handle: wmi handle
11486 * @param evt_buf: pointer to event buffer
11487 * @param index: Index into extended peer stats
11488 * @param peer_extd_stats: Pointer to hold extended peer stats
11489 *
11490 * Return: QDF_STATUS_SUCCESS for success or error code
11491 */
11492static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
11493 void *evt_buf, uint32_t index,
11494 wmi_host_peer_extd_stats *peer_extd_stats)
11495{
11496 return QDF_STATUS_SUCCESS;
11497}
11498
11499/**
11500 * extract_chan_stats_tlv() - extract chan stats from event
11501 * @wmi_handle: wmi handle
11502 * @param evt_buf: pointer to event buffer
11503 * @param index: Index into chan stats
11504 * @param vdev_extd_stats: Pointer to hold chan stats
11505 *
11506 * Return: QDF_STATUS_SUCCESS for success or error code
11507 */
11508static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
11509 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
11510{
11511 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
11512 wmi_stats_event_fixed_param *ev_param;
11513 uint8_t *data;
11514
11515 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
11516 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
11517 data = (uint8_t *) param_buf->data;
11518
11519 if (index < ev_param->num_chan_stats) {
11520 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
11521 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
11522 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
11523 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
11524 (index * sizeof(wmi_chan_stats)));
11525
11526
11527 /* Non-TLV doesnt have num_chan_stats */
11528 chan_stats->chan_mhz = ev->chan_mhz;
11529 chan_stats->sampling_period_us = ev->sampling_period_us;
11530 chan_stats->rx_clear_count = ev->rx_clear_count;
11531 chan_stats->tx_duration_us = ev->tx_duration_us;
11532 chan_stats->rx_duration_us = ev->rx_duration_us;
11533 }
11534
11535 return QDF_STATUS_SUCCESS;
11536}
11537
11538/**
11539 * extract_profile_ctx_tlv() - extract profile context from event
11540 * @wmi_handle: wmi handle
11541 * @param evt_buf: pointer to event buffer
11542 * @idx: profile stats index to extract
11543 * @param profile_ctx: Pointer to hold profile context
11544 *
11545 * Return: QDF_STATUS_SUCCESS for success or error code
11546 */
11547static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
11548 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
11549{
11550 return QDF_STATUS_SUCCESS;
11551}
11552
11553/**
11554 * extract_profile_data_tlv() - extract profile data from event
11555 * @wmi_handle: wmi handle
11556 * @param evt_buf: pointer to event buffer
11557 * @param profile_data: Pointer to hold profile data
11558 *
11559 * Return: QDF_STATUS_SUCCESS for success or error code
11560 */
11561static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
11562 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
11563{
11564
11565 return QDF_STATUS_SUCCESS;
11566}
11567
11568/**
11569 * extract_chan_info_event_tlv() - extract chan information from event
11570 * @wmi_handle: wmi handle
11571 * @param evt_buf: pointer to event buffer
11572 * @param chan_info: Pointer to hold chan information
11573 *
11574 * Return: QDF_STATUS_SUCCESS for success or error code
11575 */
11576static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
11577 void *evt_buf, wmi_host_chan_info_event *chan_info)
11578{
11579 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
11580 wmi_chan_info_event_fixed_param *ev;
11581
11582 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
11583
11584 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
11585 if (!ev) {
11586 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
11587 return QDF_STATUS_E_FAILURE;
11588 }
11589
11590 chan_info->err_code = ev->err_code;
11591 chan_info->freq = ev->freq;
11592 chan_info->cmd_flags = ev->cmd_flags;
11593 chan_info->noise_floor = ev->noise_floor;
11594 chan_info->rx_clear_count = ev->rx_clear_count;
11595 chan_info->cycle_count = ev->cycle_count;
11596
11597 return QDF_STATUS_SUCCESS;
11598}
11599
11600/**
11601 * extract_channel_hopping_event_tlv() - extract channel hopping param
11602 * from event
11603 * @wmi_handle: wmi handle
11604 * @param evt_buf: pointer to event buffer
11605 * @param ch_hopping: Pointer to hold channel hopping param
11606 *
11607 * Return: QDF_STATUS_SUCCESS for success or error code
11608 */
11609static QDF_STATUS extract_channel_hopping_event_tlv(wmi_unified_t wmi_handle,
11610 void *evt_buf, wmi_host_pdev_channel_hopping_event *chan_info)
11611{
11612 return QDF_STATUS_SUCCESS;
11613}
11614
Govind Singh06c18392016-06-10 10:33:19 +053011615#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhecf03cd2016-05-12 12:45:51 +053011616static bool is_management_record_tlv(uint32_t cmd_id)
11617{
11618 if ((cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
11619 (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID))
11620 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053011621
Govind Singhecf03cd2016-05-12 12:45:51 +053011622 return false;
11623}
Govind Singh06c18392016-06-10 10:33:19 +053011624#endif
Govind Singhecf03cd2016-05-12 12:45:51 +053011625
Govind Singh5eb51532016-03-09 11:34:12 +053011626struct wmi_ops tlv_ops = {
11627 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
11628 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
11629 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053011630 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
11631 .send_hidden_ssid_vdev_restart_cmd =
11632 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011633 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
11634 .send_peer_param_cmd = send_peer_param_cmd_tlv,
11635 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011636 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011637 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011638 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011639 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
11640 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
11641 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
11642 .send_suspend_cmd = send_suspend_cmd_tlv,
11643 .send_resume_cmd = send_resume_cmd_tlv,
11644 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
11645 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
11646 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
11647 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
11648 .send_dbglog_cmd = send_dbglog_cmd_tlv,
11649 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
11650 .send_stats_request_cmd = send_stats_request_cmd_tlv,
11651 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
11652 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
11653 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
11654 .send_scan_start_cmd = send_scan_start_cmd_tlv,
11655 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
11656 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011657 .send_mgmt_cmd = send_mgmt_cmd_tlv,
11658 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
11659 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053011660 .send_set_sta_uapsd_auto_trig_cmd =
11661 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011662 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
11663 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
11664 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
11665 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
11666 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053011667 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
11668 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
11669 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
11670 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
11671 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
11672 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
11673 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053011674 .send_ocb_start_timing_advert_cmd =
11675 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053011676 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
11677 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
11678 .send_set_mcc_channel_time_latency_cmd =
11679 send_set_mcc_channel_time_latency_cmd_tlv,
11680 .send_set_mcc_channel_time_quota_cmd =
11681 send_set_mcc_channel_time_quota_cmd_tlv,
11682 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
11683 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053011684 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053011685 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
11686 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
11687 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
11688 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
11689 .send_process_update_edca_param_cmd =
11690 send_process_update_edca_param_cmd_tlv,
11691 .send_probe_rsp_tmpl_send_cmd =
11692 send_probe_rsp_tmpl_send_cmd_tlv,
11693 .send_p2p_go_set_beacon_ie_cmd =
11694 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053011695 .send_setup_install_key_cmd =
11696 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053011697 .send_set_gateway_params_cmd =
11698 send_set_gateway_params_cmd_tlv,
11699 .send_set_rssi_monitoring_cmd =
11700 send_set_rssi_monitoring_cmd_tlv,
11701 .send_scan_probe_setoui_cmd =
11702 send_scan_probe_setoui_cmd_tlv,
11703 .send_reset_passpoint_network_list_cmd =
11704 send_reset_passpoint_network_list_cmd_tlv,
11705 .send_set_passpoint_network_list_cmd =
11706 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053011707 .send_roam_scan_offload_mode_cmd =
11708 send_roam_scan_offload_mode_cmd_tlv,
11709 .send_roam_scan_offload_rssi_thresh_cmd =
11710 send_roam_scan_offload_rssi_thresh_cmd_tlv,
11711 .send_roam_scan_filter_cmd =
11712 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053011713 .send_set_epno_network_list_cmd =
11714 send_set_epno_network_list_cmd_tlv,
11715 .send_ipa_offload_control_cmd =
11716 send_ipa_offload_control_cmd_tlv,
11717 .send_extscan_get_capabilities_cmd =
11718 send_extscan_get_capabilities_cmd_tlv,
11719 .send_extscan_get_cached_results_cmd =
11720 send_extscan_get_cached_results_cmd_tlv,
11721 .send_extscan_stop_change_monitor_cmd =
11722 send_extscan_stop_change_monitor_cmd_tlv,
11723 .send_extscan_start_change_monitor_cmd =
11724 send_extscan_start_change_monitor_cmd_tlv,
11725 .send_extscan_stop_hotlist_monitor_cmd =
11726 send_extscan_stop_hotlist_monitor_cmd_tlv,
11727 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
11728 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
11729 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
11730 .send_plm_start_cmd = send_plm_start_cmd_tlv,
11731 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
11732 .send_pno_start_cmd = send_pno_start_cmd_tlv,
11733 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
11734 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
11735 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
11736 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
11737 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011738 .send_snr_request_cmd = send_snr_request_cmd_tlv,
11739 .send_snr_cmd = send_snr_cmd_tlv,
11740 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
11741 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
11742 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
11743 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
11744 .send_lphb_config_udp_pkt_filter_cmd =
11745 send_lphb_config_udp_pkt_filter_cmd_tlv,
11746 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
11747 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
11748 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
11749 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
11750 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
11751 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
11752 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
11753 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
11754 .send_dfs_phyerr_filter_offload_en_cmd =
11755 send_dfs_phyerr_filter_offload_en_cmd_tlv,
11756 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
11757 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
11758 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
11759 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
11760 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
11761 .send_del_ts_cmd = send_del_ts_cmd_tlv,
11762 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
11763 .send_add_ts_cmd = send_add_ts_cmd_tlv,
11764 .send_enable_disable_packet_filter_cmd =
11765 send_enable_disable_packet_filter_cmd_tlv,
11766 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
11767 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
11768 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
11769 .send_process_gtk_offload_getinfo_cmd =
11770 send_process_gtk_offload_getinfo_cmd_tlv,
11771 .send_process_add_periodic_tx_ptrn_cmd =
11772 send_process_add_periodic_tx_ptrn_cmd_tlv,
11773 .send_process_del_periodic_tx_ptrn_cmd =
11774 send_process_del_periodic_tx_ptrn_cmd_tlv,
11775 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
11776 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
11777 .send_set_app_type2_params_in_fw_cmd =
11778 send_set_app_type2_params_in_fw_cmd_tlv,
11779 .send_set_auto_shutdown_timer_cmd =
11780 send_set_auto_shutdown_timer_cmd_tlv,
11781 .send_nan_req_cmd = send_nan_req_cmd_tlv,
11782 .send_process_dhcpserver_offload_cmd =
11783 send_process_dhcpserver_offload_cmd_tlv,
11784 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
11785 .send_process_ch_avoid_update_cmd =
11786 send_process_ch_avoid_update_cmd_tlv,
11787 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
11788 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
11789 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
11790 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
11791 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
11792 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053011793 .send_init_cmd = send_init_cmd_tlv,
11794 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011795 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053011796 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053011797 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011798 .send_set_base_macaddr_indicate_cmd =
11799 send_set_base_macaddr_indicate_cmd_tlv,
11800 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
11801 .send_enable_specific_fw_logs_cmd =
11802 send_enable_specific_fw_logs_cmd_tlv,
11803 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011804 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011805 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011806 .send_pdev_set_dual_mac_config_cmd =
11807 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011808 .send_enable_arp_ns_offload_cmd =
11809 send_enable_arp_ns_offload_cmd_tlv,
11810 .send_app_type1_params_in_fw_cmd =
11811 send_app_type1_params_in_fw_cmd_tlv,
11812 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
11813 .send_process_roam_synch_complete_cmd =
11814 send_process_roam_synch_complete_cmd_tlv,
11815 .send_unit_test_cmd = send_unit_test_cmd_tlv,
11816 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
11817 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
11818 .send_roam_scan_offload_ap_profile_cmd =
11819 send_roam_scan_offload_ap_profile_cmd_tlv,
11820 .send_roam_scan_offload_scan_period_cmd =
11821 send_roam_scan_offload_scan_period_cmd_tlv,
11822 .send_roam_scan_offload_chan_list_cmd =
11823 send_roam_scan_offload_chan_list_cmd_tlv,
11824 .send_roam_scan_offload_rssi_change_cmd =
11825 send_roam_scan_offload_rssi_change_cmd_tlv,
11826 .send_get_buf_extscan_hotlist_cmd =
11827 send_get_buf_extscan_hotlist_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053011828 .send_adapt_dwelltime_params_cmd =
11829 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011830 .init_cmd_send = init_cmd_send_tlv,
11831 .get_target_cap_from_service_ready = extract_service_ready_tlv,
11832 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
11833 .extract_host_mem_req = extract_host_mem_req_tlv,
11834 .save_service_bitmap = save_service_bitmap_tlv,
11835 .is_service_enabled = is_service_enabled_tlv,
11836 .save_fw_version = save_fw_version_in_service_ready_tlv,
11837 .ready_extract_init_status = ready_extract_init_status_tlv,
11838 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
11839 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
11840 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
11841 .extract_tbttoffset_update_params =
11842 extract_tbttoffset_update_params_tlv,
11843 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
11844 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
11845 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
11846 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
11847 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
11848 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
11849 .extract_swba_tim_info = extract_swba_tim_info_tlv,
11850 .extract_swba_noa_info = extract_swba_noa_info_tlv,
11851 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
11852 .extract_all_stats_count = extract_all_stats_counts_tlv,
11853 .extract_pdev_stats = extract_pdev_stats_tlv,
11854 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
11855 .extract_vdev_stats = extract_vdev_stats_tlv,
11856 .extract_peer_stats = extract_peer_stats_tlv,
11857 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
11858 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
11859 .extract_chan_stats = extract_chan_stats_tlv,
11860 .extract_profile_ctx = extract_profile_ctx_tlv,
11861 .extract_profile_data = extract_profile_data_tlv,
11862 .extract_chan_info_event = extract_chan_info_event_tlv,
11863 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011864};
11865
Govind Singhe7f2f342016-05-23 12:12:52 +053011866#ifdef WMI_TLV_AND_NON_TLV_SUPPORT
11867/**
11868 * populate_tlv_service() - populates wmi services
11869 *
11870 * @param wmi_service: Pointer to hold wmi_service
11871 * Return: None
11872 */
11873static void populate_tlv_service(uint32_t *wmi_service)
11874{
11875 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
11876 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
11877 wmi_service[wmi_service_roam_scan_offload] =
11878 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
11879 wmi_service[wmi_service_bcn_miss_offload] =
11880 WMI_SERVICE_BCN_MISS_OFFLOAD;
11881 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
11882 wmi_service[wmi_service_sta_advanced_pwrsave] =
11883 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
11884 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
11885 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
11886 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
11887 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
11888 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
11889 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
11890 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
11891 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
11892 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
11893 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
11894 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
11895 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
11896 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
11897 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
11898 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
11899 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
11900 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
11901 wmi_service[wmi_service_packet_power_save] =
11902 WMI_SERVICE_PACKET_POWER_SAVE;
11903 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
11904 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
11905 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
11906 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
11907 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
11908 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
11909 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
11910 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
11911 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
11912 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
11913 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
11914 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
11915 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
11916 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
11917 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
11918 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
11919 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
11920 wmi_service[wmi_service_mcc_bcn_interval_change] =
11921 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
11922 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
11923 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
11924 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
11925 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
11926 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
11927 wmi_service[wmi_service_lte_ant_share_support] =
11928 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
11929 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
11930 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
11931 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
11932 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
11933 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
11934 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
11935 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
11936 wmi_service[wmi_service_bcn_txrate_override] =
11937 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
11938 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
11939 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
11940 wmi_service[wmi_service_estimate_linkspeed] =
11941 WMI_SERVICE_ESTIMATE_LINKSPEED;
11942 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
11943 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
11944 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
11945 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
11946 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
11947 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
11948 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
11949 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
11950 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
11951 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
11952 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
11953 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
11954 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
11955 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
11956 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
11957 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
11958 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
11959 wmi_service[wmi_service_sap_auth_offload] =
11960 WMI_SERVICE_SAP_AUTH_OFFLOAD;
11961 wmi_service[wmi_service_dual_band_simultaneous_support] =
11962 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
11963 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
11964 wmi_service[wmi_service_ap_arpns_offload] =
11965 WMI_SERVICE_AP_ARPNS_OFFLOAD;
11966 wmi_service[wmi_service_per_band_chainmask_support] =
11967 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
11968 wmi_service[wmi_service_packet_filter_offload] =
11969 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
11970 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
11971 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
11972 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
11973 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
11974
11975 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
11976 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
11977 wmi_service[wmi_service_smart_antenna_sw_support] =
11978 WMI_SERVICE_UNAVAILABLE;
11979 wmi_service[wmi_service_smart_antenna_hw_support] =
11980 WMI_SERVICE_UNAVAILABLE;
11981 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
11982 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
11983 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
11984 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
11985 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
11986 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
11987 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
11988 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
11989 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
11990 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
11991 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
11992
11993 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
11994 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
11995 wmi_service[wmi_service_periodic_chan_stat_support] =
11996 WMI_SERVICE_UNAVAILABLE;
11997 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
11998 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
11999 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
12000}
12001
12002/**
12003 * populate_tlv_event_id() - populates wmi event ids
12004 *
12005 * @param event_ids: Pointer to hold event ids
12006 * Return: None
12007 */
12008static void populate_tlv_events_id(uint32_t *event_ids)
12009{
12010 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
12011 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
12012 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
12013 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
12014 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
12015 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
12016 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
12017 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
12018 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
12019 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
12020 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
12021 event_ids[wmi_service_ready_ext_event_id] =
12022 WMI_SERVICE_READY_EXT_EVENTID;
12023 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
12024 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
12025 event_ids[wmi_vdev_install_key_complete_event_id] =
12026 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
12027 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
12028 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
12029
12030 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
12031 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
12032 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
12033 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
12034 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
12035 event_ids[wmi_peer_estimated_linkspeed_event_id] =
12036 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
12037 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
12038 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
12039 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
12040 event_ids[wmi_tbttoffset_update_event_id] =
12041 WMI_TBTTOFFSET_UPDATE_EVENTID;
12042 event_ids[wmi_offload_bcn_tx_status_event_id] =
12043 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
12044 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
12045 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
12046 event_ids[wmi_mgmt_tx_completion_event_id] =
12047 WMI_MGMT_TX_COMPLETION_EVENTID;
12048
12049 event_ids[wmi_tx_delba_complete_event_id] =
12050 WMI_TX_DELBA_COMPLETE_EVENTID;
12051 event_ids[wmi_tx_addba_complete_event_id] =
12052 WMI_TX_ADDBA_COMPLETE_EVENTID;
12053 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
12054
12055 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
12056
12057 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
12058 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
12059
12060 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
12061
12062 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
12063
12064 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
12065
12066 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
12067 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
12068 event_ids[wmi_do_wow_disable_ack_event_id] =
12069 WMI_D0_WOW_DISABLE_ACK_EVENTID;
12070 event_ids[wmi_wow_initial_wakeup_event_id] =
12071 WMI_WOW_INITIAL_WAKEUP_EVENTID;
12072
12073 event_ids[wmi_rtt_meas_report_event_id] =
12074 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
12075 event_ids[wmi_tsf_meas_report_event_id] =
12076 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
12077 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
12078 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
12079 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
12080 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
12081 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
12082 event_ids[wmi_update_fw_mem_dump_event_id] =
12083 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
12084 event_ids[wmi_diag_event_id_log_supported_event_id] =
12085 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
12086 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
12087 event_ids[wmi_nlo_scan_complete_event_id] =
12088 WMI_NLO_SCAN_COMPLETE_EVENTID;
12089 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
12090 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
12091
12092 event_ids[wmi_gtk_offload_status_event_id] =
12093 WMI_GTK_OFFLOAD_STATUS_EVENTID;
12094 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
12095 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
12096 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
12097
12098 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
12099
12100 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
12101
12102 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
12103 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
12104 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
12105 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
12106 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
12107 event_ids[wmi_wlan_profile_data_event_id] =
12108 WMI_WLAN_PROFILE_DATA_EVENTID;
12109 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
12110 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
12111 event_ids[wmi_vdev_get_keepalive_event_id] =
12112 WMI_VDEV_GET_KEEPALIVE_EVENTID;
12113 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
12114
12115 event_ids[wmi_diag_container_event_id] =
12116 WMI_DIAG_DATA_CONTAINER_EVENTID;
12117
12118 event_ids[wmi_host_auto_shutdown_event_id] =
12119 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
12120
12121 event_ids[wmi_update_whal_mib_stats_event_id] =
12122 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
12123
12124 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
12125 event_ids[wmi_update_vdev_rate_stats_event_id] =
12126 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
12127
12128 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
12129
12130 /** Set OCB Sched Response, deprecated */
12131 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
12132
12133 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
12134 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
12135 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
12136
12137 /* GPIO Event */
12138 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
12139 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
12140
12141 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
12142 event_ids[wmi_rfkill_state_change_event_id] =
12143 WMI_RFKILL_STATE_CHANGE_EVENTID;
12144
12145 /* TDLS Event */
12146 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
12147
12148 event_ids[wmi_batch_scan_enabled_event_id] =
12149 WMI_BATCH_SCAN_ENABLED_EVENTID;
12150 event_ids[wmi_batch_scan_result_event_id] =
12151 WMI_BATCH_SCAN_RESULT_EVENTID;
12152 /* OEM Event */
12153 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
12154 event_ids[wmi_oem_meas_report_event_id] =
12155 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
12156 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
12157
12158 /* NAN Event */
12159 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
12160
12161 /* LPI Event */
12162 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
12163 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
12164 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
12165
12166 /* ExtScan events */
12167 event_ids[wmi_extscan_start_stop_event_id] =
12168 WMI_EXTSCAN_START_STOP_EVENTID;
12169 event_ids[wmi_extscan_operation_event_id] =
12170 WMI_EXTSCAN_OPERATION_EVENTID;
12171 event_ids[wmi_extscan_table_usage_event_id] =
12172 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
12173 event_ids[wmi_extscan_cached_results_event_id] =
12174 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
12175 event_ids[wmi_extscan_wlan_change_results_event_id] =
12176 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
12177 event_ids[wmi_extscan_hotlist_match_event_id] =
12178 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
12179 event_ids[wmi_extscan_capabilities_event_id] =
12180 WMI_EXTSCAN_CAPABILITIES_EVENTID;
12181 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
12182 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
12183
12184 /* mDNS offload events */
12185 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
12186
12187 /* SAP Authentication offload events */
12188 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
12189 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
12190
12191 /** Out-of-context-of-bss (OCB) events */
12192 event_ids[wmi_ocb_set_config_resp_event_id] =
12193 WMI_OCB_SET_CONFIG_RESP_EVENTID;
12194 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
12195 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
12196 event_ids[wmi_dcc_get_stats_resp_event_id] =
12197 WMI_DCC_GET_STATS_RESP_EVENTID;
12198 event_ids[wmi_dcc_update_ndl_resp_event_id] =
12199 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
12200 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
12201 /* System-On-Chip events */
12202 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
12203 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
12204 event_ids[wmi_soc_hw_mode_transition_event_id] =
12205 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
12206 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
12207 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
12208}
12209
12210/**
12211 * populate_pdev_param_tlv() - populates pdev params
12212 *
12213 * @param pdev_param: Pointer to hold pdev params
12214 * Return: None
12215 */
12216static void populate_pdev_param_tlv(uint32_t *pdev_param)
12217{
12218 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
12219 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
12220 pdev_param[wmi_pdev_param_txpower_limit2g] =
12221 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
12222 pdev_param[wmi_pdev_param_txpower_limit5g] =
12223 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
12224 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
12225 pdev_param[wmi_pdev_param_beacon_gen_mode] =
12226 WMI_PDEV_PARAM_BEACON_GEN_MODE;
12227 pdev_param[wmi_pdev_param_beacon_tx_mode] =
12228 WMI_PDEV_PARAM_BEACON_TX_MODE;
12229 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
12230 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
12231 pdev_param[wmi_pdev_param_protection_mode] =
12232 WMI_PDEV_PARAM_PROTECTION_MODE;
12233 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
12234 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
12235 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
12236 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
12237 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
12238 pdev_param[wmi_pdev_param_sta_kickout_th] =
12239 WMI_PDEV_PARAM_STA_KICKOUT_TH;
12240 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
12241 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
12242 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
12243 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
12244 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
12245 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
12246 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
12247 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
12248 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
12249 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
12250 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
12251 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
12252 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
12253 pdev_param[wmi_pdev_param_ltr_sleep_override] =
12254 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
12255 pdev_param[wmi_pdev_param_ltr_rx_override] =
12256 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
12257 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
12258 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
12259 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
12260 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
12261 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
12262 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
12263 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
12264 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
12265 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
12266 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
12267 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
12268 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
12269 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
12270 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
12271 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
12272 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
12273 pdev_param[wmi_pdev_param_peer_stats_update_period] =
12274 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
12275 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
12276 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
12277 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
12278 pdev_param[wmi_pdev_param_arp_ac_override] =
12279 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
12280 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
12281 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
12282 pdev_param[wmi_pdev_param_ani_poll_period] =
12283 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
12284 pdev_param[wmi_pdev_param_ani_listen_period] =
12285 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
12286 pdev_param[wmi_pdev_param_ani_ofdm_level] =
12287 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
12288 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
12289 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
12290 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
12291 pdev_param[wmi_pdev_param_idle_ps_config] =
12292 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
12293 pdev_param[wmi_pdev_param_power_gating_sleep] =
12294 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
12295 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
12296 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
12297 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
12298 pdev_param[wmi_pdev_param_hw_rfkill_config] =
12299 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
12300 pdev_param[wmi_pdev_param_low_power_rf_enable] =
12301 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
12302 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
12303 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
12304 pdev_param[wmi_pdev_param_power_collapse_enable] =
12305 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
12306 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
12307 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
12308 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
12309 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
12310 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
12311 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
12312 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
12313 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
12314 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
12315 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
12316 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
12317 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
12318 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
12319 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
12320 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
12321 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
12322 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
12323 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
12324 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
12325 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
12326 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
12327 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
12328 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
12329 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
12330 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
12331 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
12332 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
12333 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
12334 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
12335 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
12336 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
12337 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
12338 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
12339 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
12340 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
12341 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
12342 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
12343 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
12344 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
12345 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
12346 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
12347 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
12348 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
12349 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
12350 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
12351 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
12352 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
12353 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
12354 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
12355 WMI_UNAVAILABLE_PARAM;
12356 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
12357 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
12358 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
12359 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
12360 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
12361 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
12362 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
12363 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
12364 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
12365 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
12366 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
12367 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
12368 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
12369 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
12370 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
12371 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
12372 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
12373 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
12374 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
12375 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
12376 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
12377 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
12378 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
12379 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
12380 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
12381 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
12382 WMI_UNAVAILABLE_PARAM;
12383 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
12384 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
12385 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
12386 WMI_UNAVAILABLE_PARAM;
12387 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
12388 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
12389 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
12390 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
12391 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
12392 WMI_UNAVAILABLE_PARAM;
12393 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
12394 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
12395 WMI_UNAVAILABLE_PARAM;
12396 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] = WMI_UNAVAILABLE_PARAM;
12397 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
12398}
12399
12400/**
12401 * populate_vdev_param_tlv() - populates vdev params
12402 *
12403 * @param vdev_param: Pointer to hold vdev params
12404 * Return: None
12405 */
12406static void populate_vdev_param_tlv(uint32_t *vdev_param)
12407{
12408 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
12409 vdev_param[wmi_vdev_param_fragmentation_threshold] =
12410 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
12411 vdev_param[wmi_vdev_param_beacon_interval] =
12412 WMI_VDEV_PARAM_BEACON_INTERVAL;
12413 vdev_param[wmi_vdev_param_listen_interval] =
12414 WMI_VDEV_PARAM_LISTEN_INTERVAL;
12415 vdev_param[wmi_vdev_param_multicast_rate] =
12416 WMI_VDEV_PARAM_MULTICAST_RATE;
12417 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
12418 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
12419 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
12420 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
12421 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
12422 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
12423 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
12424 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
12425 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
12426 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
12427 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
12428 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
12429 vdev_param[wmi_vdev_param_bmiss_count_max] =
12430 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
12431 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
12432 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
12433 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
12434 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
12435 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
12436 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
12437 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
12438 vdev_param[wmi_vdev_param_disable_htprotection] =
12439 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
12440 vdev_param[wmi_vdev_param_sta_quickkickout] =
12441 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
12442 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
12443 vdev_param[wmi_vdev_param_protection_mode] =
12444 WMI_VDEV_PARAM_PROTECTION_MODE;
12445 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
12446 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
12447 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
12448 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
12449 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
12450 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
12451 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
12452 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
12453 vdev_param[wmi_vdev_param_bcast_data_rate] =
12454 WMI_VDEV_PARAM_BCAST_DATA_RATE;
12455 vdev_param[wmi_vdev_param_mcast_data_rate] =
12456 WMI_VDEV_PARAM_MCAST_DATA_RATE;
12457 vdev_param[wmi_vdev_param_mcast_indicate] =
12458 WMI_VDEV_PARAM_MCAST_INDICATE;
12459 vdev_param[wmi_vdev_param_dhcp_indicate] =
12460 WMI_VDEV_PARAM_DHCP_INDICATE;
12461 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
12462 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
12463 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
12464 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
12465 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
12466 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
12467 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
12468 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
12469 vdev_param[wmi_vdev_param_ap_enable_nawds] =
12470 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
12471 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
12472 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
12473 vdev_param[wmi_vdev_param_packet_powersave] =
12474 WMI_VDEV_PARAM_PACKET_POWERSAVE;
12475 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
12476 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
12477 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
12478 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
12479 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
12480 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
12481 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
12482 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
12483 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
12484 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
12485 vdev_param[wmi_vdev_param_early_rx_slop_step] =
12486 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
12487 vdev_param[wmi_vdev_param_early_rx_init_slop] =
12488 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
12489 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
12490 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
12491 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
12492 vdev_param[wmi_vdev_param_snr_num_for_cal] =
12493 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
12494 vdev_param[wmi_vdev_param_roam_fw_offload] =
12495 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
12496 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
12497 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
12498 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
12499 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
12500 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
12501 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
12502 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
12503 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
12504 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
12505 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
12506 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
12507 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
12508 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
12509 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
12510 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
12511 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
12512 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
12513 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
12514 vdev_param[wmi_vdev_param_inactivity_cnt] =
12515 WMI_VDEV_PARAM_INACTIVITY_CNT;
12516 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
12517 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
12518 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
12519 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
12520 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
12521 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
12522 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
12523 vdev_param[wmi_vdev_param_rx_leak_window] =
12524 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
12525 vdev_param[wmi_vdev_param_stats_avg_factor] =
12526 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
12527 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
12528 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
12529 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
12530 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
12531 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
12532 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
12533}
12534#endif
12535
Govind Singh5eb51532016-03-09 11:34:12 +053012536/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012537 * wmi_tlv_attach() - Attach TLV APIs
Govind Singh5eb51532016-03-09 11:34:12 +053012538 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012539 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053012540 */
Govind Singhe7f2f342016-05-23 12:12:52 +053012541#ifdef WMI_TLV_AND_NON_TLV_SUPPORT
12542void wmi_tlv_attach(wmi_unified_t wmi_handle)
12543{
12544 wmi_handle->ops = &tlv_ops;
12545#ifdef WMI_INTERFACE_EVENT_LOGGING
12546 wmi_handle->log_info.buf_offset_command = 2;
12547 wmi_handle->log_info.buf_offset_event = 4;
12548 wmi_handle->log_info.is_management_record =
12549 is_management_record_tlv;
12550#endif
12551 populate_tlv_service(wmi_handle->services);
12552 populate_tlv_events_id(wmi_handle->wmi_events);
12553 populate_pdev_param_tlv(wmi_handle->pdev_param);
12554 populate_vdev_param_tlv(wmi_handle->vdev_param);
12555}
12556#else
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012557void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053012558{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012559 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053012560#ifdef WMI_INTERFACE_EVENT_LOGGING
12561 wmi_handle->log_info.buf_offset_command = 2;
12562 wmi_handle->log_info.buf_offset_event = 4;
12563 wmi_handle->log_info.is_management_record =
12564 is_management_record_tlv;
12565#endif
Govind Singh5eb51532016-03-09 11:34:12 +053012566}
Govind Singhe7f2f342016-05-23 12:12:52 +053012567#endif