blob: b62fa55f0f750b3d3015a5c049cfa77888a1459a [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -08002 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Govind Singh5eb51532016-03-09 11:34:12 +053028#include "wmi_unified_api.h"
29#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053030#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053031#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053032#include "wmi_version_whitelist.h"
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053033#include <wlan_defs.h>
34
Wu Gaocd3a8512017-03-13 20:17:34 +080035#ifdef CONVERGED_P2P_ENABLE
36#include "wlan_p2p_public_struct.h"
37#endif
Dustin Brownf31f88b2017-05-12 14:01:44 -070038#ifdef WLAN_PMO_ENABLE
39#include "wlan_pmo_hw_filter_public_struct.h"
40#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053041#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053042#ifdef WLAN_SUPPORT_GREEN_AP
43#include "wlan_green_ap_api.h"
44#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053045
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080046#ifdef WLAN_FEATURE_NAN_CONVERGENCE
47#include "nan_public_structs.h"
48#endif
49
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053050/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
51 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053052 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053053 * @cmd: pointer target vdev create command buffer
54 * @param: pointer host params for vdev create
55 *
56 * Return: None
57 */
58#ifdef CONFIG_MCL
59static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053060 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053061 wmi_vdev_create_cmd_fixed_param * cmd,
62 struct vdev_create_params *param)
63{
64 cmd->pdev_id = WMI_PDEV_ID_SOC;
65}
66#else
67static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053068 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053069 wmi_vdev_create_cmd_fixed_param * cmd,
70 struct vdev_create_params *param)
71{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053072 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
73 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053074}
75#endif
76
Govind Singh5eb51532016-03-09 11:34:12 +053077/**
78 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
79 * @wmi_handle: wmi handle
80 * @param: pointer to hold vdev create parameter
81 * @macaddr: vdev mac address
82 *
Govind Singhe7f2f342016-05-23 12:12:52 +053083 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053084 */
Sathish Kumarfd347372017-02-13 12:29:09 +053085static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053086 uint8_t macaddr[IEEE80211_ADDR_LEN],
87 struct vdev_create_params *param)
88{
89 wmi_vdev_create_cmd_fixed_param *cmd;
90 wmi_buf_t buf;
91 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053092 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070093 int num_bands = 2;
94 uint8_t *buf_ptr;
95 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053096
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070097 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053098 buf = wmi_buf_alloc(wmi_handle, len);
99 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530100 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530101 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530102 }
103 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
104 WMITLV_SET_HDR(&cmd->tlv_header,
105 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
106 WMITLV_GET_STRUCT_TLVLEN
107 (wmi_vdev_create_cmd_fixed_param));
108 cmd->vdev_id = param->if_id;
109 cmd->vdev_type = param->type;
110 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700111 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530112 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530113 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700114 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
115 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530116 macaddr[0], macaddr[1], macaddr[2],
117 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700118 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
119 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
120 (num_bands * sizeof(wmi_vdev_txrx_streams)));
121 buf_ptr += WMI_TLV_HDR_SIZE;
122
Govind Singh224a7312016-06-21 14:33:26 +0530123 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700124 param->type, param->subtype,
125 param->nss_2g, param->nss_5g);
126 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
127 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
128 txrx_streams->supported_tx_streams = param->nss_2g;
129 txrx_streams->supported_rx_streams = param->nss_2g;
130 WMITLV_SET_HDR(&txrx_streams->tlv_header,
131 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
132 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
133
134 txrx_streams++;
135 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
136 txrx_streams->supported_tx_streams = param->nss_5g;
137 txrx_streams->supported_rx_streams = param->nss_5g;
138 WMITLV_SET_HDR(&txrx_streams->tlv_header,
139 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
140 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530141 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530142 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530143 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530144 wmi_buf_free(buf);
145 }
146
147 return ret;
148}
149
150/**
151 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
152 * @wmi_handle: wmi handle
153 * @if_id: vdev id
154 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530155 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530156 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530157static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530158 uint8_t if_id)
159{
160 wmi_vdev_delete_cmd_fixed_param *cmd;
161 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530162 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530163
164 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
165 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530166 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530167 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530168 }
169
170 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
171 WMITLV_SET_HDR(&cmd->tlv_header,
172 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
173 WMITLV_GET_STRUCT_TLVLEN
174 (wmi_vdev_delete_cmd_fixed_param));
175 cmd->vdev_id = if_id;
176 ret = wmi_unified_cmd_send(wmi_handle, buf,
177 sizeof(wmi_vdev_delete_cmd_fixed_param),
178 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530179 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530180 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530181 wmi_buf_free(buf);
182 }
Govind Singhb53420c2016-03-09 14:32:57 +0530183 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530184
185 return ret;
186}
187
188/**
189 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
190 * @wmi: wmi handle
191 * @vdev_id: vdev id
192 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530193 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530194 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530195static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530196 uint8_t vdev_id)
197{
198 wmi_vdev_stop_cmd_fixed_param *cmd;
199 wmi_buf_t buf;
200 int32_t len = sizeof(*cmd);
201
202 buf = wmi_buf_alloc(wmi, len);
203 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530204 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530205 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530206 }
207 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
208 WMITLV_SET_HDR(&cmd->tlv_header,
209 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
210 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
211 cmd->vdev_id = vdev_id;
212 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530213 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530214 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530215 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530216 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530217 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530218
219 return 0;
220}
221
222/**
223 * send_vdev_down_cmd_tlv() - send vdev down command to fw
224 * @wmi: wmi handle
225 * @vdev_id: vdev id
226 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530227 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530228 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530229static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530230{
231 wmi_vdev_down_cmd_fixed_param *cmd;
232 wmi_buf_t buf;
233 int32_t len = sizeof(*cmd);
234
235 buf = wmi_buf_alloc(wmi, len);
236 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530237 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530238 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530239 }
240 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
241 WMITLV_SET_HDR(&cmd->tlv_header,
242 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
243 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
244 cmd->vdev_id = vdev_id;
245 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530246 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530247 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530248 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530249 }
Govind Singhb53420c2016-03-09 14:32:57 +0530250 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530251
252 return 0;
253}
254
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530255#ifdef CONFIG_MCL
256static inline void copy_channel_info(
257 wmi_vdev_start_request_cmd_fixed_param * cmd,
258 wmi_channel *chan,
259 struct vdev_start_params *req)
260{
261 chan->mhz = req->chan_freq;
262
263 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
264
265 chan->band_center_freq1 = req->band_center_freq1;
266 chan->band_center_freq2 = req->band_center_freq2;
267
268 if (req->is_half_rate)
269 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
270 else if (req->is_quarter_rate)
271 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
272
Naveen Rawat44f2f432016-12-01 12:58:57 -0800273 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530274 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
275 cmd->disable_hw_ack = req->dis_hw_ack;
276 }
277
278 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
279 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
280
281}
282#else
283static inline void copy_channel_info(
284 wmi_vdev_start_request_cmd_fixed_param * cmd,
285 wmi_channel *chan,
286 struct vdev_start_params *req)
287{
288 chan->mhz = req->channel.mhz;
289
290 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
291
292 chan->band_center_freq1 = req->channel.cfreq1;
293 chan->band_center_freq2 = req->channel.cfreq2;
294
295 if (req->channel.half_rate)
296 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
297 else if (req->channel.quarter_rate)
298 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
299
300 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530301 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530302 cmd->disable_hw_ack = req->disable_hw_ack;
303 }
304
Krishna Rao0b952ea2017-03-20 13:30:10 +0530305 if (req->channel.dfs_set_cfreq2)
306 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
307
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530308 /* FIXME: Find out min, max and regulatory power levels */
309 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
310 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
311
312}
313#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530314/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530315 * send_vdev_start_cmd_tlv() - send vdev start request to fw
316 * @wmi_handle: wmi handle
317 * @req: vdev start params
318 *
319 * Return: QDF status
320 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530321static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530322 struct vdev_start_params *req)
323{
324 wmi_vdev_start_request_cmd_fixed_param *cmd;
325 wmi_buf_t buf;
326 wmi_channel *chan;
327 int32_t len, ret;
328 uint8_t *buf_ptr;
329
330 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
331 buf = wmi_buf_alloc(wmi_handle, len);
332 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530333 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530334 return QDF_STATUS_E_NOMEM;
335 }
336 buf_ptr = (uint8_t *) wmi_buf_data(buf);
337 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
338 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
339 WMITLV_SET_HDR(&cmd->tlv_header,
340 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
341 WMITLV_GET_STRUCT_TLVLEN
342 (wmi_vdev_start_request_cmd_fixed_param));
343 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
344 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
345 cmd->vdev_id = req->vdev_id;
346
347 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530348 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530349
350 cmd->beacon_interval = req->beacon_intval;
351 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530352
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800353 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
354 if (req->bcn_tx_rate_code)
355 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
356
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530357 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530358 cmd->beacon_interval = req->beacon_intval;
359 cmd->dtim_period = req->dtim_period;
360
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530361 /* Copy the SSID */
362 if (req->ssid.length) {
363 if (req->ssid.length < sizeof(cmd->ssid.ssid))
364 cmd->ssid.ssid_len = req->ssid.length;
365 else
366 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
367 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
368 cmd->ssid.ssid_len);
369 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530370
371 if (req->hidden_ssid)
372 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
373
374 if (req->pmf_enabled)
375 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530376 }
377
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700378 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530379 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530380 cmd->preferred_rx_streams = req->preferred_rx_streams;
381 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700382 cmd->cac_duration_ms = req->cac_duration_ms;
383 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700384 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530385
386 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
387 sizeof(wmi_channel));
388 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
389 cmd->num_noa_descriptors *
390 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800391 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530392 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
393 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700394 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800395 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530396 req->is_dfs, req->beacon_intval, cmd->dtim_period,
397 chan->band_center_freq1, chan->band_center_freq2,
398 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700399 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700400 req->ldpc_rx_enabled, req->cac_duration_ms,
401 req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530402
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530403 if (req->is_restart)
404 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
405 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530406 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530407 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
408 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530409 if (ret) {
410 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530411 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530412 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530413 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530414
415 return QDF_STATUS_SUCCESS;
416}
417
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530418/**
419 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
420 * @wmi_handle: wmi handle
421 * @restart_params: vdev restart params
422 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530423 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530424 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530425static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530426 struct hidden_ssid_vdev_restart_params *restart_params)
427{
428 wmi_vdev_start_request_cmd_fixed_param *cmd;
429 wmi_buf_t buf;
430 wmi_channel *chan;
431 int32_t len;
432 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530433 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530434
435 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
436 buf = wmi_buf_alloc(wmi_handle, len);
437 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530438 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530439 return QDF_STATUS_E_NOMEM;
440 }
441 buf_ptr = (uint8_t *) wmi_buf_data(buf);
442 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
443 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
444
445 WMITLV_SET_HDR(&cmd->tlv_header,
446 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
447 WMITLV_GET_STRUCT_TLVLEN
448 (wmi_vdev_start_request_cmd_fixed_param));
449
450 WMITLV_SET_HDR(&chan->tlv_header,
451 WMITLV_TAG_STRUC_wmi_channel,
452 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
453
454 cmd->vdev_id = restart_params->session_id;
455 cmd->ssid.ssid_len = restart_params->ssid_len;
456 qdf_mem_copy(cmd->ssid.ssid,
457 restart_params->ssid,
458 cmd->ssid.ssid_len);
459 cmd->flags = restart_params->flags;
460 cmd->requestor_id = restart_params->requestor_id;
461 cmd->disable_hw_ack = restart_params->disable_hw_ack;
462
463 chan->mhz = restart_params->mhz;
464 chan->band_center_freq1 =
465 restart_params->band_center_freq1;
466 chan->band_center_freq2 =
467 restart_params->band_center_freq2;
468 chan->info = restart_params->info;
469 chan->reg_info_1 = restart_params->reg_info_1;
470 chan->reg_info_2 = restart_params->reg_info_2;
471
472 cmd->num_noa_descriptors = 0;
473 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
474 sizeof(wmi_channel));
475 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
476 cmd->num_noa_descriptors *
477 sizeof(wmi_p2p_noa_descriptor));
478
479 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
480 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530481 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530482 wmi_buf_free(buf);
483 return QDF_STATUS_E_FAILURE;
484 }
485 return QDF_STATUS_SUCCESS;
486}
487
488
489/**
Govind Singh5eb51532016-03-09 11:34:12 +0530490 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
491 * @wmi: wmi handle
492 * @peer_addr: peer mac address
493 * @param: pointer to hold peer flush tid parameter
494 *
495 * Return: 0 for sucess or error code
496 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530497static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530498 uint8_t peer_addr[IEEE80211_ADDR_LEN],
499 struct peer_flush_params *param)
500{
501 wmi_peer_flush_tids_cmd_fixed_param *cmd;
502 wmi_buf_t buf;
503 int32_t len = sizeof(*cmd);
504
505 buf = wmi_buf_alloc(wmi, len);
506 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530507 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530508 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530509 }
510 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
511 WMITLV_SET_HDR(&cmd->tlv_header,
512 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
513 WMITLV_GET_STRUCT_TLVLEN
514 (wmi_peer_flush_tids_cmd_fixed_param));
515 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
516 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
517 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530518 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530519 peer_addr, param->vdev_id,
520 param->peer_tid_bitmap);
521 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530522 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530523 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530524 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530525 }
526
527 return 0;
528}
529
530/**
531 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
532 * @wmi: wmi handle
533 * @peer_addr: peer mac addr
534 * @vdev_id: vdev id
535 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530536 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530537 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530538static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530539 uint8_t peer_addr[IEEE80211_ADDR_LEN],
540 uint8_t vdev_id)
541{
542 wmi_peer_delete_cmd_fixed_param *cmd;
543 wmi_buf_t buf;
544 int32_t len = sizeof(*cmd);
545 buf = wmi_buf_alloc(wmi, len);
546 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530547 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530548 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530549 }
550 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
551 WMITLV_SET_HDR(&cmd->tlv_header,
552 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
553 WMITLV_GET_STRUCT_TLVLEN
554 (wmi_peer_delete_cmd_fixed_param));
555 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
556 cmd->vdev_id = vdev_id;
557
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800558 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530559 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530560 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530561 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530562 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530563 }
Govind Singh5eb51532016-03-09 11:34:12 +0530564
565 return 0;
566}
567
568/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530569 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
570 * to target id.
571 * @targ_paramid: Target parameter id to hold the result.
572 * @peer_param_id: host param id.
573 *
574 * Return: QDF_STATUS_SUCCESS for success
575 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
576 */
577#ifdef CONFIG_MCL
578static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
579 uint32_t *targ_paramid,
580 uint32_t peer_param_id)
581{
582 *targ_paramid = peer_param_id;
583 return QDF_STATUS_SUCCESS;
584}
585#else
586static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
587 uint32_t *targ_paramid,
588 uint32_t peer_param_id)
589{
590 switch (peer_param_id) {
591 case WMI_HOST_PEER_MIMO_PS_STATE:
592 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
593 break;
594 case WMI_HOST_PEER_AMPDU:
595 *targ_paramid = WMI_PEER_AMPDU;
596 break;
597 case WMI_HOST_PEER_AUTHORIZE:
598 *targ_paramid = WMI_PEER_AUTHORIZE;
599 break;
600 case WMI_HOST_PEER_CHWIDTH:
601 *targ_paramid = WMI_PEER_CHWIDTH;
602 break;
603 case WMI_HOST_PEER_NSS:
604 *targ_paramid = WMI_PEER_NSS;
605 break;
606 case WMI_HOST_PEER_USE_4ADDR:
607 *targ_paramid = WMI_PEER_USE_4ADDR;
608 break;
609 case WMI_HOST_PEER_MEMBERSHIP:
610 *targ_paramid = WMI_PEER_MEMBERSHIP;
611 break;
612 case WMI_HOST_PEER_USERPOS:
613 *targ_paramid = WMI_PEER_USERPOS;
614 break;
615 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
616 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
617 break;
618 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
619 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
620 break;
621 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
622 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
623 break;
624 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
625 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
626 break;
627 case WMI_HOST_PEER_PHYMODE:
628 *targ_paramid = WMI_PEER_PHYMODE;
629 break;
630 case WMI_HOST_PEER_USE_FIXED_PWR:
631 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
632 break;
633 case WMI_HOST_PEER_PARAM_FIXED_RATE:
634 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
635 break;
636 case WMI_HOST_PEER_SET_MU_WHITELIST:
637 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
638 break;
639 case WMI_HOST_PEER_SET_MAC_TX_RATE:
640 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
641 break;
642 case WMI_HOST_PEER_SET_MIN_TX_RATE:
643 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
644 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530645 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
646 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
647 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530648 case WMI_HOST_PEER_NSS_VHT160:
649 *targ_paramid = WMI_PEER_NSS_VHT160;
650 break;
651 case WMI_HOST_PEER_NSS_VHT80_80:
652 *targ_paramid = WMI_PEER_NSS_VHT80_80;
653 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530654 default:
655 return QDF_STATUS_E_NOSUPPORT;
656 }
657
658 return QDF_STATUS_SUCCESS;
659}
660#endif
661/**
Govind Singh5eb51532016-03-09 11:34:12 +0530662 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530663 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530664 * @peer_addr: peer mac address
665 * @param : pointer to hold peer set parameter
666 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530667 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530668 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530669static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530670 uint8_t peer_addr[IEEE80211_ADDR_LEN],
671 struct peer_set_params *param)
672{
673 wmi_peer_set_param_cmd_fixed_param *cmd;
674 wmi_buf_t buf;
675 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530676 uint32_t param_id;
677
678 if (convert_host_peer_id_to_target_id_tlv(&param_id,
679 param->param_id) != QDF_STATUS_SUCCESS)
680 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530681
682 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
683 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530684 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530685 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530686 }
687 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
688 WMITLV_SET_HDR(&cmd->tlv_header,
689 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
690 WMITLV_GET_STRUCT_TLVLEN
691 (wmi_peer_set_param_cmd_fixed_param));
692 cmd->vdev_id = param->vdev_id;
693 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530694 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530695 cmd->param_value = param->param_value;
696 err = wmi_unified_cmd_send(wmi, buf,
697 sizeof(wmi_peer_set_param_cmd_fixed_param),
698 WMI_PEER_SET_PARAM_CMDID);
699 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530700 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530701 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530702 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530703 }
704
705 return 0;
706}
707
708/**
709 * send_vdev_up_cmd_tlv() - send vdev up command in fw
710 * @wmi: wmi handle
711 * @bssid: bssid
712 * @vdev_up_params: pointer to hold vdev up parameter
713 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530714 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530715 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530716static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530717 uint8_t bssid[IEEE80211_ADDR_LEN],
718 struct vdev_up_params *params)
719{
720 wmi_vdev_up_cmd_fixed_param *cmd;
721 wmi_buf_t buf;
722 int32_t len = sizeof(*cmd);
723
Govind Singhb53420c2016-03-09 14:32:57 +0530724 WMI_LOGD("%s: VDEV_UP", __func__);
725 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530726 params->vdev_id, params->assoc_id, bssid);
727 buf = wmi_buf_alloc(wmi, len);
728 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530729 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530730 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530731 }
732 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
733 WMITLV_SET_HDR(&cmd->tlv_header,
734 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
735 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
736 cmd->vdev_id = params->vdev_id;
737 cmd->vdev_assoc_id = params->assoc_id;
738 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
739 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530740 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530741 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530742 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530743 }
744
745 return 0;
746}
747
748/**
749 * send_peer_create_cmd_tlv() - send peer create command to fw
750 * @wmi: wmi handle
751 * @peer_addr: peer mac address
752 * @peer_type: peer type
753 * @vdev_id: vdev id
754 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530755 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530756 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530757static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530758 struct peer_create_params *param)
759{
760 wmi_peer_create_cmd_fixed_param *cmd;
761 wmi_buf_t buf;
762 int32_t len = sizeof(*cmd);
763
764 buf = wmi_buf_alloc(wmi, len);
765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530766 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530767 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530768 }
769 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
770 WMITLV_SET_HDR(&cmd->tlv_header,
771 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
772 WMITLV_GET_STRUCT_TLVLEN
773 (wmi_peer_create_cmd_fixed_param));
774 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
775 cmd->peer_type = param->peer_type;
776 cmd->vdev_id = param->vdev_id;
777
778 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530779 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530780 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530781 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530782 }
Govind Singhb53420c2016-03-09 14:32:57 +0530783 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530784 param->vdev_id);
785
786 return 0;
787}
788
789/**
Leo Changeee40872016-09-28 13:43:36 -0700790 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
791 * command to fw
792 * @wmi: wmi handle
793 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
794 *
795 * Return: 0 for success or error code
796 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700797static
Leo Changeee40872016-09-28 13:43:36 -0700798QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
799 struct rx_reorder_queue_setup_params *param)
800{
801 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
802 wmi_buf_t buf;
803 int32_t len = sizeof(*cmd);
804
805 buf = wmi_buf_alloc(wmi, len);
806 if (!buf) {
807 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
808 return QDF_STATUS_E_NOMEM;
809 }
810 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
811 WMITLV_SET_HDR(&cmd->tlv_header,
812 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
813 WMITLV_GET_STRUCT_TLVLEN
814 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
815 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
816 cmd->vdev_id = param->vdev_id;
817 cmd->tid = param->tid;
818 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
819 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
820 cmd->queue_no = param->queue_no;
821
822 if (wmi_unified_cmd_send(wmi, buf, len,
823 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
824 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
825 __func__);
826 qdf_nbuf_free(buf);
827 return QDF_STATUS_E_FAILURE;
828 }
829 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
830 param->peer_macaddr, param->vdev_id, param->tid);
831
832 return QDF_STATUS_SUCCESS;
833}
834
835/**
836 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
837 * command to fw
838 * @wmi: wmi handle
839 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
840 *
841 * Return: 0 for success or error code
842 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700843static
Leo Changeee40872016-09-28 13:43:36 -0700844QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
845 struct rx_reorder_queue_remove_params *param)
846{
847 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
848 wmi_buf_t buf;
849 int32_t len = sizeof(*cmd);
850
851 buf = wmi_buf_alloc(wmi, len);
852 if (!buf) {
853 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
854 return QDF_STATUS_E_NOMEM;
855 }
856 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
857 wmi_buf_data(buf);
858 WMITLV_SET_HDR(&cmd->tlv_header,
859 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
860 WMITLV_GET_STRUCT_TLVLEN
861 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
862 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
863 cmd->vdev_id = param->vdev_id;
864 cmd->tid_mask = param->peer_tid_bitmap;
865
866 if (wmi_unified_cmd_send(wmi, buf, len,
867 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
868 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
869 __func__);
870 qdf_nbuf_free(buf);
871 return QDF_STATUS_E_FAILURE;
872 }
873 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
874 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
875
876 return QDF_STATUS_SUCCESS;
877}
878
879/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530880 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
881 * @wmi_handle: wmi handle
882 * @param: pointer holding peer details
883 *
884 * Return: 0 for success or error code
885 */
886static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
887 struct peer_add_wds_entry_params *param)
888{
889 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
890 wmi_buf_t buf;
891 int len = sizeof(*cmd);
892
893 buf = wmi_buf_alloc(wmi_handle, len);
894 if (!buf) {
895 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
896 return QDF_STATUS_E_FAILURE;
897 }
898 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
899 WMITLV_SET_HDR(&cmd->tlv_header,
900 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
901 WMITLV_GET_STRUCT_TLVLEN
902 (wmi_peer_add_wds_entry_cmd_fixed_param));
903 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
904 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800905 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
906 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530907
908 return wmi_unified_cmd_send(wmi_handle, buf, len,
909 WMI_PEER_ADD_WDS_ENTRY_CMDID);
910}
911
912/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530913 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530914 * @wmi_handle: wmi handle
915 * @param: pointer holding peer details
916 *
917 * Return: 0 for success or error code
918 */
919static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
920 struct peer_del_wds_entry_params *param)
921{
922 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
923 wmi_buf_t buf;
924 int len = sizeof(*cmd);
925
926 buf = wmi_buf_alloc(wmi_handle, len);
927 if (!buf) {
928 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
929 return QDF_STATUS_E_NOMEM;
930 }
931 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
932 WMITLV_SET_HDR(&cmd->tlv_header,
933 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
934 WMITLV_GET_STRUCT_TLVLEN
935 (wmi_peer_remove_wds_entry_cmd_fixed_param));
936 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800937 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530938 return wmi_unified_cmd_send(wmi_handle, buf, len,
939 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
940}
941
942/**
943 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
944 * @wmi_handle: wmi handle
945 * @param: pointer holding peer details
946 *
947 * Return: 0 for success or error code
948 */
949static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
950 struct peer_update_wds_entry_params *param)
951{
952 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
953 wmi_buf_t buf;
954 int len = sizeof(*cmd);
955
956 buf = wmi_buf_alloc(wmi_handle, len);
957 if (!buf) {
958 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
959 return QDF_STATUS_E_NOMEM;
960 }
961
962 /* wmi_buf_alloc returns zeroed command buffer */
963 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
964 WMITLV_SET_HDR(&cmd->tlv_header,
965 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
966 WMITLV_GET_STRUCT_TLVLEN
967 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800968 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
969 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530970 if (param->wds_macaddr)
971 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
972 &cmd->wds_macaddr);
973 if (param->peer_macaddr)
974 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
975 &cmd->peer_macaddr);
976 return wmi_unified_cmd_send(wmi_handle, buf, len,
977 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
978}
979
Himanshu Agarwal66d4a162018-01-10 14:21:53 +0530980#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530981/**
Govind Singh5eb51532016-03-09 11:34:12 +0530982 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
983 * @wmi_handle: wmi handle
984 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +0530985 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +0530986 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530987 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530988 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530989static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +0530990 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530991{
992 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
993 wmi_buf_t buf;
994 int32_t len = sizeof(*cmd);
995
Govind Singhb53420c2016-03-09 14:32:57 +0530996 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530997
998 buf = wmi_buf_alloc(wmi_handle, len);
999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301000 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301001 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301002 }
1003
1004 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1005 WMITLV_SET_HDR(&cmd->tlv_header,
1006 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1007 WMITLV_GET_STRUCT_TLVLEN
1008 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301009 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301010 cmd->enable = value;
1011
1012 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1013 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301014 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301015 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301016 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301017 }
1018
1019 return 0;
1020}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301021#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301022
1023/**
1024 * send_pdev_utf_cmd_tlv() - send utf command to fw
1025 * @wmi_handle: wmi handle
1026 * @param: pointer to pdev_utf_params
1027 * @mac_id: mac id to have radio context
1028 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301029 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301030 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301031static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301032send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1033 struct pdev_utf_params *param,
1034 uint8_t mac_id)
1035{
1036 wmi_buf_t buf;
1037 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001038 /* if param->len is 0 no data is sent, return error */
1039 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301040 static uint8_t msgref = 1;
1041 uint8_t segNumber = 0, segInfo, numSegments;
1042 uint16_t chunk_len, total_bytes;
1043 uint8_t *bufpos;
1044 struct seg_hdr_info segHdrInfo;
1045
1046 bufpos = param->utf_payload;
1047 total_bytes = param->len;
1048 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1049 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1050 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1051
1052 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1053 numSegments++;
1054
1055 while (param->len) {
1056 if (param->len > MAX_WMI_UTF_LEN)
1057 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1058 else
1059 chunk_len = param->len;
1060
1061 buf = wmi_buf_alloc(wmi_handle,
1062 (chunk_len + sizeof(segHdrInfo) +
1063 WMI_TLV_HDR_SIZE));
1064 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301065 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301066 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301067 }
1068
1069 cmd = (uint8_t *) wmi_buf_data(buf);
1070
1071 segHdrInfo.len = total_bytes;
1072 segHdrInfo.msgref = msgref;
1073 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1074 segHdrInfo.segmentInfo = segInfo;
1075 segHdrInfo.pad = 0;
1076
Govind Singhb53420c2016-03-09 14:32:57 +05301077 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301078 " segHdrInfo.segmentInfo = %d",
1079 __func__, segHdrInfo.len, segHdrInfo.msgref,
1080 segHdrInfo.segmentInfo);
1081
Govind Singhb53420c2016-03-09 14:32:57 +05301082 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301083 "chunk len %d", __func__, total_bytes, segNumber,
1084 numSegments, chunk_len);
1085
1086 segNumber++;
1087
1088 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1089 (chunk_len + sizeof(segHdrInfo)));
1090 cmd += WMI_TLV_HDR_SIZE;
1091 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1092 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1093
1094 ret = wmi_unified_cmd_send(wmi_handle, buf,
1095 (chunk_len + sizeof(segHdrInfo) +
1096 WMI_TLV_HDR_SIZE),
1097 WMI_PDEV_UTF_CMDID);
1098
Govind Singh67922e82016-04-01 16:48:57 +05301099 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301100 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301101 wmi_buf_free(buf);
1102 break;
1103 }
1104
1105 param->len -= chunk_len;
1106 bufpos += chunk_len;
1107 }
1108
1109 msgref++;
1110
1111 return ret;
1112}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301113#ifdef CONFIG_MCL
1114static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1115 uint32_t host_param)
1116{
1117 return host_param;
1118}
1119#else
1120static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1121 uint32_t host_param)
1122{
1123 if (host_param < wmi_pdev_param_max)
1124 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301125
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301126 return WMI_UNAVAILABLE_PARAM;
1127}
1128#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301129/**
1130 * send_pdev_param_cmd_tlv() - set pdev parameters
1131 * @wmi_handle: wmi handle
1132 * @param: pointer to pdev parameter
1133 * @mac_id: radio context
1134 *
1135 * Return: 0 on success, errno on failure
1136 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301137static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301138send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1139 struct pdev_params *param,
1140 uint8_t mac_id)
1141{
Govind Singh67922e82016-04-01 16:48:57 +05301142 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301143 wmi_pdev_set_param_cmd_fixed_param *cmd;
1144 wmi_buf_t buf;
1145 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301146 uint32_t pdev_param;
1147
1148 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1149 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1150 WMI_LOGW("%s: Unavailable param %d\n",
1151 __func__, param->param_id);
1152 return QDF_STATUS_E_INVAL;
1153 }
Govind Singh5eb51532016-03-09 11:34:12 +05301154
1155 buf = wmi_buf_alloc(wmi_handle, len);
1156 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301157 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301158 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301159 }
1160 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1161 WMITLV_SET_HDR(&cmd->tlv_header,
1162 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1163 WMITLV_GET_STRUCT_TLVLEN
1164 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301165 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301166 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301167 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301168 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301169 param->param_value);
1170 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1171 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301172 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301173 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301174 wmi_buf_free(buf);
1175 }
1176 return ret;
1177}
1178
1179/**
1180 * send_suspend_cmd_tlv() - WMI suspend function
1181 * @param wmi_handle : handle to WMI.
1182 * @param param : pointer to hold suspend parameter
1183 * @mac_id: radio context
1184 *
1185 * Return 0 on success and -ve on failure.
1186 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301187static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301188 struct suspend_params *param,
1189 uint8_t mac_id)
1190{
1191 wmi_pdev_suspend_cmd_fixed_param *cmd;
1192 wmi_buf_t wmibuf;
1193 uint32_t len = sizeof(*cmd);
1194 int32_t ret;
1195
1196 /*
1197 * send the comand to Target to ignore the
1198 * PCIE reset so as to ensure that Host and target
1199 * states are in sync
1200 */
1201 wmibuf = wmi_buf_alloc(wmi_handle, len);
1202 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301203 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301204
1205 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1206 WMITLV_SET_HDR(&cmd->tlv_header,
1207 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1208 WMITLV_GET_STRUCT_TLVLEN
1209 (wmi_pdev_suspend_cmd_fixed_param));
1210 if (param->disable_target_intr)
1211 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1212 else
1213 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301214
1215 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1216
Govind Singh5eb51532016-03-09 11:34:12 +05301217 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1218 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301219 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301220 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301221 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301222 }
1223
1224 return ret;
1225}
1226
1227/**
1228 * send_resume_cmd_tlv() - WMI resume function
1229 * @param wmi_handle : handle to WMI.
1230 * @mac_id: radio context
1231 *
1232 * Return: 0 on success and -ve on failure.
1233 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301234static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301235 uint8_t mac_id)
1236{
1237 wmi_buf_t wmibuf;
1238 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301239 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301240
1241 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1242 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301243 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301244 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1245 WMITLV_SET_HDR(&cmd->tlv_header,
1246 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1247 WMITLV_GET_STRUCT_TLVLEN
1248 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301249 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301250 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1251 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301252 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301253 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301254 wmi_buf_free(wmibuf);
1255 }
1256
1257 return ret;
1258}
1259
Will Huang422ac9a2017-11-17 13:19:16 +08001260#ifdef FEATURE_WLAN_D0WOW
1261/**
1262 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1263 * @param wmi_handle: handle to WMI.
1264 * @mac_id: radio context
1265 *
1266 * Return: 0 on success and error code on failure.
1267 */
1268static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1269 uint8_t mac_id)
1270{
1271 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1272 wmi_buf_t buf;
1273 int32_t len;
1274 QDF_STATUS status;
1275
1276 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1277
1278 buf = wmi_buf_alloc(wmi_handle, len);
1279 if (!buf) {
1280 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1281 return QDF_STATUS_E_NOMEM;
1282 }
1283 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1284 WMITLV_SET_HDR(&cmd->tlv_header,
1285 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1286 WMITLV_GET_STRUCT_TLVLEN
1287 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1288
1289 cmd->enable = true;
1290
1291 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1292 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1293 if (QDF_IS_STATUS_ERROR(status))
1294 wmi_buf_free(buf);
1295
1296 return status;
1297}
1298
1299/**
1300 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1301 * @param wmi_handle: handle to WMI.
1302 * @mac_id: radio context
1303 *
1304 * Return: 0 on success and error code on failure.
1305 */
1306static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1307 uint8_t mac_id)
1308{
1309 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1310 wmi_buf_t buf;
1311 int32_t len;
1312 QDF_STATUS status;
1313
1314 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1315
1316 buf = wmi_buf_alloc(wmi_handle, len);
1317 if (!buf) {
1318 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1319 return QDF_STATUS_E_NOMEM;
1320 }
1321 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1322 WMITLV_SET_HDR(&cmd->tlv_header,
1323 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1324 WMITLV_GET_STRUCT_TLVLEN
1325 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1326
1327 cmd->enable = false;
1328
1329 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1330 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1331 if (QDF_IS_STATUS_ERROR(status))
1332 wmi_buf_free(buf);
1333
1334 return status;
1335}
1336#endif
1337
Govind Singh5eb51532016-03-09 11:34:12 +05301338/**
1339 * send_wow_enable_cmd_tlv() - WMI wow enable function
1340 * @param wmi_handle : handle to WMI.
1341 * @param param : pointer to hold wow enable parameter
1342 * @mac_id: radio context
1343 *
1344 * Return: 0 on success and -ve on failure.
1345 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301346static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301347 struct wow_cmd_params *param,
1348 uint8_t mac_id)
1349{
1350 wmi_wow_enable_cmd_fixed_param *cmd;
1351 wmi_buf_t buf;
1352 int32_t len;
1353 int32_t ret;
1354
1355 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1356
1357 buf = wmi_buf_alloc(wmi_handle, len);
1358 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301359 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1360 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301361 }
1362 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1363 WMITLV_SET_HDR(&cmd->tlv_header,
1364 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1365 WMITLV_GET_STRUCT_TLVLEN
1366 (wmi_wow_enable_cmd_fixed_param));
1367 cmd->enable = param->enable;
1368 if (param->can_suspend_link)
1369 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1370 else
1371 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001372 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301373
Govind Singhb53420c2016-03-09 14:32:57 +05301374 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301375 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1376 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1377
1378 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1379 WMI_WOW_ENABLE_CMDID);
1380 if (ret)
1381 wmi_buf_free(buf);
1382
1383 return ret;
1384}
1385
1386/**
1387 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301388 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301389 * @peer_addr: peer mac address
1390 * @param: pointer to ap_ps parameter structure
1391 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301392 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301393 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301394static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301395 uint8_t *peer_addr,
1396 struct ap_ps_params *param)
1397{
1398 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1399 wmi_buf_t buf;
1400 int32_t err;
1401
1402 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1403 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301404 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301405 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301406 }
1407 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1408 WMITLV_SET_HDR(&cmd->tlv_header,
1409 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1410 WMITLV_GET_STRUCT_TLVLEN
1411 (wmi_ap_ps_peer_cmd_fixed_param));
1412 cmd->vdev_id = param->vdev_id;
1413 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1414 cmd->param = param->param;
1415 cmd->value = param->value;
1416 err = wmi_unified_cmd_send(wmi_handle, buf,
1417 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1418 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301419 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301420 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301421 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301422 }
1423
1424 return 0;
1425}
1426
1427/**
1428 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301429 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301430 * @peer_addr: peer mac address
1431 * @param: pointer to sta_ps parameter structure
1432 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301433 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301434 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301435static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301436 struct sta_ps_params *param)
1437{
1438 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1439 wmi_buf_t buf;
1440 int32_t len = sizeof(*cmd);
1441
1442 buf = wmi_buf_alloc(wmi_handle, len);
1443 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301444 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301445 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301446 }
1447
1448 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1449 WMITLV_SET_HDR(&cmd->tlv_header,
1450 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1451 WMITLV_GET_STRUCT_TLVLEN
1452 (wmi_sta_powersave_param_cmd_fixed_param));
1453 cmd->vdev_id = param->vdev_id;
1454 cmd->param = param->param;
1455 cmd->value = param->value;
1456
1457 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1458 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301459 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301460 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301461 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301462 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301463 }
1464
1465 return 0;
1466}
1467
1468/**
1469 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301470 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301471 * @param: ponirt to crash inject paramter structure
1472 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301473 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301474 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301475static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301476 struct crash_inject *param)
1477{
1478 int32_t ret = 0;
1479 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1480 uint16_t len = sizeof(*cmd);
1481 wmi_buf_t buf;
1482
1483 buf = wmi_buf_alloc(wmi_handle, len);
1484 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301485 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301486 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301487 }
1488
1489 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1490 WMITLV_SET_HDR(&cmd->tlv_header,
1491 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1492 WMITLV_GET_STRUCT_TLVLEN
1493 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1494 cmd->type = param->type;
1495 cmd->delay_time_ms = param->delay_time_ms;
1496
1497 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1498 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301499 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301500 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301501 __func__, ret);
1502 wmi_buf_free(buf);
1503 }
1504
1505 return ret;
1506}
1507
1508/**
1509 * send_dbglog_cmd_tlv() - set debug log level
1510 * @param wmi_handle : handle to WMI.
1511 * @param param : pointer to hold dbglog level parameter
1512 *
1513 * Return: 0 on success and -ve on failure.
1514 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301515 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301516send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1517 struct dbglog_params *dbglog_param)
1518{
1519 wmi_buf_t buf;
1520 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001521 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301522 int32_t i;
1523 int32_t len;
1524 int8_t *buf_ptr;
1525 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1526
Alok Kumar240afea2017-08-30 14:45:34 +05301527 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301528
1529 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1530 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1531 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1532 buf = wmi_buf_alloc(wmi_handle, len);
1533 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001534 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301535
1536 configmsg =
1537 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1538 buf_ptr = (int8_t *) configmsg;
1539 WMITLV_SET_HDR(&configmsg->tlv_header,
1540 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1541 WMITLV_GET_STRUCT_TLVLEN
1542 (wmi_debug_log_config_cmd_fixed_param));
1543 configmsg->dbg_log_param = dbglog_param->param;
1544 configmsg->value = dbglog_param->val;
1545 /* Filling in the data part of second tlv -- should
1546 * follow first tlv _ WMI_TLV_HDR_SIZE */
1547 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1548 sizeof
1549 (wmi_debug_log_config_cmd_fixed_param)
1550 + WMI_TLV_HDR_SIZE);
1551 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1552 WMITLV_TAG_ARRAY_UINT32,
1553 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1554 if (dbglog_param->module_id_bitmap) {
1555 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1556 module_id_bitmap_array[i] =
1557 dbglog_param->module_id_bitmap[i];
1558 }
1559 }
1560
1561 status = wmi_unified_cmd_send(wmi_handle, buf,
1562 len, WMI_DBGLOG_CFG_CMDID);
1563
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001564 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301565 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301566
1567 return status;
1568}
1569
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301570#ifdef CONFIG_MCL
1571static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1572 uint32_t host_param)
1573{
1574 return host_param;
1575}
1576#else
1577static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1578 uint32_t host_param)
1579{
1580 if (host_param < wmi_vdev_param_max)
1581 return wmi_handle->vdev_param[host_param];
1582
1583 return WMI_UNAVAILABLE_PARAM;
1584}
1585#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301586/**
1587 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1588 * @param wmi_handle : handle to WMI.
1589 * @param macaddr : MAC address
1590 * @param param : pointer to hold vdev set parameter
1591 *
1592 * Return: 0 on success and -ve on failure.
1593 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301594static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301595 struct vdev_set_params *param)
1596{
Govind Singh67922e82016-04-01 16:48:57 +05301597 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301598 wmi_vdev_set_param_cmd_fixed_param *cmd;
1599 wmi_buf_t buf;
1600 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301601 uint32_t vdev_param;
1602
1603 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1604 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1605 WMI_LOGW("%s:Vdev param %d not available", __func__,
1606 param->param_id);
1607 return QDF_STATUS_E_INVAL;
1608
1609 }
Govind Singh5eb51532016-03-09 11:34:12 +05301610
1611 buf = wmi_buf_alloc(wmi_handle, len);
1612 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301613 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301614 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301615 }
1616 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1617 WMITLV_SET_HDR(&cmd->tlv_header,
1618 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1619 WMITLV_GET_STRUCT_TLVLEN
1620 (wmi_vdev_set_param_cmd_fixed_param));
1621 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301622 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301623 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301624 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301625 param->if_id, param->param_id, param->param_value);
1626 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1627 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301628 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301629 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301630 wmi_buf_free(buf);
1631 }
1632
1633 return ret;
1634}
1635
1636/**
1637 * send_stats_request_cmd_tlv() - WMI request stats function
1638 * @param wmi_handle : handle to WMI.
1639 * @param macaddr : MAC address
1640 * @param param : pointer to hold stats request parameter
1641 *
1642 * Return: 0 on success and -ve on failure.
1643 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301644static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301645 uint8_t macaddr[IEEE80211_ADDR_LEN],
1646 struct stats_request_params *param)
1647{
Govind Singhd3156eb2016-02-26 17:50:39 +05301648 int32_t ret;
1649 wmi_request_stats_cmd_fixed_param *cmd;
1650 wmi_buf_t buf;
1651 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1652
1653 buf = wmi_buf_alloc(wmi_handle, len);
1654 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301655 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1656 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301657 }
1658
1659 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1660 WMITLV_SET_HDR(&cmd->tlv_header,
1661 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1662 WMITLV_GET_STRUCT_TLVLEN
1663 (wmi_request_stats_cmd_fixed_param));
1664 cmd->stats_id = param->stats_id;
1665 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301666 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1667 param->pdev_id);
1668 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001669
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301670 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1671 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001672
1673 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1674 WMI_REQUEST_STATS_CMDID);
1675
Govind Singhd3156eb2016-02-26 17:50:39 +05301676 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301677 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301678 wmi_buf_free(buf);
1679 }
1680
1681 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301682}
1683
Govind Singh87542482016-06-08 19:40:11 +05301684#ifdef CONFIG_WIN
1685/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001686 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301687 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001688 * @param PKTLOG_EVENT : packet log event
1689 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301690 *
1691 * Return: 0 on success and -ve on failure.
1692 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301693static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001694 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301695{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001696 int32_t ret;
1697 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1698 wmi_buf_t buf;
1699 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1700
1701 buf = wmi_buf_alloc(wmi_handle, len);
1702 if (!buf) {
1703 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1704 return -QDF_STATUS_E_NOMEM;
1705 }
1706
1707 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1708 WMITLV_SET_HDR(&cmd->tlv_header,
1709 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1710 WMITLV_GET_STRUCT_TLVLEN
1711 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1712 cmd->evlist = PKTLOG_EVENT;
1713 cmd->pdev_id = mac_id;
1714 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1715 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1716 if (ret) {
1717 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1718 wmi_buf_free(buf);
1719 }
1720
1721 return ret;
1722}
1723
1724/**
1725 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1726 * @param wmi_handle : handle to WMI.
1727 * @mac_id: mac id to have radio context
1728 *
1729 * Return: 0 on success and -ve on failure.
1730 */
1731static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001732 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001733{
1734 int32_t ret;
1735 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1736 wmi_buf_t buf;
1737 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1738
1739 buf = wmi_buf_alloc(wmi_handle, len);
1740 if (!buf) {
1741 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1742 return -QDF_STATUS_E_NOMEM;
1743 }
1744
1745 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1746 WMITLV_SET_HDR(&cmd->tlv_header,
1747 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1748 WMITLV_GET_STRUCT_TLVLEN
1749 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1750 cmd->pdev_id = mac_id;
1751 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1752 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1753 if (ret) {
1754 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1755 wmi_buf_free(buf);
1756 }
1757
1758 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301759}
1760#else
Govind Singh5eb51532016-03-09 11:34:12 +05301761/**
Keyur Parekhde522342017-08-18 14:01:05 -07001762 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1763 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301764 * @param wmi_handle : handle to WMI.
1765 * @param macaddr : MAC address
1766 * @param param : pointer to hold stats request parameter
1767 *
1768 * Return: 0 on success and -ve on failure.
1769 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301770static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301771 uint8_t macaddr[IEEE80211_ADDR_LEN],
1772 struct packet_enable_params *param)
1773{
1774 return 0;
1775}
Keyur Parekhde522342017-08-18 14:01:05 -07001776/**
1777 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1778 * packet-log
1779 * @param wmi_handle : handle to WMI.
1780 * @mac_id: mac id to have radio context
1781 *
1782 * Return: 0 on success and -ve on failure.
1783 */
1784static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1785 uint8_t mac_id)
1786{
1787 return 0;
1788}
Govind Singh87542482016-06-08 19:40:11 +05301789#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301790
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301791#ifdef WLAN_SUPPORT_FILS
1792/**
1793 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1794 * @wmi_handle: wmi handle
1795 * @evt_buf: pointer to event buffer
1796 * @vdev_id: pointer to hold vdev id
1797 *
1798 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1799 */
1800static QDF_STATUS
1801extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1802 void *evt_buf, uint32_t *vdev_id)
1803{
1804 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1805 wmi_host_swfda_event_fixed_param *swfda_event;
1806
1807 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1808 if (!param_buf) {
1809 WMI_LOGE("Invalid swfda event buffer");
1810 return QDF_STATUS_E_INVAL;
1811 }
1812 swfda_event = param_buf->fixed_param;
1813 *vdev_id = swfda_event->vdev_id;
1814
1815 return QDF_STATUS_SUCCESS;
1816}
1817
1818/**
1819 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
1820 * @wmi_handle: wmi handle
1821 * @param: pointer to hold FILS discovery enable param
1822 *
1823 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
1824 */
1825static QDF_STATUS
1826send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
1827 struct config_fils_params *param)
1828{
1829 wmi_enable_fils_cmd_fixed_param *cmd;
1830 wmi_buf_t buf;
1831 QDF_STATUS status;
1832 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
1833
1834 buf = wmi_buf_alloc(wmi_handle, len);
1835 if (!buf) {
1836 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1837 return QDF_STATUS_E_NOMEM;
1838 }
1839 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
1840 WMITLV_SET_HDR(&cmd->tlv_header,
1841 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
1842 WMITLV_GET_STRUCT_TLVLEN(
1843 wmi_enable_fils_cmd_fixed_param));
1844 cmd->vdev_id = param->vdev_id;
1845 cmd->fd_period = param->fd_period;
1846 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
1847 param->fd_period, param->vdev_id);
1848
1849 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1850 WMI_ENABLE_FILS_CMDID);
1851 if (status != QDF_STATUS_SUCCESS) {
1852 wmi_buf_free(buf);
1853 return QDF_STATUS_E_FAILURE;
1854 }
1855
1856 return QDF_STATUS_SUCCESS;
1857}
1858
1859/**
1860 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
1861 * @wmi_handle: wmi handle
1862 * @param: pointer to hold FD send cmd parameter
1863 *
1864 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
1865 */
1866static QDF_STATUS
1867send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
1868 struct fd_params *param)
1869{
1870 QDF_STATUS ret;
1871 wmi_fd_send_from_host_cmd_fixed_param *cmd;
1872 wmi_buf_t wmi_buf;
1873 qdf_dma_addr_t dma_addr;
1874
1875 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1876 if (!wmi_buf) {
1877 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1878 return QDF_STATUS_E_NOMEM;
1879 }
1880 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
1881 WMITLV_SET_HDR(&cmd->tlv_header,
1882 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
1883 WMITLV_GET_STRUCT_TLVLEN(
1884 wmi_fd_send_from_host_cmd_fixed_param));
1885 cmd->vdev_id = param->vdev_id;
1886 cmd->data_len = qdf_nbuf_len(param->wbuf);
1887 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1888 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
1889 cmd->frame_ctrl = param->frame_ctrl;
1890
1891 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
1892 WMI_PDEV_SEND_FD_CMDID);
1893 if (ret != QDF_STATUS_SUCCESS) {
1894 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
1895 __func__, ret);
1896 wmi_buf_free(wmi_buf);
1897 }
1898
1899 return ret;
1900}
1901#endif /* WLAN_SUPPORT_FILS */
1902
Sathish Kumarfd347372017-02-13 12:29:09 +05301903static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301904 struct beacon_params *param)
1905{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05301906 QDF_STATUS ret;
1907 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
1908 wmi_buf_t wmi_buf;
1909 qdf_dma_addr_t dma_addr;
1910 uint32_t dtim_flag = 0;
1911
1912 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1913 if (!wmi_buf) {
1914 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1915 return QDF_STATUS_E_NOMEM;
1916 }
1917 if (param->is_dtim_count_zero) {
1918 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
1919 if (param->is_bitctl_reqd) {
1920 /* deliver CAB traffic in next DTIM beacon */
1921 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
1922 }
1923 }
1924 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1925 WMITLV_SET_HDR(&cmd->tlv_header,
1926 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
1927 WMITLV_GET_STRUCT_TLVLEN
1928 (wmi_bcn_send_from_host_cmd_fixed_param));
1929 cmd->vdev_id = param->vdev_id;
1930 cmd->data_len = qdf_nbuf_len(param->wbuf);
1931 cmd->frame_ctrl = param->frame_ctrl;
1932 cmd->dtim_flag = dtim_flag;
1933 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1934 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
1935#if defined(HTT_PADDR64)
1936 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
1937#endif
1938 cmd->bcn_antenna = param->bcn_txant;
1939
1940 ret = wmi_unified_cmd_send(wmi_handle,
1941 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
1942 if (ret != QDF_STATUS_SUCCESS) {
1943 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
1944 wmi_buf_free(wmi_buf);
1945 }
1946
1947 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301948}
1949
1950/**
1951 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1952 * @param wmi_handle : handle to WMI.
1953 * @param param : pointer to hold beacon send cmd parameter
1954 *
1955 * Return: 0 on success and -ve on failure.
1956 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301957static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301958 struct beacon_tmpl_params *param)
1959{
1960 int32_t ret;
1961 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1962 wmi_bcn_prb_info *bcn_prb_info;
1963 wmi_buf_t wmi_buf;
1964 uint8_t *buf_ptr;
1965 uint32_t wmi_buf_len;
1966
Sathish Kumar45e991b2017-02-27 10:35:40 +05301967 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301968 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1969 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1970 param->tmpl_len_aligned;
1971 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1972 if (!wmi_buf) {
1973 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1974 return QDF_STATUS_E_NOMEM;
1975 }
1976 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1977 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1978 WMITLV_SET_HDR(&cmd->tlv_header,
1979 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1980 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1981 cmd->vdev_id = param->vdev_id;
1982 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301983 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1984 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301985 cmd->buf_len = param->tmpl_len;
1986 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1987
1988 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1989 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1990 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1991 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1992 bcn_prb_info->caps = 0;
1993 bcn_prb_info->erp = 0;
1994 buf_ptr += sizeof(wmi_bcn_prb_info);
1995
1996 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1997 buf_ptr += WMI_TLV_HDR_SIZE;
1998 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1999
2000 ret = wmi_unified_cmd_send(wmi_handle,
2001 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2002 if (ret) {
2003 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2004 wmi_buf_free(wmi_buf);
2005 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302006
Govind Singh87542482016-06-08 19:40:11 +05302007 return 0;
2008}
Govind Singh5eb51532016-03-09 11:34:12 +05302009
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302010#ifdef CONFIG_MCL
2011static inline void copy_peer_flags_tlv(
2012 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2013 struct peer_assoc_params *param)
2014{
2015 cmd->peer_flags = param->peer_flags;
2016}
2017#else
2018static inline void copy_peer_flags_tlv(
2019 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2020 struct peer_assoc_params *param)
2021{
2022 /*
2023 * The target only needs a subset of the flags maintained in the host.
2024 * Just populate those flags and send it down
2025 */
2026 cmd->peer_flags = 0;
2027
2028 /*
2029 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2030 */
2031 if (param->is_wme_set) {
2032
2033 if (param->qos_flag)
2034 cmd->peer_flags |= WMI_PEER_QOS;
2035 if (param->apsd_flag)
2036 cmd->peer_flags |= WMI_PEER_APSD;
2037 if (param->ht_flag)
2038 cmd->peer_flags |= WMI_PEER_HT;
2039 if (param->bw_40)
2040 cmd->peer_flags |= WMI_PEER_40MHZ;
2041 if (param->bw_80)
2042 cmd->peer_flags |= WMI_PEER_80MHZ;
2043 if (param->bw_160)
2044 cmd->peer_flags |= WMI_PEER_160MHZ;
2045
2046 /* Typically if STBC is enabled for VHT it should be enabled
2047 * for HT as well
2048 **/
2049 if (param->stbc_flag)
2050 cmd->peer_flags |= WMI_PEER_STBC;
2051
2052 /* Typically if LDPC is enabled for VHT it should be enabled
2053 * for HT as well
2054 **/
2055 if (param->ldpc_flag)
2056 cmd->peer_flags |= WMI_PEER_LDPC;
2057
2058 if (param->static_mimops_flag)
2059 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2060 if (param->dynamic_mimops_flag)
2061 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2062 if (param->spatial_mux_flag)
2063 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2064 if (param->vht_flag)
2065 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002066 if (param->he_flag)
2067 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302068 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002069
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302070 if (param->is_pmf_enabled)
2071 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302072 /*
2073 * Suppress authorization for all AUTH modes that need 4-way handshake
2074 * (during re-association).
2075 * Authorization will be done for these modes on key installation.
2076 */
2077 if (param->auth_flag)
2078 cmd->peer_flags |= WMI_PEER_AUTH;
2079 if (param->need_ptk_4_way)
2080 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2081 else
2082 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2083 if (param->need_gtk_2_way)
2084 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2085 /* safe mode bypass the 4-way handshake */
2086 if (param->safe_mode_enabled)
2087 cmd->peer_flags &=
2088 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2089 /* Disable AMSDU for station transmit, if user configures it */
2090 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2091 * it
2092 * if (param->amsdu_disable) Add after FW support
2093 **/
2094
2095 /* Target asserts if node is marked HT and all MCS is set to 0.
2096 * Mark the node as non-HT if all the mcs rates are disabled through
2097 * iwpriv
2098 **/
2099 if (param->peer_ht_rates.num_rates == 0)
2100 cmd->peer_flags &= ~WMI_PEER_HT;
2101}
2102#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302103
2104#ifdef CONFIG_MCL
2105static inline void copy_peer_mac_addr_tlv(
2106 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2107 struct peer_assoc_params *param)
2108{
2109 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2110 sizeof(param->peer_macaddr));
2111}
2112#else
2113static inline void copy_peer_mac_addr_tlv(
2114 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2115 struct peer_assoc_params *param)
2116{
2117 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2118}
2119#endif
2120
Govind Singh5eb51532016-03-09 11:34:12 +05302121/**
2122 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2123 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302124 * @param param : pointer to peer assoc parameter
2125 *
2126 * Return: 0 on success and -ve on failure.
2127 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302128static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302129 struct peer_assoc_params *param)
2130{
Govind Singhd3156eb2016-02-26 17:50:39 +05302131 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2132 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002133 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302134 wmi_buf_t buf;
2135 int32_t len;
2136 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302137 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302138 uint32_t peer_legacy_rates_align;
2139 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002140 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302141
2142
2143 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2144 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302145
2146 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002147 (peer_legacy_rates_align * sizeof(uint8_t)) +
2148 WMI_TLV_HDR_SIZE +
2149 (peer_ht_rates_align * sizeof(uint8_t)) +
2150 sizeof(wmi_vht_rate_set) +
2151 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2152 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302153
2154 buf = wmi_buf_alloc(wmi_handle, len);
2155 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302156 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302157 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302158 }
2159
2160 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2161 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2162 WMITLV_SET_HDR(&cmd->tlv_header,
2163 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2164 WMITLV_GET_STRUCT_TLVLEN
2165 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302166
Govind Singhd3156eb2016-02-26 17:50:39 +05302167 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302168
Govind Singhd3156eb2016-02-26 17:50:39 +05302169 cmd->peer_new_assoc = param->peer_new_assoc;
2170 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302171
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302172 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302173 copy_peer_mac_addr_tlv(cmd, param);
2174
Govind Singhd3156eb2016-02-26 17:50:39 +05302175 cmd->peer_rate_caps = param->peer_rate_caps;
2176 cmd->peer_caps = param->peer_caps;
2177 cmd->peer_listen_intval = param->peer_listen_intval;
2178 cmd->peer_ht_caps = param->peer_ht_caps;
2179 cmd->peer_max_mpdu = param->peer_max_mpdu;
2180 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302181 cmd->peer_vht_caps = param->peer_vht_caps;
2182 cmd->peer_phymode = param->peer_phymode;
2183
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002184 /* Update 11ax capabilities */
2185 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2186 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002187 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2188 sizeof(param->peer_he_cap_phyinfo));
2189 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2190 sizeof(param->peer_ppet));
2191
Govind Singhd3156eb2016-02-26 17:50:39 +05302192 /* Update peer legacy rate information */
2193 buf_ptr += sizeof(*cmd);
2194 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302195 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302196 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302197 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302198 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302199 param->peer_legacy_rates.num_rates);
2200
2201 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002202 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302203 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302204 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302205 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302206 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302207 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302208 param->peer_ht_rates.num_rates);
2209
2210 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002211 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302212 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2213 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2214
2215 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302216
2217 /* Update bandwidth-NSS mapping */
2218 cmd->peer_bw_rxnss_override = 0;
2219 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2220
Govind Singhd3156eb2016-02-26 17:50:39 +05302221 mcs = (wmi_vht_rate_set *) buf_ptr;
2222 if (param->vht_capable) {
2223 mcs->rx_max_rate = param->rx_max_rate;
2224 mcs->rx_mcs_set = param->rx_mcs_set;
2225 mcs->tx_max_rate = param->tx_max_rate;
2226 mcs->tx_mcs_set = param->tx_mcs_set;
2227 }
2228
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002229 /* HE Rates */
2230 cmd->peer_he_mcs = param->peer_he_mcs_count;
2231 buf_ptr += sizeof(wmi_vht_rate_set);
2232 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2233 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2234 buf_ptr += WMI_TLV_HDR_SIZE;
2235
2236 /* Loop through the HE rate set */
2237 for (i = 0; i < param->peer_he_mcs_count; i++) {
2238 he_mcs = (wmi_he_rate_set *) buf_ptr;
2239 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2240 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2241
2242 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2243 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2244 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2245 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2246 buf_ptr += sizeof(wmi_he_rate_set);
2247 }
2248
2249
Govind Singhb53420c2016-03-09 14:32:57 +05302250 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302251 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2252 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002253 "cmd->peer_vht_caps %x "
2254 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302255 "HE phy %x %x %x "
2256 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302257 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2258 cmd->peer_rate_caps, cmd->peer_caps,
2259 cmd->peer_listen_intval, cmd->peer_ht_caps,
2260 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2261 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002262 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2263 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302264 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2265 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302266
2267 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2268 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302269 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302270 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302271 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302272 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302273 }
2274
2275 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302276}
2277
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302278/* copy_scan_notify_events() - Helper routine to copy scan notify events
2279 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302280static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302281 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302282 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302283{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302284
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302285 /* Scan events subscription */
2286 if (param->scan_ev_started)
2287 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2288 if (param->scan_ev_completed)
2289 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2290 if (param->scan_ev_bss_chan)
2291 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2292 if (param->scan_ev_foreign_chan)
2293 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2294 if (param->scan_ev_dequeued)
2295 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2296 if (param->scan_ev_preempted)
2297 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2298 if (param->scan_ev_start_failed)
2299 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2300 if (param->scan_ev_restarted)
2301 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2302 if (param->scan_ev_foreign_chn_exit)
2303 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2304 if (param->scan_ev_suspended)
2305 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2306 if (param->scan_ev_resumed)
2307 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302308
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302309 /** Set scan control flags */
2310 cmd->scan_ctrl_flags = 0;
2311 if (param->scan_f_passive)
2312 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2313 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302314 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302315 if (param->scan_f_promisc_mode)
2316 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2317 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302318 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302319 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302320 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302321 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302322 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302323 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302324 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302325 if (param->scan_f_ofdm_rates)
2326 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2327 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302328 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302329 if (param->scan_f_filter_prb_req)
2330 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2331 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302332 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302333 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302334 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302335 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302336 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302337 if (param->scan_f_force_active_dfs_chn)
2338 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2339 if (param->scan_f_add_tpc_ie_in_probe)
2340 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2341 if (param->scan_f_add_ds_ie_in_probe)
2342 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2343 if (param->scan_f_add_spoofed_mac_in_probe)
2344 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2345 if (param->scan_f_add_rand_seq_in_probe)
2346 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2347 if (param->scan_f_en_ie_whitelist_in_probe)
2348 cmd->scan_ctrl_flags |=
2349 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302350
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302351 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2352 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2353 param->adaptive_dwell_time_mode);
2354}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302355
2356/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302357static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302358 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302359{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302360 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302361}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302362
Anish Natarajdd855152017-03-20 12:49:08 +05302363/*
2364 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2365 * @param wmi_handle : Handle to WMI
2366 * @param vdev_id : vdev identifier
2367 *
2368 * Return : void *
2369 */
2370static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2371{
2372 struct wlan_objmgr_vdev *vdev = NULL;
2373 struct wlan_objmgr_pdev *pdev = NULL;
2374 uint8_t pdev_id = 0;
2375
2376 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2377 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2378 vdev_id, WLAN_SCAN_ID);
2379 if (vdev) {
2380 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2381 pdev = wlan_vdev_get_pdev(vdev);
2382 if (pdev)
2383 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2384 else {
2385 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2386 }
2387 } else {
2388 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2389 }
2390
2391 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2392}
2393
Govind Singh5eb51532016-03-09 11:34:12 +05302394/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302395 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2396 * @mac: random mac addr
2397 * @mask: random mac mask
2398 * @mac_addr: wmi random mac
2399 * @mac_mask: wmi random mac mask
2400 *
2401 * Return None.
2402 */
2403static inline
2404void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2405 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2406{
2407 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2408 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2409}
2410
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302411/*
2412 * wmi_fill_vendor_oui() - fill vendor OUIs
2413 * @buf_ptr: pointer to wmi tlv buffer
2414 * @num_vendor_oui: number of vendor OUIs to be filled
2415 * @param_voui: pointer to OUI buffer
2416 *
2417 * This function populates the wmi tlv buffer when vendor specific OUIs are
2418 * present.
2419 *
2420 * Return: None
2421 */
2422static inline
2423void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2424 uint32_t *pvoui)
2425{
2426 wmi_vendor_oui *voui = NULL;
2427 uint32_t i;
2428
2429 voui = (wmi_vendor_oui *)buf_ptr;
2430
2431 for (i = 0; i < num_vendor_oui; i++) {
2432 WMITLV_SET_HDR(&voui[i].tlv_header,
2433 WMITLV_TAG_STRUC_wmi_vendor_oui,
2434 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2435 voui[i].oui_type_subtype = pvoui[i];
2436 }
2437}
2438
2439/*
2440 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2441 * @ie_bitmap: output pointer to ie bit map in cmd
2442 * @num_vendor_oui: output pointer to num vendor OUIs
2443 * @ie_whitelist: input parameter
2444 *
2445 * This function populates the IE whitelist attrs of scan, pno and
2446 * scan oui commands for ie_whitelist parameter.
2447 *
2448 * Return: None
2449 */
2450static inline
2451void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2452 uint32_t *num_vendor_oui,
2453 struct probe_req_whitelist_attr *ie_whitelist)
2454{
2455 uint32_t i = 0;
2456
2457 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2458 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2459
2460 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2461}
2462
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302463/**
Govind Singh5eb51532016-03-09 11:34:12 +05302464 * send_scan_start_cmd_tlv() - WMI scan start function
2465 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302466 * @param param : pointer to hold scan start cmd parameter
2467 *
2468 * Return: 0 on success and -ve on failure.
2469 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302470static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302471 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302472{
Govind Singhd3156eb2016-02-26 17:50:39 +05302473 int32_t ret = 0;
2474 int32_t i;
2475 wmi_buf_t wmi_buf;
2476 wmi_start_scan_cmd_fixed_param *cmd;
2477 uint8_t *buf_ptr;
2478 uint32_t *tmp_ptr;
2479 wmi_ssid *ssid = NULL;
2480 wmi_mac_addr *bssid;
2481 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302482 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302483 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302484 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302485
2486 /* Length TLV placeholder for array of uint32_t */
2487 len += WMI_TLV_HDR_SIZE;
2488 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302489 if (params->chan_list.num_chan)
2490 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302491
2492 /* Length TLV placeholder for array of wmi_ssid structures */
2493 len += WMI_TLV_HDR_SIZE;
2494 if (params->num_ssids)
2495 len += params->num_ssids * sizeof(wmi_ssid);
2496
2497 /* Length TLV placeholder for array of wmi_mac_addr structures */
2498 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302499 if (params->num_bssid)
2500 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302501
2502 /* Length TLV placeholder for array of bytes */
2503 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302504 if (params->extraie.len)
2505 extraie_len_with_pad =
2506 roundup(params->extraie.len, sizeof(uint32_t));
2507 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302508
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302509 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2510 if (ie_whitelist->num_vendor_oui)
2511 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2512
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302513 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2514 if (params->scan_f_wide_band)
2515 phymode_roundup =
2516 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2517 sizeof(uint32_t));
2518 len += phymode_roundup;
2519
Govind Singhd3156eb2016-02-26 17:50:39 +05302520 /* Allocate the memory */
2521 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2522 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302523 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302524 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302525 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302526 }
2527 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2528 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2529 WMITLV_SET_HDR(&cmd->tlv_header,
2530 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2531 WMITLV_GET_STRUCT_TLVLEN
2532 (wmi_start_scan_cmd_fixed_param));
2533
2534 cmd->scan_id = params->scan_id;
2535 cmd->scan_req_id = params->scan_req_id;
2536 cmd->vdev_id = params->vdev_id;
2537 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302538
2539 copy_scan_event_cntrl_flags(cmd, params);
2540
Govind Singhd3156eb2016-02-26 17:50:39 +05302541 cmd->dwell_time_active = params->dwell_time_active;
2542 cmd->dwell_time_passive = params->dwell_time_passive;
2543 cmd->min_rest_time = params->min_rest_time;
2544 cmd->max_rest_time = params->max_rest_time;
2545 cmd->repeat_probe_time = params->repeat_probe_time;
2546 cmd->probe_spacing_time = params->probe_spacing_time;
2547 cmd->idle_time = params->idle_time;
2548 cmd->max_scan_time = params->max_scan_time;
2549 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302550 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302551 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302552 cmd->num_bssid = params->num_bssid;
2553 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302554 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302555 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302556 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2557
2558 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2559
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302560 if (params->scan_random.randomize)
2561 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2562 params->scan_random.mac_mask,
2563 &cmd->mac_addr,
2564 &cmd->mac_mask);
2565
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302566 if (ie_whitelist->white_list)
2567 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2568 &cmd->num_vendor_oui,
2569 ie_whitelist);
2570
Govind Singhd3156eb2016-02-26 17:50:39 +05302571 buf_ptr += sizeof(*cmd);
2572 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302573 for (i = 0; i < params->chan_list.num_chan; ++i)
2574 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302575
2576 WMITLV_SET_HDR(buf_ptr,
2577 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302578 (params->chan_list.num_chan * sizeof(uint32_t)));
2579 buf_ptr += WMI_TLV_HDR_SIZE +
2580 (params->chan_list.num_chan * sizeof(uint32_t));
2581
Govind Singh4eacd2b2016-03-07 14:24:22 +05302582 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302583 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302584 goto error;
2585 }
2586
2587 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2588 (params->num_ssids * sizeof(wmi_ssid)));
2589
2590 if (params->num_ssids) {
2591 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2592 for (i = 0; i < params->num_ssids; ++i) {
2593 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302594 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302595 params->ssid[i].length);
2596 ssid++;
2597 }
2598 }
2599 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2600
2601 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2602 (params->num_bssid * sizeof(wmi_mac_addr)));
2603 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302604
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302605 if (params->num_bssid) {
2606 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302607 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2608 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302609 bssid++;
2610 }
2611 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302612
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302613 buf_ptr += WMI_TLV_HDR_SIZE +
2614 (params->num_bssid * sizeof(wmi_mac_addr));
2615
2616 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2617 if (params->extraie.len)
2618 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2619 params);
2620
2621 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302622
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302623 /* probe req ie whitelisting */
2624 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2625 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2626
2627 buf_ptr += WMI_TLV_HDR_SIZE;
2628
2629 if (cmd->num_vendor_oui) {
2630 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2631 ie_whitelist->voui);
2632 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2633 }
2634
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302635 /* Add phy mode TLV if it's a wide band scan */
2636 if (params->scan_f_wide_band) {
2637 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2638 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2639 for (i = 0; i < params->chan_list.num_chan; ++i)
2640 buf_ptr[i] =
2641 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2642 buf_ptr += phymode_roundup;
2643 } else {
2644 /* Add ZERO legth phy mode TLV */
2645 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2646 }
2647
Anish Natarajdd855152017-03-20 12:49:08 +05302648 ret = wmi_unified_cmd_send(
2649 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302650 len, WMI_START_SCAN_CMDID);
2651 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302652 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302653 wmi_buf_free(wmi_buf);
2654 }
2655 return ret;
2656error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302657 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302658 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302659}
2660
2661/**
2662 * send_scan_stop_cmd_tlv() - WMI scan start function
2663 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302664 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302665 *
2666 * Return: 0 on success and -ve on failure.
2667 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302668static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302669 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302670{
Govind Singhd3156eb2016-02-26 17:50:39 +05302671 wmi_stop_scan_cmd_fixed_param *cmd;
2672 int ret;
2673 int len = sizeof(*cmd);
2674 wmi_buf_t wmi_buf;
2675
2676 /* Allocate the memory */
2677 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2678 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302679 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302680 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302681 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302682 goto error;
2683 }
2684
2685 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2686 WMITLV_SET_HDR(&cmd->tlv_header,
2687 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2688 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2689 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302690 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302691 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302692 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2693 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302694 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302695 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2696 /* Cancelling all scans */
2697 cmd->req_type = WMI_SCAN_STOP_ALL;
2698 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2699 /* Cancelling VAP scans */
2700 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2701 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2702 /* Cancelling specific scan */
2703 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302704 } else {
2705 WMI_LOGE("%s: Invalid Command : ", __func__);
2706 wmi_buf_free(wmi_buf);
2707 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302708 }
2709
Anish Natarajdd855152017-03-20 12:49:08 +05302710 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302711 len, WMI_STOP_SCAN_CMDID);
2712 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302713 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302714 wmi_buf_free(wmi_buf);
2715 }
2716
2717error:
2718 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302719}
2720
Govind Singh87542482016-06-08 19:40:11 +05302721#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302722/**
2723 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2724 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302725 * @param param : pointer to hold scan channel list parameter
2726 *
2727 * Return: 0 on success and -ve on failure.
2728 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302729static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302730 struct scan_chan_list_params *chan_list)
2731{
2732 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302733 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302734 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302735 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302736 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302737 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302738 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2739
2740 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2741 buf = wmi_buf_alloc(wmi_handle, len);
2742 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302743 WMI_LOGE("Failed to allocate memory");
2744 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302745 goto end;
2746 }
2747
2748 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2749 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2750 WMITLV_SET_HDR(&cmd->tlv_header,
2751 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2752 WMITLV_GET_STRUCT_TLVLEN
2753 (wmi_scan_chan_list_cmd_fixed_param));
2754
Govind Singhb53420c2016-03-09 14:32:57 +05302755 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302756
2757 cmd->num_scan_chans = chan_list->num_scan_chans;
2758 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2759 WMITLV_TAG_ARRAY_STRUC,
2760 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302761 chan_info = (wmi_channel_param *)
2762 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302763 tchan_info = chan_list->chan_info;
2764
2765 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2766 WMITLV_SET_HDR(&chan_info->tlv_header,
2767 WMITLV_TAG_STRUC_wmi_channel,
2768 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2769 chan_info->mhz = tchan_info->mhz;
2770 chan_info->band_center_freq1 =
2771 tchan_info->band_center_freq1;
2772 chan_info->band_center_freq2 =
2773 tchan_info->band_center_freq2;
2774 chan_info->info = tchan_info->info;
2775 chan_info->reg_info_1 = tchan_info->reg_info_1;
2776 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302777 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302778
2779 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2780 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2781 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2782 tchan_info++;
2783 chan_info++;
2784 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302785 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2786 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302787
Anish Natarajdd855152017-03-20 12:49:08 +05302788 qdf_status = wmi_unified_cmd_send(wmi_handle,
2789 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302790
Govind Singh67922e82016-04-01 16:48:57 +05302791 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302792 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302793 wmi_buf_free(buf);
2794 }
Govind Singh67922e82016-04-01 16:48:57 +05302795
Govind Singhd3156eb2016-02-26 17:50:39 +05302796end:
Govind Singhb53420c2016-03-09 14:32:57 +05302797 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302798}
Govind Singh87542482016-06-08 19:40:11 +05302799#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302800static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302801 struct scan_chan_list_params *chan_list)
2802{
2803 wmi_buf_t buf;
2804 QDF_STATUS qdf_status;
2805 wmi_scan_chan_list_cmd_fixed_param *cmd;
2806 int i;
2807 uint8_t *buf_ptr;
2808 wmi_channel *chan_info;
2809 struct channel_param *tchan_info;
2810 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302811
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302812 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302813 buf = wmi_buf_alloc(wmi_handle, len);
2814 if (!buf) {
2815 WMI_LOGE("Failed to allocate memory");
2816 qdf_status = QDF_STATUS_E_NOMEM;
2817 goto end;
2818 }
2819
2820 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2821 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2822 WMITLV_SET_HDR(&cmd->tlv_header,
2823 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2824 WMITLV_GET_STRUCT_TLVLEN
2825 (wmi_scan_chan_list_cmd_fixed_param));
2826
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302827 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302828
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302829 if (chan_list->append)
2830 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2831
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302832 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2833 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302834 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302835 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2836 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302837 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302838 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2839 tchan_info = &(chan_list->ch_param[0]);
2840
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302841 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302842 WMITLV_SET_HDR(&chan_info->tlv_header,
2843 WMITLV_TAG_STRUC_wmi_channel,
2844 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2845 chan_info->mhz = tchan_info->mhz;
2846 chan_info->band_center_freq1 =
2847 tchan_info->cfreq1;
2848 chan_info->band_center_freq2 =
2849 tchan_info->cfreq2;
2850
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302851 if (tchan_info->is_chan_passive)
2852 WMI_SET_CHANNEL_FLAG(chan_info,
2853 WMI_CHAN_FLAG_PASSIVE);
2854
2855 if (tchan_info->allow_vht)
2856 WMI_SET_CHANNEL_FLAG(chan_info,
2857 WMI_CHAN_FLAG_ALLOW_VHT);
2858 else if (tchan_info->allow_ht)
2859 WMI_SET_CHANNEL_FLAG(chan_info,
2860 WMI_CHAN_FLAG_ALLOW_HT);
2861 WMI_SET_CHANNEL_MODE(chan_info,
2862 tchan_info->phy_mode);
2863
2864 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2865 * after FW support
2866 */
2867
2868 /* also fill in power information */
2869 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2870 tchan_info->minpower);
2871 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2872 tchan_info->maxpower);
2873 WMI_SET_CHANNEL_REG_POWER(chan_info,
2874 tchan_info->maxregpower);
2875 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2876 tchan_info->antennamax);
2877 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2878 tchan_info->reg_class_id);
2879
Govind Singh87542482016-06-08 19:40:11 +05302880 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2881
Govind Singh87542482016-06-08 19:40:11 +05302882 tchan_info++;
2883 chan_info++;
2884 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302885 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2886 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302887
Anish Natarajdd855152017-03-20 12:49:08 +05302888 qdf_status = wmi_unified_cmd_send(
2889 wmi_handle,
2890 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302891
2892 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2893 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2894 wmi_buf_free(buf);
2895 }
2896
2897end:
2898 return qdf_status;
2899}
2900#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302901
2902/**
2903 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2904 *
2905 * @bufp: Pointer to buffer
2906 * @param: Pointer to tx param
2907 *
2908 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
2909 */
2910static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
2911 struct tx_send_params param)
2912{
2913 wmi_tx_send_params *tx_param;
2914 QDF_STATUS status = QDF_STATUS_SUCCESS;
2915
2916 if (!bufp) {
2917 status = QDF_STATUS_E_FAILURE;
2918 return status;
2919 }
2920 tx_param = (wmi_tx_send_params *)bufp;
2921 WMITLV_SET_HDR(&tx_param->tlv_header,
2922 WMITLV_TAG_STRUC_wmi_tx_send_params,
2923 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
2924 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
2925 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
2926 param.mcs_mask);
2927 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
2928 param.nss_mask);
2929 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
2930 param.retry_limit);
2931 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
2932 param.chain_mask);
2933 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
2934 param.bw_mask);
2935 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
2936 param.preamble_type);
2937 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
2938 param.frame_type);
2939
2940 return status;
2941}
2942
Govind Singhd3156eb2016-02-26 17:50:39 +05302943/**
2944 * send_mgmt_cmd_tlv() - WMI scan start function
2945 * @wmi_handle : handle to WMI.
2946 * @param : pointer to hold mgmt cmd parameter
2947 *
2948 * Return: 0 on success and -ve on failure.
2949 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302950static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302951 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302952{
Govind Singh427ee5a2016-02-26 18:09:36 +05302953 wmi_buf_t buf;
2954 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2955 int32_t cmd_len;
2956 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302957 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302958 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05302959 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302960 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2961 mgmt_tx_dl_frm_len;
2962
2963 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302964 WMI_TLV_HDR_SIZE +
2965 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05302966
Sathish Kumar5b636932017-06-28 14:40:32 +05302967 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302968 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302969 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2970 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302971 }
2972
2973 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2974 bufp = (uint8_t *) cmd;
2975 WMITLV_SET_HDR(&cmd->tlv_header,
2976 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2977 WMITLV_GET_STRUCT_TLVLEN
2978 (wmi_mgmt_tx_send_cmd_fixed_param));
2979
2980 cmd->vdev_id = param->vdev_id;
2981
Govind Singh224a7312016-06-21 14:33:26 +05302982 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302983 cmd->chanfreq = param->chanfreq;
2984 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2985 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2986 sizeof(uint32_t)));
2987 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302988 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302989
2990 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2991 QDF_DMA_TO_DEVICE);
2992 if (status != QDF_STATUS_SUCCESS) {
2993 WMI_LOGE("%s: wmi buf map failed", __func__);
2994 goto err1;
2995 }
2996
Govind Singhb53420c2016-03-09 14:32:57 +05302997 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302998 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002999#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303000 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3001#endif
3002 cmd->frame_len = param->frm_len;
3003 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303004 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303005
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003006 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003007 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003008
Sathish Kumar5b636932017-06-28 14:40:32 +05303009 bufp += roundup(bufp_len, sizeof(uint32_t));
3010 if (param->tx_params_valid) {
3011 status = populate_tx_send_params(bufp, param->tx_param);
3012 if (status != QDF_STATUS_SUCCESS) {
3013 WMI_LOGE("%s: Populate TX send params failed",
3014 __func__);
3015 goto err1;
3016 }
3017 cmd_len += sizeof(wmi_tx_send_params);
3018 }
3019
Govind Singh427ee5a2016-02-26 18:09:36 +05303020 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3021 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303022 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303023 goto err1;
3024 }
Govind Singhb53420c2016-03-09 14:32:57 +05303025 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303026
3027err1:
3028 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303029 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303030}
3031
3032/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303033 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3034 * @wmi_handle : handle to WMI.
3035 * @param : pointer to offchan data tx cmd parameter
3036 *
3037 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3038 */
3039static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3040 struct wmi_offchan_data_tx_params *param)
3041{
3042 wmi_buf_t buf;
3043 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3044 int32_t cmd_len;
3045 uint64_t dma_addr;
3046 void *qdf_ctx = param->qdf_ctx;
3047 uint8_t *bufp;
3048 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3049 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303050 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303051
3052 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303053 WMI_TLV_HDR_SIZE +
3054 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303055
Sathish Kumar5b636932017-06-28 14:40:32 +05303056 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303057 if (!buf) {
3058 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3059 return QDF_STATUS_E_NOMEM;
3060 }
3061
3062 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3063 bufp = (uint8_t *) cmd;
3064 WMITLV_SET_HDR(&cmd->tlv_header,
3065 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3066 WMITLV_GET_STRUCT_TLVLEN
3067 (wmi_offchan_data_tx_send_cmd_fixed_param));
3068
3069 cmd->vdev_id = param->vdev_id;
3070
3071 cmd->desc_id = param->desc_id;
3072 cmd->chanfreq = param->chanfreq;
3073 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3074 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3075 sizeof(uint32_t)));
3076 bufp += WMI_TLV_HDR_SIZE;
3077 qdf_mem_copy(bufp, param->pdata, bufp_len);
3078 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3079 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3080 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3081#if defined(HTT_PADDR64)
3082 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3083#endif
3084 cmd->frame_len = param->frm_len;
3085 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303086 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303087
3088 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3089 bufp, cmd->vdev_id, cmd->chanfreq);
3090
Sathish Kumar5b636932017-06-28 14:40:32 +05303091 bufp += roundup(bufp_len, sizeof(uint32_t));
3092 if (param->tx_params_valid) {
3093 status = populate_tx_send_params(bufp, param->tx_param);
3094 if (status != QDF_STATUS_SUCCESS) {
3095 WMI_LOGE("%s: Populate TX send params failed",
3096 __func__);
3097 goto err1;
3098 }
3099 cmd_len += sizeof(wmi_tx_send_params);
3100 }
3101
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303102 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3103 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3104 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303105 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303106 }
3107
3108 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303109
3110err1:
3111 wmi_buf_free(buf);
3112 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303113}
3114
3115/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303116 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3117 * @wmi_handle: wmi handle
3118 * @param_value: parameter value
3119 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303120 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303121 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303122static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303123 uint32_t param_value)
3124{
Govind Singh67922e82016-04-01 16:48:57 +05303125 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303126 wmi_modem_power_state_cmd_param *cmd;
3127 wmi_buf_t buf;
3128 uint16_t len = sizeof(*cmd);
3129
3130 buf = wmi_buf_alloc(wmi_handle, len);
3131 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303132 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303133 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303134 }
3135 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3136 WMITLV_SET_HDR(&cmd->tlv_header,
3137 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3138 WMITLV_GET_STRUCT_TLVLEN
3139 (wmi_modem_power_state_cmd_param));
3140 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303141 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303142 param_value);
3143 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3144 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303145 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303146 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303147 wmi_buf_free(buf);
3148 }
Govind Singh67922e82016-04-01 16:48:57 +05303149
Govind Singh427ee5a2016-02-26 18:09:36 +05303150 return ret;
3151}
3152
3153/**
3154 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3155 * @wmi_handle: wmi handle
3156 * @vdev_id: vdev id
3157 * @val: value
3158 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303159 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303160 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303161static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303162 uint32_t vdev_id, uint8_t val)
3163{
3164 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3165 wmi_buf_t buf;
3166 int32_t len = sizeof(*cmd);
3167
Govind Singhb53420c2016-03-09 14:32:57 +05303168 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303169
3170 buf = wmi_buf_alloc(wmi_handle, len);
3171 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303172 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303173 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303174 }
3175 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3176 WMITLV_SET_HDR(&cmd->tlv_header,
3177 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3178 WMITLV_GET_STRUCT_TLVLEN
3179 (wmi_sta_powersave_mode_cmd_fixed_param));
3180 cmd->vdev_id = vdev_id;
3181 if (val)
3182 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3183 else
3184 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3185
3186 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3187 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303188 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303189 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303190 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303191 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303192 }
Govind Singh5eb51532016-03-09 11:34:12 +05303193 return 0;
3194}
3195
Govind Singh427ee5a2016-02-26 18:09:36 +05303196/**
3197 * send_set_mimops_cmd_tlv() - set MIMO powersave
3198 * @wmi_handle: wmi handle
3199 * @vdev_id: vdev id
3200 * @value: value
3201 *
Govind Singhb53420c2016-03-09 14:32:57 +05303202 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303203 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303204static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303205 uint8_t vdev_id, int value)
3206{
Govind Singh67922e82016-04-01 16:48:57 +05303207 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303208 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3209 wmi_buf_t buf;
3210 uint16_t len = sizeof(*cmd);
3211
3212 buf = wmi_buf_alloc(wmi_handle, len);
3213 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303214 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303215 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303216 }
3217 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3218 WMITLV_SET_HDR(&cmd->tlv_header,
3219 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3220 WMITLV_GET_STRUCT_TLVLEN
3221 (wmi_sta_smps_force_mode_cmd_fixed_param));
3222
3223 cmd->vdev_id = vdev_id;
3224
Houston Hoffmanb5168052016-04-14 02:18:01 -07003225 /* WMI_SMPS_FORCED_MODE values do not directly map
3226 * to SM power save values defined in the specification.
3227 * Make sure to send the right mapping.
3228 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303229 switch (value) {
3230 case 0:
3231 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3232 break;
3233 case 1:
3234 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3235 break;
3236 case 2:
3237 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3238 break;
3239 case 3:
3240 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3241 break;
3242 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303243 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
3244 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303245 }
3246
Govind Singhb53420c2016-03-09 14:32:57 +05303247 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303248
3249 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3250 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303251 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303252 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303253 wmi_buf_free(buf);
3254 }
3255
3256 return ret;
3257}
3258
3259/**
3260 * send_set_smps_params_cmd_tlv() - set smps params
3261 * @wmi_handle: wmi handle
3262 * @vdev_id: vdev id
3263 * @value: value
3264 *
Govind Singhb53420c2016-03-09 14:32:57 +05303265 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303266 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303267static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303268 int value)
3269{
Govind Singh67922e82016-04-01 16:48:57 +05303270 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303271 wmi_sta_smps_param_cmd_fixed_param *cmd;
3272 wmi_buf_t buf;
3273 uint16_t len = sizeof(*cmd);
3274
3275 buf = wmi_buf_alloc(wmi_handle, len);
3276 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303277 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303278 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303279 }
3280 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3281 WMITLV_SET_HDR(&cmd->tlv_header,
3282 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3283 WMITLV_GET_STRUCT_TLVLEN
3284 (wmi_sta_smps_param_cmd_fixed_param));
3285
3286 cmd->vdev_id = vdev_id;
3287 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3288 cmd->param =
3289 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3290
Govind Singhb53420c2016-03-09 14:32:57 +05303291 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303292 cmd->param);
3293
3294 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3295 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303296 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303297 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303298 wmi_buf_free(buf);
3299 }
3300
3301 return ret;
3302}
3303
3304/**
3305 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3306 * @wmi_handle: wmi handle
3307 * @noa: p2p power save parameters
3308 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303309 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303310 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303311static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303312 struct p2p_ps_params *noa)
3313{
3314 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3315 wmi_p2p_noa_descriptor *noa_discriptor;
3316 wmi_buf_t buf;
3317 uint8_t *buf_ptr;
3318 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303319 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303320 uint32_t duration;
3321
Govind Singhb53420c2016-03-09 14:32:57 +05303322 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303323 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3324 buf = wmi_buf_alloc(wmi_handle, len);
3325 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303326 WMI_LOGE("Failed to allocate memory");
3327 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303328 goto end;
3329 }
3330
3331 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3332 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3333 WMITLV_SET_HDR(&cmd->tlv_header,
3334 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3335 WMITLV_GET_STRUCT_TLVLEN
3336 (wmi_p2p_set_noa_cmd_fixed_param));
3337 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3338 cmd->vdev_id = noa->session_id;
3339 cmd->enable = (duration) ? true : false;
3340 cmd->num_noa = 1;
3341
3342 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3343 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3344 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3345 sizeof
3346 (wmi_p2p_set_noa_cmd_fixed_param)
3347 + WMI_TLV_HDR_SIZE);
3348 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3349 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3350 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3351 noa_discriptor->type_count = noa->count;
3352 noa_discriptor->duration = duration;
3353 noa_discriptor->interval = noa->interval;
3354 noa_discriptor->start_time = 0;
3355
Govind Singhb53420c2016-03-09 14:32:57 +05303356 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303357 cmd->vdev_id, noa->count, noa_discriptor->duration,
3358 noa->interval);
3359 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3360 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303361 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303362 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303363 wmi_buf_free(buf);
3364 }
3365
3366end:
Govind Singhb53420c2016-03-09 14:32:57 +05303367 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303368 return status;
3369}
3370
3371
3372/**
3373 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3374 * @wmi_handle: wmi handle
3375 * @noa: p2p opp power save parameters
3376 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303377 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303378 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303379static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303380 struct p2p_ps_params *oppps)
3381{
3382 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3383 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303384 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303385
Govind Singhb53420c2016-03-09 14:32:57 +05303386 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303387 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3388 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303389 WMI_LOGE("Failed to allocate memory");
3390 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303391 goto end;
3392 }
3393
3394 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3395 WMITLV_SET_HDR(&cmd->tlv_header,
3396 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3397 WMITLV_GET_STRUCT_TLVLEN
3398 (wmi_p2p_set_oppps_cmd_fixed_param));
3399 cmd->vdev_id = oppps->session_id;
3400 if (oppps->ctwindow)
3401 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3402
3403 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303404 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303405 cmd->vdev_id, oppps->ctwindow);
3406 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3407 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303408 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303409 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303410 wmi_buf_free(buf);
3411 }
3412
3413end:
Govind Singhb53420c2016-03-09 14:32:57 +05303414 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303415 return status;
3416}
3417
Wu Gaocd3a8512017-03-13 20:17:34 +08003418#ifdef CONVERGED_P2P_ENABLE
3419/**
3420 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3421 * @wmi_handle: wmi handle
3422 * @param: p2p listen offload start parameters
3423 *
3424 * Return: QDF status
3425 */
3426static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3427 struct p2p_lo_start *param)
3428{
3429 wmi_buf_t buf;
3430 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3431 int32_t len = sizeof(*cmd);
3432 uint8_t *buf_ptr;
3433 QDF_STATUS status;
3434 int device_types_len_aligned;
3435 int probe_resp_len_aligned;
3436
3437 if (!param) {
3438 WMI_LOGE("lo start param is null");
3439 return QDF_STATUS_E_INVAL;
3440 }
3441
3442 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3443
3444 device_types_len_aligned =
3445 qdf_roundup(param->dev_types_len,
3446 sizeof(A_UINT32));
3447 probe_resp_len_aligned =
3448 qdf_roundup(param->probe_resp_len,
3449 sizeof(A_UINT32));
3450
3451 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3452 probe_resp_len_aligned;
3453
3454 buf = wmi_buf_alloc(wmi_handle, len);
3455 if (!buf) {
3456 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3457 __func__);
3458 return QDF_STATUS_E_NOMEM;
3459 }
3460
3461 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3462 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3463
3464 WMITLV_SET_HDR(&cmd->tlv_header,
3465 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3466 WMITLV_GET_STRUCT_TLVLEN(
3467 wmi_p2p_lo_start_cmd_fixed_param));
3468
3469 cmd->vdev_id = param->vdev_id;
3470 cmd->ctl_flags = param->ctl_flags;
3471 cmd->channel = param->freq;
3472 cmd->period = param->period;
3473 cmd->interval = param->interval;
3474 cmd->count = param->count;
3475 cmd->device_types_len = param->dev_types_len;
3476 cmd->prob_resp_len = param->probe_resp_len;
3477
3478 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3479 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3480 device_types_len_aligned);
3481 buf_ptr += WMI_TLV_HDR_SIZE;
3482 qdf_mem_copy(buf_ptr, param->device_types,
3483 param->dev_types_len);
3484
3485 buf_ptr += device_types_len_aligned;
3486 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3487 probe_resp_len_aligned);
3488 buf_ptr += WMI_TLV_HDR_SIZE;
3489 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3490 param->probe_resp_len);
3491
3492 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3493 cmd->channel, cmd->period, cmd->interval, cmd->count);
3494
3495 status = wmi_unified_cmd_send(wmi_handle,
3496 buf, len,
3497 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3498 if (status != QDF_STATUS_SUCCESS) {
3499 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3500 __func__, status);
3501 wmi_buf_free(buf);
3502 return status;
3503 }
3504
3505 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3506
3507 return QDF_STATUS_SUCCESS;
3508}
3509
3510/**
3511 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3512 * @wmi_handle: wmi handle
3513 * @param: p2p listen offload stop parameters
3514 *
3515 * Return: QDF status
3516 */
3517static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3518 uint8_t vdev_id)
3519{
3520 wmi_buf_t buf;
3521 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3522 int32_t len;
3523 QDF_STATUS status;
3524
3525 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3526
3527 len = sizeof(*cmd);
3528 buf = wmi_buf_alloc(wmi_handle, len);
3529 if (!buf) {
3530 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3531 __func__);
3532 return QDF_STATUS_E_NOMEM;
3533 }
3534 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3535
3536 WMITLV_SET_HDR(&cmd->tlv_header,
3537 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3538 WMITLV_GET_STRUCT_TLVLEN(
3539 wmi_p2p_lo_stop_cmd_fixed_param));
3540
3541 cmd->vdev_id = vdev_id;
3542
3543 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3544
3545 status = wmi_unified_cmd_send(wmi_handle,
3546 buf, len,
3547 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3548 if (status != QDF_STATUS_SUCCESS) {
3549 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3550 __func__, status);
3551 wmi_buf_free(buf);
3552 return status;
3553 }
3554
3555 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3556
3557 return QDF_STATUS_SUCCESS;
3558}
3559#endif /* End of CONVERGED_P2P_ENABLE */
3560
Govind Singh427ee5a2016-02-26 18:09:36 +05303561/**
3562 * send_get_temperature_cmd_tlv() - get pdev temperature req
3563 * @wmi_handle: wmi handle
3564 *
Govind Singhb53420c2016-03-09 14:32:57 +05303565 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303566 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303567static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303568{
3569 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3570 wmi_buf_t wmi_buf;
3571 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3572 uint8_t *buf_ptr;
3573
3574 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303575 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3576 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303577 }
3578
3579 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3580 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303581 WMI_LOGE(FL("wmi_buf_alloc failed"));
3582 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303583 }
3584
3585 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3586
3587 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3588 WMITLV_SET_HDR(&cmd->tlv_header,
3589 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3590 WMITLV_GET_STRUCT_TLVLEN
3591 (wmi_pdev_get_temperature_cmd_fixed_param));
3592
3593 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3594 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303595 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303596 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303597 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303598 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303599
Govind Singhb53420c2016-03-09 14:32:57 +05303600 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303601}
3602
3603/**
3604 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3605 * @wmi_handle: wmi handle
3606 * @vdevid: vdev id
3607 * @peer_addr: peer mac address
3608 * @auto_triggerparam: auto trigger parameters
3609 * @num_ac: number of access category
3610 *
3611 * This function sets the trigger
3612 * uapsd params such as service interval, delay interval
3613 * and suspend interval which will be used by the firmware
3614 * to send trigger frames periodically when there is no
3615 * traffic on the transmit side.
3616 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303617 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303618 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303619static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303620 struct sta_uapsd_trig_params *param)
3621{
3622 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303623 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303624 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3625 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3626 uint32_t i;
3627 wmi_buf_t buf;
3628 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003629 struct sta_uapsd_params *uapsd_param;
3630 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303631
3632 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3633 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303634 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303635 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303636 }
3637
3638 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3639 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3640 WMITLV_SET_HDR(&cmd->tlv_header,
3641 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3642 WMITLV_GET_STRUCT_TLVLEN
3643 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3644 cmd->vdev_id = param->vdevid;
3645 cmd->num_ac = param->num_ac;
3646 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3647
3648 /* TLV indicating array of structures to follow */
3649 buf_ptr += sizeof(*cmd);
3650 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3651
3652 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303653
3654 /*
3655 * Update tag and length for uapsd auto trigger params (this will take
3656 * care of updating tag and length if it is not pre-filled by caller).
3657 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003658 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3659 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303660 for (i = 0; i < param->num_ac; i++) {
3661 WMITLV_SET_HDR((buf_ptr +
3662 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3663 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3664 WMITLV_GET_STRUCT_TLVLEN
3665 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003666 trig_param->wmm_ac = uapsd_param->wmm_ac;
3667 trig_param->user_priority = uapsd_param->user_priority;
3668 trig_param->service_interval = uapsd_param->service_interval;
3669 trig_param->suspend_interval = uapsd_param->suspend_interval;
3670 trig_param->delay_interval = uapsd_param->delay_interval;
3671 trig_param++;
3672 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303673 }
3674
3675 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3676 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303677 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303678 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303679 wmi_buf_free(buf);
3680 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303681
Govind Singh427ee5a2016-02-26 18:09:36 +05303682 return ret;
3683}
3684
Govind Singh2edc80f2016-03-01 15:30:53 +05303685/**
3686 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3687 * @wmi_handle: pointer to the wmi handle
3688 * @utc: pointer to the UTC time struct
3689 *
3690 * Return: 0 on succes
3691 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303692static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303693 struct ocb_utc_param *utc)
3694{
Govind Singh67922e82016-04-01 16:48:57 +05303695 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303696 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3697 uint8_t *buf_ptr;
3698 uint32_t len, i;
3699 wmi_buf_t buf;
3700
3701 len = sizeof(*cmd);
3702 buf = wmi_buf_alloc(wmi_handle, len);
3703 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303704 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303705 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303706 }
3707
3708 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3709 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3710 WMITLV_SET_HDR(&cmd->tlv_header,
3711 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3712 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3713 cmd->vdev_id = utc->vdev_id;
3714
3715 for (i = 0; i < SIZE_UTC_TIME; i++)
3716 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3717
3718 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3719 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3720
3721 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3722 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303723 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303724 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303725 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303726 }
3727
Govind Singh67922e82016-04-01 16:48:57 +05303728 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303729}
3730
3731/**
3732 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3733 * frames on a channel
3734 * @wmi_handle: pointer to the wmi handle
3735 * @timing_advert: pointer to the timing advertisement struct
3736 *
3737 * Return: 0 on succes
3738 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303739static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303740 struct ocb_timing_advert_param *timing_advert)
3741{
Govind Singh67922e82016-04-01 16:48:57 +05303742 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303743 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3744 uint8_t *buf_ptr;
3745 uint32_t len, len_template;
3746 wmi_buf_t buf;
3747
3748 len = sizeof(*cmd) +
3749 WMI_TLV_HDR_SIZE;
3750
3751 len_template = timing_advert->template_length;
3752 /* Add padding to the template if needed */
3753 if (len_template % 4 != 0)
3754 len_template += 4 - (len_template % 4);
3755 len += len_template;
3756
3757 buf = wmi_buf_alloc(wmi_handle, len);
3758 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303759 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303760 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303761 }
3762
3763 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3764 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3765 WMITLV_SET_HDR(&cmd->tlv_header,
3766 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3767 WMITLV_GET_STRUCT_TLVLEN(
3768 wmi_ocb_start_timing_advert_cmd_fixed_param));
3769 cmd->vdev_id = timing_advert->vdev_id;
3770 cmd->repeat_rate = timing_advert->repeat_rate;
3771 cmd->channel_freq = timing_advert->chan_freq;
3772 cmd->timestamp_offset = timing_advert->timestamp_offset;
3773 cmd->time_value_offset = timing_advert->time_value_offset;
3774 cmd->timing_advert_template_length = timing_advert->template_length;
3775 buf_ptr += sizeof(*cmd);
3776
3777 /* Add the timing advert template */
3778 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3779 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303780 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303781 (uint8_t *)timing_advert->template_value,
3782 timing_advert->template_length);
3783
3784 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3785 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303786 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303787 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303788 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303789 }
3790
Govind Singh67922e82016-04-01 16:48:57 +05303791 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303792}
3793
3794/**
3795 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3796 * on a channel
3797 * @wmi_handle: pointer to the wmi handle
3798 * @timing_advert: pointer to the timing advertisement struct
3799 *
3800 * Return: 0 on succes
3801 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303802static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303803 struct ocb_timing_advert_param *timing_advert)
3804{
Govind Singh67922e82016-04-01 16:48:57 +05303805 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303806 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3807 uint8_t *buf_ptr;
3808 uint32_t len;
3809 wmi_buf_t buf;
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(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303815 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303816 }
3817
3818 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3819 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3820 WMITLV_SET_HDR(&cmd->tlv_header,
3821 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3822 WMITLV_GET_STRUCT_TLVLEN(
3823 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3824 cmd->vdev_id = timing_advert->vdev_id;
3825 cmd->channel_freq = timing_advert->chan_freq;
3826
3827 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3828 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303829 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303830 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303831 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303832 }
3833
Govind Singh67922e82016-04-01 16:48:57 +05303834 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303835}
3836
3837/**
3838 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3839 * @wmi_handle: pointer to the wmi handle
3840 * @request: pointer to the request
3841 *
3842 * Return: 0 on succes
3843 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303844static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303845 uint8_t vdev_id)
3846{
Govind Singhb53420c2016-03-09 14:32:57 +05303847 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303848 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3849 uint8_t *buf_ptr;
3850 wmi_buf_t buf;
3851 int32_t len;
3852
3853 len = sizeof(*cmd);
3854 buf = wmi_buf_alloc(wmi_handle, len);
3855 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303856 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303857 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303858 }
3859 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3860
3861 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303862 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303863 WMITLV_SET_HDR(&cmd->tlv_header,
3864 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3865 WMITLV_GET_STRUCT_TLVLEN(
3866 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3867 cmd->vdev_id = vdev_id;
3868
3869 /* Send the WMI command */
3870 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3871 WMI_OCB_GET_TSF_TIMER_CMDID);
3872 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303873 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303874 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303875 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303876 }
3877
Govind Singh67922e82016-04-01 16:48:57 +05303878 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303879}
3880
3881/**
3882 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3883 * @wmi_handle: pointer to the wmi handle
3884 * @get_stats_param: pointer to the dcc stats
3885 *
3886 * Return: 0 on succes
3887 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303888static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303889 struct dcc_get_stats_param *get_stats_param)
3890{
Govind Singh67922e82016-04-01 16:48:57 +05303891 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303892 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3893 wmi_dcc_channel_stats_request *channel_stats_array;
3894 wmi_buf_t buf;
3895 uint8_t *buf_ptr;
3896 uint32_t len;
3897 uint32_t i;
3898
3899 /* Validate the input */
3900 if (get_stats_param->request_array_len !=
3901 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303902 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303903 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303904 }
3905
3906 /* Allocate memory for the WMI command */
3907 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3908 get_stats_param->request_array_len;
3909
3910 buf = wmi_buf_alloc(wmi_handle, len);
3911 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303912 WMI_LOGE(FL("wmi_buf_alloc failed"));
3913 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303914 }
3915
3916 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303917 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303918
3919 /* Populate the WMI command */
3920 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3921 buf_ptr += sizeof(*cmd);
3922
3923 WMITLV_SET_HDR(&cmd->tlv_header,
3924 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3925 WMITLV_GET_STRUCT_TLVLEN(
3926 wmi_dcc_get_stats_cmd_fixed_param));
3927 cmd->vdev_id = get_stats_param->vdev_id;
3928 cmd->num_channels = get_stats_param->channel_count;
3929
3930 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3931 get_stats_param->request_array_len);
3932 buf_ptr += WMI_TLV_HDR_SIZE;
3933
3934 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303935 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303936 get_stats_param->request_array_len);
3937 for (i = 0; i < cmd->num_channels; i++)
3938 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3939 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3940 WMITLV_GET_STRUCT_TLVLEN(
3941 wmi_dcc_channel_stats_request));
3942
3943 /* Send the WMI command */
3944 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3945 WMI_DCC_GET_STATS_CMDID);
3946
Govind Singh67922e82016-04-01 16:48:57 +05303947 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303948 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303949 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303950 }
3951
Govind Singh67922e82016-04-01 16:48:57 +05303952 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303953}
3954
3955/**
3956 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3957 * @wmi_handle: pointer to the wmi handle
3958 * @vdev_id: vdev id
3959 * @dcc_stats_bitmap: dcc status bitmap
3960 *
3961 * Return: 0 on succes
3962 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303963static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303964 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3965{
Govind Singh67922e82016-04-01 16:48:57 +05303966 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303967 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3968 wmi_buf_t buf;
3969 uint8_t *buf_ptr;
3970 uint32_t len;
3971
3972 /* Allocate memory for the WMI command */
3973 len = sizeof(*cmd);
3974
3975 buf = wmi_buf_alloc(wmi_handle, len);
3976 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303977 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303978 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303979 }
3980
3981 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303982 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303983
3984 /* Populate the WMI command */
3985 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3986
3987 WMITLV_SET_HDR(&cmd->tlv_header,
3988 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3989 WMITLV_GET_STRUCT_TLVLEN(
3990 wmi_dcc_clear_stats_cmd_fixed_param));
3991 cmd->vdev_id = vdev_id;
3992 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3993
3994 /* Send the WMI command */
3995 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3996 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303997 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303998 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303999 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304000 }
4001
Govind Singh67922e82016-04-01 16:48:57 +05304002 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304003}
4004
4005/**
4006 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4007 * @wmi_handle: pointer to the wmi handle
4008 * @update_ndl_param: pointer to the request parameters
4009 *
4010 * Return: 0 on success
4011 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304012static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304013 struct dcc_update_ndl_param *update_ndl_param)
4014{
Govind Singhb53420c2016-03-09 14:32:57 +05304015 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304016 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4017 wmi_dcc_ndl_chan *ndl_chan_array;
4018 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4019 uint32_t active_state_count;
4020 wmi_buf_t buf;
4021 uint8_t *buf_ptr;
4022 uint32_t len;
4023 uint32_t i;
4024
4025 /* validate the input */
4026 if (update_ndl_param->dcc_ndl_chan_list_len !=
4027 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304028 WMI_LOGE(FL("Invalid parameter"));
4029 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304030 }
4031 active_state_count = 0;
4032 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4033 for (i = 0; i < update_ndl_param->channel_count; i++)
4034 active_state_count +=
4035 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4036 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4037 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304038 WMI_LOGE(FL("Invalid parameter"));
4039 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304040 }
4041
4042 /* Allocate memory for the WMI command */
4043 len = sizeof(*cmd) +
4044 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4045 WMI_TLV_HDR_SIZE +
4046 update_ndl_param->dcc_ndl_active_state_list_len;
4047
4048 buf = wmi_buf_alloc(wmi_handle, len);
4049 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304050 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304051 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304052 }
4053
4054 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304055 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304056
4057 /* Populate the WMI command */
4058 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4059 buf_ptr += sizeof(*cmd);
4060
4061 WMITLV_SET_HDR(&cmd->tlv_header,
4062 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4063 WMITLV_GET_STRUCT_TLVLEN(
4064 wmi_dcc_update_ndl_cmd_fixed_param));
4065 cmd->vdev_id = update_ndl_param->vdev_id;
4066 cmd->num_channel = update_ndl_param->channel_count;
4067
4068 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4069 update_ndl_param->dcc_ndl_chan_list_len);
4070 buf_ptr += WMI_TLV_HDR_SIZE;
4071
4072 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304073 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304074 update_ndl_param->dcc_ndl_chan_list_len);
4075 for (i = 0; i < cmd->num_channel; i++)
4076 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4077 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4078 WMITLV_GET_STRUCT_TLVLEN(
4079 wmi_dcc_ndl_chan));
4080 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4081
4082 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4083 update_ndl_param->dcc_ndl_active_state_list_len);
4084 buf_ptr += WMI_TLV_HDR_SIZE;
4085
4086 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304087 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304088 update_ndl_param->dcc_ndl_active_state_list,
4089 update_ndl_param->dcc_ndl_active_state_list_len);
4090 for (i = 0; i < active_state_count; i++) {
4091 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4092 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4093 WMITLV_GET_STRUCT_TLVLEN(
4094 wmi_dcc_ndl_active_state_config));
4095 }
4096 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4097
4098 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304099 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304100 WMI_DCC_UPDATE_NDL_CMDID);
4101 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304102 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304103 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304104 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304105 }
4106
Govind Singh67922e82016-04-01 16:48:57 +05304107 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304108}
4109
4110/**
4111 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4112 * @wmi_handle: pointer to the wmi handle
4113 * @config: the OCB configuration
4114 *
4115 * Return: 0 on success
4116 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304117static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304118 struct ocb_config_param *config, uint32_t *ch_mhz)
4119{
Govind Singh67922e82016-04-01 16:48:57 +05304120 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304121 wmi_ocb_set_config_cmd_fixed_param *cmd;
4122 wmi_channel *chan;
4123 wmi_ocb_channel *ocb_chan;
4124 wmi_qos_parameter *qos_param;
4125 wmi_dcc_ndl_chan *ndl_chan;
4126 wmi_dcc_ndl_active_state_config *ndl_active_config;
4127 wmi_ocb_schedule_element *sched_elem;
4128 uint8_t *buf_ptr;
4129 wmi_buf_t buf;
4130 int32_t len;
4131 int32_t i, j, active_state_count;
4132
4133 /*
4134 * Validate the dcc_ndl_chan_list_len and count the number of active
4135 * states. Validate dcc_ndl_active_state_list_len.
4136 */
4137 active_state_count = 0;
4138 if (config->dcc_ndl_chan_list_len) {
4139 if (!config->dcc_ndl_chan_list ||
4140 config->dcc_ndl_chan_list_len !=
4141 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304142 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304143 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304144 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304145 }
4146
4147 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4148 i < config->channel_count; ++i, ++ndl_chan)
4149 active_state_count +=
4150 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4151
4152 if (active_state_count) {
4153 if (!config->dcc_ndl_active_state_list ||
4154 config->dcc_ndl_active_state_list_len !=
4155 active_state_count *
4156 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304157 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304158 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304159 }
4160 }
4161 }
4162
4163 len = sizeof(*cmd) +
4164 WMI_TLV_HDR_SIZE + config->channel_count *
4165 sizeof(wmi_channel) +
4166 WMI_TLV_HDR_SIZE + config->channel_count *
4167 sizeof(wmi_ocb_channel) +
4168 WMI_TLV_HDR_SIZE + config->channel_count *
4169 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4170 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4171 WMI_TLV_HDR_SIZE + active_state_count *
4172 sizeof(wmi_dcc_ndl_active_state_config) +
4173 WMI_TLV_HDR_SIZE + config->schedule_size *
4174 sizeof(wmi_ocb_schedule_element);
4175 buf = wmi_buf_alloc(wmi_handle, len);
4176 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304177 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304178 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304179 }
4180
4181 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4182 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4183 WMITLV_SET_HDR(&cmd->tlv_header,
4184 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4185 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
4186 cmd->vdev_id = config->session_id;
4187 cmd->channel_count = config->channel_count;
4188 cmd->schedule_size = config->schedule_size;
4189 cmd->flags = config->flags;
4190 buf_ptr += sizeof(*cmd);
4191
4192 /* Add the wmi_channel info */
4193 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4194 config->channel_count*sizeof(wmi_channel));
4195 buf_ptr += WMI_TLV_HDR_SIZE;
4196 for (i = 0; i < config->channel_count; i++) {
4197 chan = (wmi_channel *)buf_ptr;
4198 WMITLV_SET_HDR(&chan->tlv_header,
4199 WMITLV_TAG_STRUC_wmi_channel,
4200 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4201 chan->mhz = config->channels[i].chan_freq;
4202 chan->band_center_freq1 = config->channels[i].chan_freq;
4203 chan->band_center_freq2 = 0;
4204 chan->info = 0;
4205
4206 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
4207 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4208 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4209 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4210 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4211 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4212 config->channels[i].antenna_max);
4213
4214 if (config->channels[i].bandwidth < 10)
4215 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4216 else if (config->channels[i].bandwidth < 20)
4217 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4218 buf_ptr += sizeof(*chan);
4219 }
4220
4221 /* Add the wmi_ocb_channel info */
4222 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4223 config->channel_count*sizeof(wmi_ocb_channel));
4224 buf_ptr += WMI_TLV_HDR_SIZE;
4225 for (i = 0; i < config->channel_count; i++) {
4226 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4227 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4228 WMITLV_TAG_STRUC_wmi_ocb_channel,
4229 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4230 ocb_chan->bandwidth = config->channels[i].bandwidth;
4231 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4232 config->channels[i].mac_address.bytes,
4233 &ocb_chan->mac_address);
4234 buf_ptr += sizeof(*ocb_chan);
4235 }
4236
4237 /* Add the wmi_qos_parameter info */
4238 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4239 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4240 buf_ptr += WMI_TLV_HDR_SIZE;
4241 /* WMI_MAX_NUM_AC parameters for each channel */
4242 for (i = 0; i < config->channel_count; i++) {
4243 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4244 qos_param = (wmi_qos_parameter *)buf_ptr;
4245 WMITLV_SET_HDR(&qos_param->tlv_header,
4246 WMITLV_TAG_STRUC_wmi_qos_parameter,
4247 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4248 qos_param->aifsn =
4249 config->channels[i].qos_params[j].aifsn;
4250 qos_param->cwmin =
4251 config->channels[i].qos_params[j].cwmin;
4252 qos_param->cwmax =
4253 config->channels[i].qos_params[j].cwmax;
4254 buf_ptr += sizeof(*qos_param);
4255 }
4256 }
4257
4258 /* Add the wmi_dcc_ndl_chan (per channel) */
4259 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4260 config->dcc_ndl_chan_list_len);
4261 buf_ptr += WMI_TLV_HDR_SIZE;
4262 if (config->dcc_ndl_chan_list_len) {
4263 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304264 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304265 config->dcc_ndl_chan_list_len);
4266 for (i = 0; i < config->channel_count; i++)
4267 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4268 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4269 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4270 buf_ptr += config->dcc_ndl_chan_list_len;
4271 }
4272
4273 /* Add the wmi_dcc_ndl_active_state_config */
4274 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4275 sizeof(wmi_dcc_ndl_active_state_config));
4276 buf_ptr += WMI_TLV_HDR_SIZE;
4277 if (active_state_count) {
4278 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304279 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304280 config->dcc_ndl_active_state_list,
4281 active_state_count * sizeof(*ndl_active_config));
4282 for (i = 0; i < active_state_count; ++i)
4283 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4284 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4285 WMITLV_GET_STRUCT_TLVLEN(
4286 wmi_dcc_ndl_active_state_config));
4287 buf_ptr += active_state_count *
4288 sizeof(*ndl_active_config);
4289 }
4290
4291 /* Add the wmi_ocb_schedule_element info */
4292 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4293 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4294 buf_ptr += WMI_TLV_HDR_SIZE;
4295 for (i = 0; i < config->schedule_size; i++) {
4296 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4297 WMITLV_SET_HDR(&sched_elem->tlv_header,
4298 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4299 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4300 sched_elem->channel_freq = config->schedule[i].chan_freq;
4301 sched_elem->total_duration = config->schedule[i].total_duration;
4302 sched_elem->guard_interval = config->schedule[i].guard_interval;
4303 buf_ptr += sizeof(*sched_elem);
4304 }
4305
4306
4307 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4308 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304309 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304310 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304311 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304312 }
4313
Govind Singh67922e82016-04-01 16:48:57 +05304314 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304315}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304316
4317/**
4318 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4319 * @wmi_handle: wmi handle
4320 * @mcc_adaptive_scheduler: enable/disable
4321 *
4322 * This function enable/disable mcc adaptive scheduler in fw.
4323 *
Govind Singhb53420c2016-03-09 14:32:57 +05304324 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304325 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304326static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004327 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4328 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304329{
Govind Singh67922e82016-04-01 16:48:57 +05304330 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304331 wmi_buf_t buf = 0;
4332 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4333 uint16_t len =
4334 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4335
4336 buf = wmi_buf_alloc(wmi_handle, len);
4337 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304338 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4339 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304340 }
4341 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4342 wmi_buf_data(buf);
4343
4344 WMITLV_SET_HDR(&cmd->tlv_header,
4345 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4346 WMITLV_GET_STRUCT_TLVLEN
4347 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4348 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304349 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304350
4351 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4352 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304353 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304354 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304355 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304356 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304357 }
Govind Singh67922e82016-04-01 16:48:57 +05304358
4359 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304360}
4361
4362/**
4363 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4364 * @wmi: wmi handle
4365 * @mcc_channel: mcc channel
4366 * @mcc_channel_time_latency: MCC channel time latency.
4367 *
4368 * Currently used to set time latency for an MCC vdev/adapter using operating
4369 * channel of it and channel number. The info is provided run time using
4370 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4371 *
4372 * Return: CDF status
4373 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304374static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304375 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4376{
Govind Singh67922e82016-04-01 16:48:57 +05304377 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304378 wmi_buf_t buf = 0;
4379 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4380 uint16_t len = 0;
4381 uint8_t *buf_ptr = NULL;
4382 wmi_resmgr_chan_latency chan_latency;
4383 /* Note: we only support MCC time latency for a single channel */
4384 uint32_t num_channels = 1;
4385 uint32_t chan1_freq = mcc_channel_freq;
4386 uint32_t latency_chan1 = mcc_channel_time_latency;
4387
4388
4389 /* If 0ms latency is provided, then FW will set to a default.
4390 * Otherwise, latency must be at least 30ms.
4391 */
4392 if ((latency_chan1 > 0) &&
4393 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304394 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304395 "Minimum is 30ms (or 0 to use default value by "
4396 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304397 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304398 }
4399
4400 /* Set WMI CMD for channel time latency here */
4401 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4402 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4403 num_channels * sizeof(wmi_resmgr_chan_latency);
4404 buf = wmi_buf_alloc(wmi_handle, len);
4405 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304406 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4407 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304408 }
4409 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4410 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4411 wmi_buf_data(buf);
4412 WMITLV_SET_HDR(&cmdTL->tlv_header,
4413 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4414 WMITLV_GET_STRUCT_TLVLEN
4415 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4416 cmdTL->num_chans = num_channels;
4417 /* Update channel time latency information for home channel(s) */
4418 buf_ptr += sizeof(*cmdTL);
4419 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4420 num_channels * sizeof(wmi_resmgr_chan_latency));
4421 buf_ptr += WMI_TLV_HDR_SIZE;
4422 chan_latency.chan_mhz = chan1_freq;
4423 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304424 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304425 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4426 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304427 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304428 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304429 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304430 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304431 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304432 }
Govind Singh67922e82016-04-01 16:48:57 +05304433
4434 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304435}
4436
4437/**
4438 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4439 * @wmi: wmi handle
4440 * @adapter_1_chan_number: adapter 1 channel number
4441 * @adapter_1_quota: adapter 1 quota
4442 * @adapter_2_chan_number: adapter 2 channel number
4443 *
4444 * Return: CDF status
4445 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304446static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304447 uint32_t adapter_1_chan_freq,
4448 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4449{
Govind Singh67922e82016-04-01 16:48:57 +05304450 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304451 wmi_buf_t buf = 0;
4452 uint16_t len = 0;
4453 uint8_t *buf_ptr = NULL;
4454 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4455 wmi_resmgr_chan_time_quota chan_quota;
4456 uint32_t quota_chan1 = adapter_1_quota;
4457 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4458 uint32_t quota_chan2 = 100 - quota_chan1;
4459 /* Note: setting time quota for MCC requires info for 2 channels */
4460 uint32_t num_channels = 2;
4461 uint32_t chan1_freq = adapter_1_chan_freq;
4462 uint32_t chan2_freq = adapter_2_chan_freq;
4463
Govind Singhb53420c2016-03-09 14:32:57 +05304464 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304465 "freq2:%dMHz, Quota2:%dms", __func__,
4466 chan1_freq, quota_chan1, chan2_freq,
4467 quota_chan2);
4468
4469 /*
4470 * Perform sanity check on time quota values provided.
4471 */
4472 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4473 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304474 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304475 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304476 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304477 }
4478 /* Set WMI CMD for channel time quota here */
4479 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4480 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4481 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4482 buf = wmi_buf_alloc(wmi_handle, len);
4483 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304484 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4485 QDF_ASSERT(0);
4486 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304487 }
4488 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4489 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4490 wmi_buf_data(buf);
4491 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4492 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4493 WMITLV_GET_STRUCT_TLVLEN
4494 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4495 cmdTQ->num_chans = num_channels;
4496
4497 /* Update channel time quota information for home channel(s) */
4498 buf_ptr += sizeof(*cmdTQ);
4499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4500 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4501 buf_ptr += WMI_TLV_HDR_SIZE;
4502 chan_quota.chan_mhz = chan1_freq;
4503 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304504 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304505 /* Construct channel and quota record for the 2nd MCC mode. */
4506 buf_ptr += sizeof(chan_quota);
4507 chan_quota.chan_mhz = chan2_freq;
4508 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304509 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304510
4511 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4512 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304513 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304514 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304515 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304516 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304517 }
Govind Singh67922e82016-04-01 16:48:57 +05304518
4519 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304520}
4521
4522/**
4523 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4524 * @wmi_handle: Pointer to wmi handle
4525 * @thermal_info: Thermal command information
4526 *
4527 * This function sends the thermal management command
4528 * to the firmware
4529 *
Govind Singhb53420c2016-03-09 14:32:57 +05304530 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304531 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304532static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304533 struct thermal_cmd_params *thermal_info)
4534{
4535 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4536 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304537 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304538 uint32_t len = 0;
4539
4540 len = sizeof(*cmd);
4541
4542 buf = wmi_buf_alloc(wmi_handle, len);
4543 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304544 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4545 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304546 }
4547
4548 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4549
4550 WMITLV_SET_HDR(&cmd->tlv_header,
4551 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4552 WMITLV_GET_STRUCT_TLVLEN
4553 (wmi_thermal_mgmt_cmd_fixed_param));
4554
4555 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4556 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4557 cmd->enable = thermal_info->thermal_enable;
4558
Govind Singhb53420c2016-03-09 14:32:57 +05304559 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304560 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4561
4562 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4563 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304564 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304565 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304566 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304567 }
4568
Govind Singh67922e82016-04-01 16:48:57 +05304569 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304570}
4571
4572
4573/**
4574 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304575 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304576 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4577 *
4578 * This function sends down the LRO configuration parameters to
4579 * the firmware to enable LRO, sets the TCP flags and sets the
4580 * seed values for the toeplitz hash generation
4581 *
Govind Singhb53420c2016-03-09 14:32:57 +05304582 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304583 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304584static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304585 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4586{
4587 wmi_lro_info_cmd_fixed_param *cmd;
4588 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304589 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304590
4591
4592 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4593 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304594 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4595 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304596 }
4597
4598 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4599
4600 WMITLV_SET_HDR(&cmd->tlv_header,
4601 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4602 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4603
4604 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4605 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4606 wmi_lro_cmd->tcp_flag);
4607 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4608 wmi_lro_cmd->tcp_flag_mask);
4609 cmd->toeplitz_hash_ipv4_0_3 =
4610 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4611 cmd->toeplitz_hash_ipv4_4_7 =
4612 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4613 cmd->toeplitz_hash_ipv4_8_11 =
4614 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4615 cmd->toeplitz_hash_ipv4_12_15 =
4616 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4617 cmd->toeplitz_hash_ipv4_16 =
4618 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4619
4620 cmd->toeplitz_hash_ipv6_0_3 =
4621 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4622 cmd->toeplitz_hash_ipv6_4_7 =
4623 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4624 cmd->toeplitz_hash_ipv6_8_11 =
4625 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4626 cmd->toeplitz_hash_ipv6_12_15 =
4627 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4628 cmd->toeplitz_hash_ipv6_16_19 =
4629 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4630 cmd->toeplitz_hash_ipv6_20_23 =
4631 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4632 cmd->toeplitz_hash_ipv6_24_27 =
4633 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4634 cmd->toeplitz_hash_ipv6_28_31 =
4635 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4636 cmd->toeplitz_hash_ipv6_32_35 =
4637 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4638 cmd->toeplitz_hash_ipv6_36_39 =
4639 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4640 cmd->toeplitz_hash_ipv6_40 =
4641 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4642
Govind Singhb53420c2016-03-09 14:32:57 +05304643 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304644 cmd->lro_enable, cmd->tcp_flag_u32);
4645
4646 status = wmi_unified_cmd_send(wmi_handle, buf,
4647 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304648 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304649 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304650 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304651 }
4652
Govind Singh67922e82016-04-01 16:48:57 +05304653 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304654}
4655
Govind Singh4eacd2b2016-03-07 14:24:22 +05304656/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304657 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4658 * @wmi_handle: Pointer to wmi handle
4659 * @rate_report_params: Pointer to peer rate report parameters
4660 *
4661 *
4662 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4663 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304664static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304665 struct wmi_peer_rate_report_params *rate_report_params)
4666{
4667 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4668 wmi_buf_t buf = NULL;
4669 QDF_STATUS status = 0;
4670 uint32_t len = 0;
4671 uint32_t i, j;
4672
4673 len = sizeof(*cmd);
4674
4675 buf = wmi_buf_alloc(wmi_handle, len);
4676 if (!buf) {
4677 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4678 return QDF_STATUS_E_FAILURE;
4679 }
4680
4681 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4682 wmi_buf_data(buf);
4683
4684 WMITLV_SET_HDR(
4685 &cmd->tlv_header,
4686 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4687 WMITLV_GET_STRUCT_TLVLEN(
4688 wmi_peer_set_rate_report_condition_fixed_param));
4689
4690 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4691 cmd->report_backoff_time = rate_report_params->backoff_time;
4692 cmd->report_timer_period = rate_report_params->timer_period;
4693 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4694 cmd->cond_per_phy[i].val_cond_flags =
4695 rate_report_params->report_per_phy[i].cond_flags;
4696 cmd->cond_per_phy[i].rate_delta.min_delta =
4697 rate_report_params->report_per_phy[i].delta.delta_min;
4698 cmd->cond_per_phy[i].rate_delta.percentage =
4699 rate_report_params->report_per_phy[i].delta.percent;
4700 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4701 cmd->cond_per_phy[i].rate_threshold[j] =
4702 rate_report_params->report_per_phy[i].
4703 report_rate_threshold[j];
4704 }
4705 }
4706
4707 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4708 cmd->enable_rate_report,
4709 cmd->report_backoff_time, cmd->report_timer_period);
4710
4711 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4712 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4713 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304714 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304715 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4716 __func__);
4717 }
4718 return status;
4719}
4720
4721/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304722 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4723 * @wmi_handle: wmi handle
4724 * @param: bcn ll cmd parameter
4725 *
Govind Singhb53420c2016-03-09 14:32:57 +05304726 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304727 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304728static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304729 wmi_bcn_send_from_host_cmd_fixed_param *param)
4730{
4731 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4732 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304733 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304734
4735 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4736 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304737 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4738 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304739 }
4740
4741 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4742 WMITLV_SET_HDR(&cmd->tlv_header,
4743 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4744 WMITLV_GET_STRUCT_TLVLEN
4745 (wmi_bcn_send_from_host_cmd_fixed_param));
4746 cmd->vdev_id = param->vdev_id;
4747 cmd->data_len = param->data_len;
4748 cmd->frame_ctrl = param->frame_ctrl;
4749 cmd->frag_ptr = param->frag_ptr;
4750 cmd->dtim_flag = param->dtim_flag;
4751
4752 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4753 WMI_PDEV_SEND_BCN_CMDID);
4754
Govind Singh67922e82016-04-01 16:48:57 +05304755 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304756 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304757 wmi_buf_free(wmi_buf);
4758 }
4759
4760 return ret;
4761}
4762
4763/**
4764 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4765 * @wmi_handle: wmi handle
4766 * @vdev_id: vdev id
4767 * @max_retries: max retries
4768 * @retry_interval: retry interval
4769 * This function sets sta query related parameters in fw.
4770 *
Govind Singhb53420c2016-03-09 14:32:57 +05304771 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304772 */
4773
Sathish Kumarfd347372017-02-13 12:29:09 +05304774static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304775 uint8_t vdev_id, uint32_t max_retries,
4776 uint32_t retry_interval)
4777{
4778 wmi_buf_t buf;
4779 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4780 int len;
4781
4782 len = sizeof(*cmd);
4783 buf = wmi_buf_alloc(wmi_handle, len);
4784 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304785 WMI_LOGE(FL("wmi_buf_alloc failed"));
4786 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304787 }
4788
4789 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4790 WMITLV_SET_HDR(&cmd->tlv_header,
4791 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4792 WMITLV_GET_STRUCT_TLVLEN
4793 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4794
4795
4796 cmd->vdev_id = vdev_id;
4797 cmd->sa_query_max_retry_count = max_retries;
4798 cmd->sa_query_retry_interval = retry_interval;
4799
Govind Singhb53420c2016-03-09 14:32:57 +05304800 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304801 vdev_id, retry_interval, max_retries);
4802
4803 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4804 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304805 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304806 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304807 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304808 }
4809
Govind Singhb53420c2016-03-09 14:32:57 +05304810 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304811 return 0;
4812}
4813
4814/**
4815 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4816 * @wmi_handle: wmi handle
4817 * @params: sta keep alive parameter
4818 *
4819 * This function sets keep alive related parameters in fw.
4820 *
4821 * Return: CDF status
4822 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304823static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304824 struct sta_params *params)
4825{
4826 wmi_buf_t buf;
4827 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4828 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4829 uint8_t *buf_ptr;
4830 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304831 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304832
Govind Singhb53420c2016-03-09 14:32:57 +05304833 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304834
Govind Singh4eacd2b2016-03-07 14:24:22 +05304835 len = sizeof(*cmd) + sizeof(*arp_rsp);
4836 buf = wmi_buf_alloc(wmi_handle, len);
4837 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304838 WMI_LOGE("wmi_buf_alloc failed");
4839 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304840 }
4841
4842 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4843 buf_ptr = (uint8_t *) cmd;
4844 WMITLV_SET_HDR(&cmd->tlv_header,
4845 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4846 WMITLV_GET_STRUCT_TLVLEN
4847 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4848 cmd->interval = params->timeperiod;
4849 cmd->enable = (params->timeperiod) ? 1 : 0;
4850 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304851 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304852 params->timeperiod, params->method);
4853 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4854 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4855 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4856 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4857
c_manjee2772b9c2017-01-23 15:14:13 +05304858 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
4859 (params->method ==
4860 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05304861 if ((NULL == params->hostv4addr) ||
4862 (NULL == params->destv4addr) ||
4863 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07004864 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
4865 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304866 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304867 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304868 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304869 }
c_manjee2772b9c2017-01-23 15:14:13 +05304870 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05304871 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304872 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304873 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304874 WMI_IPV4_ADDR_LEN);
4875 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4876 } else {
4877 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4878 }
4879
Govind Singh67922e82016-04-01 16:48:57 +05304880 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4881 WMI_STA_KEEPALIVE_CMDID);
4882 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304883 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304884 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304885 }
4886
Govind Singhb53420c2016-03-09 14:32:57 +05304887 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304888 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304889}
4890
4891/**
4892 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4893 * @wmi_handle: wmi handle
4894 * @if_id: vdev id
4895 * @gtx_info: GTX config params
4896 *
4897 * This function set GTX related params in firmware.
4898 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304899 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304900 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304901static QDF_STATUS send_vdev_set_gtx_cfg_cmd_tlv(wmi_unified_t wmi_handle, uint32_t if_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304902 struct wmi_gtx_config *gtx_info)
4903{
4904 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4905 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304906 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304907 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304908
Govind Singh4eacd2b2016-03-07 14:24:22 +05304909 buf = wmi_buf_alloc(wmi_handle, len);
4910 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304911 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304912 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304913 }
4914 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4915 WMITLV_SET_HDR(&cmd->tlv_header,
4916 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4917 WMITLV_GET_STRUCT_TLVLEN
4918 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4919 cmd->vdev_id = if_id;
4920
4921 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4922 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4923 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4924 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4925 cmd->gtxPERMargin = gtx_info->gtx_margin;
4926 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4927 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4928 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4929
Govind Singhb53420c2016-03-09 14:32:57 +05304930 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304931 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4932 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4933 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4934 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4935
Abhishek Singh716c46c2016-05-04 16:24:07 +05304936 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304937 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304938 if (QDF_IS_STATUS_ERROR(ret)) {
4939 WMI_LOGE("Failed to set GTX PARAMS");
4940 wmi_buf_free(buf);
4941 }
4942 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304943}
4944
4945/**
4946 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4947 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304948 * @vdev_id: vdev id.
4949 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05304950 *
4951 * This function updates EDCA parameters to the target
4952 *
4953 * Return: CDF Status
4954 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304955static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304956 uint8_t vdev_id,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304957 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05304958{
4959 uint8_t *buf_ptr;
4960 wmi_buf_t buf;
4961 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304962 wmi_wmm_vparams *wmm_param;
4963 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304964 int len = sizeof(*cmd);
4965 int ac;
4966
4967 buf = wmi_buf_alloc(wmi_handle, len);
4968
4969 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304970 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4971 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304972 }
4973
4974 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4975 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4976 WMITLV_SET_HDR(&cmd->tlv_header,
4977 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4978 WMITLV_GET_STRUCT_TLVLEN
4979 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4980 cmd->vdev_id = vdev_id;
4981
4982 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4983 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304984 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304985 WMITLV_SET_HDR(&wmm_param->tlv_header,
4986 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4987 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4988 wmm_param->cwmin = twmm_param->cwmin;
4989 wmm_param->cwmax = twmm_param->cwmax;
4990 wmm_param->aifs = twmm_param->aifs;
4991 wmm_param->txoplimit = twmm_param->txoplimit;
4992 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304993 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304994 }
4995
4996 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4997 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4998 goto fail;
4999
Govind Singhb53420c2016-03-09 14:32:57 +05305000 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305001
5002fail:
5003 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305004 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5005 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305006}
5007
5008/**
5009 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5010 * @wmi_handle: wmi handle
5011 * @vdev_id: vdev id
5012 * @probe_rsp_info: probe response info
5013 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305014 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305015 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305016static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305017 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005018 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305019{
5020 wmi_prb_tmpl_cmd_fixed_param *cmd;
5021 wmi_bcn_prb_info *bcn_prb_info;
5022 wmi_buf_t wmi_buf;
5023 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5024 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305025 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305026
Govind Singhb53420c2016-03-09 14:32:57 +05305027 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305028
Krunal Soni89426862017-11-14 15:42:48 -08005029 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305030 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
5031
5032 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5033 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5034 tmpl_len_aligned;
5035
5036 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305037 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305038 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305039 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305040 }
5041
5042 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5043 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305044 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305045 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305046 }
5047
5048 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5049
5050 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5051 WMITLV_SET_HDR(&cmd->tlv_header,
5052 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5053 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5054 cmd->vdev_id = vdev_id;
5055 cmd->buf_len = tmpl_len;
5056 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5057
5058 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5059 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5060 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5061 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5062 bcn_prb_info->caps = 0;
5063 bcn_prb_info->erp = 0;
5064 buf_ptr += sizeof(wmi_bcn_prb_info);
5065
5066 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5067 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005068 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305069
5070 ret = wmi_unified_cmd_send(wmi_handle,
5071 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305072 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305073 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305074 wmi_buf_free(wmi_buf);
5075 }
5076
5077 return ret;
5078}
5079
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305080#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305081#define WPI_IV_LEN 16
5082
5083/**
5084 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5085 *
5086 * @dest_tx: destination address of tsc key counter
5087 * @src_tx: source address of tsc key counter
5088 * @dest_rx: destination address of rsc key counter
5089 * @src_rx: source address of rsc key counter
5090 *
5091 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5092 *
5093 * Return: None
5094 *
5095 */
5096static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5097 uint8_t *dest_rx, uint8_t *src_rx)
5098{
5099 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5100 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5101}
5102#else
5103static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5104 uint8_t *dest_rx, uint8_t *src_rx)
5105{
5106 return;
5107}
5108#endif
5109
5110/**
5111 * send_setup_install_key_cmd_tlv() - set key parameters
5112 * @wmi_handle: wmi handle
5113 * @key_params: key parameters
5114 *
5115 * This function fills structure from information
5116 * passed in key_params.
5117 *
5118 * Return: QDF_STATUS_SUCCESS - success
5119 * QDF_STATUS_E_FAILURE - failure
5120 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5121 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305122static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305123 struct set_key_params *key_params)
5124{
5125 wmi_vdev_install_key_cmd_fixed_param *cmd;
5126 wmi_buf_t buf;
5127 uint8_t *buf_ptr;
5128 uint32_t len;
5129 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305130 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305131
5132 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5133 WMI_TLV_HDR_SIZE;
5134
5135 buf = wmi_buf_alloc(wmi_handle, len);
5136 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305137 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305138 return QDF_STATUS_E_NOMEM;
5139 }
5140
5141 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5142 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5143 WMITLV_SET_HDR(&cmd->tlv_header,
5144 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5145 WMITLV_GET_STRUCT_TLVLEN
5146 (wmi_vdev_install_key_cmd_fixed_param));
5147 cmd->vdev_id = key_params->vdev_id;
5148 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305149
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305150
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305151 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5152 cmd->key_flags |= key_params->key_flags;
5153 cmd->key_cipher = key_params->key_cipher;
5154 if ((key_params->key_txmic_len) &&
5155 (key_params->key_rxmic_len)) {
5156 cmd->key_txmic_len = key_params->key_txmic_len;
5157 cmd->key_rxmic_len = key_params->key_rxmic_len;
5158 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305159#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305160 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5161 key_params->tx_iv,
5162 cmd->wpi_key_rsc_counter,
5163 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305164#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305165 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5166 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5167 roundup(key_params->key_len, sizeof(uint32_t)));
5168 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
5169 qdf_mem_copy((void *)key_data,
5170 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005171 if (key_params->key_rsc_counter)
5172 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5173 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305174 cmd->key_len = key_params->key_len;
5175
5176 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5177 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305178 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305179 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305180
Govind Singh67922e82016-04-01 16:48:57 +05305181 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305182}
5183
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305184/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005185 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5186 * @wmi_handle: wmi handle
5187 * @params: sar limit params
5188 *
5189 * Return: QDF_STATUS_SUCCESS for success or error code
5190 */
5191static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5192 struct sar_limit_cmd_params *sar_limit_params)
5193{
5194 wmi_buf_t buf;
5195 QDF_STATUS qdf_status;
5196 wmi_sar_limits_cmd_fixed_param *cmd;
5197 int i;
5198 uint8_t *buf_ptr;
5199 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5200 struct sar_limit_cmd_row *sar_rows_list;
5201 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5202
5203 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5204 buf = wmi_buf_alloc(wmi_handle, len);
5205 if (!buf) {
5206 WMI_LOGE("Failed to allocate memory");
5207 qdf_status = QDF_STATUS_E_NOMEM;
5208 goto end;
5209 }
5210
5211 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5212 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5213 WMITLV_SET_HDR(&cmd->tlv_header,
5214 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5215 WMITLV_GET_STRUCT_TLVLEN
5216 (wmi_sar_limits_cmd_fixed_param));
5217 cmd->sar_enable = sar_limit_params->sar_enable;
5218 cmd->commit_limits = sar_limit_params->commit_limits;
5219 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5220
5221 WMI_LOGD("no of sar rows = %d, len = %d",
5222 sar_limit_params->num_limit_rows, len);
5223 buf_ptr += sizeof(*cmd);
5224 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5225 sizeof(wmi_sar_limit_cmd_row) *
5226 sar_limit_params->num_limit_rows);
5227 if (cmd->num_limit_rows == 0)
5228 goto send_sar_limits;
5229
5230 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5231 (buf_ptr + WMI_TLV_HDR_SIZE);
5232 sar_rows_list = sar_limit_params->sar_limit_row_list;
5233
5234 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5235 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5236 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5237 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5238 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5239 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5240 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5241 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5242 wmi_sar_rows_list->validity_bitmap =
5243 sar_rows_list->validity_bitmap;
5244 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5245 i, wmi_sar_rows_list->band_id,
5246 wmi_sar_rows_list->chain_id,
5247 wmi_sar_rows_list->mod_id,
5248 wmi_sar_rows_list->limit_value,
5249 wmi_sar_rows_list->validity_bitmap);
5250 sar_rows_list++;
5251 wmi_sar_rows_list++;
5252 }
5253send_sar_limits:
5254 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5255 WMI_SAR_LIMITS_CMDID);
5256
5257 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5258 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5259 wmi_buf_free(buf);
5260 }
5261
5262end:
5263 return qdf_status;
5264}
5265
Jeff Johnson4783f902017-12-14 15:50:16 -08005266static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5267{
5268 wmi_sar_get_limits_cmd_fixed_param *cmd;
5269 wmi_buf_t wmi_buf;
5270 uint32_t len;
5271 QDF_STATUS status;
5272
5273 WMI_LOGD(FL("Enter"));
5274
5275 len = sizeof(*cmd);
5276 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5277 if (!wmi_buf) {
5278 WMI_LOGP(FL("failed to allocate memory for msg"));
5279 return QDF_STATUS_E_NOMEM;
5280 }
5281
5282 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5283
5284 WMITLV_SET_HDR(&cmd->tlv_header,
5285 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5286 WMITLV_GET_STRUCT_TLVLEN
5287 (wmi_sar_get_limits_cmd_fixed_param));
5288
5289 cmd->reserved = 0;
5290
5291 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5292 WMI_SAR_GET_LIMITS_CMDID);
5293 if (QDF_IS_STATUS_ERROR(status)) {
5294 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5295 wmi_buf_free(wmi_buf);
5296 }
5297
5298 WMI_LOGD(FL("Exit"));
5299
5300 return status;
5301}
5302
5303static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5304 uint8_t *evt_buf,
5305 struct sar_limit_event *event)
5306{
5307 wmi_sar_get_limits_event_fixed_param *fixed_param;
5308 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5309 wmi_sar_get_limit_event_row *row_in;
5310 struct sar_limit_event_row *row_out;
5311 uint32_t row;
5312
5313 if (!evt_buf) {
5314 WMI_LOGE(FL("input event is NULL"));
5315 return QDF_STATUS_E_INVAL;
5316 }
5317 if (!event) {
5318 WMI_LOGE(FL("output event is NULL"));
5319 return QDF_STATUS_E_INVAL;
5320 }
5321
5322 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5323
5324 fixed_param = param_buf->fixed_param;
5325 if (!fixed_param) {
5326 WMI_LOGE(FL("Invalid fixed param"));
5327 return QDF_STATUS_E_INVAL;
5328 }
5329
5330 event->sar_enable = fixed_param->sar_enable;
5331 event->num_limit_rows = fixed_param->num_limit_rows;
5332
5333 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5334 QDF_ASSERT(0);
5335 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5336 event->num_limit_rows,
5337 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5338 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5339 }
5340
5341 row_in = param_buf->sar_get_limits;
5342 row_out = &event->sar_limit_row[0];
5343 for (row = 0; row < event->num_limit_rows; row++) {
5344 row_out->band_id = row_in->band_id;
5345 row_out->chain_id = row_in->chain_id;
5346 row_out->mod_id = row_in->mod_id;
5347 row_out->limit_value = row_in->limit_value;
5348 row_out++;
5349 row_in++;
5350 }
5351
5352 return QDF_STATUS_SUCCESS;
5353}
5354
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305355#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005356/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305357 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5358 * @wmi_handle: wmi handle
5359 * @params: encrypt/decrypt params
5360 *
5361 * Return: QDF_STATUS_SUCCESS for success or error code
5362 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005363static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305364QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305365 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305366{
5367 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5368 wmi_buf_t wmi_buf;
5369 uint8_t *buf_ptr;
5370 QDF_STATUS ret;
5371 uint32_t len;
5372
5373 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5374
5375 len = sizeof(*cmd) +
5376 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
5377 WMI_TLV_HDR_SIZE;
5378 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5379 if (!wmi_buf) {
5380 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5381 __func__);
5382 return QDF_STATUS_E_NOMEM;
5383 }
5384
5385 buf_ptr = wmi_buf_data(wmi_buf);
5386 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5387
5388 WMITLV_SET_HDR(&cmd->tlv_header,
5389 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5390 WMITLV_GET_STRUCT_TLVLEN(
5391 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5392
5393 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5394 cmd->key_flag = encrypt_decrypt_params->key_flag;
5395 cmd->key_idx = encrypt_decrypt_params->key_idx;
5396 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5397 cmd->key_len = encrypt_decrypt_params->key_len;
5398 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5399 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5400
5401 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5402 encrypt_decrypt_params->key_len);
5403
5404 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5405 MAX_MAC_HEADER_LEN);
5406
5407 cmd->data_len = encrypt_decrypt_params->data_len;
5408
5409 if (cmd->data_len) {
5410 buf_ptr += sizeof(*cmd);
5411 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5412 roundup(encrypt_decrypt_params->data_len,
5413 sizeof(A_UINT32)));
5414 buf_ptr += WMI_TLV_HDR_SIZE;
5415 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5416 encrypt_decrypt_params->data_len);
5417 }
5418
5419 /* This conversion is to facilitate data to FW in little endian */
5420 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5421 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5422 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5423 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5424 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5425 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5426
5427 ret = wmi_unified_cmd_send(wmi_handle,
5428 wmi_buf, len,
5429 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5430 if (QDF_IS_STATUS_ERROR(ret)) {
5431 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5432 wmi_buf_free(wmi_buf);
5433 }
5434
5435 return ret;
5436}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305437
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305438/**
5439 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5440 * params from event
5441 * @wmi_handle: wmi handle
5442 * @evt_buf: pointer to event buffer
5443 * @resp: Pointer to hold resp parameters
5444 *
5445 * Return: QDF_STATUS_SUCCESS for success or error code
5446 */
5447static
5448QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5449 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5450{
5451 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5452 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5453
5454 param_buf = evt_buf;
5455 if (!param_buf) {
5456 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5457 return QDF_STATUS_E_INVAL;
5458 }
5459
5460 data_event = param_buf->fixed_param;
5461
5462 resp->vdev_id = data_event->vdev_id;
5463 resp->status = data_event->status;
5464
5465 if (data_event->data_length > param_buf->num_enc80211_frame) {
5466 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5467 data_event->data_length,
5468 param_buf->num_enc80211_frame);
5469 return QDF_STATUS_E_INVAL;
5470 }
5471
5472 resp->data_len = data_event->data_length;
5473
5474 if (resp->data_len)
5475 resp->data = (uint8_t *)param_buf->enc80211_frame;
5476
5477 return QDF_STATUS_SUCCESS;
5478}
5479#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305480
Govind Singh4eacd2b2016-03-07 14:24:22 +05305481/**
5482 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5483 * @wmi_handle: wmi handle
5484 * @vdev_id: vdev id
5485 * @p2p_ie: p2p IE
5486 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305487 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305488 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305489static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305490 A_UINT32 vdev_id, uint8_t *p2p_ie)
5491{
Govind Singh67922e82016-04-01 16:48:57 +05305492 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305493 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5494 wmi_buf_t wmi_buf;
5495 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5496 uint8_t *buf_ptr;
5497
5498 ie_len = (uint32_t) (p2p_ie[1] + 2);
5499
5500 /* More than one P2P IE may be included in a single frame.
5501 If multiple P2P IEs are present, the complete P2P attribute
5502 data consists of the concatenation of the P2P Attribute
5503 fields of the P2P IEs. The P2P Attributes field of each
5504 P2P IE may be any length up to the maximum (251 octets).
5505 In this case host sends one P2P IE to firmware so the length
5506 should not exceed more than 251 bytes
5507 */
5508 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305509 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305510 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305511 }
5512
5513 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
5514
5515 wmi_buf_len =
5516 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5517 WMI_TLV_HDR_SIZE;
5518
5519 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5520 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305521 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305522 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305523 }
5524
5525 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5526
5527 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5528 WMITLV_SET_HDR(&cmd->tlv_header,
5529 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5530 WMITLV_GET_STRUCT_TLVLEN
5531 (wmi_p2p_go_set_beacon_ie_fixed_param));
5532 cmd->vdev_id = vdev_id;
5533 cmd->ie_buf_len = ie_len;
5534
5535 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5536 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5537 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305538 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305539
Govind Singhb53420c2016-03-09 14:32:57 +05305540 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305541
5542 ret = wmi_unified_cmd_send(wmi_handle,
5543 wmi_buf, wmi_buf_len,
5544 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305545 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305546 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305547 wmi_buf_free(wmi_buf);
5548 }
5549
Govind Singhb53420c2016-03-09 14:32:57 +05305550 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305551 return ret;
5552}
5553
5554/**
5555 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5556 * @wmi_handle: wmi handle
5557 * @req: gateway parameter update request structure
5558 *
5559 * This function reads the incoming @req and fill in the destination
5560 * WMI structure and sends down the gateway configs down to the firmware
5561 *
Govind Singhb53420c2016-03-09 14:32:57 +05305562 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305563 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305564static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305565 struct gateway_update_req_param *req)
5566{
5567 wmi_roam_subnet_change_config_fixed_param *cmd;
5568 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305569 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305570 int len = sizeof(*cmd);
5571
5572 buf = wmi_buf_alloc(wmi_handle, len);
5573 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305574 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5575 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305576 }
5577
5578 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5579 WMITLV_SET_HDR(&cmd->tlv_header,
5580 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5581 WMITLV_GET_STRUCT_TLVLEN(
5582 wmi_roam_subnet_change_config_fixed_param));
5583
5584 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305585 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5586 QDF_IPV4_ADDR_SIZE);
5587 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5588 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305589 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5590 &cmd->inet_gw_mac_addr);
5591 cmd->max_retries = req->max_retries;
5592 cmd->timeout = req->timeout;
5593 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5594 cmd->flag = 0;
5595 if (req->ipv4_addr_type)
5596 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5597
5598 if (req->ipv6_addr_type)
5599 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5600
5601 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5602 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305603 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305604 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305605 ret);
5606 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305607 }
5608
Govind Singh67922e82016-04-01 16:48:57 +05305609 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305610}
5611
5612/**
5613 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5614 * @wmi_handle: wmi handle
5615 * @req: rssi monitoring request structure
5616 *
5617 * This function reads the incoming @req and fill in the destination
5618 * WMI structure and send down the rssi monitoring configs down to the firmware
5619 *
5620 * Return: 0 on success; error number otherwise
5621 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305622static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305623 struct rssi_monitor_param *req)
5624{
5625 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5626 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305627 QDF_STATUS ret;
5628 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305629
5630 buf = wmi_buf_alloc(wmi_handle, len);
5631 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305632 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5633 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305634 }
5635
5636 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5637 WMITLV_SET_HDR(&cmd->tlv_header,
5638 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5639 WMITLV_GET_STRUCT_TLVLEN(
5640 wmi_rssi_breach_monitor_config_fixed_param));
5641
5642 cmd->vdev_id = req->session_id;
5643 cmd->request_id = req->request_id;
5644 cmd->lo_rssi_reenable_hysteresis = 0;
5645 cmd->hi_rssi_reenable_histeresis = 0;
5646 cmd->min_report_interval = 0;
5647 cmd->max_num_report = 1;
5648 if (req->control) {
5649 /* enable one threshold for each min/max */
5650 cmd->enabled_bitmap = 0x09;
5651 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5652 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5653 } else {
5654 cmd->enabled_bitmap = 0;
5655 cmd->low_rssi_breach_threshold[0] = 0;
5656 cmd->hi_rssi_breach_threshold[0] = 0;
5657 }
5658
5659 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5660 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305661 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305662 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305663 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305664 }
5665
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005666 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5667
Govind Singh67922e82016-04-01 16:48:57 +05305668 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305669}
5670
5671/**
5672 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5673 * @wmi_handle: wmi handle
5674 * @psetoui: OUI parameters
5675 *
5676 * set scan probe OUI parameters in firmware
5677 *
5678 * Return: CDF status
5679 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305680static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305681 struct scan_mac_oui *psetoui)
5682{
5683 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5684 wmi_buf_t wmi_buf;
5685 uint32_t len;
5686 uint8_t *buf_ptr;
5687 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305688 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305689
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305690 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5691 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5692
Govind Singh4eacd2b2016-03-07 14:24:22 +05305693 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5694 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305695 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5696 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305697 }
5698 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5699 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5700 WMITLV_SET_HDR(&cmd->tlv_header,
5701 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5702 WMITLV_GET_STRUCT_TLVLEN
5703 (wmi_scan_prob_req_oui_cmd_fixed_param));
5704
5705 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305706 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305707 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5708 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305709 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305710 cmd->prob_req_oui);
5711
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305712 cmd->vdev_id = psetoui->vdev_id;
5713 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5714 if (psetoui->enb_probe_req_sno_randomization)
5715 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5716
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305717 if (ie_whitelist->white_list) {
5718 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5719 &cmd->num_vendor_oui,
5720 ie_whitelist);
5721 cmd->flags |=
5722 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5723 }
5724
5725 buf_ptr += sizeof(*cmd);
5726 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5727 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5728 buf_ptr += WMI_TLV_HDR_SIZE;
5729
5730 if (cmd->num_vendor_oui != 0) {
5731 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5732 ie_whitelist->voui);
5733 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5734 }
5735
Govind Singh4eacd2b2016-03-07 14:24:22 +05305736 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5737 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305738 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305739 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305740 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305741 }
Govind Singhb53420c2016-03-09 14:32:57 +05305742 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305743}
5744
5745/**
5746 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5747 * @wmi_handle: wmi handle
5748 * @req: passpoint network request structure
5749 *
5750 * This function sends down WMI command with network id set to wildcard id.
5751 * firmware shall clear all the config entries
5752 *
Govind Singhb53420c2016-03-09 14:32:57 +05305753 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305754 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305755static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305756 struct wifi_passpoint_req_param *req)
5757{
5758 wmi_passpoint_config_cmd_fixed_param *cmd;
5759 wmi_buf_t buf;
5760 uint32_t len;
5761 int ret;
5762
5763 len = sizeof(*cmd);
5764 buf = wmi_buf_alloc(wmi_handle, len);
5765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305766 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5767 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305768 }
5769
5770 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5771
5772 WMITLV_SET_HDR(&cmd->tlv_header,
5773 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5774 WMITLV_GET_STRUCT_TLVLEN(
5775 wmi_passpoint_config_cmd_fixed_param));
5776 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5777
5778 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5779 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5780 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305781 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305782 __func__);
5783 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305784 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305785 }
5786
Govind Singhb53420c2016-03-09 14:32:57 +05305787 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305788}
5789
5790/**
5791 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5792 * @wmi_handle: wmi handle
5793 * @req: passpoint network request structure
5794 *
5795 * This function reads the incoming @req and fill in the destination
5796 * WMI structure and send down the passpoint configs down to the firmware
5797 *
Govind Singhb53420c2016-03-09 14:32:57 +05305798 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305799 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305800static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305801 struct wifi_passpoint_req_param *req)
5802{
5803 wmi_passpoint_config_cmd_fixed_param *cmd;
5804 u_int8_t i, j, *bytes;
5805 wmi_buf_t buf;
5806 uint32_t len;
5807 int ret;
5808
5809 len = sizeof(*cmd);
5810 for (i = 0; i < req->num_networks; i++) {
5811 buf = wmi_buf_alloc(wmi_handle, len);
5812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305813 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5814 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305815 }
5816
5817 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5818 wmi_buf_data(buf);
5819
5820 WMITLV_SET_HDR(&cmd->tlv_header,
5821 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5822 WMITLV_GET_STRUCT_TLVLEN(
5823 wmi_passpoint_config_cmd_fixed_param));
5824 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305825 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5826 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305827 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305828 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305829 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5830 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305831 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305832 j, bytes[0], bytes[1], bytes[2], bytes[3],
5833 bytes[4], bytes[5], bytes[6], bytes[7]);
5834
Govind Singhb53420c2016-03-09 14:32:57 +05305835 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305836 &req->networks[i].roaming_consortium_ids[j],
5837 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5838 }
Govind Singhb53420c2016-03-09 14:32:57 +05305839 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305840 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305841 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305842 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5843
5844 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5845 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5846 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305847 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305848 __func__);
5849 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305850 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305851 }
5852 }
5853
Govind Singhb53420c2016-03-09 14:32:57 +05305854 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305855}
5856
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05305857#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05305858/**
5859 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
5860 * @wmi_handle: wmi handle
5861 * @roam_req: Roam scan offload params
5862 * @buf_ptr: command buffer to send
5863 * @fils_tlv_len: fils tlv length
5864 *
5865 * Return: Updated buffer pointer
5866 */
5867static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
5868 struct roam_offload_scan_params *roam_req,
5869 uint8_t *buf_ptr, uint32_t fils_tlv_len)
5870{
5871 wmi_roam_fils_offload_tlv_param *fils_tlv;
5872 wmi_erp_info *erp_info;
5873 struct roam_fils_params *roam_fils_params;
5874
5875 if (!roam_req->add_fils_tlv)
5876 return buf_ptr;
5877
5878 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5879 sizeof(*fils_tlv));
5880 buf_ptr += WMI_TLV_HDR_SIZE;
5881
5882 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
5883 WMITLV_SET_HDR(&fils_tlv->tlv_header,
5884 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
5885 WMITLV_GET_STRUCT_TLVLEN
5886 (wmi_roam_fils_offload_tlv_param));
5887
5888 roam_fils_params = &roam_req->roam_fils_params;
5889 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
5890
5891 erp_info->username_length = roam_fils_params->username_length;
5892 qdf_mem_copy(erp_info->username, roam_fils_params->username,
5893 erp_info->username_length);
5894
5895 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
5896
5897 erp_info->rRk_length = roam_fils_params->rrk_length;
5898 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
5899 erp_info->rRk_length);
5900
5901 erp_info->rIk_length = roam_fils_params->rik_length;
5902 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
5903 erp_info->rIk_length);
5904
5905 erp_info->realm_len = roam_fils_params->realm_len;
5906 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
5907 erp_info->realm_len);
5908
5909 buf_ptr += sizeof(*fils_tlv);
5910 return buf_ptr;
5911}
5912#else
5913static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
5914 struct roam_offload_scan_params *roam_req,
5915 uint8_t *buf_ptr, uint32_t fils_tlv_len)
5916{
5917 return buf_ptr;
5918}
5919#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305920/**
5921 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5922 * @wmi_handle: wmi handle
5923 * @scan_cmd_fp: start scan command ptr
5924 * @roam_req: roam request param
5925 *
5926 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5927 * of WMI_ROAM_SCAN_MODE.
5928 *
5929 * Return: QDF status
5930 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305931static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305932 wmi_start_scan_cmd_fixed_param *
5933 scan_cmd_fp,
5934 struct roam_offload_scan_params *roam_req)
5935{
5936 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305937 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305938 int len;
5939 uint8_t *buf_ptr;
5940 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305941
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305942#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5943 int auth_mode = roam_req->auth_mode;
5944 wmi_roam_offload_tlv_param *roam_offload_params;
5945 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5946 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5947 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305948 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05305949 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305950#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5951 /* Need to create a buf with roam_scan command at
5952 * front and piggyback with scan command */
5953 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5954#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5955 (2 * WMI_TLV_HDR_SIZE) +
5956#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5957 sizeof(wmi_start_scan_cmd_fixed_param);
5958#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07005959 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305960 if (roam_req->is_roam_req_valid &&
5961 roam_req->roam_offload_enabled) {
5962 len += sizeof(wmi_roam_offload_tlv_param);
5963 len += WMI_TLV_HDR_SIZE;
5964 if ((auth_mode != WMI_AUTH_NONE) &&
5965 ((auth_mode != WMI_AUTH_OPEN) ||
5966 (auth_mode == WMI_AUTH_OPEN &&
5967 roam_req->mdid.mdie_present) ||
5968 roam_req->is_ese_assoc)) {
5969 len += WMI_TLV_HDR_SIZE;
5970 if (roam_req->is_ese_assoc)
5971 len +=
5972 sizeof(wmi_roam_ese_offload_tlv_param);
5973 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5974 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5975 (auth_mode == WMI_AUTH_OPEN &&
5976 roam_req->mdid.mdie_present))
5977 len +=
5978 sizeof(wmi_roam_11r_offload_tlv_param);
5979 else
5980 len +=
5981 sizeof(wmi_roam_11i_offload_tlv_param);
5982 } else {
5983 len += WMI_TLV_HDR_SIZE;
5984 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305985
5986 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5987 + roundup(roam_req->assoc_ie_length,
5988 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05305989
5990 if (roam_req->add_fils_tlv) {
5991 fils_tlv_len = sizeof(
5992 wmi_roam_fils_offload_tlv_param);
5993 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
5994 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305995 } else {
5996 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305997 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305998 __func__, roam_req->roam_offload_enabled);
5999 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306000 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306001 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306002 }
6003 if (roam_req->is_roam_req_valid &&
6004 roam_req->roam_offload_enabled) {
6005 roam_req->mode = roam_req->mode |
6006 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6007 }
6008#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6009
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306010 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6011 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6012 len = sizeof(wmi_roam_scan_mode_fixed_param);
6013
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306014 buf = wmi_buf_alloc(wmi_handle, len);
6015 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306016 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306017 return QDF_STATUS_E_NOMEM;
6018 }
6019
6020 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6021 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6022 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6023 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6024 WMITLV_GET_STRUCT_TLVLEN
6025 (wmi_roam_scan_mode_fixed_param));
6026
6027 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6028 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306029 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6030 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6031 roam_scan_mode_fp->flags |=
6032 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306033 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306034 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306035
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306036 /* Fill in scan parameters suitable for roaming scan */
6037 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306038
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306039 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6040 sizeof(wmi_start_scan_cmd_fixed_param));
6041 /* Ensure there is no additional IEs */
6042 scan_cmd_fp->ie_len = 0;
6043 WMITLV_SET_HDR(buf_ptr,
6044 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6045 WMITLV_GET_STRUCT_TLVLEN
6046 (wmi_start_scan_cmd_fixed_param));
6047#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6048 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6049 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6050 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6051 sizeof(wmi_roam_offload_tlv_param));
6052 buf_ptr += WMI_TLV_HDR_SIZE;
6053 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6054 WMITLV_SET_HDR(buf_ptr,
6055 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6056 WMITLV_GET_STRUCT_TLVLEN
6057 (wmi_roam_offload_tlv_param));
6058 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6059 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6060 roam_offload_params->select_5g_margin =
6061 roam_req->select_5ghz_margin;
6062 roam_offload_params->reassoc_failure_timeout =
6063 roam_req->reassoc_failure_timeout;
6064
6065 /* Fill the capabilities */
6066 roam_offload_params->capability =
6067 roam_req->roam_offload_params.capability;
6068 roam_offload_params->ht_caps_info =
6069 roam_req->roam_offload_params.ht_caps_info;
6070 roam_offload_params->ampdu_param =
6071 roam_req->roam_offload_params.ampdu_param;
6072 roam_offload_params->ht_ext_cap =
6073 roam_req->roam_offload_params.ht_ext_cap;
6074 roam_offload_params->ht_txbf =
6075 roam_req->roam_offload_params.ht_txbf;
6076 roam_offload_params->asel_cap =
6077 roam_req->roam_offload_params.asel_cap;
6078 roam_offload_params->qos_caps =
6079 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006080 roam_offload_params->qos_enabled =
6081 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306082 roam_offload_params->wmm_caps =
6083 roam_req->roam_offload_params.wmm_caps;
6084 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6085 (uint8_t *)roam_req->roam_offload_params.mcsset,
6086 ROAM_OFFLOAD_NUM_MCS_SET);
6087
6088 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6089 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6090 * they are filled in the same order.Depending on the
6091 * authentication type, the other mode TLV's are nullified
6092 * and only headers are filled.*/
6093 if ((auth_mode != WMI_AUTH_NONE) &&
6094 ((auth_mode != WMI_AUTH_OPEN) ||
6095 (auth_mode == WMI_AUTH_OPEN
6096 && roam_req->mdid.mdie_present) ||
6097 roam_req->is_ese_assoc)) {
6098 if (roam_req->is_ese_assoc) {
6099 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6100 WMITLV_GET_STRUCT_TLVLEN(0));
6101 buf_ptr += WMI_TLV_HDR_SIZE;
6102 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6103 WMITLV_GET_STRUCT_TLVLEN(0));
6104 buf_ptr += WMI_TLV_HDR_SIZE;
6105 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6106 sizeof(wmi_roam_ese_offload_tlv_param));
6107 buf_ptr += WMI_TLV_HDR_SIZE;
6108 roam_offload_ese =
6109 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6110 qdf_mem_copy(roam_offload_ese->krk,
6111 roam_req->krk,
6112 sizeof(roam_req->krk));
6113 qdf_mem_copy(roam_offload_ese->btk,
6114 roam_req->btk,
6115 sizeof(roam_req->btk));
6116 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6117 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6118 WMITLV_GET_STRUCT_TLVLEN
6119 (wmi_roam_ese_offload_tlv_param));
6120 buf_ptr +=
6121 sizeof(wmi_roam_ese_offload_tlv_param);
6122 } else if (auth_mode == WMI_AUTH_FT_RSNA
6123 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6124 || (auth_mode == WMI_AUTH_OPEN
6125 && roam_req->mdid.mdie_present)) {
6126 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6127 0);
6128 buf_ptr += WMI_TLV_HDR_SIZE;
6129 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6130 sizeof(wmi_roam_11r_offload_tlv_param));
6131 buf_ptr += WMI_TLV_HDR_SIZE;
6132 roam_offload_11r =
6133 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6134 roam_offload_11r->r0kh_id_len =
6135 roam_req->rokh_id_length;
6136 qdf_mem_copy(roam_offload_11r->r0kh_id,
6137 roam_req->rokh_id,
6138 roam_offload_11r->r0kh_id_len);
6139 qdf_mem_copy(roam_offload_11r->psk_msk,
6140 roam_req->psk_pmk,
6141 sizeof(roam_req->psk_pmk));
6142 roam_offload_11r->psk_msk_len =
6143 roam_req->pmk_len;
6144 roam_offload_11r->mdie_present =
6145 roam_req->mdid.mdie_present;
6146 roam_offload_11r->mdid =
6147 roam_req->mdid.mobility_domain;
6148 if (auth_mode == WMI_AUTH_OPEN) {
6149 /* If FT-Open ensure pmk length
6150 and r0khid len are zero */
6151 roam_offload_11r->r0kh_id_len = 0;
6152 roam_offload_11r->psk_msk_len = 0;
6153 }
6154 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6155 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6156 WMITLV_GET_STRUCT_TLVLEN
6157 (wmi_roam_11r_offload_tlv_param));
6158 buf_ptr +=
6159 sizeof(wmi_roam_11r_offload_tlv_param);
6160 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6161 WMITLV_GET_STRUCT_TLVLEN(0));
6162 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006163 WMI_LOGD("psk_msk_len = %d",
6164 roam_offload_11r->psk_msk_len);
6165 if (roam_offload_11r->psk_msk_len)
6166 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6167 QDF_TRACE_LEVEL_DEBUG,
6168 roam_offload_11r->psk_msk,
6169 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306170 } else {
6171 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6172 sizeof(wmi_roam_11i_offload_tlv_param));
6173 buf_ptr += WMI_TLV_HDR_SIZE;
6174 roam_offload_11i =
6175 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006176
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006177 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006178 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306179 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6180 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006181 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306182 } else {
6183 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6184 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006185 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006186 }
6187 if (roam_req->roam_key_mgmt_offload_enabled &&
6188 roam_req->fw_pmksa_cache) {
6189 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6190 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006191 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006192 } else {
6193 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6194 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006195 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306196 }
6197
6198 qdf_mem_copy(roam_offload_11i->pmk,
6199 roam_req->psk_pmk,
6200 sizeof(roam_req->psk_pmk));
6201 roam_offload_11i->pmk_len = roam_req->pmk_len;
6202 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6203 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6204 WMITLV_GET_STRUCT_TLVLEN
6205 (wmi_roam_11i_offload_tlv_param));
6206 buf_ptr +=
6207 sizeof(wmi_roam_11i_offload_tlv_param);
6208 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6209 0);
6210 buf_ptr += WMI_TLV_HDR_SIZE;
6211 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6212 0);
6213 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006214 WMI_LOGD("pmk_len = %d",
6215 roam_offload_11i->pmk_len);
6216 if (roam_offload_11i->pmk_len)
6217 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6218 QDF_TRACE_LEVEL_DEBUG,
6219 roam_offload_11i->pmk,
6220 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306221 }
6222 } else {
6223 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6224 WMITLV_GET_STRUCT_TLVLEN(0));
6225 buf_ptr += WMI_TLV_HDR_SIZE;
6226 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6227 WMITLV_GET_STRUCT_TLVLEN(0));
6228 buf_ptr += WMI_TLV_HDR_SIZE;
6229 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6230 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306231 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306232 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306233
6234 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6235 sizeof(*assoc_ies));
6236 buf_ptr += WMI_TLV_HDR_SIZE;
6237
6238 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6239 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6240 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6241 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6242 assoc_ies->buf_len = roam_req->assoc_ie_length;
6243
6244 buf_ptr += sizeof(*assoc_ies);
6245
6246 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6247 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6248 buf_ptr += WMI_TLV_HDR_SIZE;
6249
6250 if (assoc_ies->buf_len != 0) {
6251 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6252 assoc_ies->buf_len);
6253 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306254 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6255 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6256 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306257 } else {
6258 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6259 WMITLV_GET_STRUCT_TLVLEN(0));
6260 buf_ptr += WMI_TLV_HDR_SIZE;
6261 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6262 WMITLV_GET_STRUCT_TLVLEN(0));
6263 buf_ptr += WMI_TLV_HDR_SIZE;
6264 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6265 WMITLV_GET_STRUCT_TLVLEN(0));
6266 buf_ptr += WMI_TLV_HDR_SIZE;
6267 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6268 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306269 buf_ptr += WMI_TLV_HDR_SIZE;
6270 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6271 WMITLV_GET_STRUCT_TLVLEN(0));
6272 buf_ptr += WMI_TLV_HDR_SIZE;
6273 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6274 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306275 }
6276#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306277
6278send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306279 status = wmi_unified_cmd_send(wmi_handle, buf,
6280 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306281 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306282 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306283 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6284 status);
6285 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306286 }
6287
Govind Singh67922e82016-04-01 16:48:57 +05306288 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306289}
6290
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006291static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6292 struct wmi_mawc_roam_params *params)
6293{
6294 wmi_buf_t buf = NULL;
6295 QDF_STATUS status;
6296 int len;
6297 uint8_t *buf_ptr;
6298 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6299
6300 len = sizeof(*wmi_roam_mawc_params);
6301 buf = wmi_buf_alloc(wmi_handle, len);
6302 if (!buf) {
6303 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6304 return QDF_STATUS_E_NOMEM;
6305 }
6306
6307 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6308 wmi_roam_mawc_params =
6309 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6310 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6311 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6312 WMITLV_GET_STRUCT_TLVLEN
6313 (wmi_roam_configure_mawc_cmd_fixed_param));
6314 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6315 if (params->enable)
6316 wmi_roam_mawc_params->enable = 1;
6317 else
6318 wmi_roam_mawc_params->enable = 0;
6319 wmi_roam_mawc_params->traffic_load_threshold =
6320 params->traffic_load_threshold;
6321 wmi_roam_mawc_params->best_ap_rssi_threshold =
6322 params->best_ap_rssi_threshold;
6323 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6324 params->rssi_stationary_high_adjust;
6325 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6326 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006327 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6328 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6329 wmi_roam_mawc_params->traffic_load_threshold,
6330 wmi_roam_mawc_params->best_ap_rssi_threshold,
6331 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6332 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006333
6334 status = wmi_unified_cmd_send(wmi_handle, buf,
6335 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6336 if (QDF_IS_STATUS_ERROR(status)) {
6337 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6338 status);
6339 wmi_buf_free(buf);
6340 return status;
6341 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006342
6343 return QDF_STATUS_SUCCESS;
6344}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306345
6346/**
6347 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6348 * rssi threashold
6349 * @wmi_handle: wmi handle
6350 * @roam_req: Roaming request buffer
6351 *
6352 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6353 *
6354 * Return: QDF status
6355 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306356static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306357 struct roam_offload_scan_rssi_params *roam_req)
6358{
6359 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306360 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306361 int len;
6362 uint8_t *buf_ptr;
6363 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6364 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6365 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306366 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006367 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306368
6369 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6370 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6371 len += sizeof(wmi_roam_scan_extended_threshold_param);
6372 len += WMI_TLV_HDR_SIZE;
6373 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306374 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6375 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006376 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6377 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306378 buf = wmi_buf_alloc(wmi_handle, len);
6379 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306380 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306381 return QDF_STATUS_E_NOMEM;
6382 }
6383
6384 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6385 rssi_threshold_fp =
6386 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6387 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6388 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6389 WMITLV_GET_STRUCT_TLVLEN
6390 (wmi_roam_scan_rssi_threshold_fixed_param));
6391 /* fill in threshold values */
6392 rssi_threshold_fp->vdev_id = roam_req->session_id;
6393 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6394 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6395 rssi_threshold_fp->hirssi_scan_max_count =
6396 roam_req->hi_rssi_scan_max_count;
6397 rssi_threshold_fp->hirssi_scan_delta =
6398 roam_req->hi_rssi_scan_rssi_delta;
6399 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006400 rssi_threshold_fp->rssi_thresh_offset_5g =
6401 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306402
6403 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6404 WMITLV_SET_HDR(buf_ptr,
6405 WMITLV_TAG_ARRAY_STRUC,
6406 sizeof(wmi_roam_scan_extended_threshold_param));
6407 buf_ptr += WMI_TLV_HDR_SIZE;
6408 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6409
6410 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6411 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6412 ext_thresholds->boost_threshold_5g =
6413 roam_req->boost_threshold_5g;
6414
6415 ext_thresholds->boost_algorithm_5g =
6416 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6417 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6418 ext_thresholds->penalty_algorithm_5g =
6419 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6420 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6421 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6422 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6423 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6424
6425 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6426 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6427 WMITLV_GET_STRUCT_TLVLEN
6428 (wmi_roam_scan_extended_threshold_param));
6429 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6430 WMITLV_SET_HDR(buf_ptr,
6431 WMITLV_TAG_ARRAY_STRUC,
6432 sizeof(wmi_roam_earlystop_rssi_thres_param));
6433 buf_ptr += WMI_TLV_HDR_SIZE;
6434 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6435 early_stop_thresholds->roam_earlystop_thres_min =
6436 roam_req->roam_earlystop_thres_min;
6437 early_stop_thresholds->roam_earlystop_thres_max =
6438 roam_req->roam_earlystop_thres_max;
6439 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6440 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6441 WMITLV_GET_STRUCT_TLVLEN
6442 (wmi_roam_earlystop_rssi_thres_param));
6443
Gupta, Kapil7e652922016-04-12 15:02:00 +05306444 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6445 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6446 sizeof(wmi_roam_dense_thres_param));
6447 buf_ptr += WMI_TLV_HDR_SIZE;
6448 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6449 dense_thresholds->roam_dense_rssi_thres_offset =
6450 roam_req->dense_rssi_thresh_offset;
6451 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6452 dense_thresholds->roam_dense_traffic_thres =
6453 roam_req->traffic_threshold;
6454 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6455 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6456 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6457 WMITLV_GET_STRUCT_TLVLEN
6458 (wmi_roam_dense_thres_param));
6459
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006460 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6461 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6462 sizeof(wmi_roam_bg_scan_roaming_param));
6463 buf_ptr += WMI_TLV_HDR_SIZE;
6464 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6465 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6466 roam_req->bg_scan_bad_rssi_thresh;
6467 bg_scan_params->roam_bg_scan_client_bitmap =
6468 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306469 bg_scan_params->bad_rssi_thresh_offset_2g =
6470 roam_req->roam_bad_rssi_thresh_offset_2g;
6471 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006472 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6473 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6474 WMITLV_GET_STRUCT_TLVLEN
6475 (wmi_roam_bg_scan_roaming_param));
6476
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306477 status = wmi_unified_cmd_send(wmi_handle, buf,
6478 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306479 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306480 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306481 status);
6482 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306483 }
6484
Govind Singh67922e82016-04-01 16:48:57 +05306485 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306486}
6487
6488/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306489 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6490 * configuration params
6491 * @wma_handle: wma handler
6492 * @dwelltime_params: pointer to dwelltime_params
6493 *
6494 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6495 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006496static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306497QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6498 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6499{
6500 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6501 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6502 wmi_buf_t buf;
6503 uint8_t *buf_ptr;
6504 int32_t err;
6505 int len;
6506
6507 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6508 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6509 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6510 buf = wmi_buf_alloc(wmi_handle, len);
6511 if (!buf) {
6512 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6513 __func__);
6514 return QDF_STATUS_E_NOMEM;
6515 }
6516 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6517 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6518 WMITLV_SET_HDR(&dwell_param->tlv_header,
6519 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6520 WMITLV_GET_STRUCT_TLVLEN
6521 (wmi_scan_adaptive_dwell_config_fixed_param));
6522
6523 dwell_param->enable = dwelltime_params->is_enabled;
6524 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6525 WMITLV_SET_HDR(buf_ptr,
6526 WMITLV_TAG_ARRAY_STRUC,
6527 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6528 buf_ptr += WMI_TLV_HDR_SIZE;
6529
6530 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6531 WMITLV_SET_HDR(&cmd->tlv_header,
6532 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6533 WMITLV_GET_STRUCT_TLVLEN(
6534 wmi_scan_adaptive_dwell_parameters_tlv));
6535
6536 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6537 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6538 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6539 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6540 err = wmi_unified_cmd_send(wmi_handle, buf,
6541 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6542 if (err) {
6543 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6544 wmi_buf_free(buf);
6545 return QDF_STATUS_E_FAILURE;
6546 }
6547
6548 return QDF_STATUS_SUCCESS;
6549}
6550
Nitesh Shah52323d02017-05-22 15:49:00 +05306551/**
6552 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6553 * configuration params
6554 * @wmi_handle: wmi handler
6555 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6556 *
6557 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6558 */
6559static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6560 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6561{
6562 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6563 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6564 wmi_buf_t buf;
6565 uint8_t *buf_ptr;
6566 QDF_STATUS err;
6567 uint32_t i;
6568 int len;
6569
6570 len = sizeof(*dbs_scan_param);
6571 len += WMI_TLV_HDR_SIZE;
6572 len += dbs_scan_params->num_clients * sizeof(*cmd);
6573
6574 buf = wmi_buf_alloc(wmi_handle, len);
6575 if (!buf) {
6576 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6577 return QDF_STATUS_E_NOMEM;
6578 }
6579
6580 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6581 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6582 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6583 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6584 WMITLV_GET_STRUCT_TLVLEN
6585 (wmi_scan_dbs_duty_cycle_fixed_param));
6586
6587 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6588 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6589 buf_ptr += sizeof(*dbs_scan_param);
6590 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6591 (sizeof(*cmd) * dbs_scan_params->num_clients));
6592 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6593
6594 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6595 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6596 WMITLV_SET_HDR(&cmd->tlv_header,
6597 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6598 WMITLV_GET_STRUCT_TLVLEN(
6599 wmi_scan_dbs_duty_cycle_tlv_param));
6600 cmd->module_id = dbs_scan_params->module_id[i];
6601 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6602 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6603 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6604 }
6605
6606 err = wmi_unified_cmd_send(wmi_handle, buf,
6607 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6608 if (QDF_IS_STATUS_ERROR(err)) {
6609 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6610 wmi_buf_free(buf);
6611 return QDF_STATUS_E_FAILURE;
6612 }
6613
6614 return QDF_STATUS_SUCCESS;
6615}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306616
6617/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306618 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6619 * @wmi_handle: wmi handle
6620 * @roam_req: Request which contains the filters
6621 *
6622 * There are filters such as whitelist, blacklist and preferred
6623 * list that need to be applied to the scan results to form the
6624 * probable candidates for roaming.
6625 *
6626 * Return: Return success upon succesfully passing the
6627 * parameters to the firmware, otherwise failure.
6628 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306629static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306630 struct roam_scan_filter_params *roam_req)
6631{
6632 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306633 QDF_STATUS status;
6634 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306635 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306636 uint8_t *buf_ptr;
6637 wmi_roam_filter_fixed_param *roam_filter;
6638 uint8_t *bssid_src_ptr = NULL;
6639 wmi_mac_addr *bssid_dst_ptr = NULL;
6640 wmi_ssid *ssid_ptr = NULL;
6641 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306642 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306643 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306644
6645 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306646
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306647 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306648 if (roam_req->num_bssid_black_list)
6649 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6650 len += WMI_TLV_HDR_SIZE;
6651 if (roam_req->num_ssid_white_list)
6652 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6653 len += 2 * WMI_TLV_HDR_SIZE;
6654 if (roam_req->num_bssid_preferred_list) {
6655 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
6656 len += roam_req->num_bssid_preferred_list * sizeof(A_UINT32);
6657 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306658 len += WMI_TLV_HDR_SIZE;
6659 if (roam_req->lca_disallow_config_present) {
6660 len += sizeof(*blist_param);
6661 blist_len = sizeof(*blist_param);
6662 }
6663
6664 len += WMI_TLV_HDR_SIZE;
6665 if (roam_req->num_rssi_rejection_ap)
6666 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306667
6668 buf = wmi_buf_alloc(wmi_handle, len);
6669 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306670 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306671 return QDF_STATUS_E_NOMEM;
6672 }
6673
6674 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6675 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6676 WMITLV_SET_HDR(&roam_filter->tlv_header,
6677 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6678 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6679 /* fill in fixed values */
6680 roam_filter->vdev_id = roam_req->session_id;
6681 roam_filter->flags = 0;
6682 roam_filter->op_bitmap = roam_req->op_bitmap;
6683 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6684 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6685 roam_filter->num_bssid_preferred_list =
6686 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306687 roam_filter->num_rssi_rejection_ap =
6688 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306689 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6690
6691 WMITLV_SET_HDR((buf_ptr),
6692 WMITLV_TAG_ARRAY_FIXED_STRUC,
6693 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6694 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6695 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6696 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6697 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6698 bssid_src_ptr += ATH_MAC_LEN;
6699 bssid_dst_ptr++;
6700 }
6701 buf_ptr += WMI_TLV_HDR_SIZE +
6702 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6703 WMITLV_SET_HDR((buf_ptr),
6704 WMITLV_TAG_ARRAY_FIXED_STRUC,
6705 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6706 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6707 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6708 qdf_mem_copy(&ssid_ptr->ssid,
6709 &roam_req->ssid_allowed_list[i].mac_ssid,
6710 roam_req->ssid_allowed_list[i].length);
6711 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6712 ssid_ptr++;
6713 }
6714 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6715 sizeof(wmi_ssid));
6716 WMITLV_SET_HDR((buf_ptr),
6717 WMITLV_TAG_ARRAY_FIXED_STRUC,
6718 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6719 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6720 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6721 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6722 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6723 (wmi_mac_addr *)bssid_dst_ptr);
6724 bssid_src_ptr += ATH_MAC_LEN;
6725 bssid_dst_ptr++;
6726 }
6727 buf_ptr += WMI_TLV_HDR_SIZE +
6728 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6729 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6730 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6731 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6732 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6733 *bssid_preferred_factor_ptr =
6734 roam_req->bssid_favored_factor[i];
6735 bssid_preferred_factor_ptr++;
6736 }
6737 buf_ptr += WMI_TLV_HDR_SIZE +
6738 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6739
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306740 WMITLV_SET_HDR(buf_ptr,
6741 WMITLV_TAG_ARRAY_STRUC, blist_len);
6742 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306743 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306744 blist_param =
6745 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6746 WMITLV_SET_HDR(&blist_param->tlv_header,
6747 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6748 WMITLV_GET_STRUCT_TLVLEN(
6749 wmi_roam_lca_disallow_config_tlv_param));
6750
6751 blist_param->disallow_duration = roam_req->disallow_duration;
6752 blist_param->rssi_channel_penalization =
6753 roam_req->rssi_channel_penalization;
6754 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05306755 blist_param->disallow_lca_enable_source_bitmap =
6756 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
6757 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306758 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6759 }
6760
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306761 WMITLV_SET_HDR(buf_ptr,
6762 WMITLV_TAG_ARRAY_STRUC,
6763 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6764 buf_ptr += WMI_TLV_HDR_SIZE;
6765 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
6766 rssi_rej =
6767 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
6768 WMITLV_SET_HDR(&rssi_rej->tlv_header,
6769 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
6770 WMITLV_GET_STRUCT_TLVLEN(
6771 wmi_roam_rssi_rejection_oce_config_param));
6772 WMI_CHAR_ARRAY_TO_MAC_ADDR(
6773 roam_req->rssi_rejection_ap[i].bssid.bytes,
6774 &rssi_rej->bssid);
6775 rssi_rej->remaining_disallow_duration =
6776 roam_req->rssi_rejection_ap[i].remaining_duration;
6777 rssi_rej->requested_rssi =
6778 (A_INT32)roam_req->rssi_rejection_ap[i].expected_rssi;
6779 buf_ptr +=
6780 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
6781 }
6782
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306783 status = wmi_unified_cmd_send(wmi_handle, buf,
6784 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306785 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306786 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306787 status);
6788 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306789 }
Govind Singh67922e82016-04-01 16:48:57 +05306790
6791 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306792}
6793
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306794#if defined(WLAN_FEATURE_FILS_SK)
6795static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
6796 struct hlp_params *params)
6797{
6798 uint32_t len;
6799 uint8_t *buf_ptr;
6800 wmi_buf_t buf = NULL;
6801 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
6802
6803 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
6804 len += WMI_TLV_HDR_SIZE;
6805 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
6806
6807 buf = wmi_buf_alloc(wmi_handle, len);
6808 if (!buf) {
6809 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6810 return QDF_STATUS_E_NOMEM;
6811 }
6812
6813 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6814 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
6815 WMITLV_SET_HDR(&hlp_params->tlv_header,
6816 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
6817 WMITLV_GET_STRUCT_TLVLEN(
6818 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
6819
6820 hlp_params->vdev_id = params->vdev_id;
6821 hlp_params->size = params->hlp_ie_len;
6822 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
6823
6824 buf_ptr += sizeof(*hlp_params);
6825
6826 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6827 round_up(params->hlp_ie_len,
6828 sizeof(uint32_t)));
6829 buf_ptr += WMI_TLV_HDR_SIZE;
6830 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
6831
6832 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
6833 hlp_params->vdev_id, hlp_params->size);
6834 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6835 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
6836 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
6837 wmi_buf_free(buf);
6838 return QDF_STATUS_E_FAILURE;
6839 }
6840
6841 return QDF_STATUS_SUCCESS;
6842}
6843#endif
6844
Govind Singh4eacd2b2016-03-07 14:24:22 +05306845/** send_set_epno_network_list_cmd_tlv() - set epno network list
6846 * @wmi_handle: wmi handle
6847 * @req: epno config params request structure
6848 *
6849 * This function reads the incoming epno config request structure
6850 * and constructs the WMI message to the firmware.
6851 *
6852 * Returns: 0 on success, error number otherwise
6853 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306854static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306855 struct wifi_enhanched_pno_params *req)
6856{
6857 wmi_nlo_config_cmd_fixed_param *cmd;
6858 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306859 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306860 u_int8_t i, *buf_ptr;
6861 wmi_buf_t buf;
6862 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05306863 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306864
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306865 /* Fixed Params */
6866 len = sizeof(*cmd);
6867 if (req->num_networks) {
6868 /* TLV place holder for array of structures
6869 * then each nlo_configured_parameters(nlo_list) TLV.
6870 */
6871 len += WMI_TLV_HDR_SIZE;
6872 len += (sizeof(nlo_configured_parameters)
6873 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
6874 /* TLV for array of uint32 channel_list */
6875 len += WMI_TLV_HDR_SIZE;
6876 /* TLV for nlo_channel_prediction_cfg */
6877 len += WMI_TLV_HDR_SIZE;
6878 /* TLV for candidate score params */
6879 len += sizeof(enlo_candidate_score_params);
6880 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05306881
6882 buf = wmi_buf_alloc(wmi_handle, len);
6883 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306884 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6885 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306886 }
6887
6888 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6889
6890 buf_ptr = (u_int8_t *) cmd;
6891 WMITLV_SET_HDR(&cmd->tlv_header,
6892 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6893 WMITLV_GET_STRUCT_TLVLEN(
6894 wmi_nlo_config_cmd_fixed_param));
6895 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306896
6897 /* set flag to reset if num of networks are 0 */
6898 cmd->flags = (req->num_networks == 0 ?
6899 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306900
6901 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6902
Govind Singhb53420c2016-03-09 14:32:57 +05306903 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306904 WMI_LOGD("SSID count: %d flags: %d",
6905 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306906
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306907 /* Fill nlo_config only when num_networks are non zero */
6908 if (cmd->no_of_ssids) {
6909 /* Fill networks */
6910 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6911 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6912 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306913
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306914 nlo_list = (nlo_configured_parameters *) buf_ptr;
6915 for (i = 0; i < cmd->no_of_ssids; i++) {
6916 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6917 WMITLV_TAG_ARRAY_BYTE,
6918 WMITLV_GET_STRUCT_TLVLEN(
6919 nlo_configured_parameters));
6920 /* Copy ssid and it's length */
6921 nlo_list[i].ssid.valid = true;
6922 nlo_list[i].ssid.ssid.ssid_len =
6923 req->networks[i].ssid.length;
6924 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
6925 req->networks[i].ssid.mac_ssid,
6926 nlo_list[i].ssid.ssid.ssid_len);
6927 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
6928 nlo_list[i].ssid.ssid.ssid_len,
6929 (char *) nlo_list[i].ssid.ssid.ssid,
6930 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306931
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306932 /* Copy pno flags */
6933 nlo_list[i].bcast_nw_type.valid = true;
6934 nlo_list[i].bcast_nw_type.bcast_nw_type =
6935 req->networks[i].flags;
6936 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306937 nlo_list[i].bcast_nw_type.bcast_nw_type);
6938
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306939 /* Copy auth bit field */
6940 nlo_list[i].auth_type.valid = true;
6941 nlo_list[i].auth_type.auth_type =
6942 req->networks[i].auth_bit_field;
6943 WMI_LOGD("Auth bit field (%u)",
6944 nlo_list[i].auth_type.auth_type);
6945 }
6946
6947 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6948 /* Fill the channel list */
6949 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6950 buf_ptr += WMI_TLV_HDR_SIZE;
6951
6952 /* Fill prediction_param */
6953 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6954 buf_ptr += WMI_TLV_HDR_SIZE;
6955
6956 /* Fill epno candidate score params */
6957 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
6958 WMITLV_SET_HDR(buf_ptr,
6959 WMITLV_TAG_STRUC_enlo_candidate_score_param,
6960 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
6961 cand_score_params->min5GHz_rssi =
6962 req->min_5ghz_rssi;
6963 cand_score_params->min24GHz_rssi =
6964 req->min_24ghz_rssi;
6965 cand_score_params->initial_score_max =
6966 req->initial_score_max;
6967 cand_score_params->current_connection_bonus =
6968 req->current_connection_bonus;
6969 cand_score_params->same_network_bonus =
6970 req->same_network_bonus;
6971 cand_score_params->secure_bonus =
6972 req->secure_bonus;
6973 cand_score_params->band5GHz_bonus =
6974 req->band_5ghz_bonus;
6975 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306976 }
6977
Govind Singh4eacd2b2016-03-07 14:24:22 +05306978 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306979 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306980 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306981 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306982 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306983 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306984 }
6985
Govind Singhb53420c2016-03-09 14:32:57 +05306986 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306987 req->session_id);
6988
Govind Singh67922e82016-04-01 16:48:57 +05306989 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306990}
6991
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306992
Govind Singh4eacd2b2016-03-07 14:24:22 +05306993/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
6994 * @wmi_handle: wmi handle
6995 * @ipa_offload: ipa offload control parameter
6996 *
6997 * Returns: 0 on success, error number otherwise
6998 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306999static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307000 struct ipa_offload_control_params *ipa_offload)
7001{
7002 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7003 wmi_buf_t wmi_buf;
7004 uint32_t len;
7005 u_int8_t *buf_ptr;
7006
7007 len = sizeof(*cmd);
7008 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7009 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307010 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7011 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307012 }
7013
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007014 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307015 ipa_offload->offload_type, ipa_offload->enable);
7016
7017 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7018
7019 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7020 WMITLV_SET_HDR(&cmd->tlv_header,
7021 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7022 WMITLV_GET_STRUCT_TLVLEN(
7023 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7024
7025 cmd->offload_type = ipa_offload->offload_type;
7026 cmd->vdev_id = ipa_offload->vdev_id;
7027 cmd->enable = ipa_offload->enable;
7028
7029 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7030 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307031 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307032 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307033 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307034 }
7035
Govind Singhb53420c2016-03-09 14:32:57 +05307036 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307037}
7038
7039/**
7040 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
7041 * @wmi_handle: wmi handle
7042 * @pgetcapab: get capabilities params
7043 *
7044 * This function send request to fw to get extscan capabilities.
7045 *
7046 * Return: CDF status
7047 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307048static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307049 struct extscan_capabilities_params *pgetcapab)
7050{
7051 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
7052 wmi_buf_t wmi_buf;
7053 uint32_t len;
7054 uint8_t *buf_ptr;
7055
7056 len = sizeof(*cmd);
7057 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7058 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307059 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7060 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307061 }
7062 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7063
7064 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
7065 WMITLV_SET_HDR(&cmd->tlv_header,
7066 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
7067 WMITLV_GET_STRUCT_TLVLEN
7068 (wmi_extscan_get_capabilities_cmd_fixed_param));
7069
7070 cmd->request_id = pgetcapab->request_id;
7071
7072 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7073 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307074 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307075 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307076 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307077 }
Govind Singhb53420c2016-03-09 14:32:57 +05307078 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307079}
7080
7081/**
7082 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
7083 * @wmi_handle: wmi handle
7084 * @pcached_results: cached results parameters
7085 *
7086 * This function send request to fw to get cached results.
7087 *
7088 * Return: CDF status
7089 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307090static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307091 struct extscan_cached_result_params *pcached_results)
7092{
7093 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
7094 wmi_buf_t wmi_buf;
7095 uint32_t len;
7096 uint8_t *buf_ptr;
7097
7098 len = sizeof(*cmd);
7099 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7100 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307101 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7102 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307103 }
7104 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7105
7106 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
7107 WMITLV_SET_HDR(&cmd->tlv_header,
7108 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
7109 WMITLV_GET_STRUCT_TLVLEN
7110 (wmi_extscan_get_cached_results_cmd_fixed_param));
7111
7112 cmd->request_id = pcached_results->request_id;
7113 cmd->vdev_id = pcached_results->session_id;
7114 cmd->control_flags = pcached_results->flush;
7115
7116 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7117 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307118 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307119 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307120 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307121 }
Govind Singhb53420c2016-03-09 14:32:57 +05307122 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307123}
7124
7125/**
7126 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
7127 * @wmi_handle: wmi handle
7128 * @reset_req: Reset change request params
7129 *
7130 * This function sends stop change monitor request to fw.
7131 *
7132 * Return: CDF status
7133 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307134static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307135 struct extscan_capabilities_reset_params *reset_req)
7136{
7137 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7138 wmi_buf_t wmi_buf;
7139 uint32_t len;
7140 uint8_t *buf_ptr;
7141 int change_list = 0;
7142
7143 len = sizeof(*cmd);
7144
7145 /* reset significant change tlv is set to 0 */
7146 len += WMI_TLV_HDR_SIZE;
7147 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
7148 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7149 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307150 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7151 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307152 }
7153 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7154
7155 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7156 buf_ptr;
7157 WMITLV_SET_HDR(&cmd->tlv_header,
7158 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7159 WMITLV_GET_STRUCT_TLVLEN
7160 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7161
7162 cmd->request_id = reset_req->request_id;
7163 cmd->vdev_id = reset_req->session_id;
7164 cmd->mode = 0;
7165
7166 buf_ptr += sizeof(*cmd);
7167 WMITLV_SET_HDR(buf_ptr,
7168 WMITLV_TAG_ARRAY_STRUC,
7169 change_list *
7170 sizeof(wmi_extscan_wlan_change_bssid_param));
7171 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
7172 sizeof
7173 (wmi_extscan_wlan_change_bssid_param));
7174
7175 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7176 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307177 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307178 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307179 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307180 }
Govind Singhb53420c2016-03-09 14:32:57 +05307181 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307182}
7183
7184/**
7185 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
7186 * @wmi_handle: wmi handle
7187 * @psigchange: change monitor request params
7188 * @buf: wmi buffer
7189 * @buf_len: buffer length
7190 *
7191 * This function fills elements of change monitor request buffer.
7192 *
7193 * Return: CDF status
7194 */
Govind Singhb53420c2016-03-09 14:32:57 +05307195static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307196 struct extscan_set_sig_changereq_params
7197 *psigchange, wmi_buf_t *buf, int *buf_len)
7198{
7199 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7200 wmi_extscan_wlan_change_bssid_param *dest_chglist;
7201 uint8_t *buf_ptr;
7202 int j;
7203 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007204 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307205 struct ap_threshold_params *src_ap = psigchange->ap;
7206
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007207 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307208 WMI_LOGE("%s: Invalid number of bssid's", __func__);
7209 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307210 }
7211 len += WMI_TLV_HDR_SIZE;
7212 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
7213
7214 *buf = wmi_buf_alloc(wmi_handle, len);
7215 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307216 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307217 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307218 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307219 }
7220 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7221 cmd =
7222 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7223 buf_ptr;
7224 WMITLV_SET_HDR(&cmd->tlv_header,
7225 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7226 WMITLV_GET_STRUCT_TLVLEN
7227 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7228
7229 cmd->request_id = psigchange->request_id;
7230 cmd->vdev_id = psigchange->session_id;
7231 cmd->total_entries = numap;
7232 cmd->mode = 1;
7233 cmd->num_entries_in_page = numap;
7234 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
7235 cmd->max_rssi_samples = psigchange->rssi_sample_size;
7236 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
7237 cmd->max_out_of_range_count = psigchange->min_breaching;
7238
7239 buf_ptr += sizeof(*cmd);
7240 WMITLV_SET_HDR(buf_ptr,
7241 WMITLV_TAG_ARRAY_STRUC,
7242 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7243 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
7244 (buf_ptr + WMI_TLV_HDR_SIZE);
7245
7246 for (j = 0; j < numap; j++) {
7247 WMITLV_SET_HDR(dest_chglist,
7248 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7249 WMITLV_GET_STRUCT_TLVLEN
7250 (wmi_extscan_wlan_change_bssid_param));
7251
7252 dest_chglist->lower_rssi_limit = src_ap->low;
7253 dest_chglist->upper_rssi_limit = src_ap->high;
7254 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
7255 &dest_chglist->bssid);
7256
Govind Singhb53420c2016-03-09 14:32:57 +05307257 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307258 dest_chglist->lower_rssi_limit);
7259 dest_chglist++;
7260 src_ap++;
7261 }
7262 buf_ptr += WMI_TLV_HDR_SIZE +
7263 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7264 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307265 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307266}
7267
7268/**
7269 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
7270 * @wmi_handle: wmi handle
7271 * @psigchange: change monitor request params
7272 *
7273 * This function sends start change monitor request to fw.
7274 *
7275 * Return: CDF status
7276 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307277static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307278 struct extscan_set_sig_changereq_params *
7279 psigchange)
7280{
Govind Singhb53420c2016-03-09 14:32:57 +05307281 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307282 wmi_buf_t buf;
7283 int len;
7284
7285
Govind Singhb53420c2016-03-09 14:32:57 +05307286 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307287 psigchange, &buf,
7288 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307289 if (qdf_status != QDF_STATUS_SUCCESS) {
7290 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307291 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307292 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307293 }
7294 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307295 WMI_LOGE("%s: Failed to get buffer", __func__);
7296 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307297 }
7298 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7299 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307300 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307301 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307302 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307303 }
Govind Singhb53420c2016-03-09 14:32:57 +05307304 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307305}
7306
7307/**
7308 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
7309 * @wmi_handle: wmi handle
7310 * @photlist_reset: hotlist reset params
7311 *
7312 * This function configures hotlist monitor to stop in fw.
7313 *
7314 * Return: CDF status
7315 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307316static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307317 struct extscan_bssid_hotlist_reset_params *photlist_reset)
7318{
7319 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
7320 wmi_buf_t wmi_buf;
7321 uint32_t len;
7322 uint8_t *buf_ptr;
7323 int hotlist_entries = 0;
7324
7325 len = sizeof(*cmd);
7326
7327 /* reset bssid hotlist with tlv set to 0 */
7328 len += WMI_TLV_HDR_SIZE;
7329 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
7330
7331 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7332 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307333 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7334 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307335 }
7336
7337 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7338 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
7339 buf_ptr;
7340 WMITLV_SET_HDR(&cmd->tlv_header,
7341 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
7342 WMITLV_GET_STRUCT_TLVLEN
7343 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
7344
7345 cmd->request_id = photlist_reset->request_id;
7346 cmd->vdev_id = photlist_reset->session_id;
7347 cmd->mode = 0;
7348
7349 buf_ptr += sizeof(*cmd);
7350 WMITLV_SET_HDR(buf_ptr,
7351 WMITLV_TAG_ARRAY_STRUC,
7352 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7353 buf_ptr += WMI_TLV_HDR_SIZE +
7354 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7355
7356 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7357 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307358 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307359 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307360 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307361 }
Govind Singhb53420c2016-03-09 14:32:57 +05307362 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307363}
7364
7365/**
7366 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
7367 * @wmi_handle: wmi handle
7368 * @pstopcmd: stop scan command request params
7369 *
7370 * This function sends stop extscan request to fw.
7371 *
7372 * Return: CDF Status.
7373 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307374static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307375 struct extscan_stop_req_params *pstopcmd)
7376{
7377 wmi_extscan_stop_cmd_fixed_param *cmd;
7378 wmi_buf_t wmi_buf;
7379 uint32_t len;
7380 uint8_t *buf_ptr;
7381
7382 len = sizeof(*cmd);
7383 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7384 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307385 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7386 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307387 }
7388 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7389 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
7390 WMITLV_SET_HDR(&cmd->tlv_header,
7391 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
7392 WMITLV_GET_STRUCT_TLVLEN
7393 (wmi_extscan_stop_cmd_fixed_param));
7394
7395 cmd->request_id = pstopcmd->request_id;
7396 cmd->vdev_id = pstopcmd->session_id;
7397
7398 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7399 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307400 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307401 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307402 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307403 }
7404
Govind Singhb53420c2016-03-09 14:32:57 +05307405 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307406}
7407
7408/**
7409 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
7410 * @wmi_handle: wmi handle
7411 * @pstart: scan command request params
7412 * @buf: event buffer
7413 * @buf_len: length of buffer
7414 *
7415 * This function fills individual elements of extscan request and
7416 * TLV for buckets, channel list.
7417 *
7418 * Return: CDF Status.
7419 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007420static
Govind Singhb53420c2016-03-09 14:32:57 +05307421QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307422 struct wifi_scan_cmd_req_params *pstart,
7423 wmi_buf_t *buf, int *buf_len)
7424{
7425 wmi_extscan_start_cmd_fixed_param *cmd;
7426 wmi_extscan_bucket *dest_blist;
7427 wmi_extscan_bucket_channel *dest_clist;
7428 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
7429 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
7430 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
7431
7432 uint8_t *buf_ptr;
7433 int i, k, count = 0;
7434 int len = sizeof(*cmd);
7435 int nbuckets = pstart->numBuckets;
7436 int nchannels = 0;
7437
7438 /* These TLV's are are NULL by default */
7439 uint32_t ie_len_with_pad = 0;
7440 int num_ssid = 0;
7441 int num_bssid = 0;
7442 int ie_len = 0;
7443
7444 uint32_t base_period = pstart->basePeriod;
7445
7446 /* TLV placeholder for ssid_list (NULL) */
7447 len += WMI_TLV_HDR_SIZE;
7448 len += num_ssid * sizeof(wmi_ssid);
7449
7450 /* TLV placeholder for bssid_list (NULL) */
7451 len += WMI_TLV_HDR_SIZE;
7452 len += num_bssid * sizeof(wmi_mac_addr);
7453
7454 /* TLV placeholder for ie_data (NULL) */
7455 len += WMI_TLV_HDR_SIZE;
7456 len += ie_len * sizeof(uint32_t);
7457
7458 /* TLV placeholder for bucket */
7459 len += WMI_TLV_HDR_SIZE;
7460 len += nbuckets * sizeof(wmi_extscan_bucket);
7461
7462 /* TLV channel placeholder */
7463 len += WMI_TLV_HDR_SIZE;
7464 for (i = 0; i < nbuckets; i++) {
7465 nchannels += src_bucket->numChannels;
7466 src_bucket++;
7467 }
7468
Govind Singhb53420c2016-03-09 14:32:57 +05307469 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307470 __func__, nbuckets, nchannels);
7471 len += nchannels * sizeof(wmi_extscan_bucket_channel);
7472 /* Allocate the memory */
7473 *buf = wmi_buf_alloc(wmi_handle, len);
7474 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307475 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307476 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307477 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307478 }
7479 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7480 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
7481 WMITLV_SET_HDR(&cmd->tlv_header,
7482 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
7483 WMITLV_GET_STRUCT_TLVLEN
7484 (wmi_extscan_start_cmd_fixed_param));
7485
7486 cmd->request_id = pstart->requestId;
7487 cmd->vdev_id = pstart->sessionId;
7488 cmd->base_period = pstart->basePeriod;
7489 cmd->num_buckets = nbuckets;
7490 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05307491 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307492 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05307493 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307494 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05307495#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05307496 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
7497 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05307498 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
7499 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
7500#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307501 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7502
7503 /* The max dwell time is retrieved from the first channel
7504 * of the first bucket and kept common for all channels.
7505 */
7506 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
7507 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
7508 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
7509 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
7510 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7511 cmd->max_table_usage = pstart->report_threshold_percent;
7512 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
7513
7514 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05307515 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307516 cmd->probe_delay = 0;
7517 cmd->probe_spacing_time = 0;
7518 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307519 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
7520 WMI_SCAN_ADD_CCK_RATES |
7521 WMI_SCAN_ADD_OFDM_RATES |
7522 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
7523 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05307524 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
7525 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05307526 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307527 cmd->num_ssids = 0;
7528 cmd->num_bssid = 0;
7529 cmd->ie_len = 0;
7530 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
7531 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7532
7533 buf_ptr += sizeof(*cmd);
7534 WMITLV_SET_HDR(buf_ptr,
7535 WMITLV_TAG_ARRAY_FIXED_STRUC,
7536 num_ssid * sizeof(wmi_ssid));
7537 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7538
7539 WMITLV_SET_HDR(buf_ptr,
7540 WMITLV_TAG_ARRAY_FIXED_STRUC,
7541 num_bssid * sizeof(wmi_mac_addr));
7542 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7543
7544 ie_len_with_pad = 0;
7545 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7546 ie_len_with_pad);
7547 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7548
7549 WMITLV_SET_HDR(buf_ptr,
7550 WMITLV_TAG_ARRAY_STRUC,
7551 nbuckets * sizeof(wmi_extscan_bucket));
7552 dest_blist = (wmi_extscan_bucket *)
7553 (buf_ptr + WMI_TLV_HDR_SIZE);
7554 src_bucket = pstart->buckets;
7555
7556 /* Retrieve scanning information from each bucket and
7557 * channels and send it to the target
7558 */
7559 for (i = 0; i < nbuckets; i++) {
7560 WMITLV_SET_HDR(dest_blist,
7561 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7562 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7563
7564 dest_blist->bucket_id = src_bucket->bucket;
7565 dest_blist->base_period_multiplier =
7566 src_bucket->period / base_period;
7567 dest_blist->min_period = src_bucket->period;
7568 dest_blist->max_period = src_bucket->max_period;
7569 dest_blist->exp_backoff = src_bucket->exponent;
7570 dest_blist->exp_max_step_count = src_bucket->step_count;
7571 dest_blist->channel_band = src_bucket->band;
7572 dest_blist->num_channels = src_bucket->numChannels;
7573 dest_blist->notify_extscan_events = 0;
7574
7575 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7576 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007577 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7578 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307579
7580 if (src_bucket->reportEvents &
7581 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7582 dest_blist->forwarding_flags =
7583 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7584 dest_blist->notify_extscan_events |=
7585 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7586 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7587 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7588 } else {
7589 dest_blist->forwarding_flags =
7590 WMI_EXTSCAN_NO_FORWARDING;
7591 }
7592
7593 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7594 dest_blist->configuration_flags = 0;
7595 else
7596 dest_blist->configuration_flags =
7597 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7598
Govind Singhb53420c2016-03-09 14:32:57 +05307599 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307600 __func__, dest_blist->notify_extscan_events,
7601 dest_blist->configuration_flags,
7602 dest_blist->forwarding_flags);
7603
7604 dest_blist->min_dwell_time_active =
7605 src_bucket->min_dwell_time_active;
7606 dest_blist->max_dwell_time_active =
7607 src_bucket->max_dwell_time_active;
7608 dest_blist->min_dwell_time_passive =
7609 src_bucket->min_dwell_time_passive;
7610 dest_blist->max_dwell_time_passive =
7611 src_bucket->max_dwell_time_passive;
7612 src_channel = src_bucket->channels;
7613
7614 /* save the channel info to later populate
7615 * the channel TLV
7616 */
7617 for (k = 0; k < src_bucket->numChannels; k++) {
7618 save_channel[count++].channel = src_channel->channel;
7619 src_channel++;
7620 }
7621 dest_blist++;
7622 src_bucket++;
7623 }
7624 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7625 WMITLV_SET_HDR(buf_ptr,
7626 WMITLV_TAG_ARRAY_STRUC,
7627 nchannels * sizeof(wmi_extscan_bucket_channel));
7628 dest_clist = (wmi_extscan_bucket_channel *)
7629 (buf_ptr + WMI_TLV_HDR_SIZE);
7630
7631 /* Active or passive scan is based on the bucket dwell time
7632 * and channel specific active,passive scans are not
7633 * supported yet
7634 */
7635 for (i = 0; i < nchannels; i++) {
7636 WMITLV_SET_HDR(dest_clist,
7637 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7638 WMITLV_GET_STRUCT_TLVLEN
7639 (wmi_extscan_bucket_channel));
7640 dest_clist->channel = save_channel[i].channel;
7641 dest_clist++;
7642 }
7643 buf_ptr += WMI_TLV_HDR_SIZE +
7644 (nchannels * sizeof(wmi_extscan_bucket_channel));
7645 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307646 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307647}
7648
7649/**
7650 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7651 * @wmi_handle: wmi handle
7652 * @pstart: scan command request params
7653 *
7654 * This function sends start extscan request to fw.
7655 *
7656 * Return: CDF Status.
7657 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307658static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307659 struct wifi_scan_cmd_req_params *pstart)
7660{
Govind Singhb53420c2016-03-09 14:32:57 +05307661 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307662 wmi_buf_t buf;
7663 int len;
7664
7665 /* Fill individual elements of extscan request and
7666 * TLV for buckets, channel list.
7667 */
Govind Singhb53420c2016-03-09 14:32:57 +05307668 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307669 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307670 if (qdf_status != QDF_STATUS_SUCCESS) {
7671 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7672 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307673 }
7674 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307675 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307676 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307677 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307678 }
7679 if (wmi_unified_cmd_send(wmi_handle, buf,
7680 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307681 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307682 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307683 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307684 }
7685
Govind Singhb53420c2016-03-09 14:32:57 +05307686 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307687}
7688
7689/**
7690 * send_plm_stop_cmd_tlv() - plm stop request
7691 * @wmi_handle: wmi handle
7692 * @plm: plm request parameters
7693 *
7694 * This function request FW to stop PLM.
7695 *
7696 * Return: CDF status
7697 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307698static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307699 const struct plm_req_params *plm)
7700{
7701 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7702 int32_t len;
7703 wmi_buf_t buf;
7704 uint8_t *buf_ptr;
7705 int ret;
7706
7707 len = sizeof(*cmd);
7708 buf = wmi_buf_alloc(wmi_handle, len);
7709 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307710 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7711 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307712 }
7713
7714 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7715
7716 buf_ptr = (uint8_t *) cmd;
7717
7718 WMITLV_SET_HDR(&cmd->tlv_header,
7719 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7720 WMITLV_GET_STRUCT_TLVLEN
7721 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7722
7723 cmd->vdev_id = plm->session_id;
7724
7725 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307726 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307727
7728 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7729 WMI_VDEV_PLMREQ_STOP_CMDID);
7730 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307731 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307732 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307733 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307734 }
7735
Govind Singhb53420c2016-03-09 14:32:57 +05307736 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307737}
7738
7739/**
7740 * send_plm_start_cmd_tlv() - plm start request
7741 * @wmi_handle: wmi handle
7742 * @plm: plm request parameters
7743 *
7744 * This function request FW to start PLM.
7745 *
7746 * Return: CDF status
7747 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307748static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307749 const struct plm_req_params *plm,
7750 uint32_t *gchannel_list)
7751{
7752 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7753 uint32_t *channel_list;
7754 int32_t len;
7755 wmi_buf_t buf;
7756 uint8_t *buf_ptr;
7757 uint8_t count;
7758 int ret;
7759
7760 /* TLV place holder for channel_list */
7761 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7762 len += sizeof(uint32_t) * plm->plm_num_ch;
7763
7764 buf = wmi_buf_alloc(wmi_handle, len);
7765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307766 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7767 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307768 }
7769 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7770
7771 buf_ptr = (uint8_t *) cmd;
7772
7773 WMITLV_SET_HDR(&cmd->tlv_header,
7774 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7775 WMITLV_GET_STRUCT_TLVLEN
7776 (wmi_vdev_plmreq_start_cmd_fixed_param));
7777
7778 cmd->vdev_id = plm->session_id;
7779
7780 cmd->meas_token = plm->meas_token;
7781 cmd->dialog_token = plm->diag_token;
7782 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307783 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307784 cmd->off_duration = plm->meas_duration;
7785 cmd->burst_cycle = plm->burst_len;
7786 cmd->tx_power = plm->desired_tx_pwr;
7787 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7788 cmd->num_chans = plm->plm_num_ch;
7789
7790 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7791
Govind Singhb53420c2016-03-09 14:32:57 +05307792 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7793 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7794 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7795 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7796 WMI_LOGD("off_duration: %d", cmd->off_duration);
7797 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7798 WMI_LOGD("tx_power: %d", cmd->tx_power);
7799 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307800
7801 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7802 (cmd->num_chans * sizeof(uint32_t)));
7803
7804 buf_ptr += WMI_TLV_HDR_SIZE;
7805 if (cmd->num_chans) {
7806 channel_list = (uint32_t *) buf_ptr;
7807 for (count = 0; count < cmd->num_chans; count++) {
7808 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307809 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307810 channel_list[count] =
7811 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307812 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307813 }
7814 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7815 }
7816
7817 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7818 WMI_VDEV_PLMREQ_START_CMDID);
7819 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307820 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307821 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307822 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307823 }
7824
Govind Singhb53420c2016-03-09 14:32:57 +05307825 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307826}
7827
7828/**
7829 * send_pno_stop_cmd_tlv() - PNO stop request
7830 * @wmi_handle: wmi handle
7831 * @vdev_id: vdev id
7832 *
7833 * This function request FW to stop ongoing PNO operation.
7834 *
7835 * Return: CDF status
7836 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307837static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307838{
7839 wmi_nlo_config_cmd_fixed_param *cmd;
7840 int32_t len = sizeof(*cmd);
7841 wmi_buf_t buf;
7842 uint8_t *buf_ptr;
7843 int ret;
7844
7845 /*
7846 * TLV place holder for array of structures nlo_configured_parameters
7847 * TLV place holder for array of uint32_t channel_list
7848 * TLV place holder for chnl prediction cfg
7849 */
7850 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7851 buf = wmi_buf_alloc(wmi_handle, len);
7852 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307853 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7854 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307855 }
7856
7857 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7858 buf_ptr = (uint8_t *) cmd;
7859
7860 WMITLV_SET_HDR(&cmd->tlv_header,
7861 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7862 WMITLV_GET_STRUCT_TLVLEN
7863 (wmi_nlo_config_cmd_fixed_param));
7864
7865 cmd->vdev_id = vdev_id;
7866 cmd->flags = WMI_NLO_CONFIG_STOP;
7867 buf_ptr += sizeof(*cmd);
7868
7869 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7870 buf_ptr += WMI_TLV_HDR_SIZE;
7871
7872 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7873 buf_ptr += WMI_TLV_HDR_SIZE;
7874
7875 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7876 buf_ptr += WMI_TLV_HDR_SIZE;
7877
7878
7879 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7880 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7881 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307882 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307883 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307884 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307885 }
7886
Govind Singhb53420c2016-03-09 14:32:57 +05307887 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307888}
7889
7890/**
Govind Singhccb0c272016-04-01 16:30:08 +05307891 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7892 * @buf_ptr: Buffer passed by upper layers
7893 * @pno: Buffer to be sent to the firmware
7894 *
7895 * Copy the PNO Channel prediction configuration parameters
7896 * passed by the upper layers to a WMI format TLV and send it
7897 * down to the firmware.
7898 *
7899 * Return: None
7900 */
7901static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7902 struct pno_scan_req_params *pno)
7903{
7904 nlo_channel_prediction_cfg *channel_prediction_cfg =
7905 (nlo_channel_prediction_cfg *) buf_ptr;
7906 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7907 WMITLV_TAG_ARRAY_BYTE,
7908 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307909#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307910 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7911 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7912 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7913 channel_prediction_cfg->full_scan_period_ms =
7914 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307915#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307916 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7917 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7918 channel_prediction_cfg->enable,
7919 channel_prediction_cfg->top_k_num,
7920 channel_prediction_cfg->stationary_threshold,
7921 channel_prediction_cfg->full_scan_period_ms);
7922}
7923
7924/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007925 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7926 * @wmi_handle: wmi handle
7927 * @params: configuration parameters
7928 *
7929 * Return: QDF_STATUS
7930 */
7931static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7932 struct nlo_mawc_params *params)
7933{
7934 wmi_buf_t buf = NULL;
7935 QDF_STATUS status;
7936 int len;
7937 uint8_t *buf_ptr;
7938 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7939
7940 len = sizeof(*wmi_nlo_mawc_params);
7941 buf = wmi_buf_alloc(wmi_handle, len);
7942 if (!buf) {
7943 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7944 return QDF_STATUS_E_NOMEM;
7945 }
7946
7947 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7948 wmi_nlo_mawc_params =
7949 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7950 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7951 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7952 WMITLV_GET_STRUCT_TLVLEN
7953 (wmi_nlo_configure_mawc_cmd_fixed_param));
7954 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7955 if (params->enable)
7956 wmi_nlo_mawc_params->enable = 1;
7957 else
7958 wmi_nlo_mawc_params->enable = 0;
7959 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7960 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7961 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007962 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7963 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7964 wmi_nlo_mawc_params->exp_backoff_ratio,
7965 wmi_nlo_mawc_params->init_scan_interval,
7966 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007967
7968 status = wmi_unified_cmd_send(wmi_handle, buf,
7969 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7970 if (QDF_IS_STATUS_ERROR(status)) {
7971 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7972 status);
7973 wmi_buf_free(buf);
7974 return QDF_STATUS_E_FAILURE;
7975 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007976
7977 return QDF_STATUS_SUCCESS;
7978}
7979
7980/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307981 * send_pno_start_cmd_tlv() - PNO start request
7982 * @wmi_handle: wmi handle
7983 * @pno: PNO request
7984 *
7985 * This function request FW to start PNO request.
7986 * Request: CDF status
7987 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307988static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307989 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307990{
7991 wmi_nlo_config_cmd_fixed_param *cmd;
7992 nlo_configured_parameters *nlo_list;
7993 uint32_t *channel_list;
7994 int32_t len;
7995 wmi_buf_t buf;
7996 uint8_t *buf_ptr;
7997 uint8_t i;
7998 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307999 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308000 connected_nlo_rssi_params *nlo_relative_rssi;
8001 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308002
8003 /*
8004 * TLV place holder for array nlo_configured_parameters(nlo_list)
8005 * TLV place holder for array of uint32_t channel_list
8006 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308007 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308008 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05308009 */
8010 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308011 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308012 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308013
Abhishek Singh5987b632017-03-03 22:09:07 +05308014 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308015 WMI_NLO_MAX_CHAN);
8016 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05308017 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308018 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308019 len += sizeof(enlo_candidate_score_params);
8020 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308021 len += sizeof(connected_nlo_rssi_params);
8022 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308023
8024 buf = wmi_buf_alloc(wmi_handle, len);
8025 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308026 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8027 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308028 }
8029
8030 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8031
8032 buf_ptr = (uint8_t *) cmd;
8033 WMITLV_SET_HDR(&cmd->tlv_header,
8034 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8035 WMITLV_GET_STRUCT_TLVLEN
8036 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05308037 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308038 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
8039
Govind Singh87542482016-06-08 19:40:11 +05308040#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05308041 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05308042 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05308043#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05308044 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05308045 cmd->active_dwell_time = pno->active_dwell_time;
8046 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308047
Manjeet Singhcd2dc062016-08-11 15:31:34 +05308048 if (pno->do_passive_scan)
8049 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308050 /* Copy scan interval */
8051 cmd->fast_scan_period = pno->fast_scan_period;
8052 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08008053 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308054 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07008055 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05308056 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308057 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05308058 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308059
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05308060 /* mac randomization attributes */
8061 if (pno->scan_random.randomize) {
8062 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
8063 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
8064 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
8065 pno->scan_random.mac_mask,
8066 &cmd->mac_addr,
8067 &cmd->mac_mask);
8068 }
8069
Govind Singh4eacd2b2016-03-07 14:24:22 +05308070 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
8071
Abhishek Singh5987b632017-03-03 22:09:07 +05308072 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05308073 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308074 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8075 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
8076 buf_ptr += WMI_TLV_HDR_SIZE;
8077
8078 nlo_list = (nlo_configured_parameters *) buf_ptr;
8079 for (i = 0; i < cmd->no_of_ssids; i++) {
8080 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
8081 WMITLV_TAG_ARRAY_BYTE,
8082 WMITLV_GET_STRUCT_TLVLEN
8083 (nlo_configured_parameters));
8084 /* Copy ssid and it's length */
8085 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05308086 nlo_list[i].ssid.ssid.ssid_len =
8087 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05308088 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05308089 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308090 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05308091 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308092 nlo_list[i].ssid.ssid.ssid_len,
8093 (char *)nlo_list[i].ssid.ssid.ssid,
8094 nlo_list[i].ssid.ssid.ssid_len);
8095
8096 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05308097 if (pno->networks_list[i].rssi_thresh &&
8098 pno->networks_list[i].rssi_thresh >
8099 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05308100 nlo_list[i].rssi_cond.valid = true;
8101 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05308102 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05308103 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308104 nlo_list[i].rssi_cond.rssi);
8105 }
8106 nlo_list[i].bcast_nw_type.valid = true;
8107 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05308108 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07008109 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308110 nlo_list[i].bcast_nw_type.bcast_nw_type);
8111 }
8112 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
8113
8114 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05308115 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308116 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05308117 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308118 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8119 (cmd->num_of_channels * sizeof(uint32_t)));
8120 buf_ptr += WMI_TLV_HDR_SIZE;
8121
8122 channel_list = (uint32_t *) buf_ptr;
8123 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05308124 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05308125
8126 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05308127 channel_list[i] =
8128 wlan_chan_to_freq(pno->
8129 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308130
Govind Singhb53420c2016-03-09 14:32:57 +05308131 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308132 }
8133 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
8134 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8135 sizeof(nlo_channel_prediction_cfg));
8136 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05308137 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308138 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308139 /** TODO: Discrete firmware doesn't have command/option to configure
8140 * App IE which comes from wpa_supplicant as of part PNO start request.
8141 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308142 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
8143 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
8144 buf_ptr += sizeof(enlo_candidate_score_params);
8145
8146 if (ie_whitelist->white_list) {
8147 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
8148 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
8149 &cmd->num_vendor_oui,
8150 ie_whitelist);
8151 }
8152
8153 /* ie white list */
8154 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8155 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
8156 buf_ptr += WMI_TLV_HDR_SIZE;
8157 if (cmd->num_vendor_oui != 0) {
8158 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
8159 ie_whitelist->voui);
8160 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
8161 }
8162
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308163 if (pno->relative_rssi_set)
8164 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
8165
8166 /*
8167 * Firmware calculation using connected PNO params:
8168 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
8169 * deduction of rssi_pref for chosen band_pref and
8170 * addition of rssi_pref for remaining bands (other than chosen band).
8171 */
8172 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
8173 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
8174 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
8175 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
8176 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
8177 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
8178 buf_ptr += sizeof(*nlo_relative_rssi);
8179
8180 /*
8181 * As of now Kernel and Host supports one band and rssi preference.
8182 * Firmware supports array of band and rssi preferences
8183 */
8184 cmd->num_cnlo_band_pref = 1;
8185 WMITLV_SET_HDR(buf_ptr,
8186 WMITLV_TAG_ARRAY_STRUC,
8187 cmd->num_cnlo_band_pref *
8188 sizeof(connected_nlo_bss_band_rssi_pref));
8189 buf_ptr += WMI_TLV_HDR_SIZE;
8190
8191 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
8192 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
8193 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
8194 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
8195 WMITLV_GET_STRUCT_TLVLEN(
8196 connected_nlo_bss_band_rssi_pref));
8197 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
8198 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
8199 WMI_LOGI("band_pref %d, rssi_pref %d",
8200 nlo_band_rssi[i].band,
8201 nlo_band_rssi[i].rssi_pref);
8202 }
8203 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
8204
Govind Singh4eacd2b2016-03-07 14:24:22 +05308205 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8206 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8207 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308208 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308209 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308210 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308211 }
8212
Govind Singhb53420c2016-03-09 14:32:57 +05308213 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308214}
8215
8216/* send_set_ric_req_cmd_tlv() - set ric request element
8217 * @wmi_handle: wmi handle
8218 * @msg: message
8219 * @is_add_ts: is addts required
8220 *
8221 * This function sets ric request element for 11r roaming.
8222 *
8223 * Return: CDF status
8224 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308225static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308226 void *msg, uint8_t is_add_ts)
8227{
8228 wmi_ric_request_fixed_param *cmd;
8229 wmi_ric_tspec *tspec_param;
8230 wmi_buf_t buf;
8231 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05308232 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308233 int32_t len = sizeof(wmi_ric_request_fixed_param) +
8234 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
8235
8236 buf = wmi_buf_alloc(wmi_handle, len);
8237 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308238 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8239 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308240 }
8241
8242 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8243
8244 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
8245 WMITLV_SET_HDR(&cmd->tlv_header,
8246 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
8247 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
8248 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07008249 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308250 else
8251 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
8252 cmd->num_ric_request = 1;
8253 cmd->is_add_ric = is_add_ts;
8254
8255 buf_ptr += sizeof(wmi_ric_request_fixed_param);
8256 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
8257
8258 buf_ptr += WMI_TLV_HDR_SIZE;
8259 tspec_param = (wmi_ric_tspec *) buf_ptr;
8260 WMITLV_SET_HDR(&tspec_param->tlv_header,
8261 WMITLV_TAG_STRUC_wmi_ric_tspec,
8262 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
8263
8264 if (is_add_ts)
8265 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05308266#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05308267 else
8268 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05308269#endif
8270 if (ptspecIE) {
8271 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308272#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05308273 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
8274 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308275#else
Govind Singh87542482016-06-08 19:40:11 +05308276 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
8277 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308278#endif /* ANI_LITTLE_BIT_ENDIAN */
8279
Govind Singh87542482016-06-08 19:40:11 +05308280 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
8281 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
8282 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
8283 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
8284 tspec_param->inactivity_interval = ptspecIE->inactInterval;
8285 tspec_param->suspension_interval = ptspecIE->suspendInterval;
8286 tspec_param->svc_start_time = ptspecIE->svcStartTime;
8287 tspec_param->min_data_rate = ptspecIE->minDataRate;
8288 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
8289 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
8290 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
8291 tspec_param->delay_bound = ptspecIE->delayBound;
8292 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8293 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8294 tspec_param->medium_time = 0;
8295 }
Govind Singhb53420c2016-03-09 14:32:57 +05308296 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308297
8298 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8299 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308300 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308301 __func__);
8302 if (is_add_ts)
8303 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308304 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308305 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308306 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308307 }
8308
Govind Singhb53420c2016-03-09 14:32:57 +05308309 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308310}
8311
8312/**
8313 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8314 * @wmi_handle: wmi handle
8315 * @clear_req: ll stats clear request command params
8316 *
Govind Singhb53420c2016-03-09 14:32:57 +05308317 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308318 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308319static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308320 const struct ll_stats_clear_params *clear_req,
8321 uint8_t addr[IEEE80211_ADDR_LEN])
8322{
8323 wmi_clear_link_stats_cmd_fixed_param *cmd;
8324 int32_t len;
8325 wmi_buf_t buf;
8326 uint8_t *buf_ptr;
8327 int ret;
8328
8329 len = sizeof(*cmd);
8330 buf = wmi_buf_alloc(wmi_handle, len);
8331
8332 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308333 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8334 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308335 }
8336
8337 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308338 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308339 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8340
8341 WMITLV_SET_HDR(&cmd->tlv_header,
8342 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8343 WMITLV_GET_STRUCT_TLVLEN
8344 (wmi_clear_link_stats_cmd_fixed_param));
8345
8346 cmd->stop_stats_collection_req = clear_req->stop_req;
8347 cmd->vdev_id = clear_req->sta_id;
8348 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8349
8350 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8351 &cmd->peer_macaddr);
8352
Govind Singhb53420c2016-03-09 14:32:57 +05308353 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8354 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8355 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8356 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8357 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308358 cmd->peer_macaddr); */
8359
8360 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8361 WMI_CLEAR_LINK_STATS_CMDID);
8362 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308363 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308364 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308365 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308366 }
8367
Govind Singhb53420c2016-03-09 14:32:57 +05308368 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8369 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308370}
8371
8372/**
8373 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8374 * @wmi_handle: wmi handle
8375 * @setReq: ll stats set request command params
8376 *
Govind Singhb53420c2016-03-09 14:32:57 +05308377 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308378 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308379static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308380 const struct ll_stats_set_params *set_req)
8381{
8382 wmi_start_link_stats_cmd_fixed_param *cmd;
8383 int32_t len;
8384 wmi_buf_t buf;
8385 uint8_t *buf_ptr;
8386 int ret;
8387
8388 len = sizeof(*cmd);
8389 buf = wmi_buf_alloc(wmi_handle, len);
8390
8391 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308392 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8393 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308394 }
8395
8396 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308397 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308398 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8399
8400 WMITLV_SET_HDR(&cmd->tlv_header,
8401 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8402 WMITLV_GET_STRUCT_TLVLEN
8403 (wmi_start_link_stats_cmd_fixed_param));
8404
8405 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8406 cmd->aggressive_statistics_gathering =
8407 set_req->aggressive_statistics_gathering;
8408
Govind Singhb53420c2016-03-09 14:32:57 +05308409 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8410 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8411 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308412
8413 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8414 WMI_START_LINK_STATS_CMDID);
8415 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308416 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308417 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308418 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308419 }
8420
Govind Singhb53420c2016-03-09 14:32:57 +05308421 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308422}
8423
8424/**
8425 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8426 * @wmi_handle:wmi handle
8427 * @get_req:ll stats get request command params
8428 * @addr: mac address
8429 *
Govind Singhb53420c2016-03-09 14:32:57 +05308430 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308431 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308432static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308433 const struct ll_stats_get_params *get_req,
8434 uint8_t addr[IEEE80211_ADDR_LEN])
8435{
8436 wmi_request_link_stats_cmd_fixed_param *cmd;
8437 int32_t len;
8438 wmi_buf_t buf;
8439 uint8_t *buf_ptr;
8440 int ret;
8441
8442 len = sizeof(*cmd);
8443 buf = wmi_buf_alloc(wmi_handle, len);
8444
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308445 if (!buf) {
8446 WMI_LOGE("%s: buf allocation failed", __func__);
8447 return QDF_STATUS_E_NOMEM;
8448 }
8449
Govind Singh4eacd2b2016-03-07 14:24:22 +05308450 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308451 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308452 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8453
8454 WMITLV_SET_HDR(&cmd->tlv_header,
8455 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8456 WMITLV_GET_STRUCT_TLVLEN
8457 (wmi_request_link_stats_cmd_fixed_param));
8458
8459 cmd->request_id = get_req->req_id;
8460 cmd->stats_type = get_req->param_id_mask;
8461 cmd->vdev_id = get_req->sta_id;
8462
8463 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8464 &cmd->peer_macaddr);
8465
Govind Singhb53420c2016-03-09 14:32:57 +05308466 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008467 WMI_LOGD("Request ID : %u", cmd->request_id);
8468 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308469 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8470 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308471
8472 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8473 WMI_REQUEST_LINK_STATS_CMDID);
8474 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308475 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308476 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308477 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308478 }
8479
Govind Singhb53420c2016-03-09 14:32:57 +05308480 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308481}
8482
Govind Singh4eacd2b2016-03-07 14:24:22 +05308483
Govind Singh20c5dac2016-03-07 15:33:31 +05308484/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308485 * send_congestion_cmd_tlv() - send request to fw to get CCA
8486 * @wmi_handle: wmi handle
8487 * @vdev_id: vdev id
8488 *
8489 * Return: CDF status
8490 */
8491static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
8492 A_UINT8 vdev_id)
8493{
8494 wmi_buf_t buf;
8495 wmi_request_stats_cmd_fixed_param *cmd;
8496 uint8_t len;
8497 uint8_t *buf_ptr;
8498
8499 len = sizeof(*cmd);
8500 buf = wmi_buf_alloc(wmi_handle, len);
8501 if (!buf) {
8502 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8503 return QDF_STATUS_E_FAILURE;
8504 }
8505
8506 buf_ptr = wmi_buf_data(buf);
8507 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8508 WMITLV_SET_HDR(&cmd->tlv_header,
8509 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8510 WMITLV_GET_STRUCT_TLVLEN
8511 (wmi_request_stats_cmd_fixed_param));
8512
8513 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8514 cmd->vdev_id = vdev_id;
8515 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8516 cmd->vdev_id, cmd->stats_id);
8517
8518 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8519 WMI_REQUEST_STATS_CMDID)) {
8520 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8521 __func__);
8522 wmi_buf_free(buf);
8523 return QDF_STATUS_E_FAILURE;
8524 }
8525
8526 return QDF_STATUS_SUCCESS;
8527}
8528
8529/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308530 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8531 * @wmi_handle: wmi handle
8532 * @rssi_req: get RSSI request
8533 *
8534 * Return: CDF status
8535 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308536static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308537{
8538 wmi_buf_t buf;
8539 wmi_request_stats_cmd_fixed_param *cmd;
8540 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8541
8542 buf = wmi_buf_alloc(wmi_handle, len);
8543 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308544 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8545 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308546 }
8547
8548 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8549 WMITLV_SET_HDR(&cmd->tlv_header,
8550 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8551 WMITLV_GET_STRUCT_TLVLEN
8552 (wmi_request_stats_cmd_fixed_param));
8553 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8554 if (wmi_unified_cmd_send
8555 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308556 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308557 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308558 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308559 }
8560
Govind Singhb53420c2016-03-09 14:32:57 +05308561 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308562}
8563
8564/**
8565 * send_snr_cmd_tlv() - get RSSI from fw
8566 * @wmi_handle: wmi handle
8567 * @vdev_id: vdev id
8568 *
8569 * Return: CDF status
8570 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308571static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308572{
8573 wmi_buf_t buf;
8574 wmi_request_stats_cmd_fixed_param *cmd;
8575 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8576
8577 buf = wmi_buf_alloc(wmi_handle, len);
8578 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308579 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8580 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308581 }
8582
8583 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8584 cmd->vdev_id = vdev_id;
8585
8586 WMITLV_SET_HDR(&cmd->tlv_header,
8587 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8588 WMITLV_GET_STRUCT_TLVLEN
8589 (wmi_request_stats_cmd_fixed_param));
8590 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8591 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8592 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308593 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308594 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308595 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308596 }
8597
Govind Singhb53420c2016-03-09 14:32:57 +05308598 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308599}
8600
8601/**
8602 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8603 * @wmi_handle: wmi handle
8604 * @link_status: get link params
8605 *
8606 * Return: CDF status
8607 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308608static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308609 struct link_status_params *link_status)
8610{
8611 wmi_buf_t buf;
8612 wmi_request_stats_cmd_fixed_param *cmd;
8613 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8614
8615 buf = wmi_buf_alloc(wmi_handle, len);
8616 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308617 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8618 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308619 }
8620
8621 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8622 WMITLV_SET_HDR(&cmd->tlv_header,
8623 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8624 WMITLV_GET_STRUCT_TLVLEN
8625 (wmi_request_stats_cmd_fixed_param));
8626 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8627 cmd->vdev_id = link_status->session_id;
8628 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8629 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308630 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308631 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308632 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308633 }
8634
Govind Singhb53420c2016-03-09 14:32:57 +05308635 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308636}
8637
Govind Singh20c5dac2016-03-07 15:33:31 +05308638/**
8639 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8640 * @wmi_handle: wmi handle
8641 * @ta_dhcp_ind: DHCP indication parameter
8642 *
8643 * Return: CDF Status
8644 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308645static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308646 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8647{
Govind Singh67922e82016-04-01 16:48:57 +05308648 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308649 wmi_buf_t buf = NULL;
8650 uint8_t *buf_ptr;
8651 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8652 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8653
8654
8655 buf = wmi_buf_alloc(wmi_handle, len);
8656 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308657 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8658 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308659 }
8660
8661 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8662 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8663 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8664 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8665 WMITLV_GET_STRUCT_TLVLEN
8666 (wmi_peer_set_param_cmd_fixed_param));
8667
8668 /* fill in values */
8669 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8670 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8671 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308672 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308673 &ta_dhcp_ind->peer_macaddr,
8674 sizeof(ta_dhcp_ind->peer_macaddr));
8675
8676 status = wmi_unified_cmd_send(wmi_handle, buf,
8677 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308678 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308679 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308680 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308681 wmi_buf_free(buf);
8682 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308683
Govind Singh67922e82016-04-01 16:48:57 +05308684 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308685}
8686
8687/**
8688 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8689 * @wmi_handle: wmi handle
8690 * @pLinkSpeed: link speed info
8691 *
8692 * Return: CDF status
8693 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308694static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308695 wmi_mac_addr peer_macaddr)
8696{
8697 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8698 wmi_buf_t wmi_buf;
8699 uint32_t len;
8700 uint8_t *buf_ptr;
8701
8702 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8703 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8704 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308705 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8706 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308707 }
8708 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8709
8710 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8711 WMITLV_SET_HDR(&cmd->tlv_header,
8712 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8713 WMITLV_GET_STRUCT_TLVLEN
8714 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8715
8716 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308717 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308718 &peer_macaddr,
8719 sizeof(peer_macaddr));
8720
8721
8722 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8723 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308724 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308725 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308726 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308727 }
Govind Singhb53420c2016-03-09 14:32:57 +05308728 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308729}
8730
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308731#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308732/**
8733 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8734 * @wmi_handle: wmi handler
8735 * @egap_params: pointer to egap_params
8736 *
8737 * Return: 0 for success, otherwise appropriate error code
8738 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308739static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308740 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308741{
8742 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8743 wmi_buf_t buf;
8744 int32_t err;
8745
8746 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8747 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308748 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8749 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308750 }
8751 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8752 WMITLV_SET_HDR(&cmd->tlv_header,
8753 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8754 WMITLV_GET_STRUCT_TLVLEN(
8755 wmi_ap_ps_egap_param_cmd_fixed_param));
8756
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308757 cmd->enable = egap_params->host_enable_egap;
8758 cmd->inactivity_time = egap_params->egap_inactivity_time;
8759 cmd->wait_time = egap_params->egap_wait_time;
8760 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308761 err = wmi_unified_cmd_send(wmi_handle, buf,
8762 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8763 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308764 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308765 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308766 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308767 }
8768
Govind Singhb53420c2016-03-09 14:32:57 +05308769 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308770}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308771#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308772
8773/**
8774 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8775 * @wmi_handl: wmi handle
8776 * @cmd: Profiling command index
8777 * @value1: parameter1 value
8778 * @value2: parameter2 value
8779 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308780 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308781 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308782static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308783 uint32_t cmd, uint32_t value1, uint32_t value2)
8784{
8785 wmi_buf_t buf;
8786 int32_t len = 0;
8787 int ret;
8788 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8789 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8790 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8791 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8792
8793 switch (cmd) {
8794 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8795 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8796 buf = wmi_buf_alloc(wmi_handle, len);
8797 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308798 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308799 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308800 }
8801 prof_trig_cmd =
8802 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8803 wmi_buf_data(buf);
8804 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8805 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8806 WMITLV_GET_STRUCT_TLVLEN
8807 (wmi_wlan_profile_trigger_cmd_fixed_param));
8808 prof_trig_cmd->enable = value1;
8809 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8810 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8811 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308812 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308813 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308814 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308815 return ret;
8816 }
8817 break;
8818
8819 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8820 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8821 buf = wmi_buf_alloc(wmi_handle, len);
8822 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308823 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308824 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308825 }
8826 profile_getdata_cmd =
8827 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8828 wmi_buf_data(buf);
8829 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8830 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8831 WMITLV_GET_STRUCT_TLVLEN
8832 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8833 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8834 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8835 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308836 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308837 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308838 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308839 return ret;
8840 }
8841 break;
8842
8843 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8844 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8845 buf = wmi_buf_alloc(wmi_handle, len);
8846 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308847 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308848 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308849 }
8850 hist_intvl_cmd =
8851 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8852 wmi_buf_data(buf);
8853 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8854 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8855 WMITLV_GET_STRUCT_TLVLEN
8856 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8857 hist_intvl_cmd->profile_id = value1;
8858 hist_intvl_cmd->value = value2;
8859 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8860 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8861 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308862 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308863 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308864 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308865 return ret;
8866 }
8867 break;
8868
8869 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8870 len =
8871 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8872 buf = wmi_buf_alloc(wmi_handle, len);
8873 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308874 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308875 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308876 }
8877 profile_enable_cmd =
8878 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8879 wmi_buf_data(buf);
8880 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8881 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8882 WMITLV_GET_STRUCT_TLVLEN
8883 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8884 profile_enable_cmd->profile_id = value1;
8885 profile_enable_cmd->enable = value2;
8886 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8887 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8888 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308889 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308890 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308891 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308892 return ret;
8893 }
8894 break;
8895
8896 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308897 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308898 break;
8899 }
8900
8901 return 0;
8902}
8903
Paul Zhang92ab8d32017-12-08 16:08:00 +08008904static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8905 struct wlm_latency_level_param *params)
8906{
8907 wmi_wlm_config_cmd_fixed_param *cmd;
8908 wmi_buf_t buf;
8909 uint32_t len = sizeof(*cmd);
8910 static uint32_t ll[4] = {100, 60, 40, 20};
8911
8912 buf = wmi_buf_alloc(wmi_handle, len);
8913 if (!buf) {
8914 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8915 return QDF_STATUS_E_NOMEM;
8916 }
8917 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8918 WMITLV_SET_HDR(&cmd->tlv_header,
8919 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8920 WMITLV_GET_STRUCT_TLVLEN
8921 (wmi_wlm_config_cmd_fixed_param));
8922 cmd->vdev_id = params->vdev_id;
8923 cmd->latency_level = params->wlm_latency_level;
8924 cmd->ul_latency = ll[params->wlm_latency_level];
8925 cmd->dl_latency = ll[params->wlm_latency_level];
8926 cmd->flags = params->wlm_latency_flags;
8927 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8928 WMI_WLM_CONFIG_CMDID)) {
8929 WMI_LOGE("%s: Failed to send setting latency config command",
8930 __func__);
8931 wmi_buf_free(buf);
8932 return QDF_STATUS_E_FAILURE;
8933 }
8934
8935 return 0;
8936}
Govind Singh20c5dac2016-03-07 15:33:31 +05308937/**
8938 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8939 * @wmi_handle: wmi handle
8940 * @vdev_id: vdev id
8941 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308942 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308943 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308944static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308945{
8946 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8947 wmi_buf_t buf;
8948 int32_t len = sizeof(*cmd);
8949
Govind Singhb53420c2016-03-09 14:32:57 +05308950 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308951 buf = wmi_buf_alloc(wmi_handle, len);
8952 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308953 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308954 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308955 }
8956 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8957 wmi_buf_data(buf);
8958 WMITLV_SET_HDR(&cmd->tlv_header,
8959 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8960 WMITLV_GET_STRUCT_TLVLEN
8961 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8962 cmd->vdev_id = vdev_id;
8963 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8964 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8965 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308966 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308967 __func__);
8968 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308969 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308970 }
8971
8972 return 0;
8973}
8974
8975/**
8976 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8977 * @wmi_handle: wmi handle
8978 * @vdev_id: vdev id
8979 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308980 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308981 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308982static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308983 uint8_t vdev_id)
8984{
8985 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8986 wmi_buf_t buf;
8987 int32_t len = sizeof(*cmd);
8988
Govind Singhb53420c2016-03-09 14:32:57 +05308989 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308990 buf = wmi_buf_alloc(wmi_handle, len);
8991 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308992 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308993 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308994 }
8995 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8996 WMITLV_SET_HDR(&cmd->tlv_header,
8997 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8998 WMITLV_GET_STRUCT_TLVLEN
8999 (wmi_csa_offload_enable_cmd_fixed_param));
9000 cmd->vdev_id = vdev_id;
9001 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
9002 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9003 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309004 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309005 __func__);
9006 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309007 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309008 }
9009
9010 return 0;
9011}
9012
Naveen Rawat42cd1e62017-05-13 15:56:57 -07009013#ifdef WLAN_FEATURE_CIF_CFR
9014/**
9015 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
9016 * @wmi_handle: wmi handle
9017 * @data_len: len of dma cfg req
9018 * @data: dma cfg req
9019 *
9020 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9021 */
9022static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9023 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
9024{
9025 wmi_buf_t buf;
9026 uint8_t *cmd;
9027 QDF_STATUS ret;
9028
9029 WMITLV_SET_HDR(cfg,
9030 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
9031 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
9032
9033 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
9034 if (!buf) {
9035 WMI_LOGE(FL("wmi_buf_alloc failed"));
9036 return QDF_STATUS_E_FAILURE;
9037 }
9038
9039 cmd = (uint8_t *) wmi_buf_data(buf);
9040 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
9041 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
9042 sizeof(*cfg));
9043 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
9044 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
9045 if (QDF_IS_STATUS_ERROR(ret)) {
9046 WMI_LOGE(FL(":wmi cmd send failed"));
9047 wmi_buf_free(buf);
9048 }
9049
9050 return ret;
9051}
9052#endif
9053
Govind Singh20c5dac2016-03-07 15:33:31 +05309054/**
Sathish Kumarf396c722017-11-17 17:30:41 +05309055 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
9056 * @wmi_handle: wmi handle
9057 * @data_len: len of dma cfg req
9058 * @data: dma cfg req
9059 *
9060 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9061 */
9062static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9063 struct direct_buf_rx_cfg_req *cfg)
9064{
9065 wmi_buf_t buf;
9066 wmi_dma_ring_cfg_req_fixed_param *cmd;
9067 QDF_STATUS ret;
9068 int32_t len = sizeof(*cmd);
9069
9070 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9071 if (!buf) {
9072 WMI_LOGE(FL("wmi_buf_alloc failed"));
9073 return QDF_STATUS_E_FAILURE;
9074 }
9075
9076 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
9077
9078 WMITLV_SET_HDR(&cmd->tlv_header,
9079 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
9080 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
9081
9082 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9083 cfg->pdev_id);
9084 cmd->mod_id = cfg->mod_id;
9085 cmd->base_paddr_lo = cfg->base_paddr_lo;
9086 cmd->base_paddr_hi = cfg->base_paddr_hi;
9087 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
9088 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
9089 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
9090 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
9091 cmd->num_elems = cfg->num_elems;
9092 cmd->buf_size = cfg->buf_size;
9093 cmd->num_resp_per_event = cfg->num_resp_per_event;
9094 cmd->event_timeout_ms = cfg->event_timeout_ms;
9095
9096 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
9097 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
9098 "head idx paddr hi %x tail idx paddr lo %x"
9099 "tail idx addr hi %x num elems %d buf size %d num resp %d"
9100 "event timeout %d\n", __func__, cmd->pdev_id,
9101 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
9102 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
9103 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
9104 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
9105 cmd->event_timeout_ms);
9106 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9107 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
9108 if (QDF_IS_STATUS_ERROR(ret)) {
9109 WMI_LOGE(FL(":wmi cmd send failed"));
9110 wmi_buf_free(buf);
9111 }
9112
9113 return ret;
9114}
9115
9116/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009117 * send_start_11d_scan_cmd_tlv() - start 11d scan request
9118 * @wmi_handle: wmi handle
9119 * @start_11d_scan: 11d scan start request parameters
9120 *
9121 * This function request FW to start 11d scan.
9122 *
9123 * Return: QDF status
9124 */
9125static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9126 struct reg_start_11d_scan_req *start_11d_scan)
9127{
9128 wmi_11d_scan_start_cmd_fixed_param *cmd;
9129 int32_t len;
9130 wmi_buf_t buf;
9131 int ret;
9132
9133 len = sizeof(*cmd);
9134 buf = wmi_buf_alloc(wmi_handle, len);
9135 if (!buf) {
9136 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9137 return QDF_STATUS_E_NOMEM;
9138 }
9139
9140 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
9141
9142 WMITLV_SET_HDR(&cmd->tlv_header,
9143 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
9144 WMITLV_GET_STRUCT_TLVLEN
9145 (wmi_11d_scan_start_cmd_fixed_param));
9146
9147 cmd->vdev_id = start_11d_scan->vdev_id;
9148 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
9149 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
9150
9151 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
9152
9153 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9154 WMI_11D_SCAN_START_CMDID);
9155 if (ret) {
9156 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
9157 wmi_buf_free(buf);
9158 return QDF_STATUS_E_FAILURE;
9159 }
9160
9161 return QDF_STATUS_SUCCESS;
9162}
9163
9164/**
9165 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
9166 * @wmi_handle: wmi handle
9167 * @start_11d_scan: 11d scan stop request parameters
9168 *
9169 * This function request FW to stop 11d scan.
9170 *
9171 * Return: QDF status
9172 */
9173static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9174 struct reg_stop_11d_scan_req *stop_11d_scan)
9175{
9176 wmi_11d_scan_stop_cmd_fixed_param *cmd;
9177 int32_t len;
9178 wmi_buf_t buf;
9179 int ret;
9180
9181 len = sizeof(*cmd);
9182 buf = wmi_buf_alloc(wmi_handle, len);
9183 if (!buf) {
9184 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9185 return QDF_STATUS_E_NOMEM;
9186 }
9187
9188 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
9189
9190 WMITLV_SET_HDR(&cmd->tlv_header,
9191 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
9192 WMITLV_GET_STRUCT_TLVLEN
9193 (wmi_11d_scan_stop_cmd_fixed_param));
9194
9195 cmd->vdev_id = stop_11d_scan->vdev_id;
9196
9197 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
9198
9199 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9200 WMI_11D_SCAN_STOP_CMDID);
9201 if (ret) {
9202 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
9203 wmi_buf_free(buf);
9204 return QDF_STATUS_E_FAILURE;
9205 }
9206
9207 return QDF_STATUS_SUCCESS;
9208}
9209
9210/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309211 * send_start_oem_data_cmd_tlv() - start OEM data request to target
9212 * @wmi_handle: wmi handle
9213 * @startOemDataReq: start request params
9214 *
9215 * Return: CDF status
9216 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309217static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07009218 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05309219 uint8_t *data)
9220{
9221 wmi_buf_t buf;
9222 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309223 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309224
9225 buf = wmi_buf_alloc(wmi_handle,
9226 (data_len + WMI_TLV_HDR_SIZE));
9227 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309228 WMI_LOGE(FL("wmi_buf_alloc failed"));
9229 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309230 }
9231
9232 cmd = (uint8_t *) wmi_buf_data(buf);
9233
9234 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
9235 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309236 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05309237 data_len);
9238
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08009239 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309240 data_len);
9241
9242 ret = wmi_unified_cmd_send(wmi_handle, buf,
9243 (data_len +
9244 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
9245
Govind Singh67922e82016-04-01 16:48:57 +05309246 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309247 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309248 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309249 }
9250
Govind Singh67922e82016-04-01 16:48:57 +05309251 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309252}
9253
9254/**
9255 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
9256 * @wmi_handle: wmi handle
9257 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
9258 *
9259 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
9260 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
9261 * to firmware based on phyerr filtering
9262 * offload status.
9263 *
9264 * Return: 1 success, 0 failure
9265 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309266static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309267send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9268 bool dfs_phyerr_filter_offload)
9269{
9270 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9271 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9272 wmi_buf_t buf;
9273 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309274 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309275
9276
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009277 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309278 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309279 __func__);
9280 len = sizeof(*disable_phyerr_offload_cmd);
9281 buf = wmi_buf_alloc(wmi_handle, len);
9282 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309283 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309284 return 0;
9285 }
9286 disable_phyerr_offload_cmd =
9287 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9288 wmi_buf_data(buf);
9289
9290 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9291 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9292 WMITLV_GET_STRUCT_TLVLEN
9293 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9294
9295 /*
9296 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9297 * to the firmware to disable the phyerror
9298 * filtering offload.
9299 */
9300 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9301 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309302 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309303 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309304 __func__, ret);
9305 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309306 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309307 }
Govind Singhb53420c2016-03-09 14:32:57 +05309308 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309309 __func__);
9310 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309311 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309312 __func__);
9313
9314 len = sizeof(*enable_phyerr_offload_cmd);
9315 buf = wmi_buf_alloc(wmi_handle, len);
9316 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309317 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9318 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309319 }
9320
9321 enable_phyerr_offload_cmd =
9322 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9323 wmi_buf_data(buf);
9324
9325 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9326 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9327 WMITLV_GET_STRUCT_TLVLEN
9328 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9329
9330 /*
9331 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9332 * to the firmware to enable the phyerror
9333 * filtering offload.
9334 */
9335 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9336 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9337
Govind Singh67922e82016-04-01 16:48:57 +05309338 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309339 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309340 __func__, ret);
9341 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309342 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309343 }
Govind Singhb53420c2016-03-09 14:32:57 +05309344 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309345 __func__);
9346 }
9347
Govind Singhb53420c2016-03-09 14:32:57 +05309348 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309349}
9350
Naveen Rawata5817e72017-10-26 18:50:19 -07009351/**
9352 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9353 * will wake up host after specified time is elapsed
9354 * @wmi_handle: wmi handle
9355 * @vdev_id: vdev id
9356 * @cookie: value to identify reason why host set up wake call.
9357 * @time: time in ms
9358 *
9359 * Return: QDF status
9360 */
9361static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9362 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9363{
9364 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9365 wmi_buf_t buf;
9366 uint8_t *buf_ptr;
9367 int32_t len;
9368 int ret;
9369
9370 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9371 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9372 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9373 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9374 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
9375 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32) +
9376 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
9377
9378 buf = wmi_buf_alloc(wmi_handle, len);
9379 if (!buf) {
9380 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9381 return QDF_STATUS_E_NOMEM;
9382 }
9383
9384 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9385 buf_ptr = (uint8_t *) cmd;
9386
9387 WMITLV_SET_HDR(&cmd->tlv_header,
9388 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9389 WMITLV_GET_STRUCT_TLVLEN
9390 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9391 cmd->vdev_id = vdev_id;
9392 cmd->pattern_id = cookie,
9393 cmd->pattern_type = WOW_TIMER_PATTERN;
9394 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9395
9396 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9397 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9398 buf_ptr += WMI_TLV_HDR_SIZE;
9399
9400 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9401 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9402 buf_ptr += WMI_TLV_HDR_SIZE;
9403
9404 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9405 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9406 buf_ptr += WMI_TLV_HDR_SIZE;
9407
9408 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9409 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9410 buf_ptr += WMI_TLV_HDR_SIZE;
9411
9412 /* Fill TLV for pattern_info_timeout, and time value */
9413 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9414 buf_ptr += WMI_TLV_HDR_SIZE;
9415 *((A_UINT32 *) buf_ptr) = time;
9416 buf_ptr += sizeof(A_UINT32);
9417
9418 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
9419 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9420 buf_ptr += WMI_TLV_HDR_SIZE;
9421 *((A_UINT32 *) buf_ptr) = 0;
9422
9423 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9424 __func__, time, vdev_id);
9425
9426 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9427 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9428 if (ret) {
9429 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9430 __func__);
9431 wmi_buf_free(buf);
9432 return QDF_STATUS_E_FAILURE;
9433 }
9434
9435 return QDF_STATUS_SUCCESS;
9436}
9437
Govind Singh20c5dac2016-03-07 15:33:31 +05309438#if !defined(REMOVE_PKT_LOG)
9439/**
9440 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9441 * @wmi_handle: wmi handle
9442 * @pktlog_event: pktlog event
9443 * @cmd_id: pktlog cmd id
9444 *
9445 * Return: CDF status
9446 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309447static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309448 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309449 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309450{
9451 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9452 WMI_CMD_ID CMD_ID;
9453 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9454 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9455 int len = 0;
9456 wmi_buf_t buf;
9457
9458 PKTLOG_EVENT = pktlog_event;
9459 CMD_ID = cmd_id;
9460
9461 switch (CMD_ID) {
9462 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9463 len = sizeof(*cmd);
9464 buf = wmi_buf_alloc(wmi_handle, len);
9465 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309466 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9467 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309468 }
9469 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9470 wmi_buf_data(buf);
9471 WMITLV_SET_HDR(&cmd->tlv_header,
9472 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9473 WMITLV_GET_STRUCT_TLVLEN
9474 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9475 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309476 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9477 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309478 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9479 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309480 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9481 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309482 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309483 goto wmi_send_failed;
9484 }
9485 break;
9486 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9487 len = sizeof(*disable_cmd);
9488 buf = wmi_buf_alloc(wmi_handle, len);
9489 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309490 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9491 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309492 }
9493 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9494 wmi_buf_data(buf);
9495 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9496 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9497 WMITLV_GET_STRUCT_TLVLEN
9498 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309499 disable_cmd->pdev_id =
9500 wmi_handle->ops->convert_pdev_id_host_to_target(
9501 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309502 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9503 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309504 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309505 goto wmi_send_failed;
9506 }
9507 break;
9508 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309509 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309510 break;
9511 }
9512
Govind Singhb53420c2016-03-09 14:32:57 +05309513 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309514
9515wmi_send_failed:
9516 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309517 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309518}
9519#endif /* REMOVE_PKT_LOG */
9520
9521/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309522 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9523 * @wmi_handle: wmi handle
9524 * @ptrn_id: pattern id
9525 * @vdev_id: vdev id
9526 *
9527 * Return: CDF status
9528 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309529static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9530 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309531{
9532 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9533 wmi_buf_t buf;
9534 int32_t len;
9535 int ret;
9536
9537 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9538
9539
9540 buf = wmi_buf_alloc(wmi_handle, len);
9541 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309542 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9543 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309544 }
9545
9546 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9547
9548 WMITLV_SET_HDR(&cmd->tlv_header,
9549 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9550 WMITLV_GET_STRUCT_TLVLEN(
9551 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9552 cmd->vdev_id = vdev_id;
9553 cmd->pattern_id = ptrn_id;
9554 cmd->pattern_type = WOW_BITMAP_PATTERN;
9555
Govind Singhb53420c2016-03-09 14:32:57 +05309556 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309557 cmd->pattern_id, vdev_id);
9558
9559 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9560 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9561 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309562 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309563 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309564 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309565 }
9566
Govind Singhb53420c2016-03-09 14:32:57 +05309567 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309568}
9569
9570/**
9571 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9572 * @wmi_handle: wmi handle
9573 *
9574 * Sends host wakeup indication to FW. On receiving this indication,
9575 * FW will come out of WOW.
9576 *
9577 * Return: CDF status
9578 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309579static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309580{
9581 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9582 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309583 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309584 int32_t len;
9585 int ret;
9586
9587 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9588
9589 buf = wmi_buf_alloc(wmi_handle, len);
9590 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309591 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9592 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309593 }
9594
9595 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9596 wmi_buf_data(buf);
9597 WMITLV_SET_HDR(&cmd->tlv_header,
9598 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9599 WMITLV_GET_STRUCT_TLVLEN
9600 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9601
9602
9603 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9604 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9605 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309606 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309607 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309608 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309609 }
9610
Govind Singhb53420c2016-03-09 14:32:57 +05309611 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309612}
9613
9614/**
9615 * send_del_ts_cmd_tlv() - send DELTS request to fw
9616 * @wmi_handle: wmi handle
9617 * @msg: delts params
9618 *
9619 * Return: CDF status
9620 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309621static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309622 uint8_t ac)
9623{
9624 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9625 wmi_buf_t buf;
9626 int32_t len = sizeof(*cmd);
9627
9628 buf = wmi_buf_alloc(wmi_handle, len);
9629 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309630 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9631 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309632 }
9633 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9634 WMITLV_SET_HDR(&cmd->tlv_header,
9635 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9636 WMITLV_GET_STRUCT_TLVLEN
9637 (wmi_vdev_wmm_delts_cmd_fixed_param));
9638 cmd->vdev_id = vdev_id;
9639 cmd->ac = ac;
9640
Govind Singhb53420c2016-03-09 14:32:57 +05309641 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309642 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9643 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9644 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309645 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309646 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309647 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309648 }
9649
Govind Singhb53420c2016-03-09 14:32:57 +05309650 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309651}
9652
9653/**
9654 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9655 * @wmi_handle: handle to wmi
9656 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9657 *
Govind Singhb53420c2016-03-09 14:32:57 +05309658 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309659 * ADD_TS requestes to firmware in loop for all the ACs with
9660 * active flow.
9661 *
9662 * Return: CDF status
9663 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309664static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309665 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9666{
9667 int i = 0;
9668 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9669 wmi_buf_t buf;
9670 int32_t len = sizeof(*cmd);
9671
9672 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9673 /* if flow in this AC is active */
9674 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9675 /*
9676 * as per implementation of wma_add_ts_req() we
9677 * are not waiting any response from firmware so
9678 * apart from sending ADDTS to firmware just send
9679 * success to upper layers
9680 */
Govind Singhb53420c2016-03-09 14:32:57 +05309681 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309682
9683 buf = wmi_buf_alloc(wmi_handle, len);
9684 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309685 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9686 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309687 }
9688 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9689 wmi_buf_data(buf);
9690 WMITLV_SET_HDR(&cmd->tlv_header,
9691 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9692 WMITLV_GET_STRUCT_TLVLEN
9693 (wmi_vdev_wmm_addts_cmd_fixed_param));
9694 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9695 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309696 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309697 traffic.userPrio);
9698 cmd->medium_time_us =
9699 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9700 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309701 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309702 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9703 cmd->medium_time_us, cmd->downgrade_type);
9704 if (wmi_unified_cmd_send
9705 (wmi_handle, buf, len,
9706 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309707 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309708 __func__);
9709 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309710 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309711 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309712 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309713 }
9714 }
9715 }
9716
Govind Singhb53420c2016-03-09 14:32:57 +05309717 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309718}
9719
9720/**
9721 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9722 * @wmi_handle: wmi handle
9723 * @msg: ADDTS params
9724 *
9725 * Return: CDF status
9726 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309727static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309728 struct add_ts_param *msg)
9729{
9730 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9731 wmi_buf_t buf;
9732 int32_t len = sizeof(*cmd);
9733
Govind Singhb53420c2016-03-09 14:32:57 +05309734 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309735
9736 buf = wmi_buf_alloc(wmi_handle, len);
9737 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309738 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9739 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309740 }
9741 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9742 WMITLV_SET_HDR(&cmd->tlv_header,
9743 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9744 WMITLV_GET_STRUCT_TLVLEN
9745 (wmi_vdev_wmm_addts_cmd_fixed_param));
9746 cmd->vdev_id = msg->sme_session_id;
9747 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9748 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9749 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309750 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309751 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9752 cmd->downgrade_type, __func__, __LINE__);
9753 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9754 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309755 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9756 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309757 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309758 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309759 }
9760
Govind Singhb53420c2016-03-09 14:32:57 +05309761 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309762}
9763
9764/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309765 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9766 * @wmi_handle: wmi handle
9767 * @pAddPeriodicTxPtrnParams: tx ptrn params
9768 *
9769 * Retrun: CDF status
9770 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309771static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309772 struct periodic_tx_pattern *
9773 pAddPeriodicTxPtrnParams,
9774 uint8_t vdev_id)
9775{
9776 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9777 wmi_buf_t wmi_buf;
9778 uint32_t len;
9779 uint8_t *buf_ptr;
9780 uint32_t ptrn_len, ptrn_len_aligned;
9781 int j;
9782
9783 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9784 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9785 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9786 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9787
9788 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9789 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309790 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9791 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309792 }
9793
9794 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9795
9796 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9797 WMITLV_SET_HDR(&cmd->tlv_header,
9798 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9799 WMITLV_GET_STRUCT_TLVLEN
9800 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9801
9802 /* Pass the pattern id to delete for the corresponding vdev id */
9803 cmd->vdev_id = vdev_id;
9804 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9805 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9806 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9807
9808 /* Pattern info */
9809 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9810 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9811 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309812 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309813 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309814 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309815
Govind Singhb53420c2016-03-09 14:32:57 +05309816 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309817 __func__, cmd->pattern_id, cmd->vdev_id);
9818
9819 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9820 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309821 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309822 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309823 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309824 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309825 }
Govind Singhb53420c2016-03-09 14:32:57 +05309826 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309827}
9828
9829/**
9830 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9831 * @wmi_handle: wmi handle
9832 * @vdev_id: vdev id
9833 * @pattern_id: pattern id
9834 *
9835 * Retrun: CDF status
9836 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309837static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309838 uint8_t vdev_id,
9839 uint8_t pattern_id)
9840{
9841 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9842 wmi_buf_t wmi_buf;
9843 uint32_t len =
9844 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9845
9846 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9847 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309848 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9849 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309850 }
9851
9852 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9853 wmi_buf_data(wmi_buf);
9854 WMITLV_SET_HDR(&cmd->tlv_header,
9855 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9856 WMITLV_GET_STRUCT_TLVLEN
9857 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9858
9859 /* Pass the pattern id to delete for the corresponding vdev id */
9860 cmd->vdev_id = vdev_id;
9861 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309862 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309863 __func__, cmd->pattern_id, cmd->vdev_id);
9864
9865 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9866 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309867 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309868 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309869 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309870 }
Govind Singhb53420c2016-03-09 14:32:57 +05309871 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309872}
9873
9874/**
9875 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9876 * @wmi_handle: wmi handle
9877 * @preq: stats ext params
9878 *
9879 * Return: CDF status
9880 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309881static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309882 struct stats_ext_params *preq)
9883{
Govind Singh67922e82016-04-01 16:48:57 +05309884 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309885 wmi_req_stats_ext_cmd_fixed_param *cmd;
9886 wmi_buf_t buf;
9887 uint16_t len;
9888 uint8_t *buf_ptr;
9889
9890 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9891
9892 buf = wmi_buf_alloc(wmi_handle, len);
9893 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309894 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309895 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309896 }
9897
9898 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9899 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9900
9901 WMITLV_SET_HDR(&cmd->tlv_header,
9902 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9903 WMITLV_GET_STRUCT_TLVLEN
9904 (wmi_req_stats_ext_cmd_fixed_param));
9905 cmd->vdev_id = preq->vdev_id;
9906 cmd->data_len = preq->request_data_len;
9907
Govind Singhb53420c2016-03-09 14:32:57 +05309908 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309909 __func__, preq->request_data_len, preq->vdev_id);
9910
9911 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9912 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9913
9914 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309915 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309916
9917 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9918 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309919 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309920 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309921 ret);
9922 wmi_buf_free(buf);
9923 }
9924
9925 return ret;
9926}
9927
9928/**
9929 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9930 * @wmi_handle: wmi handle
9931 * @params: ext wow params
9932 *
9933 * Return:0 for success or error code
9934 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309935static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309936 struct ext_wow_params *params)
9937{
9938 wmi_extwow_enable_cmd_fixed_param *cmd;
9939 wmi_buf_t buf;
9940 int32_t len;
9941 int ret;
9942
9943 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9944 buf = wmi_buf_alloc(wmi_handle, len);
9945 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309946 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9947 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309948 }
9949
9950 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9951
9952 WMITLV_SET_HDR(&cmd->tlv_header,
9953 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9954 WMITLV_GET_STRUCT_TLVLEN
9955 (wmi_extwow_enable_cmd_fixed_param));
9956
9957 cmd->vdev_id = params->vdev_id;
9958 cmd->type = params->type;
9959 cmd->wakeup_pin_num = params->wakeup_pin_num;
9960
Govind Singhb53420c2016-03-09 14:32:57 +05309961 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309962 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9963
9964 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9965 WMI_EXTWOW_ENABLE_CMDID);
9966 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309967 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309968 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309969 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309970 }
9971
Govind Singhb53420c2016-03-09 14:32:57 +05309972 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309973
9974}
9975
9976/**
9977 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9978 * @wmi_handle: wmi handle
9979 * @app_type1_params: app type1 params
9980 *
9981 * Return: CDF status
9982 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309983static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309984 struct app_type1_params *app_type1_params)
9985{
9986 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9987 wmi_buf_t buf;
9988 int32_t len;
9989 int ret;
9990
9991 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9992 buf = wmi_buf_alloc(wmi_handle, len);
9993 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309994 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9995 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309996 }
9997
9998 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9999 wmi_buf_data(buf);
10000
10001 WMITLV_SET_HDR(&cmd->tlv_header,
10002 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
10003 WMITLV_GET_STRUCT_TLVLEN
10004 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
10005
10006 cmd->vdev_id = app_type1_params->vdev_id;
10007 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
10008 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +053010009 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +053010010 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +053010011 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010012 cmd->passwd_len = app_type1_params->pass_length;
10013
Govind Singhb53420c2016-03-09 14:32:57 +053010014 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010015 "identification_id %.8s id_length %u "
10016 "password %.16s pass_length %u",
10017 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
10018 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
10019
10020 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10021 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
10022 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010023 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010024 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010025 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010026 }
10027
Govind Singhb53420c2016-03-09 14:32:57 +053010028 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010029}
10030
10031/**
10032 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
10033 * @wmi_handle: wmi handle
10034 * @appType2Params: app type2 params
10035 *
10036 * Return: CDF status
10037 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010038static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010039 struct app_type2_params *appType2Params)
10040{
10041 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
10042 wmi_buf_t buf;
10043 int32_t len;
10044 int ret;
10045
10046 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
10047 buf = wmi_buf_alloc(wmi_handle, len);
10048 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010049 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10050 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010051 }
10052
10053 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
10054 wmi_buf_data(buf);
10055
10056 WMITLV_SET_HDR(&cmd->tlv_header,
10057 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
10058 WMITLV_GET_STRUCT_TLVLEN
10059 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
10060
10061 cmd->vdev_id = appType2Params->vdev_id;
10062
Govind Singhb53420c2016-03-09 14:32:57 +053010063 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010064 cmd->rc4_key_len = appType2Params->rc4_key_len;
10065
10066 cmd->ip_id = appType2Params->ip_id;
10067 cmd->ip_device_ip = appType2Params->ip_device_ip;
10068 cmd->ip_server_ip = appType2Params->ip_server_ip;
10069
10070 cmd->tcp_src_port = appType2Params->tcp_src_port;
10071 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
10072 cmd->tcp_seq = appType2Params->tcp_seq;
10073 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
10074
10075 cmd->keepalive_init = appType2Params->keepalive_init;
10076 cmd->keepalive_min = appType2Params->keepalive_min;
10077 cmd->keepalive_max = appType2Params->keepalive_max;
10078 cmd->keepalive_inc = appType2Params->keepalive_inc;
10079
10080 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
10081 &cmd->gateway_mac);
10082 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
10083 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
10084
Govind Singhb53420c2016-03-09 14:32:57 +053010085 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010086 "rc4_key %.16s rc4_key_len %u "
10087 "ip_id %x ip_device_ip %x ip_server_ip %x "
10088 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
10089 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
10090 "keepalive_max %u keepalive_inc %u "
10091 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
10092 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
10093 cmd->rc4_key, cmd->rc4_key_len,
10094 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
10095 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
10096 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
10097 cmd->keepalive_max, cmd->keepalive_inc,
10098 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
10099
10100 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10101 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
10102 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010103 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010104 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010105 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010106 }
10107
Govind Singhb53420c2016-03-09 14:32:57 +053010108 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010109
10110}
10111
10112/**
10113 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
10114 * @wmi_handle: wmi handle
10115 * @timer_val: auto shutdown timer value
10116 *
10117 * Return: CDF status
10118 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010119static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010120 uint32_t timer_val)
10121{
Govind Singh67922e82016-04-01 16:48:57 +053010122 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010123 wmi_buf_t buf = NULL;
10124 uint8_t *buf_ptr;
10125 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
10126 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
10127
Govind Singhb53420c2016-03-09 14:32:57 +053010128 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010129 __func__, timer_val);
10130
10131 buf = wmi_buf_alloc(wmi_handle, len);
10132 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010133 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10134 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010135 }
10136
10137 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10138 wmi_auto_sh_cmd =
10139 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
10140 wmi_auto_sh_cmd->timer_value = timer_val;
10141
10142 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
10143 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
10144 WMITLV_GET_STRUCT_TLVLEN
10145 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
10146
10147 status = wmi_unified_cmd_send(wmi_handle, buf,
10148 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010149 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010150 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010151 __func__, status);
10152 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010153 }
10154
Govind Singh67922e82016-04-01 16:48:57 +053010155 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010156}
10157
10158/**
10159 * send_nan_req_cmd_tlv() - to send nan request to target
10160 * @wmi_handle: wmi handle
10161 * @nan_req: request data which will be non-null
10162 *
10163 * Return: CDF status
10164 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010165static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010166 struct nan_req_params *nan_req)
10167{
Govind Singh67922e82016-04-01 16:48:57 +053010168 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010169 wmi_nan_cmd_param *cmd;
10170 wmi_buf_t buf;
10171 uint16_t len = sizeof(*cmd);
10172 uint16_t nan_data_len, nan_data_len_aligned;
10173 uint8_t *buf_ptr;
10174
10175 /*
10176 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
10177 * +------------+----------+-----------------------+--------------+
10178 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
10179 * +------------+----------+-----------------------+--------------+
10180 */
10181 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +053010182 WMI_LOGE("%s:nan req is not valid", __func__);
10183 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010184 }
10185 nan_data_len = nan_req->request_data_len;
10186 nan_data_len_aligned = roundup(nan_req->request_data_len,
10187 sizeof(uint32_t));
10188 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
10189 buf = wmi_buf_alloc(wmi_handle, len);
10190 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010191 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
10192 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010193 }
10194 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10195 cmd = (wmi_nan_cmd_param *) buf_ptr;
10196 WMITLV_SET_HDR(&cmd->tlv_header,
10197 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
10198 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
10199 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +053010200 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +053010201 __func__, nan_req->request_data_len);
10202 buf_ptr += sizeof(wmi_nan_cmd_param);
10203 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
10204 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010205 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010206
10207 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10208 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010209 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010210 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010211 __func__, ret);
10212 wmi_buf_free(buf);
10213 }
10214
10215 return ret;
10216}
10217
10218/**
10219 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
10220 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -070010221 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +053010222 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010223 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010224 */
Jeff Johnsona87370f2017-10-04 19:19:20 -070010225static QDF_STATUS
10226send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
10227 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +053010228{
10229 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
10230 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +053010231 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010232
10233 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10234 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010235 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +053010236 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010237 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010238 }
10239
10240 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010241
10242 WMITLV_SET_HDR(&cmd->tlv_header,
10243 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
10244 WMITLV_GET_STRUCT_TLVLEN
10245 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -070010246 cmd->vdev_id = params->vdev_id;
10247 cmd->enable = params->dhcp_offload_enabled;
10248 cmd->num_client = params->dhcp_client_num;
10249 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +053010250 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +053010251 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +053010252 sizeof(*cmd),
10253 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010254 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010255 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +053010256 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010257 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010258 }
Govind Singhb53420c2016-03-09 14:32:57 +053010259 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010260 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010261
10262 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010263}
10264
10265/**
10266 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10267 * @wmi_handle: wmi handle
10268 * @flashing: flashing request
10269 *
10270 * Return: CDF status
10271 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010272static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010273 struct flashing_req_params *flashing)
10274{
10275 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010276 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010277 wmi_buf_t buf;
10278 uint8_t *buf_ptr;
10279 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10280
10281 buf = wmi_buf_alloc(wmi_handle, len);
10282 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010283 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010284 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010285 }
10286 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10287 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10288 WMITLV_SET_HDR(&cmd->tlv_header,
10289 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10290 WMITLV_GET_STRUCT_TLVLEN
10291 (wmi_set_led_flashing_cmd_fixed_param));
10292 cmd->pattern_id = flashing->pattern_id;
10293 cmd->led_x0 = flashing->led_x0;
10294 cmd->led_x1 = flashing->led_x1;
10295
10296 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10297 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010298 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010299 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010300 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010301 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010302 }
Govind Singh67922e82016-04-01 16:48:57 +053010303
10304 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010305}
10306
10307/**
10308 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10309 * @wmi_handle: wmi handle
10310 * @ch_avoid_update_req: channel avoid update params
10311 *
10312 * Return: CDF status
10313 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010314static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010315{
Govind Singh67922e82016-04-01 16:48:57 +053010316 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010317 wmi_buf_t buf = NULL;
10318 uint8_t *buf_ptr;
10319 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10320 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10321
10322
10323 buf = wmi_buf_alloc(wmi_handle, len);
10324 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010325 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10326 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010327 }
10328
10329 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10330 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10331 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10332 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10333 WMITLV_GET_STRUCT_TLVLEN
10334 (wmi_chan_avoid_update_cmd_param));
10335
10336 status = wmi_unified_cmd_send(wmi_handle, buf,
10337 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010338 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010339 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010340 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10341 " returned Error %d", status);
10342 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010343 }
10344
Govind Singh67922e82016-04-01 16:48:57 +053010345 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010346}
10347
10348/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010349 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10350 * @wmi_handle: wmi handle
10351 * @param: pointer to pdev regdomain params
10352 *
10353 * Return: 0 for success or error code
10354 */
10355static QDF_STATUS
10356send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10357 struct pdev_set_regdomain_params *param)
10358{
10359 wmi_buf_t buf;
10360 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10361 int32_t len = sizeof(*cmd);
10362
10363
10364 buf = wmi_buf_alloc(wmi_handle, len);
10365 if (!buf) {
10366 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10367 return QDF_STATUS_E_NOMEM;
10368 }
10369 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10370 WMITLV_SET_HDR(&cmd->tlv_header,
10371 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10372 WMITLV_GET_STRUCT_TLVLEN
10373 (wmi_pdev_set_regdomain_cmd_fixed_param));
10374
10375 cmd->reg_domain = param->currentRDinuse;
10376 cmd->reg_domain_2G = param->currentRD2G;
10377 cmd->reg_domain_5G = param->currentRD5G;
10378 cmd->conformance_test_limit_2G = param->ctl_2G;
10379 cmd->conformance_test_limit_5G = param->ctl_5G;
10380 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010381 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10382 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010383
10384 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10385 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10386 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10387 __func__);
10388 wmi_buf_free(buf);
10389 return QDF_STATUS_E_FAILURE;
10390 }
10391
10392 return QDF_STATUS_SUCCESS;
10393}
10394
10395/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010396 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10397 * @wmi_handle: wmi handle
10398 * @reg_dmn: reg domain
10399 * @regdmn2G: 2G reg domain
10400 * @regdmn5G: 5G reg domain
10401 * @ctl2G: 2G test limit
10402 * @ctl5G: 5G test limit
10403 *
10404 * Return: none
10405 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010406static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010407 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010408 uint16_t regdmn5G, uint8_t ctl2G,
10409 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010410{
10411 wmi_buf_t buf;
10412 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10413 int32_t len = sizeof(*cmd);
10414
10415
10416 buf = wmi_buf_alloc(wmi_handle, len);
10417 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010418 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10419 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010420 }
10421 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10422 WMITLV_SET_HDR(&cmd->tlv_header,
10423 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10424 WMITLV_GET_STRUCT_TLVLEN
10425 (wmi_pdev_set_regdomain_cmd_fixed_param));
10426 cmd->reg_domain = reg_dmn;
10427 cmd->reg_domain_2G = regdmn2G;
10428 cmd->reg_domain_5G = regdmn5G;
10429 cmd->conformance_test_limit_2G = ctl2G;
10430 cmd->conformance_test_limit_5G = ctl5G;
10431
10432 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10433 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010434 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010435 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010436 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010437 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010438 }
10439
Govind Singhb53420c2016-03-09 14:32:57 +053010440 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010441}
10442
10443
10444/**
10445 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10446 * @wmi_handle: wmi handle
10447 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10448 *
10449 * This function sets tdls off channel mode
10450 *
10451 * Return: 0 on success; Negative errno otherwise
10452 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010453static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010454 struct tdls_channel_switch_params *chan_switch_params)
10455{
10456 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10457 wmi_buf_t wmi_buf;
10458 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10459
10460 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10461 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010462 WMI_LOGE(FL("wmi_buf_alloc failed"));
10463 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010464 }
10465 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10466 wmi_buf_data(wmi_buf);
10467 WMITLV_SET_HDR(&cmd->tlv_header,
10468 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10469 WMITLV_GET_STRUCT_TLVLEN(
10470 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10471
10472 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10473 &cmd->peer_macaddr);
10474 cmd->vdev_id = chan_switch_params->vdev_id;
10475 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10476 cmd->is_peer_responder = chan_switch_params->is_responder;
10477 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10478 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10479 cmd->offchan_oper_class = chan_switch_params->oper_class;
10480
Govind Singhb53420c2016-03-09 14:32:57 +053010481 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010482 cmd->peer_macaddr.mac_addr31to0,
10483 cmd->peer_macaddr.mac_addr47to32);
10484
Govind Singhb53420c2016-03-09 14:32:57 +053010485 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010486 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10487 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10488 ),
10489 cmd->vdev_id,
10490 cmd->offchan_mode,
10491 cmd->offchan_num,
10492 cmd->offchan_bw_bitmap,
10493 cmd->is_peer_responder,
10494 cmd->offchan_oper_class);
10495
10496 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10497 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010498 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010499 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010500 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010501 }
10502
10503
Govind Singhb53420c2016-03-09 14:32:57 +053010504 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010505}
10506
10507/**
10508 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10509 * @wmi_handle: wmi handle
10510 * @pwmaTdlsparams: TDLS params
10511 *
10512 * Return: 0 for sucess or error code
10513 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010514static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010515 void *tdls_param, uint8_t tdls_state)
10516{
10517 wmi_tdls_set_state_cmd_fixed_param *cmd;
10518 wmi_buf_t wmi_buf;
10519
10520 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10521 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10522
10523 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10524 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010525 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10526 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010527 }
10528 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10529 WMITLV_SET_HDR(&cmd->tlv_header,
10530 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10531 WMITLV_GET_STRUCT_TLVLEN
10532 (wmi_tdls_set_state_cmd_fixed_param));
10533 cmd->vdev_id = wmi_tdls->vdev_id;
10534 cmd->state = tdls_state;
10535 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10536 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10537 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10538 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10539 cmd->rssi_delta = wmi_tdls->rssi_delta;
10540 cmd->tdls_options = wmi_tdls->tdls_options;
10541 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10542 cmd->tdls_peer_traffic_response_timeout_ms =
10543 wmi_tdls->peer_traffic_response_timeout;
10544 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10545 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10546 cmd->tdls_puapsd_rx_frame_threshold =
10547 wmi_tdls->puapsd_rx_frame_threshold;
10548 cmd->teardown_notification_ms =
10549 wmi_tdls->teardown_notification_ms;
10550 cmd->tdls_peer_kickout_threshold =
10551 wmi_tdls->tdls_peer_kickout_threshold;
10552
Govind Singhb53420c2016-03-09 14:32:57 +053010553 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010554 "notification_interval_ms: %d, "
10555 "tx_discovery_threshold: %d, "
10556 "tx_teardown_threshold: %d, "
10557 "rssi_teardown_threshold: %d, "
10558 "rssi_delta: %d, "
10559 "tdls_options: 0x%x, "
10560 "tdls_peer_traffic_ind_window: %d, "
10561 "tdls_peer_traffic_response_timeout: %d, "
10562 "tdls_puapsd_mask: 0x%x, "
10563 "tdls_puapsd_inactivity_time: %d, "
10564 "tdls_puapsd_rx_frame_threshold: %d, "
10565 "teardown_notification_ms: %d, "
10566 "tdls_peer_kickout_threshold: %d",
10567 __func__, tdls_state, cmd->state,
10568 cmd->notification_interval_ms,
10569 cmd->tx_discovery_threshold,
10570 cmd->tx_teardown_threshold,
10571 cmd->rssi_teardown_threshold,
10572 cmd->rssi_delta,
10573 cmd->tdls_options,
10574 cmd->tdls_peer_traffic_ind_window,
10575 cmd->tdls_peer_traffic_response_timeout_ms,
10576 cmd->tdls_puapsd_mask,
10577 cmd->tdls_puapsd_inactivity_time_ms,
10578 cmd->tdls_puapsd_rx_frame_threshold,
10579 cmd->teardown_notification_ms,
10580 cmd->tdls_peer_kickout_threshold);
10581
10582 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10583 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010584 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010585 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010586 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010587 }
Govind Singhb53420c2016-03-09 14:32:57 +053010588 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010589
Govind Singhb53420c2016-03-09 14:32:57 +053010590 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010591}
10592
10593/**
10594 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10595 * @wmi_handle: wmi handle
10596 * @peerStateParams: TDLS peer state params
10597 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010598 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010599 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010600static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010601 struct tdls_peer_state_params *peerStateParams,
10602 uint32_t *ch_mhz)
10603{
10604 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10605 wmi_tdls_peer_capabilities *peer_cap;
10606 wmi_channel *chan_info;
10607 wmi_buf_t wmi_buf;
10608 uint8_t *buf_ptr;
10609 uint32_t i;
10610 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10611 sizeof(wmi_tdls_peer_capabilities);
10612
10613
10614 len += WMI_TLV_HDR_SIZE +
10615 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10616
10617 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10618 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010619 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10620 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010621 }
10622
10623 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10624 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10625 WMITLV_SET_HDR(&cmd->tlv_header,
10626 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10627 WMITLV_GET_STRUCT_TLVLEN
10628 (wmi_tdls_peer_update_cmd_fixed_param));
10629
10630 cmd->vdev_id = peerStateParams->vdevId;
10631 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10632 &cmd->peer_macaddr);
10633
10634
10635 cmd->peer_state = peerStateParams->peerState;
10636
Govind Singhb53420c2016-03-09 14:32:57 +053010637 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010638 "peer_macaddr.mac_addr31to0: 0x%x, "
10639 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10640 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10641 cmd->peer_macaddr.mac_addr31to0,
10642 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10643
10644 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10645 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10646 WMITLV_SET_HDR(&peer_cap->tlv_header,
10647 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10648 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10649
10650 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10651 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10652 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10653 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10654 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10655 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10656 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10657 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10658
10659 /* Ack and More Data Ack are sent as 0, so no need to set
10660 * but fill SP
10661 */
10662 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10663 peerStateParams->peerCap.peerMaxSp);
10664
10665 peer_cap->buff_sta_support =
10666 peerStateParams->peerCap.peerBuffStaSupport;
10667 peer_cap->off_chan_support =
10668 peerStateParams->peerCap.peerOffChanSupport;
10669 peer_cap->peer_curr_operclass =
10670 peerStateParams->peerCap.peerCurrOperClass;
10671 /* self curr operclass is not being used and so pass op class for
10672 * preferred off chan in it.
10673 */
10674 peer_cap->self_curr_operclass =
10675 peerStateParams->peerCap.opClassForPrefOffChan;
10676 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10677 peer_cap->peer_operclass_len =
10678 peerStateParams->peerCap.peerOperClassLen;
10679
Govind Singhb53420c2016-03-09 14:32:57 +053010680 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010681 __func__, peer_cap->peer_operclass_len);
10682 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10683 peer_cap->peer_operclass[i] =
10684 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010685 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010686 __func__, i, peer_cap->peer_operclass[i]);
10687 }
10688
10689 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10690 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10691 peer_cap->pref_offchan_bw =
10692 peerStateParams->peerCap.prefOffChanBandwidth;
10693
Govind Singhb53420c2016-03-09 14:32:57 +053010694 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010695 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10696 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10697 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10698 " %d, pref_offchan_bw: %d",
10699 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10700 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10701 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10702 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10703 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10704
10705 /* next fill variable size array of peer chan info */
10706 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10707 WMITLV_SET_HDR(buf_ptr,
10708 WMITLV_TAG_ARRAY_STRUC,
10709 sizeof(wmi_channel) *
10710 peerStateParams->peerCap.peerChanLen);
10711 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10712
10713 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10714 WMITLV_SET_HDR(&chan_info->tlv_header,
10715 WMITLV_TAG_STRUC_wmi_channel,
10716 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10717 chan_info->mhz = ch_mhz[i];
10718 chan_info->band_center_freq1 = chan_info->mhz;
10719 chan_info->band_center_freq2 = 0;
10720
Govind Singhb53420c2016-03-09 14:32:57 +053010721 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010722
10723 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10724 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010725 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010726 peerStateParams->peerCap.peerChan[i].chanId,
10727 peerStateParams->peerCap.peerChan[i].dfsSet);
10728 }
10729
10730 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10731 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10732 else
10733 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10734
10735 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10736 peerStateParams->peerCap.
10737 peerChan[i].pwr);
10738
10739 WMI_SET_CHANNEL_REG_POWER(chan_info,
10740 peerStateParams->peerCap.peerChan[i].
10741 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010742 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010743 peerStateParams->peerCap.peerChan[i].pwr);
10744
10745 chan_info++;
10746 }
10747
10748 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10749 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010750 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010751 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010752 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010753 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010754 }
10755
10756
Govind Singhb53420c2016-03-09 14:32:57 +053010757 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010758}
10759
10760/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010761 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10762 * @wmi_handle: Pointer to WMi handle
10763 * @ie_data: Pointer for ie data
10764 *
10765 * This function sends IE information to firmware
10766 *
Govind Singhb53420c2016-03-09 14:32:57 +053010767 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010768 *
10769 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010770static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010771 struct vdev_ie_info_param *ie_info)
10772{
10773 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10774 wmi_buf_t buf;
10775 uint8_t *buf_ptr;
10776 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010777 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010778
10779
10780 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10781 /* Allocate memory for the WMI command */
10782 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10783
10784 buf = wmi_buf_alloc(wmi_handle, len);
10785 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010786 WMI_LOGE(FL("wmi_buf_alloc failed"));
10787 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010788 }
10789
10790 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010791 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010792
10793 /* Populate the WMI command */
10794 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10795
10796 WMITLV_SET_HDR(&cmd->tlv_header,
10797 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10798 WMITLV_GET_STRUCT_TLVLEN(
10799 wmi_vdev_set_ie_cmd_fixed_param));
10800 cmd->vdev_id = ie_info->vdev_id;
10801 cmd->ie_id = ie_info->ie_id;
10802 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010803 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010804
Govind Singhb53420c2016-03-09 14:32:57 +053010805 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010806 ie_info->length, ie_info->vdev_id);
10807
10808 buf_ptr += sizeof(*cmd);
10809 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10810 buf_ptr += WMI_TLV_HDR_SIZE;
10811
Govind Singhb53420c2016-03-09 14:32:57 +053010812 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010813
10814 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10815 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010816 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010817 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010818 wmi_buf_free(buf);
10819 }
10820
10821 return ret;
10822}
10823
Sathish Kumar497bef42017-03-01 14:02:36 +053010824/**
10825 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10826 *
10827 * @param wmi_handle : handle to WMI.
10828 * @param param : pointer to antenna param
10829 *
10830 * This function sends smart antenna enable command to FW
10831 *
10832 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10833 */
10834static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10835 struct smart_ant_enable_params *param)
10836{
10837 /* Send WMI COMMAND to Enable */
10838 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10839 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10840 wmi_buf_t buf;
10841 uint8_t *buf_ptr;
10842 int len = 0;
10843 QDF_STATUS ret;
10844 int loop = 0;
10845
10846 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10847 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10848 buf = wmi_buf_alloc(wmi_handle, len);
10849
10850 if (!buf) {
10851 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10852 return QDF_STATUS_E_NOMEM;
10853 }
10854
10855 buf_ptr = wmi_buf_data(buf);
10856 qdf_mem_zero(buf_ptr, len);
10857 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10858
10859 WMITLV_SET_HDR(&cmd->tlv_header,
10860 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10861 WMITLV_GET_STRUCT_TLVLEN(
10862 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10863
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010864 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10865 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010866 cmd->enable = param->enable;
10867 cmd->mode = param->mode;
10868 cmd->rx_antenna = param->rx_antenna;
10869 cmd->tx_default_antenna = param->rx_antenna;
10870
10871 /* TLV indicating array of structures to follow */
10872 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10873 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10874 WMI_HAL_MAX_SANTENNA *
10875 sizeof(wmi_pdev_smart_ant_gpio_handle));
10876
10877 buf_ptr += WMI_TLV_HDR_SIZE;
10878 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10879
10880 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10881 WMITLV_SET_HDR(&gpio_param->tlv_header,
10882 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10883 WMITLV_GET_STRUCT_TLVLEN(
10884 wmi_pdev_smart_ant_gpio_handle));
10885 if (param->mode == SMART_ANT_MODE_SERIAL) {
10886 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10887 gpio_param->gpio_pin = param->gpio_pin[loop];
10888 gpio_param->gpio_func = param->gpio_func[loop];
10889 } else {
10890 gpio_param->gpio_pin = 0;
10891 gpio_param->gpio_func = 0;
10892 }
10893 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10894 gpio_param->gpio_pin = param->gpio_pin[loop];
10895 gpio_param->gpio_func = param->gpio_func[loop];
10896 }
10897 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010898 gpio_param->pdev_id =
10899 wmi_handle->ops->convert_pdev_id_host_to_target(
10900 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010901 gpio_param++;
10902 }
10903
10904 ret = wmi_unified_cmd_send(wmi_handle,
10905 buf,
10906 len,
10907 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10908
10909 if (ret != 0) {
10910 WMI_LOGE(" %s :WMI Failed\n", __func__);
10911 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10912 cmd->enable,
10913 cmd->mode,
10914 cmd->rx_antenna,
10915 param->gpio_pin[0], param->gpio_pin[1],
10916 param->gpio_pin[2], param->gpio_pin[3],
10917 param->gpio_func[0], param->gpio_func[1],
10918 param->gpio_func[2], param->gpio_func[3],
10919 ret);
10920 wmi_buf_free(buf);
10921 }
10922
10923 return ret;
10924}
10925
10926/**
10927 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10928 *
10929 * @param wmi_handle : handle to WMI.
10930 * @param param : pointer to rx antenna param
10931 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10932 */
10933static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10934 struct smart_ant_rx_ant_params *param)
10935{
10936 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10937 wmi_buf_t buf;
10938 uint8_t *buf_ptr;
10939 uint32_t len;
10940 QDF_STATUS ret;
10941
10942 len = sizeof(*cmd);
10943 buf = wmi_buf_alloc(wmi_handle, len);
10944 WMI_LOGD("%s:\n", __func__);
10945 if (!buf) {
10946 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10947 return QDF_STATUS_E_NOMEM;
10948 }
10949
10950 buf_ptr = wmi_buf_data(buf);
10951 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10952 WMITLV_SET_HDR(&cmd->tlv_header,
10953 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10954 WMITLV_GET_STRUCT_TLVLEN(
10955 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10956 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010957 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10958 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010959
10960 ret = wmi_unified_cmd_send(wmi_handle,
10961 buf,
10962 len,
10963 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10964
10965 if (ret != 0) {
10966 WMI_LOGE(" %s :WMI Failed\n", __func__);
10967 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10968 __func__,
10969 cmd->rx_antenna,
10970 ret);
10971 wmi_buf_free(buf);
10972 }
10973
10974 return ret;
10975}
10976
10977/**
10978 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10979 * @wmi_handle: wmi handle
10980 * @param: pointer to hold ctl table param
10981 *
10982 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10983 */
10984static QDF_STATUS
10985send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10986 struct ctl_table_params *param)
10987{
10988 uint16_t len, ctl_tlv_len;
10989 uint8_t *buf_ptr;
10990 wmi_buf_t buf;
10991 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10992 uint32_t *ctl_array;
10993
10994 if (!param->ctl_array)
10995 return QDF_STATUS_E_FAILURE;
10996
10997 if (param->ctl_cmd_len !=
10998 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
10999 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
11000 qdf_print("CTL array len not correct\n");
11001 return QDF_STATUS_E_FAILURE;
11002 }
11003
11004 ctl_tlv_len = WMI_TLV_HDR_SIZE +
11005 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
11006 len = sizeof(*cmd) + ctl_tlv_len;
11007
11008 buf = wmi_buf_alloc(wmi_handle, len);
11009 if (!buf) {
11010 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11011 return QDF_STATUS_E_FAILURE;
11012 }
11013
11014 buf_ptr = wmi_buf_data(buf);
11015 qdf_mem_zero(buf_ptr, len);
11016
11017 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
11018
11019 WMITLV_SET_HDR(&cmd->tlv_header,
11020 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
11021 WMITLV_GET_STRUCT_TLVLEN(
11022 wmi_pdev_set_ctl_table_cmd_fixed_param));
11023 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011024 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11025 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011026
11027 buf_ptr += sizeof(*cmd);
11028 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11029 (cmd->ctl_len));
11030 buf_ptr += WMI_TLV_HDR_SIZE;
11031 ctl_array = (uint32_t *)buf_ptr;
11032
11033 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
11034 sizeof(param->ctl_band));
11035 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
11036 param->ctl_cmd_len -
11037 sizeof(param->ctl_band));
11038
11039 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11040 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
11041 WMI_LOGE("%s:Failed to send command\n", __func__);
11042 wmi_buf_free(buf);
11043 return QDF_STATUS_E_FAILURE;
11044 }
11045
11046 return QDF_STATUS_SUCCESS;
11047}
11048
11049/**
11050 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
11051 * @wmi_handle: wmi handle
11052 * @param: pointer to hold mimogain table param
11053 *
11054 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11055 */
11056static QDF_STATUS
11057send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
11058 struct mimogain_table_params *param)
11059{
11060 uint16_t len, table_tlv_len;
11061 wmi_buf_t buf;
11062 uint8_t *buf_ptr;
11063 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
11064 uint32_t *gain_table;
11065
11066 if (!param->array_gain)
11067 return QDF_STATUS_E_FAILURE;
11068
11069 /* len must be multiple of a single array gain table */
11070 if (param->tbl_len %
11071 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
11072 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
11073 WMI_LOGE("Array gain table len not correct\n");
11074 return QDF_STATUS_E_FAILURE;
11075 }
11076
11077 table_tlv_len = WMI_TLV_HDR_SIZE +
11078 roundup(param->tbl_len, sizeof(uint32_t));
11079 len = sizeof(*cmd) + table_tlv_len;
11080
11081 buf = wmi_buf_alloc(wmi_handle, len);
11082 if (!buf) {
11083 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11084 return QDF_STATUS_E_FAILURE;
11085 }
11086
11087 buf_ptr = wmi_buf_data(buf);
11088 qdf_mem_zero(buf_ptr, len);
11089
11090 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
11091
11092 WMITLV_SET_HDR(&cmd->tlv_header,
11093 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
11094 WMITLV_GET_STRUCT_TLVLEN(
11095 wmi_pdev_set_mimogain_table_cmd_fixed_param));
11096
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011097 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11098 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011099 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
11100 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
11101 param->multichain_gain_bypass);
11102
11103 buf_ptr += sizeof(*cmd);
11104 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11105 (param->tbl_len));
11106 buf_ptr += WMI_TLV_HDR_SIZE;
11107 gain_table = (uint32_t *)buf_ptr;
11108
11109 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
11110 param->array_gain,
11111 param->tbl_len);
11112
11113 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11114 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
11115 return QDF_STATUS_E_FAILURE;
11116 }
11117
11118 return QDF_STATUS_SUCCESS;
11119}
11120
11121/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011122 * enum packet_power_tlv_flags: target defined
11123 * packet power rate flags for TLV
11124 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
11125 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
11126 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
11127 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
11128 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
11129 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
11130 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
11131 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
11132 * @WMI_TLV_FLAG_STBC: STBC is set
11133 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
11134 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
11135 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
11136 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
11137 * @WMI_TLV_FLAG_RTSENA: RTS enabled
11138 * @WMI_TLV_FLAG_CTSENA: CTS enabled
11139 * @WMI_TLV_FLAG_LDPC: LDPC is set
11140 * @WMI_TLV_FLAG_SGI: Short gaurd interval
11141 * @WMI_TLV_FLAG_SU: SU Data
11142 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
11143 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
11144 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
11145 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
11146 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
11147 *
11148 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
11149 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
11150 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
11151 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
11152 */
11153enum packet_power_tlv_flags {
11154 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
11155 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
11156 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
11157 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
11158 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
11159 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
11160 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
11161 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
11162 WMI_TLV_FLAG_STBC = 0x00000100,
11163 WMI_TLV_FLAG_40MHZ = 0x00000200,
11164 WMI_TLV_FLAG_80MHZ = 0x00000300,
11165 WMI_TLV_FLAG_160MHZ = 0x00000400,
11166 WMI_TLV_FLAG_TXBF = 0x00000800,
11167 WMI_TLV_FLAG_RTSENA = 0x00001000,
11168 WMI_TLV_FLAG_CTSENA = 0x00002000,
11169 WMI_TLV_FLAG_LDPC = 0x00004000,
11170 WMI_TLV_FLAG_SGI = 0x00008000,
11171 WMI_TLV_FLAG_SU = 0x00100000,
11172 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
11173 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
11174 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
11175 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
11176 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
11177
11178 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
11179 WMI_TLV_FLAG_BW_MASK = 0x3,
11180 WMI_TLV_FLAG_BW_SHIFT = 9,
11181 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
11182 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
11183};
11184
11185/**
11186 * convert_to_power_info_rate_flags() - convert packet_power_info_params
11187 * to FW understandable format
11188 * @param: pointer to hold packet power info param
11189 *
11190 * @return FW understandable 32 bit rate flags
11191 */
11192static uint32_t
11193convert_to_power_info_rate_flags(struct packet_power_info_params *param)
11194{
11195 uint32_t rateflags = 0;
11196
11197 if (param->chainmask)
11198 rateflags |=
11199 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
11200 if (param->chan_width)
11201 rateflags |=
11202 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
11203 << WMI_TLV_FLAG_BW_SHIFT);
11204 if (param->su_mu_ofdma)
11205 rateflags |=
11206 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
11207 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
11208 if (param->rate_flags & WMI_HOST_FLAG_STBC)
11209 rateflags |= WMI_TLV_FLAG_STBC;
11210 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
11211 rateflags |= WMI_TLV_FLAG_LDPC;
11212 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
11213 rateflags |= WMI_TLV_FLAG_TXBF;
11214 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
11215 rateflags |= WMI_TLV_FLAG_RTSENA;
11216 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
11217 rateflags |= WMI_TLV_FLAG_CTSENA;
11218 if (param->rate_flags & WMI_HOST_FLAG_SGI)
11219 rateflags |= WMI_TLV_FLAG_SGI;
11220
11221 return rateflags;
11222}
11223
11224/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011225 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
11226 * info to fw
11227 * @wmi_handle: wmi handle
11228 * @param: pointer to hold packet power info param
11229 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011230 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011231 */
11232static QDF_STATUS
11233send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11234 struct packet_power_info_params *param)
11235{
11236 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11237 wmi_buf_t wmibuf;
11238 uint8_t *buf_ptr;
11239 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11240
11241 wmibuf = wmi_buf_alloc(wmi_handle, len);
11242 if (wmibuf == NULL)
11243 return QDF_STATUS_E_NOMEM;
11244
11245 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11246
11247 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11248 WMITLV_SET_HDR(&cmd->tlv_header,
11249 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11250 WMITLV_GET_STRUCT_TLVLEN(
11251 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011252 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11253 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011254 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011255 cmd->nss = param->nss;
11256 cmd->preamble = param->preamble;
11257 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011258
11259 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11260 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11261 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11262 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11263
Sathish Kumar497bef42017-03-01 14:02:36 +053011264 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11265 WMI_PDEV_GET_TPC_CMDID)) {
11266 WMI_LOGE(FL("Failed to get tpc command\n"));
11267 wmi_buf_free(wmibuf);
11268 return QDF_STATUS_E_FAILURE;
11269 }
11270
11271 return QDF_STATUS_SUCCESS;
11272}
11273
11274/**
11275 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11276 * @wmi_handle: wmi handle
11277 * @param: pointer to hold config ratemask params
11278 *
11279 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11280 */
11281static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11282 struct config_ratemask_params *param)
11283{
11284 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11285 wmi_buf_t buf;
11286 int32_t len = sizeof(*cmd);
11287
11288 buf = wmi_buf_alloc(wmi_handle, len);
11289 if (!buf) {
11290 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11291 return QDF_STATUS_E_FAILURE;
11292 }
11293 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11294 WMITLV_SET_HDR(&cmd->tlv_header,
11295 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11296 WMITLV_GET_STRUCT_TLVLEN(
11297 wmi_vdev_config_ratemask_cmd_fixed_param));
11298 cmd->vdev_id = param->vdev_id;
11299 cmd->type = param->type;
11300 cmd->mask_lower32 = param->lower32;
11301 cmd->mask_higher32 = param->higher32;
11302 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
11303 param->vdev_id, param->type, param->lower32, param->higher32);
11304
11305 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11306 WMI_VDEV_RATEMASK_CMDID)) {
11307 WMI_LOGE("Seting vdev ratemask failed\n");
11308 wmi_buf_free(buf);
11309 return QDF_STATUS_E_FAILURE;
11310 }
11311
11312 return QDF_STATUS_SUCCESS;
11313}
11314
11315/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011316 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11317 * @param: param sent from the host side
11318 * @cmd: param to be sent to the fw side
11319 */
11320static inline void copy_custom_aggr_bitmap(
11321 struct set_custom_aggr_size_params *param,
11322 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11323{
11324 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11325 param->ac);
11326 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11327 param->aggr_type);
11328 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11329 param->tx_aggr_size_disable);
11330 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11331 param->rx_aggr_size_disable);
11332 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11333 param->tx_ac_enable);
11334}
11335
11336/**
11337 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11338 * @wmi_handle: wmi handle
11339 * @param: pointer to hold custom aggr size params
11340 *
11341 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11342 */
11343static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11344 wmi_unified_t wmi_handle,
11345 struct set_custom_aggr_size_params *param)
11346{
11347 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11348 wmi_buf_t buf;
11349 int32_t len = sizeof(*cmd);
11350
11351 buf = wmi_buf_alloc(wmi_handle, len);
11352 if (!buf) {
11353 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11354 return QDF_STATUS_E_FAILURE;
11355 }
11356 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11357 wmi_buf_data(buf);
11358 WMITLV_SET_HDR(&cmd->tlv_header,
11359 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11360 WMITLV_GET_STRUCT_TLVLEN(
11361 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11362 cmd->vdev_id = param->vdev_id;
11363 cmd->tx_aggr_size = param->tx_aggr_size;
11364 cmd->rx_aggr_size = param->rx_aggr_size;
11365 copy_custom_aggr_bitmap(param, cmd);
11366
11367 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11368 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11369 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11370 "tx_ac_enable=0x%X\n",
11371 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11372 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11373 param->rx_aggr_size_disable, param->tx_ac_enable);
11374
11375 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11376 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11377 WMI_LOGE("Seting custom aggregation size failed\n");
11378 wmi_buf_free(buf);
11379 return QDF_STATUS_E_FAILURE;
11380 }
11381
11382 return QDF_STATUS_SUCCESS;
11383}
11384
11385/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011386 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11387 * @param wmi_handle : handle to WMI.
11388 * @param param : pointer to tx antenna param
11389 *
11390 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11391 */
11392
11393static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11394 struct set_qdepth_thresh_params *param)
11395{
11396 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11397 wmi_msduq_qdepth_thresh_update *cmd_update;
11398 wmi_buf_t buf;
11399 int32_t len = 0;
11400 int i;
11401 uint8_t *buf_ptr;
11402 QDF_STATUS ret;
11403
11404 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11405 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11406 return QDF_STATUS_E_INVAL;
11407 }
11408
11409 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11410 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11411 param->num_of_msduq_updates);
11412 buf = wmi_buf_alloc(wmi_handle, len);
11413
11414 if (!buf) {
11415 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11416 return QDF_STATUS_E_NOMEM;
11417 }
11418
11419 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11420 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11421 buf_ptr;
11422
11423 WMITLV_SET_HDR(&cmd->tlv_header,
11424 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11425 , WMITLV_GET_STRUCT_TLVLEN(
11426 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11427
11428 cmd->pdev_id =
11429 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11430 cmd->vdev_id = param->vdev_id;
11431 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11432 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11433
11434 buf_ptr += sizeof(
11435 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11436 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11437 param->num_of_msduq_updates *
11438 sizeof(wmi_msduq_qdepth_thresh_update));
11439 buf_ptr += WMI_TLV_HDR_SIZE;
11440 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11441
11442 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11443 WMITLV_SET_HDR(&cmd_update->tlv_header,
11444 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11445 WMITLV_GET_STRUCT_TLVLEN(
11446 wmi_msduq_qdepth_thresh_update));
11447 cmd_update->tid_num = param->update_params[i].tid_num;
11448 cmd_update->msduq_update_mask =
11449 param->update_params[i].msduq_update_mask;
11450 cmd_update->qdepth_thresh_value =
11451 param->update_params[i].qdepth_thresh_value;
11452 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11453 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11454 " update mask=0x%X thresh val=0x%X\n",
11455 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11456 cmd->peer_mac_address.mac_addr31to0,
11457 cmd->peer_mac_address.mac_addr47to32,
11458 cmd_update->msduq_update_mask,
11459 cmd_update->qdepth_thresh_value);
11460 cmd_update++;
11461 }
11462
11463 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11464 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11465
11466 if (ret != 0) {
11467 WMI_LOGE(" %s :WMI Failed\n", __func__);
11468 wmi_buf_free(buf);
11469 }
11470
11471 return ret;
11472}
11473
11474/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011475 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11476 * @wmi_handle: wmi handle
11477 * @param: pointer to hold vap dscp tid map param
11478 *
11479 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11480 */
11481static QDF_STATUS
11482send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11483 struct vap_dscp_tid_map_params *param)
11484{
11485 wmi_buf_t buf;
11486 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11487 int32_t len = sizeof(*cmd);
11488
11489 buf = wmi_buf_alloc(wmi_handle, len);
11490 if (!buf) {
11491 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11492 return QDF_STATUS_E_FAILURE;
11493 }
11494
11495 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11496 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
11497 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
11498
11499 cmd->vdev_id = param->vdev_id;
11500 cmd->enable_override = 0;
11501
11502 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11503 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11504 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11505 WMI_LOGE("Failed to set dscp cmd\n");
11506 wmi_buf_free(buf);
11507 return QDF_STATUS_E_FAILURE;
11508 }
11509
11510 return QDF_STATUS_SUCCESS;
11511}
11512
11513/**
11514 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11515 * @wmi_handle: wmi handle
11516 * @macaddr: vdev mac address
11517 * @param: pointer to hold neigbour rx param
11518 *
11519 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11520 */
11521static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11522 uint8_t macaddr[IEEE80211_ADDR_LEN],
11523 struct set_neighbour_rx_params *param)
11524{
11525 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11526 wmi_buf_t buf;
11527 int32_t len = sizeof(*cmd);
11528
11529 buf = wmi_buf_alloc(wmi_handle, len);
11530 if (!buf) {
11531 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11532 return QDF_STATUS_E_FAILURE;
11533 }
11534 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11535 WMITLV_SET_HDR(&cmd->tlv_header,
11536 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11537 WMITLV_GET_STRUCT_TLVLEN(
11538 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11539 cmd->vdev_id = param->vdev_id;
11540 cmd->bssid_idx = param->idx;
11541 cmd->action = param->action;
11542 cmd->type = param->type;
11543 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11544 cmd->flag = 0;
11545
11546 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11547 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11548 WMI_LOGE("Failed to set neighbour rx param\n");
11549 wmi_buf_free(buf);
11550 return QDF_STATUS_E_FAILURE;
11551 }
11552
11553 return QDF_STATUS_SUCCESS;
11554}
11555
11556/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011557 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011558 * @param wmi_handle : handle to WMI.
11559 * @param macaddr : vdev mac address
11560 * @param param : pointer to tx antenna param
11561 *
11562 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11563 */
11564static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11565 uint8_t macaddr[IEEE80211_ADDR_LEN],
11566 struct smart_ant_tx_ant_params *param)
11567{
11568 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11569 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11570 wmi_buf_t buf;
11571 int32_t len = 0;
11572 int i;
11573 uint8_t *buf_ptr;
11574 QDF_STATUS ret;
11575
11576 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11577 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11578 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11579 buf = wmi_buf_alloc(wmi_handle, len);
11580
11581 if (!buf) {
11582 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11583 return QDF_STATUS_E_NOMEM;
11584 }
11585
11586 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11587 qdf_mem_zero(buf_ptr, len);
11588 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11589
11590 WMITLV_SET_HDR(&cmd->tlv_header,
11591 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11592 WMITLV_GET_STRUCT_TLVLEN(
11593 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11594
11595 cmd->vdev_id = param->vdev_id;
11596 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11597
11598 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11599 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11600 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11601 buf_ptr += WMI_TLV_HDR_SIZE;
11602 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11603
11604 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11605 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11606 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11607 WMITLV_GET_STRUCT_TLVLEN(
11608 wmi_peer_smart_ant_set_tx_antenna_series));
11609 ant_tx_series->antenna_series = param->antenna_array[i];
11610 ant_tx_series++;
11611 }
11612
11613 ret = wmi_unified_cmd_send(wmi_handle,
11614 buf,
11615 len,
11616 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11617
11618 if (ret != 0) {
11619 WMI_LOGE(" %s :WMI Failed\n", __func__);
11620 wmi_buf_free(buf);
11621 }
11622
11623 return ret;
11624}
11625
Sathish Kumar02c3b542017-02-22 17:24:45 +053011626/**
11627 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11628 * @wmi_handle: wmi handle
11629 * @param: pointer to hold ant switch tbl param
11630 *
11631 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11632 */
11633static QDF_STATUS
11634send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11635 struct ant_switch_tbl_params *param)
11636{
11637 uint8_t len;
11638 wmi_buf_t buf;
11639 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11640 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11641 uint8_t *buf_ptr;
11642
11643 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11644 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11645 buf = wmi_buf_alloc(wmi_handle, len);
11646
11647 if (!buf) {
11648 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11649 return QDF_STATUS_E_NOMEM;
11650 }
11651
11652 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11653 qdf_mem_zero(buf_ptr, len);
11654 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11655
11656 WMITLV_SET_HDR(&cmd->tlv_header,
11657 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11658 WMITLV_GET_STRUCT_TLVLEN(
11659 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11660
11661 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11662 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011663 cmd->mac_id =
11664 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011665
11666 /* TLV indicating array of structures to follow */
11667 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11668 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11669 sizeof(wmi_pdev_set_ant_ctrl_chain));
11670 buf_ptr += WMI_TLV_HDR_SIZE;
11671 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11672
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011673 ctrl_chain->pdev_id =
11674 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011675 ctrl_chain->antCtrlChain = param->antCtrlChain;
11676
11677 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11678 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11679 wmi_buf_free(buf);
11680 return QDF_STATUS_E_FAILURE;
11681 }
11682
11683 return QDF_STATUS_SUCCESS;
11684}
11685
11686/**
11687 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11688 * training information function
11689 * @param wmi_handle : handle to WMI.
11690 * @macaddr : vdev mac address
11691 * @param param : pointer to tx antenna param
11692 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11693 */
11694static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11695 wmi_unified_t wmi_handle,
11696 uint8_t macaddr[IEEE80211_ADDR_LEN],
11697 struct smart_ant_training_info_params *param)
11698{
11699 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11700 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11701 wmi_buf_t buf;
11702 uint8_t *buf_ptr;
11703 int32_t len = 0;
11704 QDF_STATUS ret;
11705 int loop;
11706
11707 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11708 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11709 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11710 buf = wmi_buf_alloc(wmi_handle, len);
11711
11712 if (!buf) {
11713 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11714 return QDF_STATUS_E_NOMEM;
11715 }
11716
11717 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11718 qdf_mem_zero(buf_ptr, len);
11719 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11720
11721 WMITLV_SET_HDR(&cmd->tlv_header,
11722 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11723 WMITLV_GET_STRUCT_TLVLEN(
11724 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11725
11726 cmd->vdev_id = param->vdev_id;
11727 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11728 cmd->num_pkts = param->numpkts;
11729
11730 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11731 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11732 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11733 WMI_SMART_ANT_MAX_RATE_SERIES);
11734
11735 buf_ptr += WMI_TLV_HDR_SIZE;
11736 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11737
11738 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11739 WMITLV_SET_HDR(&train_param->tlv_header,
11740 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11741 WMITLV_GET_STRUCT_TLVLEN(
11742 wmi_peer_smart_ant_set_train_antenna_param));
11743 train_param->train_rate_series = param->rate_array[loop];
11744 train_param->train_antenna_series = param->antenna_array[loop];
11745 train_param->rc_flags = 0;
11746 WMI_LOGI(FL("Series number:%d\n"), loop);
11747 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11748 train_param->train_rate_series,
11749 train_param->train_antenna_series);
11750 train_param++;
11751 }
11752
11753 ret = wmi_unified_cmd_send(wmi_handle,
11754 buf,
11755 len,
11756 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11757
11758 if (ret != 0) {
11759 WMI_LOGE(" %s :WMI Failed\n", __func__);
11760 wmi_buf_free(buf);
11761 return QDF_STATUS_E_FAILURE;
11762 }
11763
11764 return ret;
11765}
11766
11767/**
11768 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11769 * configuration function
11770 * @param wmi_handle : handle to WMI.
11771 * @macaddr : vdev mad address
11772 * @param param : pointer to tx antenna param
11773 *
11774 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11775 */
11776static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11777 wmi_unified_t wmi_handle,
11778 uint8_t macaddr[IEEE80211_ADDR_LEN],
11779 struct smart_ant_node_config_params *param)
11780{
11781 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11782 wmi_buf_t buf;
11783 uint8_t *buf_ptr;
11784 int32_t len = 0, args_tlv_len;
11785 int ret;
11786 int i = 0;
11787 A_UINT32 *node_config_args;
11788
11789 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
11790 len = sizeof(*cmd) + args_tlv_len;
11791
11792 if ((param->args_count == 0)) {
11793 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11794 __func__, param->args_count);
11795 return QDF_STATUS_E_FAILURE;
11796 }
11797
11798 buf = wmi_buf_alloc(wmi_handle, len);
11799 if (!buf) {
11800 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11801 return QDF_STATUS_E_NOMEM;
11802 }
11803
11804 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11805 wmi_buf_data(buf);
11806 buf_ptr = (uint8_t *)cmd;
11807 WMITLV_SET_HDR(&cmd->tlv_header,
11808 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11809 WMITLV_GET_STRUCT_TLVLEN(
11810 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11811 cmd->vdev_id = param->vdev_id;
11812 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11813 cmd->cmd_id = param->cmd_id;
11814 cmd->args_count = param->args_count;
11815 buf_ptr += sizeof(
11816 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11817 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11818 (cmd->args_count * sizeof(A_UINT32)));
11819 buf_ptr += WMI_TLV_HDR_SIZE;
11820 node_config_args = (A_UINT32 *)buf_ptr;
11821
11822 for (i = 0; i < param->args_count; i++) {
11823 node_config_args[i] = param->args_arr[i];
11824 WMI_LOGI("%d", param->args_arr[i]);
11825 }
11826
11827 ret = wmi_unified_cmd_send(wmi_handle,
11828 buf,
11829 len,
11830 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11831
11832 if (ret != 0) {
11833 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11834 __func__, param->cmd_id, macaddr[0],
11835 macaddr[1], macaddr[2], macaddr[3],
11836 macaddr[4], macaddr[5], ret);
11837 wmi_buf_free(buf);
11838 }
11839
11840 return ret;
11841}
11842
11843/**
11844 * send_set_atf_cmd_tlv() - send set atf command to fw
11845 * @wmi_handle: wmi handle
11846 * @param: pointer to set atf param
11847 *
11848 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11849 */
11850static QDF_STATUS
11851send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11852 struct set_atf_params *param)
11853{
11854 wmi_atf_peer_info *peer_info;
11855 wmi_peer_atf_request_fixed_param *cmd;
11856 wmi_buf_t buf;
11857 uint8_t *buf_ptr;
11858 int i;
11859 int32_t len = 0;
11860 QDF_STATUS retval;
11861
11862 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11863 len += param->num_peers * sizeof(wmi_atf_peer_info);
11864 buf = wmi_buf_alloc(wmi_handle, len);
11865 if (!buf) {
11866 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11867 return QDF_STATUS_E_FAILURE;
11868 }
11869 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11870 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11871 WMITLV_SET_HDR(&cmd->tlv_header,
11872 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11873 WMITLV_GET_STRUCT_TLVLEN(
11874 wmi_peer_atf_request_fixed_param));
11875 cmd->num_peers = param->num_peers;
11876
11877 buf_ptr += sizeof(*cmd);
11878 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11879 sizeof(wmi_atf_peer_info) *
11880 cmd->num_peers);
11881 buf_ptr += WMI_TLV_HDR_SIZE;
11882 peer_info = (wmi_atf_peer_info *)buf_ptr;
11883
11884 for (i = 0; i < cmd->num_peers; i++) {
11885 WMITLV_SET_HDR(&peer_info->tlv_header,
11886 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11887 WMITLV_GET_STRUCT_TLVLEN(
11888 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011889 qdf_mem_copy(&(peer_info->peer_macaddr),
11890 &(param->peer_info[i].peer_macaddr),
11891 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011892 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011893 peer_info->vdev_id = param->peer_info[i].vdev_id;
11894 peer_info->pdev_id =
11895 wmi_handle->ops->convert_pdev_id_host_to_target(
11896 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011897 /*
11898 * TLV definition for peer atf request fixed param combines
11899 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11900 * stats and atf extension stats as two different
11901 * implementations.
11902 * Need to discuss with FW on this.
11903 *
11904 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11905 * peer_info->atf_units_reserved =
11906 * param->peer_ext_info[i].atf_index_reserved;
11907 */
11908 peer_info++;
11909 }
11910
11911 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11912 WMI_PEER_ATF_REQUEST_CMDID);
11913
11914 if (retval != QDF_STATUS_SUCCESS) {
11915 WMI_LOGE("%s : WMI Failed\n", __func__);
11916 wmi_buf_free(buf);
11917 }
11918
11919 return retval;
11920}
11921
11922/**
11923 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11924 * @wmi_handle: wmi handle
11925 * @param: pointer to hold fwtest param
11926 *
11927 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11928 */
11929static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11930 struct set_fwtest_params *param)
11931{
11932 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11933 wmi_buf_t buf;
11934 int32_t len = sizeof(*cmd);
11935
11936 buf = wmi_buf_alloc(wmi_handle, len);
11937
11938 if (!buf) {
11939 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11940 return QDF_STATUS_E_FAILURE;
11941 }
11942
11943 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11944 WMITLV_SET_HDR(&cmd->tlv_header,
11945 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11946 WMITLV_GET_STRUCT_TLVLEN(
11947 wmi_fwtest_set_param_cmd_fixed_param));
11948 cmd->param_id = param->arg;
11949 cmd->param_value = param->value;
11950
11951 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11952 WMI_LOGE("Setting FW test param failed\n");
11953 wmi_buf_free(buf);
11954 return QDF_STATUS_E_FAILURE;
11955 }
11956
11957 return QDF_STATUS_SUCCESS;
11958}
11959
11960/**
11961 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11962 * @wmi_handle: wmi handle
11963 * @param: pointer to qboost params
11964 * @macaddr: vdev mac address
11965 *
11966 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11967 */
11968static QDF_STATUS
11969send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11970 uint8_t macaddr[IEEE80211_ADDR_LEN],
11971 struct set_qboost_params *param)
11972{
11973 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11974 wmi_buf_t buf;
11975 int32_t len;
11976 QDF_STATUS ret;
11977
11978 len = sizeof(*cmd);
11979
11980 buf = wmi_buf_alloc(wmi_handle, len);
11981 if (!buf) {
11982 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11983 return QDF_STATUS_E_FAILURE;
11984 }
11985
11986 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11987 WMITLV_SET_HDR(&cmd->tlv_header,
11988 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11989 WMITLV_GET_STRUCT_TLVLEN(
11990 WMI_QBOOST_CFG_CMD_fixed_param));
11991 cmd->vdev_id = param->vdev_id;
11992 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11993 cmd->qb_enable = param->value;
11994
11995 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11996 WMI_QBOOST_CFG_CMDID);
11997
11998 if (ret != 0) {
11999 WMI_LOGE("Setting qboost cmd failed\n");
12000 wmi_buf_free(buf);
12001 }
12002
12003 return ret;
12004}
12005
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012006/**
12007 * send_gpio_config_cmd_tlv() - send gpio config to fw
12008 * @wmi_handle: wmi handle
12009 * @param: pointer to hold gpio config param
12010 *
12011 * Return: 0 for success or error code
12012 */
12013static QDF_STATUS
12014send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
12015 struct gpio_config_params *param)
12016{
12017 wmi_gpio_config_cmd_fixed_param *cmd;
12018 wmi_buf_t buf;
12019 int32_t len;
12020 QDF_STATUS ret;
12021
12022 len = sizeof(*cmd);
12023
12024 /* Sanity Checks */
12025 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
12026 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
12027 return QDF_STATUS_E_FAILURE;
12028 }
12029
12030 buf = wmi_buf_alloc(wmi_handle, len);
12031 if (!buf) {
12032 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12033 return QDF_STATUS_E_FAILURE;
12034 }
12035
12036 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
12037 WMITLV_SET_HDR(&cmd->tlv_header,
12038 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
12039 WMITLV_GET_STRUCT_TLVLEN(
12040 wmi_gpio_config_cmd_fixed_param));
12041 cmd->gpio_num = param->gpio_num;
12042 cmd->input = param->input;
12043 cmd->pull_type = param->pull_type;
12044 cmd->intr_mode = param->intr_mode;
12045
12046 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12047 WMI_GPIO_CONFIG_CMDID);
12048
12049 if (ret != 0) {
12050 WMI_LOGE("Sending GPIO config cmd failed\n");
12051 wmi_buf_free(buf);
12052 }
12053
12054 return ret;
12055}
12056
12057/**
12058 * send_gpio_output_cmd_tlv() - send gpio output to fw
12059 * @wmi_handle: wmi handle
12060 * @param: pointer to hold gpio output param
12061 *
12062 * Return: 0 for success or error code
12063 */
12064static QDF_STATUS
12065send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
12066 struct gpio_output_params *param)
12067{
12068 wmi_gpio_output_cmd_fixed_param *cmd;
12069 wmi_buf_t buf;
12070 int32_t len;
12071 QDF_STATUS ret;
12072
12073 len = sizeof(*cmd);
12074
12075 buf = wmi_buf_alloc(wmi_handle, len);
12076 if (!buf) {
12077 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12078 return QDF_STATUS_E_FAILURE;
12079 }
12080
12081 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
12082 WMITLV_SET_HDR(&cmd->tlv_header,
12083 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
12084 WMITLV_GET_STRUCT_TLVLEN(
12085 wmi_gpio_output_cmd_fixed_param));
12086 cmd->gpio_num = param->gpio_num;
12087 cmd->set = param->set;
12088
12089 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12090 WMI_GPIO_OUTPUT_CMDID);
12091
12092 if (ret != 0) {
12093 WMI_LOGE("Sending GPIO output cmd failed\n");
12094 wmi_buf_free(buf);
12095 }
12096
12097 return ret;
12098
12099}
12100
12101/**
12102 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
12103 *
12104 * @param wmi_handle : handle to WMI.
12105 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12106 */
12107static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
12108{
12109 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
12110 wmi_buf_t buf;
12111 QDF_STATUS ret;
12112 int32_t len;
12113
12114 len = sizeof(*cmd);
12115
12116 buf = wmi_buf_alloc(wmi_handle, len);
12117 if (!buf) {
12118 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12119 return QDF_STATUS_E_FAILURE;
12120 }
12121
12122 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
12123 WMITLV_SET_HDR(&cmd->tlv_header,
12124 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
12125 WMITLV_GET_STRUCT_TLVLEN(
12126 wmi_pdev_dfs_disable_cmd_fixed_param));
12127 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012128 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12129 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012130
12131 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12132 WMI_PDEV_DFS_DISABLE_CMDID);
12133
12134 if (ret != 0) {
12135 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
12136 wmi_buf_free(buf);
12137 }
12138
12139 return ret;
12140}
12141
12142/**
12143 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
12144 *
12145 * @param wmi_handle : handle to WMI.
12146 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12147 */
12148static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
12149{
12150 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
12151 wmi_buf_t buf;
12152 QDF_STATUS ret;
12153 int32_t len;
12154
12155 len = sizeof(*cmd);
12156
12157 buf = wmi_buf_alloc(wmi_handle, len);
12158 if (!buf) {
12159 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12160 return QDF_STATUS_E_FAILURE;
12161 }
12162
12163 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
12164 WMITLV_SET_HDR(&cmd->tlv_header,
12165 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
12166 WMITLV_GET_STRUCT_TLVLEN(
12167 wmi_pdev_dfs_enable_cmd_fixed_param));
12168 /* Reserved for future use */
12169 cmd->reserved0 = 0;
12170
12171 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12172 WMI_PDEV_DFS_ENABLE_CMDID);
12173
12174 if (ret != 0) {
12175 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
12176 wmi_buf_free(buf);
12177 }
12178
12179 return ret;
12180}
12181
12182/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012183 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
12184 * to fw
12185 * @wmi_handle: wmi handle
12186 * @param: pointer to hold periodic chan stats param
12187 *
12188 * Return: 0 for success or error code
12189 */
12190static QDF_STATUS
12191send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
12192 struct periodic_chan_stats_params *param)
12193{
12194 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
12195 wmi_buf_t buf;
12196 QDF_STATUS ret;
12197 int32_t len;
12198
12199 len = sizeof(*cmd);
12200
12201 buf = wmi_buf_alloc(wmi_handle, len);
12202 if (!buf) {
12203 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12204 return QDF_STATUS_E_FAILURE;
12205 }
12206
12207 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12208 wmi_buf_data(buf);
12209 WMITLV_SET_HDR(&cmd->tlv_header,
12210 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12211 WMITLV_GET_STRUCT_TLVLEN(
12212 wmi_set_periodic_channel_stats_config_fixed_param));
12213 cmd->enable = param->enable;
12214 cmd->stats_period = param->stats_period;
12215 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12216 param->pdev_id);
12217
12218 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12219 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12220
12221 if (ret != 0) {
12222 WMI_LOGE("Sending periodic chan stats config failed");
12223 wmi_buf_free(buf);
12224 }
12225
12226 return ret;
12227}
12228
12229/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012230 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12231 * @wmi_handle: wmi handle
12232 *
12233 * Return: 0 for success or error code
12234 */
12235static QDF_STATUS
12236send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
12237{
12238 wmi_buf_t buf;
12239 QDF_STATUS ret;
12240
12241 buf = wmi_buf_alloc(wmi_handle, 0);
12242 if (buf == NULL)
12243 return QDF_STATUS_E_NOMEM;
12244
12245 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
12246 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12247 if (ret != 0) {
12248 WMI_LOGE("Sending get nfcal power cmd failed\n");
12249 wmi_buf_free(buf);
12250 }
12251
12252 return ret;
12253}
12254
12255/**
12256 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12257 * @wmi_handle: wmi handle
12258 * @param: pointer to ht ie param
12259 *
12260 * Return: 0 for success or error code
12261 */
12262static QDF_STATUS
12263send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12264 struct ht_ie_params *param)
12265{
12266 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12267 wmi_buf_t buf;
12268 QDF_STATUS ret;
12269 int32_t len;
12270 uint8_t *buf_ptr;
12271
12272 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12273 roundup(param->ie_len, sizeof(uint32_t));
12274
12275 buf = wmi_buf_alloc(wmi_handle, len);
12276 if (!buf) {
12277 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12278 return QDF_STATUS_E_FAILURE;
12279 }
12280
12281 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12282 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12283 WMITLV_SET_HDR(&cmd->tlv_header,
12284 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12285 WMITLV_GET_STRUCT_TLVLEN(
12286 wmi_pdev_set_ht_ie_cmd_fixed_param));
12287 cmd->reserved0 = 0;
12288 cmd->ie_len = param->ie_len;
12289 cmd->tx_streams = param->tx_streams;
12290 cmd->rx_streams = param->rx_streams;
12291
12292 buf_ptr += sizeof(*cmd);
12293 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12294 buf_ptr += WMI_TLV_HDR_SIZE;
12295 if (param->ie_len)
12296 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12297 cmd->ie_len);
12298
12299 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12300 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12301
12302 if (ret != 0) {
12303 WMI_LOGE("Sending set ht ie cmd failed\n");
12304 wmi_buf_free(buf);
12305 }
12306
12307 return ret;
12308}
12309
12310/**
12311 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12312 * @wmi_handle: wmi handle
12313 * @param: pointer to vht ie param
12314 *
12315 * Return: 0 for success or error code
12316 */
12317static QDF_STATUS
12318send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12319 struct vht_ie_params *param)
12320{
12321 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12322 wmi_buf_t buf;
12323 QDF_STATUS ret;
12324 int32_t len;
12325 uint8_t *buf_ptr;
12326
12327 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12328 roundup(param->ie_len, sizeof(uint32_t));
12329
12330 buf = wmi_buf_alloc(wmi_handle, len);
12331 if (!buf) {
12332 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12333 return QDF_STATUS_E_FAILURE;
12334 }
12335
12336 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12337 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12338 WMITLV_SET_HDR(&cmd->tlv_header,
12339 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12340 WMITLV_GET_STRUCT_TLVLEN(
12341 wmi_pdev_set_vht_ie_cmd_fixed_param));
12342 cmd->reserved0 = 0;
12343 cmd->ie_len = param->ie_len;
12344 cmd->tx_streams = param->tx_streams;
12345 cmd->rx_streams = param->rx_streams;
12346
12347 buf_ptr += sizeof(*cmd);
12348 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12349 buf_ptr += WMI_TLV_HDR_SIZE;
12350 if (param->ie_len)
12351 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12352 cmd->ie_len);
12353
12354 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12355 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12356
12357 if (ret != 0) {
12358 WMI_LOGE("Sending set vht ie cmd failed\n");
12359 wmi_buf_free(buf);
12360 }
12361
12362 return ret;
12363}
12364
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012365/**
12366 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12367 * @wmi_handle: wmi handle
12368 * @param: pointer to quiet mode params
12369 *
12370 * Return: 0 for success or error code
12371 */
12372static QDF_STATUS
12373send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12374 struct set_quiet_mode_params *param)
12375{
12376 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12377 wmi_buf_t buf;
12378 QDF_STATUS ret;
12379 int32_t len;
12380
12381 len = sizeof(*quiet_cmd);
12382 buf = wmi_buf_alloc(wmi_handle, len);
12383 if (!buf) {
12384 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12385 return QDF_STATUS_E_FAILURE;
12386 }
12387
12388 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12389 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12390 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12391 WMITLV_GET_STRUCT_TLVLEN(
12392 wmi_pdev_set_quiet_cmd_fixed_param));
12393 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12394 quiet_cmd->enabled = param->enabled;
12395 quiet_cmd->period = (param->period)*(param->intval);
12396 quiet_cmd->duration = param->duration;
12397 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012398 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12399 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012400
12401 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12402 WMI_PDEV_SET_QUIET_MODE_CMDID);
12403
12404 if (ret != 0) {
12405 WMI_LOGE("Sending set quiet cmd failed\n");
12406 wmi_buf_free(buf);
12407 }
12408
12409 return ret;
12410}
12411
12412/**
12413 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12414 * @wmi_handle: wmi handle
12415 * @param: pointer to set bwf param
12416 *
12417 * Return: 0 for success or error code
12418 */
12419static QDF_STATUS
12420send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12421 struct set_bwf_params *param)
12422{
12423 wmi_bwf_peer_info *peer_info;
12424 wmi_peer_bwf_request_fixed_param *cmd;
12425 wmi_buf_t buf;
12426 QDF_STATUS retval;
12427 int32_t len;
12428 uint8_t *buf_ptr;
12429 int i;
12430
12431 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12432 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12433 buf = wmi_buf_alloc(wmi_handle, len);
12434 if (!buf) {
12435 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12436 return QDF_STATUS_E_FAILURE;
12437 }
12438 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12439 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12440 WMITLV_SET_HDR(&cmd->tlv_header,
12441 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12442 WMITLV_GET_STRUCT_TLVLEN(
12443 wmi_peer_bwf_request_fixed_param));
12444 cmd->num_peers = param->num_peers;
12445
12446 buf_ptr += sizeof(*cmd);
12447 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12448 sizeof(wmi_bwf_peer_info) *
12449 cmd->num_peers);
12450 buf_ptr += WMI_TLV_HDR_SIZE;
12451 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12452
12453 for (i = 0; i < cmd->num_peers; i++) {
12454 WMITLV_SET_HDR(&peer_info->tlv_header,
12455 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12456 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12457 peer_info->bwf_guaranteed_bandwidth =
12458 param->peer_info[i].throughput;
12459 peer_info->bwf_max_airtime =
12460 param->peer_info[i].max_airtime;
12461 peer_info->bwf_peer_priority =
12462 param->peer_info[i].priority;
12463 qdf_mem_copy(&peer_info->peer_macaddr,
12464 &param->peer_info[i].peer_macaddr,
12465 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012466 peer_info->vdev_id =
12467 param->peer_info[i].vdev_id;
12468 peer_info->pdev_id =
12469 wmi_handle->ops->convert_pdev_id_host_to_target(
12470 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012471 peer_info++;
12472 }
12473
12474 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12475 WMI_PEER_BWF_REQUEST_CMDID);
12476
12477 if (retval != QDF_STATUS_SUCCESS) {
12478 WMI_LOGE("%s : WMI Failed\n", __func__);
12479 wmi_buf_free(buf);
12480 }
12481
12482 return retval;
12483}
12484
12485/**
12486 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12487 * @wmi_handle: wmi handle
12488 * @param: pointer to hold mcast update param
12489 *
12490 * Return: 0 for success or error code
12491 */
12492static QDF_STATUS
12493send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12494 struct mcast_group_update_params *param)
12495{
12496 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12497 wmi_buf_t buf;
12498 QDF_STATUS ret;
12499 int32_t len;
12500 int offset = 0;
12501 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12502
12503 len = sizeof(*cmd);
12504 buf = wmi_buf_alloc(wmi_handle, len);
12505 if (!buf) {
12506 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12507 return QDF_STATUS_E_FAILURE;
12508 }
12509 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12510 WMITLV_SET_HDR(&cmd->tlv_header,
12511 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12512 WMITLV_GET_STRUCT_TLVLEN(
12513 wmi_peer_mcast_group_cmd_fixed_param));
12514 /* confirm the buffer is 4-byte aligned */
12515 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12516 qdf_mem_zero(cmd, sizeof(*cmd));
12517
12518 cmd->vdev_id = param->vap_id;
12519 /* construct the message assuming our endianness matches the target */
12520 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12521 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12522 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12523 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12524 if (param->is_action_delete)
12525 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12526
12527 if (param->is_mcast_addr_len)
12528 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12529
12530 if (param->is_filter_mode_snoop)
12531 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12532
12533 /* unicast address spec only applies for non-wildcard cases */
12534 if (!param->wildcard && param->ucast_mac_addr) {
12535 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12536 &cmd->ucast_mac_addr);
12537 }
Amar Singhal5593c902017-10-03 13:00:29 -070012538
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012539 if (param->mcast_ip_addr) {
12540 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12541 sizeof(cmd->mcast_ip_addr));
12542 offset = sizeof(cmd->mcast_ip_addr) -
12543 param->mcast_ip_addr_bytes;
12544 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12545 param->mcast_ip_addr,
12546 param->mcast_ip_addr_bytes);
12547 }
12548 if (!param->mask)
12549 param->mask = &dummymask[0];
12550
12551 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12552 param->mask,
12553 param->mcast_ip_addr_bytes);
12554
12555 if (param->srcs && param->nsrcs) {
12556 cmd->num_filter_addr = param->nsrcs;
12557 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12558 sizeof(cmd->filter_addr));
12559
12560 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12561 param->nsrcs * param->mcast_ip_addr_bytes);
12562 }
12563
12564 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12565 WMI_PEER_MCAST_GROUP_CMDID);
12566
12567 if (ret != QDF_STATUS_SUCCESS) {
12568 WMI_LOGE("%s : WMI Failed\n", __func__);
12569 wmi_buf_free(buf);
12570 }
12571
12572 return ret;
12573}
12574
12575/**
12576 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12577 * command to fw
12578 * @wmi_handle: wmi handle
12579 * @param: pointer to hold spectral config parameter
12580 *
12581 * Return: 0 for success or error code
12582 */
12583static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12584 struct vdev_spectral_configure_params *param)
12585{
12586 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12587 wmi_buf_t buf;
12588 QDF_STATUS ret;
12589 int32_t len;
12590
12591 len = sizeof(*cmd);
12592 buf = wmi_buf_alloc(wmi_handle, len);
12593 if (!buf) {
12594 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12595 return QDF_STATUS_E_FAILURE;
12596 }
12597
12598 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12599 WMITLV_SET_HDR(&cmd->tlv_header,
12600 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12601 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012602 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012603
12604 cmd->vdev_id = param->vdev_id;
12605 cmd->spectral_scan_count = param->count;
12606 cmd->spectral_scan_period = param->period;
12607 cmd->spectral_scan_priority = param->spectral_pri;
12608 cmd->spectral_scan_fft_size = param->fft_size;
12609 cmd->spectral_scan_gc_ena = param->gc_enable;
12610 cmd->spectral_scan_restart_ena = param->restart_enable;
12611 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12612 cmd->spectral_scan_init_delay = param->init_delay;
12613 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12614 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12615 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12616 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12617 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12618 cmd->spectral_scan_pwr_format = param->pwr_format;
12619 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12620 cmd->spectral_scan_bin_scale = param->bin_scale;
12621 cmd->spectral_scan_dBm_adj = param->dBm_adj;
12622 cmd->spectral_scan_chn_mask = param->chn_mask;
12623
12624 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12625 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12626
12627 if (ret != 0) {
12628 WMI_LOGE("Sending set quiet cmd failed\n");
12629 wmi_buf_free(buf);
12630 }
12631
12632 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12633 __func__);
12634
12635 WMI_LOGI("vdev_id = %u\n"
12636 "spectral_scan_count = %u\n"
12637 "spectral_scan_period = %u\n"
12638 "spectral_scan_priority = %u\n"
12639 "spectral_scan_fft_size = %u\n"
12640 "spectral_scan_gc_ena = %u\n"
12641 "spectral_scan_restart_ena = %u\n"
12642 "spectral_scan_noise_floor_ref = %u\n"
12643 "spectral_scan_init_delay = %u\n"
12644 "spectral_scan_nb_tone_thr = %u\n"
12645 "spectral_scan_str_bin_thr = %u\n"
12646 "spectral_scan_wb_rpt_mode = %u\n"
12647 "spectral_scan_rssi_rpt_mode = %u\n"
12648 "spectral_scan_rssi_thr = %u\n"
12649 "spectral_scan_pwr_format = %u\n"
12650 "spectral_scan_rpt_mode = %u\n"
12651 "spectral_scan_bin_scale = %u\n"
12652 "spectral_scan_dBm_adj = %u\n"
12653 "spectral_scan_chn_mask = %u\n",
12654 param->vdev_id,
12655 param->count,
12656 param->period,
12657 param->spectral_pri,
12658 param->fft_size,
12659 param->gc_enable,
12660 param->restart_enable,
12661 param->noise_floor_ref,
12662 param->init_delay,
12663 param->nb_tone_thr,
12664 param->str_bin_thr,
12665 param->wb_rpt_mode,
12666 param->rssi_rpt_mode,
12667 param->rssi_thr,
12668 param->pwr_format,
12669 param->rpt_mode,
12670 param->bin_scale,
12671 param->dBm_adj,
12672 param->chn_mask);
12673 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12674
12675 return ret;
12676}
12677
12678/**
12679 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12680 * command to fw
12681 * @wmi_handle: wmi handle
12682 * @param: pointer to hold spectral enable parameter
12683 *
12684 * Return: 0 for success or error code
12685 */
12686static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12687 struct vdev_spectral_enable_params *param)
12688{
12689 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12690 wmi_buf_t buf;
12691 QDF_STATUS ret;
12692 int32_t len;
12693
12694 len = sizeof(*cmd);
12695 buf = wmi_buf_alloc(wmi_handle, len);
12696 if (!buf) {
12697 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12698 return QDF_STATUS_E_FAILURE;
12699 }
12700
12701 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12702 WMITLV_SET_HDR(&cmd->tlv_header,
12703 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12704 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012705 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012706
12707 cmd->vdev_id = param->vdev_id;
12708
12709 if (param->active_valid) {
12710 cmd->trigger_cmd = param->active ? 1 : 2;
12711 /* 1: Trigger, 2: Clear Trigger */
12712 } else {
12713 cmd->trigger_cmd = 0; /* 0: Ignore */
12714 }
12715
12716 if (param->enabled_valid) {
12717 cmd->enable_cmd = param->enabled ? 1 : 2;
12718 /* 1: Enable 2: Disable */
12719 } else {
12720 cmd->enable_cmd = 0; /* 0: Ignore */
12721 }
12722
12723 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12724 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12725
12726 if (ret != 0) {
12727 WMI_LOGE("Sending scan enable CMD failed\n");
12728 wmi_buf_free(buf);
12729 }
12730
12731 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12732
12733 WMI_LOGI("vdev_id = %u\n"
12734 "trigger_cmd = %u\n"
12735 "enable_cmd = %u\n",
12736 cmd->vdev_id,
12737 cmd->trigger_cmd,
12738 cmd->enable_cmd);
12739
12740 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12741
12742 return ret;
12743}
12744
12745/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012746 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12747 * @param wmi_handle : handle to WMI.
12748 * @param param : pointer to hold thermal mitigation param
12749 *
12750 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12751 */
12752static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12753 wmi_unified_t wmi_handle,
12754 struct thermal_mitigation_params *param)
12755{
12756 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12757 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12758 wmi_buf_t buf = NULL;
12759 uint8_t *buf_ptr = NULL;
12760 int error;
12761 int32_t len;
12762 int i;
12763
12764 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12765 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12766
12767 buf = wmi_buf_alloc(wmi_handle, len);
12768 if (!buf) {
12769 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12770 return QDF_STATUS_E_NOMEM;
12771 }
12772 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12773
12774 /* init fixed params */
12775 WMITLV_SET_HDR(tt_conf,
12776 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12777 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12778
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012779 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12780 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012781 tt_conf->enable = param->enable;
12782 tt_conf->dc = param->dc;
12783 tt_conf->dc_per_event = param->dc_per_event;
12784 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12785
12786 buf_ptr = (uint8_t *) ++tt_conf;
12787 /* init TLV params */
12788 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12789 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12790
12791 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12792 for (i = 0; i < THERMAL_LEVELS; i++) {
12793 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12794 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12795 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12796 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12797 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12798 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12799 lvl_conf->prio = param->levelconf[i].priority;
12800 lvl_conf++;
12801 }
12802
12803 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12804 WMI_THERM_THROT_SET_CONF_CMDID);
12805 if (QDF_IS_STATUS_ERROR(error)) {
12806 wmi_buf_free(buf);
12807 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12808 }
12809
12810 return error;
12811}
12812
12813/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012814 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12815 * @wmi_handle: wmi handle
12816 * @param: pointer to pdev_qvit_params
12817 *
12818 * Return: 0 for success or error code
12819 */
12820static QDF_STATUS
12821send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12822 struct pdev_qvit_params *param)
12823{
12824 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012825 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012826 uint8_t *cmd;
12827 static uint8_t msgref = 1;
12828 uint8_t segnumber = 0, seginfo, numsegments;
12829 uint16_t chunk_len, total_bytes;
12830 uint8_t *bufpos;
12831 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12832
12833 bufpos = param->utf_payload;
12834 total_bytes = param->len;
12835 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12836 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12837 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12838
12839 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12840 numsegments++;
12841
12842 while (param->len) {
12843 if (param->len > MAX_WMI_QVIT_LEN)
12844 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
12845 else
12846 chunk_len = param->len;
12847
12848 buf = wmi_buf_alloc(wmi_handle,
12849 (chunk_len + sizeof(seghdrinfo) +
12850 WMI_TLV_HDR_SIZE));
12851 if (!buf) {
12852 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12853 return QDF_STATUS_E_NOMEM;
12854 }
12855
12856 cmd = (uint8_t *) wmi_buf_data(buf);
12857
12858 seghdrinfo.len = total_bytes;
12859 seghdrinfo.msgref = msgref;
12860 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12861 seghdrinfo.segmentInfo = seginfo;
12862
12863 segnumber++;
12864
12865 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12866 (chunk_len + sizeof(seghdrinfo)));
12867 cmd += WMI_TLV_HDR_SIZE;
12868 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12869 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12870
12871 ret = wmi_unified_cmd_send(wmi_handle, buf,
12872 (chunk_len + sizeof(seghdrinfo) +
12873 WMI_TLV_HDR_SIZE),
12874 WMI_PDEV_QVIT_CMDID);
12875
12876 if (ret != 0) {
12877 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12878 wmi_buf_free(buf);
12879 break;
12880 }
12881
12882 param->len -= chunk_len;
12883 bufpos += chunk_len;
12884 }
12885 msgref++;
12886
12887 return ret;
12888}
12889
12890/**
12891 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12892 * @wmi_handle: wmi handle
12893 * @param: pointer to wmm update param
12894 *
12895 * Return: 0 for success or error code
12896 */
12897static QDF_STATUS
12898send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12899 struct wmm_update_params *param)
12900{
12901 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12902 wmi_wmm_params *wmm_param;
12903 wmi_buf_t buf;
12904 QDF_STATUS ret;
12905 int32_t len;
12906 int ac = 0;
12907 struct wmi_host_wmeParams *wmep;
12908 uint8_t *buf_ptr;
12909
12910 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12911 buf = wmi_buf_alloc(wmi_handle, len);
12912 if (!buf) {
12913 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12914 return QDF_STATUS_E_FAILURE;
12915 }
12916
12917 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12918 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12919 WMITLV_SET_HDR(&cmd->tlv_header,
12920 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12921 WMITLV_GET_STRUCT_TLVLEN
12922 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12923
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012924 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012925
12926 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12927
12928 for (ac = 0; ac < WME_NUM_AC; ac++) {
12929 wmep = &param->wmep_array[ac];
12930 wmm_param = (wmi_wmm_params *)buf_ptr;
12931 WMITLV_SET_HDR(&wmm_param->tlv_header,
12932 WMITLV_TAG_STRUC_wmi_wmm_params,
12933 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12934 wmm_param->aifs = wmep->wmep_aifsn;
12935 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12936 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12937 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12938 wmm_param->acm = wmep->wmep_acm;
12939 wmm_param->no_ack = wmep->wmep_noackPolicy;
12940 buf_ptr += sizeof(wmi_wmm_params);
12941 }
12942 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12943 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12944
12945 if (ret != 0) {
12946 WMI_LOGE("Sending WMM update CMD failed\n");
12947 wmi_buf_free(buf);
12948 }
12949
12950 return ret;
12951}
12952
Sathish Kumar80f4f382017-04-24 11:36:00 +053012953/**
12954 * send_coex_config_cmd_tlv() - send coex config command to fw
12955 * @wmi_handle: wmi handle
12956 * @param: pointer to coex config param
12957 *
12958 * Return: 0 for success or error code
12959 */
12960static QDF_STATUS
12961send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12962 struct coex_config_params *param)
12963{
12964 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12965 wmi_buf_t buf;
12966 QDF_STATUS ret;
12967 int32_t len;
12968
12969 len = sizeof(*cmd);
12970 buf = wmi_buf_alloc(wmi_handle, len);
12971 if (!buf) {
12972 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12973 return QDF_STATUS_E_FAILURE;
12974 }
12975
12976 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12977 WMITLV_SET_HDR(&cmd->tlv_header,
12978 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12979 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012980 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012981
12982 cmd->vdev_id = param->vdev_id;
12983 cmd->config_type = param->config_type;
12984 cmd->config_arg1 = param->config_arg1;
12985 cmd->config_arg2 = param->config_arg2;
12986 cmd->config_arg3 = param->config_arg3;
12987 cmd->config_arg4 = param->config_arg4;
12988 cmd->config_arg5 = param->config_arg5;
12989 cmd->config_arg6 = param->config_arg6;
12990
12991 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12992 WMI_COEX_CONFIG_CMDID);
12993
12994 if (ret != 0) {
12995 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12996 wmi_buf_free(buf);
12997 }
12998
12999 return ret;
13000}
13001
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013002static
Govind Singh9ddd5162016-03-07 16:30:32 +053013003void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053013004 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053013005{
Govind Singhe7f2f342016-05-23 12:12:52 +053013006 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053013007 resource_cfg->num_peers = tgt_res_cfg->num_peers;
13008 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
13009 resource_cfg->num_offload_reorder_buffs =
13010 tgt_res_cfg->num_offload_reorder_buffs;
13011 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
13012 resource_cfg->num_tids = tgt_res_cfg->num_tids;
13013 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
13014 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
13015 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
13016 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
13017 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
13018 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
13019 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
13020 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
13021 resource_cfg->scan_max_pending_req =
13022 tgt_res_cfg->scan_max_pending_req;
13023 resource_cfg->bmiss_offload_max_vdev =
13024 tgt_res_cfg->bmiss_offload_max_vdev;
13025 resource_cfg->roam_offload_max_vdev =
13026 tgt_res_cfg->roam_offload_max_vdev;
13027 resource_cfg->roam_offload_max_ap_profiles =
13028 tgt_res_cfg->roam_offload_max_ap_profiles;
13029 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
13030 resource_cfg->num_mcast_table_elems =
13031 tgt_res_cfg->num_mcast_table_elems;
13032 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
13033 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
13034 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
13035 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
13036 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
13037 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
13038 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
13039 resource_cfg->vow_config = tgt_res_cfg->vow_config;
13040 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
13041 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
13042 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
13043 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
13044 resource_cfg->num_tdls_conn_table_entries =
13045 tgt_res_cfg->num_tdls_conn_table_entries;
13046 resource_cfg->beacon_tx_offload_max_vdev =
13047 tgt_res_cfg->beacon_tx_offload_max_vdev;
13048 resource_cfg->num_multicast_filter_entries =
13049 tgt_res_cfg->num_multicast_filter_entries;
13050 resource_cfg->num_wow_filters =
13051 tgt_res_cfg->num_wow_filters;
13052 resource_cfg->num_keep_alive_pattern =
13053 tgt_res_cfg->num_keep_alive_pattern;
13054 resource_cfg->keep_alive_pattern_size =
13055 tgt_res_cfg->keep_alive_pattern_size;
13056 resource_cfg->max_tdls_concurrent_sleep_sta =
13057 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
13058 resource_cfg->max_tdls_concurrent_buffer_sta =
13059 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
13060 resource_cfg->wmi_send_separate =
13061 tgt_res_cfg->wmi_send_separate;
13062 resource_cfg->num_ocb_vdevs =
13063 tgt_res_cfg->num_ocb_vdevs;
13064 resource_cfg->num_ocb_channels =
13065 tgt_res_cfg->num_ocb_channels;
13066 resource_cfg->num_ocb_schedules =
13067 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013068 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
13069 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
13070 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013071 resource_cfg->max_num_dbs_scan_duty_cycle =
13072 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080013073 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053013074
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013075 if (tgt_res_cfg->atf_config)
13076 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
13077 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
13078 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
13079 resource_cfg->flag1, 1);
13080 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
13081 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
13082 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053013083 if (tgt_res_cfg->cce_disable)
13084 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Govind Singh9ddd5162016-03-07 16:30:32 +053013085}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013086
13087/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13088 * @wmi_handle: pointer to wmi handle
13089 * @buf_ptr: pointer to current position in init command buffer
13090 * @len: pointer to length. This will be updated with current lenght of cmd
13091 * @param: point host parameters for init command
13092 *
13093 * Return: Updated pointer of buf_ptr.
13094 */
13095static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
13096 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
13097{
13098 uint16_t idx;
13099
13100 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13101 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13102 wmi_pdev_band_to_mac *band_to_mac;
13103
13104 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13105 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13106 sizeof(wmi_resource_config) +
13107 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13108 sizeof(wlan_host_memory_chunk)));
13109
13110 WMITLV_SET_HDR(&hw_mode->tlv_header,
13111 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13112 (WMITLV_GET_STRUCT_TLVLEN
13113 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13114
13115 hw_mode->hw_mode_index = param->hw_mode_id;
13116 hw_mode->num_band_to_mac = param->num_band_to_mac;
13117
13118 buf_ptr = (uint8_t *) (hw_mode + 1);
13119 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13120 WMI_TLV_HDR_SIZE);
13121 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13122 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13123 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13124 WMITLV_GET_STRUCT_TLVLEN
13125 (wmi_pdev_band_to_mac));
13126 band_to_mac[idx].pdev_id =
13127 wmi_handle->ops->convert_pdev_id_host_to_target(
13128 param->band_to_mac[idx].pdev_id);
13129 band_to_mac[idx].start_freq =
13130 param->band_to_mac[idx].start_freq;
13131 band_to_mac[idx].end_freq =
13132 param->band_to_mac[idx].end_freq;
13133 }
13134 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13135 (param->num_band_to_mac *
13136 sizeof(wmi_pdev_band_to_mac)) +
13137 WMI_TLV_HDR_SIZE;
13138
13139 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13140 (param->num_band_to_mac *
13141 sizeof(wmi_pdev_band_to_mac)));
13142 }
13143
13144 return buf_ptr;
13145}
13146
13147static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
13148 wmi_init_cmd_fixed_param *cmd)
13149{
13150 int num_whitelist;
13151 wmi_abi_version my_vers;
13152
13153 num_whitelist = sizeof(version_whitelist) /
13154 sizeof(wmi_whitelist_version_info);
13155 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13156 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13157 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13158 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13159 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13160 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13161
13162 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13163 &my_vers,
13164 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13165 &cmd->host_abi_vers);
13166
13167 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13168 __func__,
13169 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13170 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13171 cmd->host_abi_vers.abi_version_ns_0,
13172 cmd->host_abi_vers.abi_version_ns_1,
13173 cmd->host_abi_vers.abi_version_ns_2,
13174 cmd->host_abi_vers.abi_version_ns_3);
13175
13176 /* Save version sent from host -
13177 * Will be used to check ready event
13178 */
13179 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13180 sizeof(wmi_abi_version));
13181}
13182
Sathish Kumarfd347372017-02-13 12:29:09 +053013183static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013184{
13185 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13186 wmi_service_ready_event_fixed_param *ev;
13187
13188
13189 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13190
13191 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13192 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013193 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013194
13195 /*Save fw version from service ready message */
13196 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013197 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013198 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013199
Govind Singhb53420c2016-03-09 14:32:57 +053013200 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013201}
13202
13203/**
13204 * wmi_unified_save_fw_version_cmd() - save fw version
13205 * @wmi_handle: pointer to wmi handle
13206 * @res_cfg: resource config
13207 * @num_mem_chunks: no of mem chunck
13208 * @mem_chunk: pointer to mem chunck structure
13209 *
13210 * This function sends IE information to firmware
13211 *
Govind Singhb53420c2016-03-09 14:32:57 +053013212 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013213 *
13214 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013215static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013216 void *evt_buf)
13217{
13218 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13219 wmi_ready_event_fixed_param *ev = NULL;
13220
13221 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13222 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013223 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13224 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013225 &ev->fw_abi_vers)) {
13226 /*
13227 * Error: Our host version and the given firmware version
13228 * are incompatible.
13229 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013230 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013231 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13232 __func__,
13233 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13234 abi_version_0),
13235 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13236 abi_version_0),
13237 wmi_handle->final_abi_vers.abi_version_ns_0,
13238 wmi_handle->final_abi_vers.abi_version_ns_1,
13239 wmi_handle->final_abi_vers.abi_version_ns_2,
13240 wmi_handle->final_abi_vers.abi_version_ns_3,
13241 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13242 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13243 ev->fw_abi_vers.abi_version_ns_0,
13244 ev->fw_abi_vers.abi_version_ns_1,
13245 ev->fw_abi_vers.abi_version_ns_2,
13246 ev->fw_abi_vers.abi_version_ns_3);
13247
Govind Singhb53420c2016-03-09 14:32:57 +053013248 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013249 }
Govind Singhb53420c2016-03-09 14:32:57 +053013250 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013251 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013252 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013253 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013254
Govind Singhb53420c2016-03-09 14:32:57 +053013255 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013256}
Govind Singha4836fd2016-03-07 16:45:38 +053013257
13258/**
13259 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13260 * @wmi_handle: wmi handle
13261 * @custom_addr: base mac address
13262 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013263 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013264 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013265static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013266 uint8_t *custom_addr)
13267{
13268 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13269 wmi_buf_t buf;
13270 int err;
13271
13272 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13273 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013274 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013275 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013276 }
13277
13278 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013279 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013280
13281 WMITLV_SET_HDR(&cmd->tlv_header,
13282 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13283 WMITLV_GET_STRUCT_TLVLEN
13284 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13285 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013286 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13287 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013288 err = wmi_unified_cmd_send(wmi_handle, buf,
13289 sizeof(*cmd),
13290 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13291 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013292 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013293 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013294 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013295 }
13296
13297 return 0;
13298}
13299
13300/**
13301 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13302 * @handle: wmi handle
13303 * @event: Event received from FW
13304 * @len: Length of the event
13305 *
13306 * Enables the low frequency events and disables the high frequency
13307 * events. Bit 17 indicates if the event if low/high frequency.
13308 * 1 - high frequency, 0 - low frequency
13309 *
13310 * Return: 0 on successfully enabling/disabling the events
13311 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013312static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013313 uint8_t *event,
13314 uint32_t len)
13315{
13316 uint32_t num_of_diag_events_logs;
13317 wmi_diag_event_log_config_fixed_param *cmd;
13318 wmi_buf_t buf;
13319 uint8_t *buf_ptr;
13320 uint32_t *cmd_args, *evt_args;
13321 uint32_t buf_len, i;
13322
13323 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13324 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13325
Govind Singhb53420c2016-03-09 14:32:57 +053013326 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013327
13328 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13329 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013330 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013331 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013332 }
13333 wmi_event = param_buf->fixed_param;
13334 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013335
13336 if (num_of_diag_events_logs >
13337 param_buf->num_diag_events_logs_list) {
13338 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13339 num_of_diag_events_logs,
13340 param_buf->num_diag_events_logs_list);
13341 return QDF_STATUS_E_INVAL;
13342 }
13343
Govind Singha4836fd2016-03-07 16:45:38 +053013344 evt_args = param_buf->diag_events_logs_list;
13345 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013346 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013347 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013348 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013349 }
13350
Govind Singhb53420c2016-03-09 14:32:57 +053013351 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013352 __func__, num_of_diag_events_logs);
13353
13354 /* Free any previous allocation */
13355 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013356 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013357
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013358 if (num_of_diag_events_logs >
13359 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13360 WMI_LOGE("%s: excess num of logs:%d", __func__,
13361 num_of_diag_events_logs);
13362 QDF_ASSERT(0);
13363 return QDF_STATUS_E_INVAL;
13364 }
Govind Singha4836fd2016-03-07 16:45:38 +053013365 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013366 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013367 sizeof(uint32_t));
13368 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013369 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013370 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013371 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013372 }
13373 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13374
13375 /* Prepare the send buffer */
13376 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13377 (num_of_diag_events_logs * sizeof(uint32_t));
13378
13379 buf = wmi_buf_alloc(wmi_handle, buf_len);
13380 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013381 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13382 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013383 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013384 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013385 }
13386
13387 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13388 buf_ptr = (uint8_t *) cmd;
13389
13390 WMITLV_SET_HDR(&cmd->tlv_header,
13391 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13392 WMITLV_GET_STRUCT_TLVLEN(
13393 wmi_diag_event_log_config_fixed_param));
13394
13395 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13396
13397 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13398
13399 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13400 (num_of_diag_events_logs * sizeof(uint32_t)));
13401
13402 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13403
13404 /* Populate the events */
13405 for (i = 0; i < num_of_diag_events_logs; i++) {
13406 /* Low freq (0) - Enable (1) the event
13407 * High freq (1) - Disable (0) the event
13408 */
13409 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13410 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13411 /* Set the event ID */
13412 WMI_DIAG_ID_SET(cmd_args[i],
13413 WMI_DIAG_ID_GET(evt_args[i]));
13414 /* Set the type */
13415 WMI_DIAG_TYPE_SET(cmd_args[i],
13416 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013417 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013418 wmi_handle->events_logs_list[i] = evt_args[i];
13419 }
13420
13421 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13422 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013423 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013424 __func__);
13425 wmi_buf_free(buf);
13426 /* Not clearing events_logs_list, though wmi cmd failed.
13427 * Host can still have this list
13428 */
Govind Singh67922e82016-04-01 16:48:57 +053013429 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013430 }
13431
13432 return 0;
13433}
13434
13435/**
13436 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13437 * @wmi_handle: wmi handle
13438 * @start_log: Start logging related parameters
13439 *
13440 * Send the command to the FW based on which specific logging of diag
13441 * event/log id can be started/stopped
13442 *
13443 * Return: None
13444 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013445static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013446 struct wmi_wifi_start_log *start_log)
13447{
13448 wmi_diag_event_log_config_fixed_param *cmd;
13449 wmi_buf_t buf;
13450 uint8_t *buf_ptr;
13451 uint32_t len, count, log_level, i;
13452 uint32_t *cmd_args;
13453 uint32_t total_len;
13454 count = 0;
13455
13456 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013457 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013458 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013459 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013460 }
13461 /* total_len stores the number of events where BITS 17 and 18 are set.
13462 * i.e., events of high frequency (17) and for extended debugging (18)
13463 */
13464 total_len = 0;
13465 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13466 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13467 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13468 total_len++;
13469 }
13470
13471 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13472 (total_len * sizeof(uint32_t));
13473
13474 buf = wmi_buf_alloc(wmi_handle, len);
13475 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013476 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013477 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013478 }
13479 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13480 buf_ptr = (uint8_t *) cmd;
13481
13482 WMITLV_SET_HDR(&cmd->tlv_header,
13483 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13484 WMITLV_GET_STRUCT_TLVLEN(
13485 wmi_diag_event_log_config_fixed_param));
13486
13487 cmd->num_of_diag_events_logs = total_len;
13488
13489 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13490
13491 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13492 (total_len * sizeof(uint32_t)));
13493
13494 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13495
Govind Singh224a7312016-06-21 14:33:26 +053013496 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013497 log_level = 1;
13498 else
13499 log_level = 0;
13500
Govind Singhb53420c2016-03-09 14:32:57 +053013501 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013502 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13503 uint32_t val = wmi_handle->events_logs_list[i];
13504 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13505 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13506
13507 WMI_DIAG_ID_SET(cmd_args[count],
13508 WMI_DIAG_ID_GET(val));
13509 WMI_DIAG_TYPE_SET(cmd_args[count],
13510 WMI_DIAG_TYPE_GET(val));
13511 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13512 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013513 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013514 count++;
13515 }
13516 }
13517
13518 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13519 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013520 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013521 __func__);
13522 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013523 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013524 }
13525
Govind Singhb53420c2016-03-09 14:32:57 +053013526 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013527}
13528
13529/**
13530 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13531 * @wmi_handle: WMI handle
13532 *
13533 * This function is used to send the flush command to the FW,
13534 * that will flush the fw logs that are residue in the FW
13535 *
13536 * Return: None
13537 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013538static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013539{
13540 wmi_debug_mesg_flush_fixed_param *cmd;
13541 wmi_buf_t buf;
13542 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013543 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013544
13545 buf = wmi_buf_alloc(wmi_handle, len);
13546 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013547 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013548 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013549 }
13550
13551 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13552 WMITLV_SET_HDR(&cmd->tlv_header,
13553 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13554 WMITLV_GET_STRUCT_TLVLEN(
13555 wmi_debug_mesg_flush_fixed_param));
13556 cmd->reserved0 = 0;
13557
13558 ret = wmi_unified_cmd_send(wmi_handle,
13559 buf,
13560 len,
13561 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013562 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013563 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013564 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013565 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013566 }
Govind Singhb53420c2016-03-09 14:32:57 +053013567 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013568
Govind Singh67922e82016-04-01 16:48:57 +053013569 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013570}
13571
13572/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013573 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013574 * @wmi_handle: wmi handle
13575 * @msg: PCL structure containing the PCL and the number of channels
13576 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013577 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013578 * firmware. The DBS Manager is the consumer of this information in the WLAN
13579 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13580 * to migrate to a new channel without host driver involvement. An example of
13581 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13582 * manage the channel selection without firmware involvement.
13583 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013584 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13585 * channel list. The weights corresponds to the channels sent in
13586 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13587 * weightage compared to the non PCL channels.
13588 *
Govind Singha4836fd2016-03-07 16:45:38 +053013589 * Return: Success if the cmd is sent successfully to the firmware
13590 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013591static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013592 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013593{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013594 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013595 wmi_buf_t buf;
13596 uint8_t *buf_ptr;
13597 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013598 uint32_t chan_len;
13599
13600 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013601
13602 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013603 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013604
13605 buf = wmi_buf_alloc(wmi_handle, len);
13606 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013607 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13608 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013609 }
13610
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013611 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013612 buf_ptr = (uint8_t *) cmd;
13613 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013614 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13615 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013616
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013617 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13618 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013619 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013620 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013621
13622 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013623 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013624 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013625 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013626 for (i = 0; i < chan_len ; i++) {
13627 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013628 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013629 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013630 }
13631 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013632 WMI_PDEV_SET_PCL_CMDID)) {
13633 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013634 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013635 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013636 }
Govind Singhb53420c2016-03-09 14:32:57 +053013637 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013638}
13639
13640/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013641 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013642 * @wmi_handle: wmi handle
13643 * @msg: Structure containing the following parameters
13644 *
13645 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13646 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13647 *
13648 * Provides notification to the WLAN firmware that host driver is requesting a
13649 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13650 * configurations that include the Dual Band Simultaneous (DBS) feature.
13651 *
13652 * Return: Success if the cmd is sent successfully to the firmware
13653 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013654static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013655 uint32_t hw_mode_index)
13656{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013657 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013658 wmi_buf_t buf;
13659 uint32_t len;
13660
13661 len = sizeof(*cmd);
13662
13663 buf = wmi_buf_alloc(wmi_handle, len);
13664 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013665 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13666 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013667 }
13668
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013669 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013670 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013671 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13672 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13673
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013674 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13675 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013676 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013677 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013678
13679 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013680 WMI_PDEV_SET_HW_MODE_CMDID)) {
13681 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013682 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013683 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013684 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013685 }
13686
Govind Singhb53420c2016-03-09 14:32:57 +053013687 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013688}
13689
13690/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013691 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013692 * @wmi_handle: wmi handle
13693 * @msg: Dual MAC config parameters
13694 *
13695 * Configures WLAN firmware with the dual MAC features
13696 *
Govind Singhb53420c2016-03-09 14:32:57 +053013697 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013698 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013699static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013700QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013701 struct wmi_dual_mac_config *msg)
13702{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013703 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013704 wmi_buf_t buf;
13705 uint32_t len;
13706
13707 len = sizeof(*cmd);
13708
13709 buf = wmi_buf_alloc(wmi_handle, len);
13710 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013711 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13712 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013713 }
13714
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013715 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013716 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013717 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013718 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013719 wmi_pdev_set_mac_config_cmd_fixed_param));
13720
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013721 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13722 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013723 cmd->concurrent_scan_config_bits = msg->scan_config;
13724 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013725 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013726 __func__, msg->scan_config, msg->fw_mode_config);
13727
13728 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013729 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13730 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013731 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013732 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013733 }
Govind Singhb53420c2016-03-09 14:32:57 +053013734 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013735}
13736
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013737#ifdef BIG_ENDIAN_HOST
13738/**
13739* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13740* @param data_len - data length
13741* @param data - pointer to data
13742*
13743* Return: QDF_STATUS - success or error status
13744*/
13745static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13746 struct fips_params *param)
13747{
13748 unsigned char *key_unaligned, *data_unaligned;
13749 int c;
13750 u_int8_t *key_aligned = NULL;
13751 u_int8_t *data_aligned = NULL;
13752
13753 /* Assigning unaligned space to copy the key */
13754 key_unaligned = qdf_mem_malloc(
13755 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13756 data_unaligned = qdf_mem_malloc(
13757 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13758
13759 /* Checking if kmalloc is succesful to allocate space */
13760 if (key_unaligned == NULL)
13761 return QDF_STATUS_SUCCESS;
13762 /* Checking if space is aligned */
13763 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13764 /* align to 4 */
13765 key_aligned =
13766 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13767 FIPS_ALIGN);
13768 } else {
13769 key_aligned = (u_int8_t *)key_unaligned;
13770 }
13771
13772 /* memset and copy content from key to key aligned */
13773 OS_MEMSET(key_aligned, 0, param->key_len);
13774 OS_MEMCPY(key_aligned, param->key, param->key_len);
13775
13776 /* print a hexdump for host debug */
13777 print_hex_dump(KERN_DEBUG,
13778 "\t Aligned and Copied Key:@@@@ ",
13779 DUMP_PREFIX_NONE,
13780 16, 1, key_aligned, param->key_len, true);
13781
13782 /* Checking if kmalloc is succesful to allocate space */
13783 if (data_unaligned == NULL)
13784 return QDF_STATUS_SUCCESS;
13785 /* Checking of space is aligned */
13786 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13787 /* align to 4 */
13788 data_aligned =
13789 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13790 FIPS_ALIGN);
13791 } else {
13792 data_aligned = (u_int8_t *)data_unaligned;
13793 }
13794
13795 /* memset and copy content from data to data aligned */
13796 OS_MEMSET(data_aligned, 0, param->data_len);
13797 OS_MEMCPY(data_aligned, param->data, param->data_len);
13798
13799 /* print a hexdump for host debug */
13800 print_hex_dump(KERN_DEBUG,
13801 "\t Properly Aligned and Copied Data:@@@@ ",
13802 DUMP_PREFIX_NONE,
13803 16, 1, data_aligned, param->data_len, true);
13804
13805 /* converting to little Endian both key_aligned and
13806 * data_aligned*/
13807 for (c = 0; c < param->key_len/4; c++) {
13808 *((u_int32_t *)key_aligned+c) =
13809 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13810 }
13811 for (c = 0; c < param->data_len/4; c++) {
13812 *((u_int32_t *)data_aligned+c) =
13813 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13814 }
13815
13816 /* update endian data to key and data vectors */
13817 OS_MEMCPY(param->key, key_aligned, param->key_len);
13818 OS_MEMCPY(param->data, data_aligned, param->data_len);
13819
13820 /* clean up allocated spaces */
13821 qdf_mem_free(key_unaligned);
13822 key_unaligned = NULL;
13823 key_aligned = NULL;
13824
13825 qdf_mem_free(data_unaligned);
13826 data_unaligned = NULL;
13827 data_aligned = NULL;
13828
13829 return QDF_STATUS_SUCCESS;
13830}
13831#else
13832/**
13833* fips_align_data_be() - DUMMY for LE platform
13834*
13835* Return: QDF_STATUS - success
13836*/
13837static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13838 struct fips_params *param)
13839{
13840 return QDF_STATUS_SUCCESS;
13841}
13842#endif
13843
13844
13845/**
13846 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13847 * @wmi_handle: wmi handle
13848 * @param: pointer to hold pdev fips param
13849 *
13850 * Return: 0 for success or error code
13851 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013852static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013853send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13854 struct fips_params *param)
13855{
13856 wmi_pdev_fips_cmd_fixed_param *cmd;
13857 wmi_buf_t buf;
13858 uint8_t *buf_ptr;
13859 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13860 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13861
13862 /* Length TLV placeholder for array of bytes */
13863 len += WMI_TLV_HDR_SIZE;
13864 if (param->data_len)
13865 len += (param->data_len*sizeof(uint8_t));
13866
13867 /*
13868 * Data length must be multiples of 16 bytes - checked against 0xF -
13869 * and must be less than WMI_SVC_MSG_SIZE - static size of
13870 * wmi_pdev_fips_cmd structure
13871 */
13872
13873 /* do sanity on the input */
13874 if (!(((param->data_len & 0xF) == 0) &&
13875 ((param->data_len > 0) &&
13876 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13877 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13878 return QDF_STATUS_E_INVAL;
13879 }
13880
13881 buf = wmi_buf_alloc(wmi_handle, len);
13882 if (!buf) {
13883 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
13884 return QDF_STATUS_E_FAILURE;
13885 }
13886
13887 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13888 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13889 WMITLV_SET_HDR(&cmd->tlv_header,
13890 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13891 WMITLV_GET_STRUCT_TLVLEN
13892 (wmi_pdev_fips_cmd_fixed_param));
13893
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013894 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13895 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013896 if (param->key != NULL && param->data != NULL) {
13897 cmd->key_len = param->key_len;
13898 cmd->data_len = param->data_len;
13899 cmd->fips_cmd = !!(param->op);
13900
13901 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13902 return QDF_STATUS_E_FAILURE;
13903
13904 qdf_mem_copy(cmd->key, param->key, param->key_len);
13905
13906 if (param->mode == FIPS_ENGINE_AES_CTR ||
13907 param->mode == FIPS_ENGINE_AES_MIC) {
13908 cmd->mode = param->mode;
13909 } else {
13910 cmd->mode = FIPS_ENGINE_AES_CTR;
13911 }
13912 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
13913 cmd->key_len, cmd->data_len);
13914
13915 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13916 cmd->key, cmd->key_len, true);
13917 buf_ptr += sizeof(*cmd);
13918
13919 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13920
13921 buf_ptr += WMI_TLV_HDR_SIZE;
13922 if (param->data_len)
13923 qdf_mem_copy(buf_ptr,
13924 (uint8_t *) param->data, param->data_len);
13925
13926 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13927 16, 1, buf_ptr, cmd->data_len, true);
13928
13929 buf_ptr += param->data_len;
13930
13931 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13932 WMI_PDEV_FIPS_CMDID);
13933 qdf_print("%s return value %d\n", __func__, retval);
13934 } else {
13935 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
13936 wmi_buf_free(buf);
13937 retval = -QDF_STATUS_E_BADMSG;
13938 }
13939
13940 return retval;
13941}
13942
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013943#ifdef WLAN_PMO_ENABLE
13944/**
13945 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13946 * @wmi_handle: wmi handle
13947 * @vdev_id: vdev id
13948 * @bitmap: Event bitmap
13949 * @enable: enable/disable
13950 *
13951 * Return: CDF status
13952 */
13953static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13954 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013955 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013956 bool enable)
13957{
13958 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13959 uint16_t len;
13960 wmi_buf_t buf;
13961 int ret;
13962
13963 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13964 buf = wmi_buf_alloc(wmi_handle, len);
13965 if (!buf) {
13966 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13967 return QDF_STATUS_E_NOMEM;
13968 }
13969 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13970 WMITLV_SET_HDR(&cmd->tlv_header,
13971 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13972 WMITLV_GET_STRUCT_TLVLEN
13973 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13974 cmd->vdev_id = vdev_id;
13975 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013976 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13977 WMI_WOW_MAX_EVENT_BM_LEN);
13978
13979 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13980 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13981 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013982
13983 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13984 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13985 if (ret) {
13986 WMI_LOGE("Failed to config wow wakeup event");
13987 wmi_buf_free(buf);
13988 return QDF_STATUS_E_FAILURE;
13989 }
13990
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013991 return QDF_STATUS_SUCCESS;
13992}
13993
13994/**
13995 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13996 * @wmi_handle: wmi handle
13997 * @vdev_id: vdev id
13998 * @ptrn_id: pattern id
13999 * @ptrn: pattern
14000 * @ptrn_len: pattern length
14001 * @ptrn_offset: pattern offset
14002 * @mask: mask
14003 * @mask_len: mask length
14004 * @user: true for user configured pattern and false for default pattern
14005 * @default_patterns: default patterns
14006 *
14007 * Return: CDF status
14008 */
14009static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
14010 uint8_t vdev_id, uint8_t ptrn_id,
14011 const uint8_t *ptrn, uint8_t ptrn_len,
14012 uint8_t ptrn_offset, const uint8_t *mask,
14013 uint8_t mask_len, bool user,
14014 uint8_t default_patterns)
14015{
14016 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14017 WOW_BITMAP_PATTERN_T *bitmap_pattern;
14018 wmi_buf_t buf;
14019 uint8_t *buf_ptr;
14020 int32_t len;
14021 int ret;
14022
14023 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14024 WMI_TLV_HDR_SIZE +
14025 1 * sizeof(WOW_BITMAP_PATTERN_T) +
14026 WMI_TLV_HDR_SIZE +
14027 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14028 WMI_TLV_HDR_SIZE +
14029 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14030 WMI_TLV_HDR_SIZE +
14031 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14032 WMI_TLV_HDR_SIZE +
14033 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
14034
14035 buf = wmi_buf_alloc(wmi_handle, len);
14036 if (!buf) {
14037 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14038 return QDF_STATUS_E_NOMEM;
14039 }
14040
14041 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14042 buf_ptr = (uint8_t *) cmd;
14043
14044 WMITLV_SET_HDR(&cmd->tlv_header,
14045 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14046 WMITLV_GET_STRUCT_TLVLEN
14047 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14048 cmd->vdev_id = vdev_id;
14049 cmd->pattern_id = ptrn_id;
14050
14051 cmd->pattern_type = WOW_BITMAP_PATTERN;
14052 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14053
14054 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14055 sizeof(WOW_BITMAP_PATTERN_T));
14056 buf_ptr += WMI_TLV_HDR_SIZE;
14057 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
14058
14059 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
14060 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
14061 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
14062
14063 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
14064 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
14065
14066 bitmap_pattern->pattern_offset = ptrn_offset;
14067 bitmap_pattern->pattern_len = ptrn_len;
14068
14069 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
14070 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
14071
14072 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
14073 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
14074
14075 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
14076 bitmap_pattern->pattern_id = ptrn_id;
14077
14078 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
14079 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
14080 bitmap_pattern->pattern_offset, user);
14081 WMI_LOGI("Pattern : ");
14082 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14083 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
14084
14085 WMI_LOGI("Mask : ");
14086 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14087 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
14088
14089 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
14090
14091 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14092 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14093 buf_ptr += WMI_TLV_HDR_SIZE;
14094
14095 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14096 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14097 buf_ptr += WMI_TLV_HDR_SIZE;
14098
14099 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14100 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14101 buf_ptr += WMI_TLV_HDR_SIZE;
14102
14103 /* Fill TLV for pattern_info_timeout but no data. */
14104 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14105 buf_ptr += WMI_TLV_HDR_SIZE;
14106
14107 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
14108 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
14109 buf_ptr += WMI_TLV_HDR_SIZE;
14110 *(A_UINT32 *) buf_ptr = 0;
14111
14112 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14113 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14114 if (ret) {
14115 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
14116 wmi_buf_free(buf);
14117 return QDF_STATUS_E_FAILURE;
14118 }
14119
14120 return QDF_STATUS_SUCCESS;
14121}
14122
Govind Singha4836fd2016-03-07 16:45:38 +053014123/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014124 * fill_arp_offload_params_tlv() - Fill ARP offload data
14125 * @wmi_handle: wmi handle
14126 * @offload_req: offload request
14127 * @buf_ptr: buffer pointer
14128 *
14129 * To fill ARP offload data to firmware
14130 * when target goes to wow mode.
14131 *
14132 * Return: None
14133 */
14134static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014135 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014136{
14137
14138 int i;
14139 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014140 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014141
14142 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14143 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
14144 *buf_ptr += WMI_TLV_HDR_SIZE;
14145 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
14146 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
14147 WMITLV_SET_HDR(&arp_tuple->tlv_header,
14148 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
14149 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
14150
14151 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014152 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014153 /* Copy the target ip addr and flags */
14154 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
14155 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014156 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014157 WMI_IPV4_ADDR_LEN);
14158 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014159 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014160 }
14161 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
14162 }
14163}
14164
14165#ifdef WLAN_NS_OFFLOAD
14166/**
14167 * fill_ns_offload_params_tlv() - Fill NS offload data
14168 * @wmi|_handle: wmi handle
14169 * @offload_req: offload request
14170 * @buf_ptr: buffer pointer
14171 *
14172 * To fill NS offload data to firmware
14173 * when target goes to wow mode.
14174 *
14175 * Return: None
14176 */
14177static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014178 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014179{
14180
14181 int i;
14182 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014183
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014184 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14185 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14186 *buf_ptr += WMI_TLV_HDR_SIZE;
14187 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14188 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14189 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14190 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14191 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14192
14193 /*
14194 * Fill data only for NS offload in the first ARP tuple for LA
14195 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014196 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014197 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14198 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014199 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014200 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014201 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014202 sizeof(WMI_IPV6_ADDR));
14203 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014204 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014205 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014206 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014207 ns_tuple->flags |=
14208 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14209 }
14210 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014211 i, &ns_req->self_ipv6_addr[i],
14212 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014213
14214 /* target MAC is optional, check if it is valid,
14215 * if this is not valid, the target will use the known
14216 * local MAC address rather than the tuple
14217 */
14218 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014219 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014220 &ns_tuple->target_mac);
14221 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14222 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14223 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14224 }
14225 }
14226 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14227 }
14228}
14229
14230
14231/**
14232 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14233 * @wmi: wmi handle
14234 * @offload_req: offload request
14235 * @buf_ptr: buffer pointer
14236 *
14237 * To fill extended NS offload extended data to firmware
14238 * when target goes to wow mode.
14239 *
14240 * Return: None
14241 */
14242static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014243 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014244{
14245 int i;
14246 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14247 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014248
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014249 count = ns_req->num_ns_offload_count;
14250 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014251 WMI_MAX_NS_OFFLOADS;
14252
14253 /* Populate extended NS offload tuples */
14254 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14255 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14256 *buf_ptr += WMI_TLV_HDR_SIZE;
14257 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14258 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14259 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14260 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14261 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14262
14263 /*
14264 * Fill data only for NS offload in the first ARP tuple for LA
14265 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014266 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014267 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14268 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014269 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014270 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014271 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014272 sizeof(WMI_IPV6_ADDR));
14273 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014274 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014275 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014276 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014277 ns_tuple->flags |=
14278 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14279 }
14280 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014281 i, &ns_req->self_ipv6_addr[i],
14282 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014283
14284 /* target MAC is optional, check if it is valid,
14285 * if this is not valid, the target will use the
14286 * known local MAC address rather than the tuple
14287 */
14288 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014289 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014290 &ns_tuple->target_mac);
14291 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14292 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14293 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14294 }
14295 }
14296 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14297 }
14298}
14299#else
14300static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014301 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014302{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014303}
14304
14305static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014306 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014307{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014308}
14309#endif
14310
14311/**
Govind Singha4836fd2016-03-07 16:45:38 +053014312 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14313 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014314 * @arp_offload_req: arp offload request
14315 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014316 * @arp_only: flag
14317 *
14318 * To configure ARP NS off load data to firmware
14319 * when target goes to wow mode.
14320 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014321 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014322 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014323static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014324 struct pmo_arp_offload_params *arp_offload_req,
14325 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014326 uint8_t vdev_id)
14327{
Govind Singha4836fd2016-03-07 16:45:38 +053014328 int32_t res;
14329 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053014330 A_UINT8 *buf_ptr;
14331 wmi_buf_t buf;
14332 int32_t len;
14333 uint32_t count = 0, num_ns_ext_tuples = 0;
14334
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014335 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014336
Govind Singha4836fd2016-03-07 16:45:38 +053014337 /*
14338 * TLV place holder size for array of NS tuples
14339 * TLV place holder size for array of ARP tuples
14340 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014341 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14342 WMI_TLV_HDR_SIZE +
14343 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14344 WMI_TLV_HDR_SIZE +
14345 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014346
14347 /*
14348 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14349 * extra length for extended NS offload tuples which follows ARP offload
14350 * tuples. Host needs to fill this structure in following format:
14351 * 2 NS ofload tuples
14352 * 2 ARP offload tuples
14353 * N numbers of extended NS offload tuples if HDD has given more than
14354 * 2 NS offload addresses
14355 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014356 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014357 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014358 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14359 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014360 }
14361
14362 buf = wmi_buf_alloc(wmi_handle, len);
14363 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014364 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014365 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014366 }
14367
14368 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14369 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14370 WMITLV_SET_HDR(&cmd->tlv_header,
14371 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14372 WMITLV_GET_STRUCT_TLVLEN
14373 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14374 cmd->flags = 0;
14375 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014376 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014377
Govind Singhb53420c2016-03-09 14:32:57 +053014378 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014379
Govind Singha4836fd2016-03-07 16:45:38 +053014380 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014381 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14382 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14383 if (num_ns_ext_tuples)
14384 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014385
14386 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14387 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14388 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014389 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014390 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014391 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014392 }
14393
Govind Singhb53420c2016-03-09 14:32:57 +053014394 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014395}
14396
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014397/**
14398 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14399 * @wmi_handle: wmi handle
14400 * @vdev_id: vdev id
14401 * @action: true for enable else false
14402 *
14403 * To enable enhance multicast offload to firmware
14404 * when target goes to wow mode.
14405 *
14406 * Return: QDF Status
14407 */
14408
14409static
14410QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14411 wmi_unified_t wmi_handle,
14412 uint8_t vdev_id, bool action)
14413{
14414 QDF_STATUS status;
14415 wmi_buf_t buf;
14416 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14417
14418 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14419 if (!buf) {
14420 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14421 return QDF_STATUS_E_NOMEM;
14422 }
14423
14424 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14425 wmi_buf_data(buf);
14426
14427 WMITLV_SET_HDR(&cmd->tlv_header,
14428 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14429 WMITLV_GET_STRUCT_TLVLEN(
14430 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14431
14432 cmd->vdev_id = vdev_id;
14433 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14434 ENHANCED_MCAST_FILTER_ENABLED);
14435 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14436 __func__, action, vdev_id);
14437 status = wmi_unified_cmd_send(wmi_handle, buf,
14438 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14439 if (status != QDF_STATUS_SUCCESS) {
14440 qdf_nbuf_free(buf);
14441 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14442 __func__);
14443 }
14444
14445 return status;
14446}
14447
14448/**
14449 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14450 * @wmi_handle: wmi handle
14451 * @param evt_buf: pointer to event buffer
14452 * @param hdr: Pointer to hold header
14453 * @param bufp: Pointer to hold pointer to rx param buffer
14454 *
14455 * Return: QDF_STATUS_SUCCESS for success or error code
14456 */
14457static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14458 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14459{
14460 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14461 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14462
14463 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14464 if (!param_buf) {
14465 WMI_LOGE("gtk param_buf is NULL");
14466 return QDF_STATUS_E_INVAL;
14467 }
14468
14469 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14470 WMI_LOGE("Invalid length for GTK status");
14471 return QDF_STATUS_E_INVAL;
14472 }
14473
14474 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14475 param_buf->fixed_param;
14476 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14477 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14478 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14479 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14480 &fixed_param->replay_counter,
14481 GTK_REPLAY_COUNTER_BYTES);
14482
14483 return QDF_STATUS_SUCCESS;
14484
14485}
14486
14487#ifdef FEATURE_WLAN_RA_FILTERING
14488/**
14489 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14490 * @wmi_handle: wmi handle
14491 * @vdev_id: vdev id
14492 *
14493 * Return: CDF status
14494 */
14495static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14496 uint8_t vdev_id, uint8_t default_pattern,
14497 uint16_t rate_limit_interval)
14498{
14499
14500 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14501 wmi_buf_t buf;
14502 uint8_t *buf_ptr;
14503 int32_t len;
14504 int ret;
14505
14506 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14507 WMI_TLV_HDR_SIZE +
14508 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14509 WMI_TLV_HDR_SIZE +
14510 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14511 WMI_TLV_HDR_SIZE +
14512 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14513 WMI_TLV_HDR_SIZE +
14514 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14515 WMI_TLV_HDR_SIZE +
14516 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
14517
14518 buf = wmi_buf_alloc(wmi_handle, len);
14519 if (!buf) {
14520 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14521 return QDF_STATUS_E_NOMEM;
14522 }
14523
14524 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14525 buf_ptr = (uint8_t *) cmd;
14526
14527 WMITLV_SET_HDR(&cmd->tlv_header,
14528 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14529 WMITLV_GET_STRUCT_TLVLEN
14530 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14531 cmd->vdev_id = vdev_id;
14532 cmd->pattern_id = default_pattern,
14533 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14534 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14535
14536 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14537 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14538 buf_ptr += WMI_TLV_HDR_SIZE;
14539
14540 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14541 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14542 buf_ptr += WMI_TLV_HDR_SIZE;
14543
14544 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14545 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14546 buf_ptr += WMI_TLV_HDR_SIZE;
14547
14548 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14549 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14550 buf_ptr += WMI_TLV_HDR_SIZE;
14551
14552 /* Fill TLV for pattern_info_timeout but no data. */
14553 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14554 buf_ptr += WMI_TLV_HDR_SIZE;
14555
14556 /* Fill TLV for ra_ratelimit_interval. */
14557 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
14558 buf_ptr += WMI_TLV_HDR_SIZE;
14559
14560 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
14561
14562 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14563 rate_limit_interval, vdev_id);
14564
14565 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14566 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14567 if (ret) {
14568 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14569 wmi_buf_free(buf);
14570 return QDF_STATUS_E_FAILURE;
14571 }
14572
14573 return QDF_STATUS_SUCCESS;
14574
14575}
14576#endif /* FEATURE_WLAN_RA_FILTERING */
14577
14578/**
14579 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14580 * @wmi_handle: wmi handle
14581 * @vdev_id: vdev id
14582 * @multicastAddr: mcast address
14583 * @clearList: clear list flag
14584 *
14585 * Return: QDF_STATUS_SUCCESS for success or error code
14586 */
14587static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14588 uint8_t vdev_id,
14589 struct qdf_mac_addr multicast_addr,
14590 bool clearList)
14591{
14592 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14593 wmi_buf_t buf;
14594 int err;
14595
14596 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14597 if (!buf) {
14598 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14599 return QDF_STATUS_E_NOMEM;
14600 }
14601
14602 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14603 qdf_mem_zero(cmd, sizeof(*cmd));
14604
14605 WMITLV_SET_HDR(&cmd->tlv_header,
14606 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14607 WMITLV_GET_STRUCT_TLVLEN
14608 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14609 cmd->action =
14610 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14611 cmd->vdev_id = vdev_id;
14612 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14613
14614 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14615 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14616
14617 err = wmi_unified_cmd_send(wmi_handle, buf,
14618 sizeof(*cmd),
14619 WMI_SET_MCASTBCAST_FILTER_CMDID);
14620 if (err) {
14621 WMI_LOGE("Failed to send set_param cmd");
14622 wmi_buf_free(buf);
14623 return QDF_STATUS_E_FAILURE;
14624 }
14625
14626 return QDF_STATUS_SUCCESS;
14627}
14628
14629/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014630 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14631 * command to fw
14632 * @wmi_handle: wmi handle
14633 * @vdev_id: vdev id
14634 * @mcast_filter_params: mcast filter params
14635 *
14636 * Return: QDF_STATUS_SUCCESS for success or error code
14637 */
14638static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14639 wmi_unified_t wmi_handle,
14640 uint8_t vdev_id,
14641 struct pmo_mcast_filter_params *filter_param)
14642
14643{
14644 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14645 uint8_t *buf_ptr;
14646 wmi_buf_t buf;
14647 int err;
14648 int i;
14649 uint8_t *mac_addr_src_ptr = NULL;
14650 wmi_mac_addr *mac_addr_dst_ptr;
14651 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14652 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14653
14654 buf = wmi_buf_alloc(wmi_handle, len);
14655 if (!buf) {
14656 WMI_LOGE("Failed to allocate memory");
14657 return QDF_STATUS_E_NOMEM;
14658 }
14659
14660 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14661 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14662 wmi_buf_data(buf);
14663 qdf_mem_zero(cmd, sizeof(*cmd));
14664
14665 WMITLV_SET_HDR(&cmd->tlv_header,
14666 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14667 WMITLV_GET_STRUCT_TLVLEN
14668 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14669 cmd->operation =
14670 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14671 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14672 cmd->vdev_id = vdev_id;
14673 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14674
14675 buf_ptr += sizeof(*cmd);
14676 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14677 sizeof(wmi_mac_addr) *
14678 filter_param->multicast_addr_cnt);
14679
14680 if (filter_param->multicast_addr_cnt == 0)
14681 goto send_cmd;
14682
14683 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14684 mac_addr_dst_ptr = (wmi_mac_addr *)
14685 (buf_ptr + WMI_TLV_HDR_SIZE);
14686
14687 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14688 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14689 mac_addr_src_ptr += ATH_MAC_LEN;
14690 mac_addr_dst_ptr++;
14691 }
14692
14693send_cmd:
14694 err = wmi_unified_cmd_send(wmi_handle, buf,
14695 len,
14696 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14697 if (err) {
14698 WMI_LOGE("Failed to send set_param cmd");
14699 wmi_buf_free(buf);
14700 return QDF_STATUS_E_FAILURE;
14701 }
14702
14703 return QDF_STATUS_SUCCESS;
14704}
14705
14706
14707/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014708 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14709 * @wmi_handle: wmi handle
14710 * @vdev_id: vdev id
14711 * @params: GTK offload parameters
14712 *
14713 * Return: CDF status
14714 */
14715static
14716QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14717 struct pmo_gtk_req *params,
14718 bool enable_offload,
14719 uint32_t gtk_offload_opcode)
14720{
14721 int len;
14722 wmi_buf_t buf;
14723 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014724 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014725 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014726 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014727
14728 WMI_LOGD("%s Enter", __func__);
14729
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014730 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014731
14732 /* alloc wmi buffer */
14733 buf = wmi_buf_alloc(wmi_handle, len);
14734 if (!buf) {
14735 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14736 status = QDF_STATUS_E_NOMEM;
14737 goto out;
14738 }
14739
14740 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014741 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014742 WMITLV_SET_HDR(&cmd->tlv_header,
14743 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14744 WMITLV_GET_STRUCT_TLVLEN
14745 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14746
14747 cmd->vdev_id = vdev_id;
14748
14749 /* Request target to enable GTK offload */
14750 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14751 cmd->flags = gtk_offload_opcode;
14752
14753 /* Copy the keys and replay counter */
14754 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014755 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014756 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14757 GTK_REPLAY_COUNTER_BYTES);
14758 } else {
14759 cmd->flags = gtk_offload_opcode;
14760 }
14761
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014762 buf_ptr += sizeof(*cmd);
14763 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
14764 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014765
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014766 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14767 WMITLV_SET_HDR(&ext_param->tlv_header,
14768 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14769 WMITLV_GET_STRUCT_TLVLEN(
14770 wmi_gtk_offload_fils_tlv_param));
14771 ext_param->vdev_id = vdev_id;
14772 ext_param->flags = cmd->flags;
14773 ext_param->kek_len = params->kek_len;
14774 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14775 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
14776 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14777 GTK_REPLAY_COUNTER_BYTES);
14778
14779 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x kek len %d", vdev_id, cmd->flags, params->kek_len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014780 /* send the wmi command */
14781 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14782 WMI_GTK_OFFLOAD_CMDID)) {
14783 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14784 wmi_buf_free(buf);
14785 status = QDF_STATUS_E_FAILURE;
14786 }
14787
14788out:
14789 WMI_LOGD("%s Exit", __func__);
14790 return status;
14791}
14792
14793/**
14794 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14795 * @wmi_handle: wmi handle
14796 * @params: GTK offload params
14797 *
14798 * Return: CDF status
14799 */
14800static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14801 wmi_unified_t wmi_handle,
14802 uint8_t vdev_id,
14803 uint64_t offload_req_opcode)
14804{
14805 int len;
14806 wmi_buf_t buf;
14807 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14808 QDF_STATUS status = QDF_STATUS_SUCCESS;
14809
14810 len = sizeof(*cmd);
14811
14812 /* alloc wmi buffer */
14813 buf = wmi_buf_alloc(wmi_handle, len);
14814 if (!buf) {
14815 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14816 status = QDF_STATUS_E_NOMEM;
14817 goto out;
14818 }
14819
14820 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14821 WMITLV_SET_HDR(&cmd->tlv_header,
14822 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14823 WMITLV_GET_STRUCT_TLVLEN
14824 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14825
14826 /* Request for GTK offload status */
14827 cmd->flags = offload_req_opcode;
14828 cmd->vdev_id = vdev_id;
14829
14830 /* send the wmi command */
14831 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14832 WMI_GTK_OFFLOAD_CMDID)) {
14833 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14834 wmi_buf_free(buf);
14835 status = QDF_STATUS_E_FAILURE;
14836 }
14837
14838out:
14839 return status;
14840}
14841
14842/**
14843 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14844 * @wmi_handle: wmi handler
14845 * @action_params: pointer to action_params
14846 *
14847 * Return: 0 for success, otherwise appropriate error code
14848 */
14849static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14850 struct pmo_action_wakeup_set_params *action_params)
14851{
14852 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14853 wmi_buf_t buf;
14854 int i;
14855 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014856 uint32_t len = 0, *cmd_args;
14857 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014858
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014859 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32))
14860 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14861 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014862 if (!buf) {
14863 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14864 return QDF_STATUS_E_NOMEM;
14865 }
14866 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014867 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014868 WMITLV_SET_HDR(&cmd->tlv_header,
14869 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14870 WMITLV_GET_STRUCT_TLVLEN(
14871 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14872
14873 cmd->vdev_id = action_params->vdev_id;
14874 cmd->operation = action_params->operation;
14875
14876 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14877 cmd->action_category_map[i] =
14878 action_params->action_category_map[i];
14879
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014880 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14881 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14882 (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32)));
14883 buf_ptr += WMI_TLV_HDR_SIZE;
14884 cmd_args = (uint32_t *) buf_ptr;
14885 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14886 cmd_args[i] = action_params->action_per_category[i];
14887
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014888 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014889 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014890 if (err) {
14891 WMI_LOGE("Failed to send ap_ps_egap cmd");
14892 wmi_buf_free(buf);
14893 return QDF_STATUS_E_FAILURE;
14894 }
14895
14896 return QDF_STATUS_SUCCESS;
14897}
14898
14899#ifdef FEATURE_WLAN_LPHB
14900
14901/**
14902 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14903 * @wmi_handle: wmi handle
14904 * @lphb_conf_req: configuration info
14905 *
14906 * Return: CDF status
14907 */
14908static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14909 wmi_hb_set_enable_cmd_fixed_param *params)
14910{
14911 QDF_STATUS status;
14912 wmi_buf_t buf = NULL;
14913 uint8_t *buf_ptr;
14914 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14915 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14916
14917
14918 buf = wmi_buf_alloc(wmi_handle, len);
14919 if (!buf) {
14920 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14921 return QDF_STATUS_E_NOMEM;
14922 }
14923
14924 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14925 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14926 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14927 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14928 WMITLV_GET_STRUCT_TLVLEN
14929 (wmi_hb_set_enable_cmd_fixed_param));
14930
14931 /* fill in values */
14932 hb_enable_fp->vdev_id = params->session;
14933 hb_enable_fp->enable = params->enable;
14934 hb_enable_fp->item = params->item;
14935 hb_enable_fp->session = params->session;
14936
14937 status = wmi_unified_cmd_send(wmi_handle, buf,
14938 len, WMI_HB_SET_ENABLE_CMDID);
14939 if (QDF_IS_STATUS_ERROR(status)) {
14940 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14941 status);
14942 wmi_buf_free(buf);
14943 }
14944
14945 return status;
14946}
14947
14948/**
14949 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14950 * @wmi_handle: wmi handle
14951 * @lphb_conf_req: lphb config request
14952 *
14953 * Return: CDF status
14954 */
14955static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14956 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14957{
14958 QDF_STATUS status;
14959 wmi_buf_t buf = NULL;
14960 uint8_t *buf_ptr;
14961 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14962 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14963
14964 buf = wmi_buf_alloc(wmi_handle, len);
14965 if (!buf) {
14966 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14967 return QDF_STATUS_E_NOMEM;
14968 }
14969
14970 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14971 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14972 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14973 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14974 WMITLV_GET_STRUCT_TLVLEN
14975 (wmi_hb_set_tcp_params_cmd_fixed_param));
14976
14977 /* fill in values */
14978 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14979 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14980 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14981 hb_tcp_params_fp->seq = lphb_conf_req->seq;
14982 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
14983 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
14984 hb_tcp_params_fp->interval = lphb_conf_req->interval;
14985 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
14986 hb_tcp_params_fp->session = lphb_conf_req->session;
14987 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
14988 &lphb_conf_req->gateway_mac,
14989 sizeof(hb_tcp_params_fp->gateway_mac));
14990
14991 status = wmi_unified_cmd_send(wmi_handle, buf,
14992 len, WMI_HB_SET_TCP_PARAMS_CMDID);
14993 if (QDF_IS_STATUS_ERROR(status)) {
14994 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
14995 status);
14996 wmi_buf_free(buf);
14997 }
14998
14999 return status;
15000}
15001
15002/**
15003 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
15004 * @wmi_handle: wmi handle
15005 * @lphb_conf_req: lphb config request
15006 *
15007 * Return: CDF status
15008 */
15009static
15010QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15011 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
15012{
15013 QDF_STATUS status;
15014 wmi_buf_t buf = NULL;
15015 uint8_t *buf_ptr;
15016 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
15017 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
15018
15019 buf = wmi_buf_alloc(wmi_handle, len);
15020 if (!buf) {
15021 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15022 return QDF_STATUS_E_NOMEM;
15023 }
15024
15025 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15026 hb_tcp_filter_fp =
15027 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
15028 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
15029 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
15030 WMITLV_GET_STRUCT_TLVLEN
15031 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
15032
15033 /* fill in values */
15034 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
15035 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
15036 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
15037 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
15038 memcpy((void *)&hb_tcp_filter_fp->filter,
15039 (void *)&g_hb_tcp_filter_fp->filter,
15040 WMI_WLAN_HB_MAX_FILTER_SIZE);
15041
15042 status = wmi_unified_cmd_send(wmi_handle, buf,
15043 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
15044 if (QDF_IS_STATUS_ERROR(status)) {
15045 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
15046 status);
15047 wmi_buf_free(buf);
15048 }
15049
15050 return status;
15051}
15052
15053/**
15054 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
15055 * @wmi_handle: wmi handle
15056 * @lphb_conf_req: lphb config request
15057 *
15058 * Return: CDF status
15059 */
15060static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
15061 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
15062{
15063 QDF_STATUS status;
15064 wmi_buf_t buf = NULL;
15065 uint8_t *buf_ptr;
15066 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
15067 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
15068
15069 buf = wmi_buf_alloc(wmi_handle, len);
15070 if (!buf) {
15071 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15072 return QDF_STATUS_E_NOMEM;
15073 }
15074
15075 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15076 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
15077 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
15078 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
15079 WMITLV_GET_STRUCT_TLVLEN
15080 (wmi_hb_set_udp_params_cmd_fixed_param));
15081
15082 /* fill in values */
15083 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15084 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15085 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15086 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
15087 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
15088 hb_udp_params_fp->interval = lphb_conf_req->interval;
15089 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
15090 hb_udp_params_fp->session = lphb_conf_req->session;
15091 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
15092 &lphb_conf_req->gateway_mac,
15093 sizeof(lphb_conf_req->gateway_mac));
15094
15095 status = wmi_unified_cmd_send(wmi_handle, buf,
15096 len, WMI_HB_SET_UDP_PARAMS_CMDID);
15097 if (QDF_IS_STATUS_ERROR(status)) {
15098 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
15099 status);
15100 wmi_buf_free(buf);
15101 }
15102
15103 return status;
15104}
15105
15106/**
15107 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
15108 * @wmi_handle: wmi handle
15109 * @lphb_conf_req: lphb config request
15110 *
15111 * Return: CDF status
15112 */
15113static
15114QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15115 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
15116{
15117 QDF_STATUS status;
15118 wmi_buf_t buf = NULL;
15119 uint8_t *buf_ptr;
15120 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
15121 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
15122
15123 buf = wmi_buf_alloc(wmi_handle, len);
15124 if (!buf) {
15125 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15126 return QDF_STATUS_E_NOMEM;
15127 }
15128
15129 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15130 hb_udp_filter_fp =
15131 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
15132 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
15133 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
15134 WMITLV_GET_STRUCT_TLVLEN
15135 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
15136
15137 /* fill in values */
15138 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
15139 hb_udp_filter_fp->length = lphb_conf_req->length;
15140 hb_udp_filter_fp->offset = lphb_conf_req->offset;
15141 hb_udp_filter_fp->session = lphb_conf_req->session;
15142 memcpy((void *)&hb_udp_filter_fp->filter,
15143 (void *)&lphb_conf_req->filter,
15144 WMI_WLAN_HB_MAX_FILTER_SIZE);
15145
15146 status = wmi_unified_cmd_send(wmi_handle, buf,
15147 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
15148 if (QDF_IS_STATUS_ERROR(status)) {
15149 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
15150 status);
15151 wmi_buf_free(buf);
15152 }
15153
15154 return status;
15155}
15156#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015157
Dustin Brownf31f88b2017-05-12 14:01:44 -070015158static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
15159 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015160{
Dustin Brownf31f88b2017-05-12 14:01:44 -070015161 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015162 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070015163 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015164
Dustin Brownf31f88b2017-05-12 14:01:44 -070015165 if (!req) {
15166 WMI_LOGE("req is null");
15167 return QDF_STATUS_E_INVAL;
15168 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015169
Dustin Brownf31f88b2017-05-12 14:01:44 -070015170 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15171 if (!wmi_buf) {
15172 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015173 return QDF_STATUS_E_NOMEM;
15174 }
15175
Dustin Brownf31f88b2017-05-12 14:01:44 -070015176 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015177 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015178 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15179 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15180 cmd->vdev_id = req->vdev_id;
15181 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
15182 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015183
Dustin Brownf31f88b2017-05-12 14:01:44 -070015184 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
15185 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015186
Dustin Brownf31f88b2017-05-12 14:01:44 -070015187 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15188 WMI_HW_DATA_FILTER_CMDID);
15189 if (QDF_IS_STATUS_ERROR(status)) {
15190 WMI_LOGE("Failed to configure hw filter");
15191 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015192 }
15193
Dustin Brownf31f88b2017-05-12 14:01:44 -070015194 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015195}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015196
15197/**
15198 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15199 * @wmi_handle: wmi handle
15200 * @vdev_id: vdev id
15201 * @enable: Flag to enable/disable packet filter
15202 *
15203 * Return: QDF_STATUS_SUCCESS for success or error code
15204 */
15205static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15206 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15207{
15208 int32_t len;
15209 int ret = 0;
15210 wmi_buf_t buf;
15211 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15212
15213 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15214
15215 buf = wmi_buf_alloc(wmi_handle, len);
15216 if (!buf) {
15217 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15218 return QDF_STATUS_E_NOMEM;
15219 }
15220
15221 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15222 WMITLV_SET_HDR(&cmd->tlv_header,
15223 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15224 WMITLV_GET_STRUCT_TLVLEN(
15225 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15226
15227 cmd->vdev_id = vdev_id;
15228 if (enable)
15229 cmd->enable = PACKET_FILTER_SET_ENABLE;
15230 else
15231 cmd->enable = PACKET_FILTER_SET_DISABLE;
15232
15233 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15234 __func__, cmd->enable, vdev_id);
15235
15236 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15237 WMI_PACKET_FILTER_ENABLE_CMDID);
15238 if (ret) {
15239 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15240 wmi_buf_free(buf);
15241 }
15242
15243 return ret;
15244}
15245
15246/**
15247 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15248 * @wmi_handle: wmi handle
15249 * @vdev_id: vdev id
15250 * @rcv_filter_param: Packet filter parameters
15251 * @filter_id: Filter id
15252 * @enable: Flag to add/delete packet filter configuration
15253 *
15254 * Return: QDF_STATUS_SUCCESS for success or error code
15255 */
15256static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15257 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15258 uint8_t filter_id, bool enable)
15259{
15260 int len, i;
15261 int err = 0;
15262 wmi_buf_t buf;
15263 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15264
15265
15266 /* allocate the memory */
15267 len = sizeof(*cmd);
15268 buf = wmi_buf_alloc(wmi_handle, len);
15269 if (!buf) {
15270 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15271 return QDF_STATUS_E_NOMEM;
15272 }
15273
15274 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15275 WMITLV_SET_HDR(&cmd->tlv_header,
15276 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15277 WMITLV_GET_STRUCT_TLVLEN
15278 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15279
15280 cmd->vdev_id = vdev_id;
15281 cmd->filter_id = filter_id;
15282 if (enable)
15283 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15284 else
15285 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15286
15287 if (enable) {
15288 cmd->num_params = QDF_MIN(
15289 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15290 rcv_filter_param->num_params);
15291 cmd->filter_type = rcv_filter_param->filter_type;
15292 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15293
15294 for (i = 0; i < cmd->num_params; i++) {
15295 cmd->paramsData[i].proto_type =
15296 rcv_filter_param->params_data[i].protocol_layer;
15297 cmd->paramsData[i].cmp_type =
15298 rcv_filter_param->params_data[i].compare_flag;
15299 cmd->paramsData[i].data_length =
15300 rcv_filter_param->params_data[i].data_length;
15301 cmd->paramsData[i].data_offset =
15302 rcv_filter_param->params_data[i].data_offset;
15303 memcpy(&cmd->paramsData[i].compareData,
15304 rcv_filter_param->params_data[i].compare_data,
15305 sizeof(cmd->paramsData[i].compareData));
15306 memcpy(&cmd->paramsData[i].dataMask,
15307 rcv_filter_param->params_data[i].data_mask,
15308 sizeof(cmd->paramsData[i].dataMask));
15309 }
15310 }
15311
15312 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15313 cmd->filter_action, cmd->filter_id, cmd->num_params);
15314 /* send the command along with data */
15315 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15316 WMI_PACKET_FILTER_CONFIG_CMDID);
15317 if (err) {
15318 WMI_LOGE("Failed to send pkt_filter cmd");
15319 wmi_buf_free(buf);
15320 return QDF_STATUS_E_FAILURE;
15321 }
15322
15323 return QDF_STATUS_SUCCESS;
15324}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053015325#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015326
Govind Singha4836fd2016-03-07 16:45:38 +053015327/**
15328 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15329 * @wmi_handle: wmi handle
15330 * @request: SSID hotlist set request
15331 *
Govind Singhb53420c2016-03-09 14:32:57 +053015332 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015333 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015334static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015335send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15336 struct ssid_hotlist_request_params *request)
15337{
15338 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15339 wmi_buf_t wmi_buf;
15340 uint32_t len;
15341 uint32_t array_size;
15342 uint8_t *buf_ptr;
15343
15344 /* length of fixed portion */
15345 len = sizeof(*cmd);
15346
15347 /* length of variable portion */
15348 array_size =
15349 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15350 len += WMI_TLV_HDR_SIZE + array_size;
15351
15352 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15353 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015354 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15355 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015356 }
15357
15358 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15359 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15360 buf_ptr;
15361 WMITLV_SET_HDR
15362 (&cmd->tlv_header,
15363 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15364 WMITLV_GET_STRUCT_TLVLEN
15365 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15366
15367 cmd->request_id = request->request_id;
15368 cmd->requestor_id = 0;
15369 cmd->vdev_id = request->session_id;
15370 cmd->table_id = 0;
15371 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15372 cmd->total_entries = request->ssid_count;
15373 cmd->num_entries_in_page = request->ssid_count;
15374 cmd->first_entry_index = 0;
15375
15376 buf_ptr += sizeof(*cmd);
15377 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15378
15379 if (request->ssid_count) {
15380 wmi_extscan_hotlist_ssid_entry *entry;
15381 int i;
15382
15383 buf_ptr += WMI_TLV_HDR_SIZE;
15384 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15385 for (i = 0; i < request->ssid_count; i++) {
15386 WMITLV_SET_HDR
15387 (entry,
15388 WMITLV_TAG_ARRAY_STRUC,
15389 WMITLV_GET_STRUCT_TLVLEN
15390 (wmi_extscan_hotlist_ssid_entry));
15391 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015392 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015393 request->ssids[i].ssid.mac_ssid,
15394 request->ssids[i].ssid.length);
15395 entry->band = request->ssids[i].band;
15396 entry->min_rssi = request->ssids[i].rssi_low;
15397 entry->max_rssi = request->ssids[i].rssi_high;
15398 entry++;
15399 }
15400 cmd->mode = WMI_EXTSCAN_MODE_START;
15401 } else {
15402 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15403 }
15404
15405 if (wmi_unified_cmd_send
15406 (wmi_handle, wmi_buf, len,
15407 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015408 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015409 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015410 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015411 }
15412
Govind Singhb53420c2016-03-09 14:32:57 +053015413 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015414}
15415
15416/**
15417 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15418 * @wmi_handle: wmi handle
15419 * @vdev_id: vdev id
15420 *
15421 * This function sends roam synch complete event to fw.
15422 *
15423 * Return: CDF STATUS
15424 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015425static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015426 uint8_t vdev_id)
15427{
15428 wmi_roam_synch_complete_fixed_param *cmd;
15429 wmi_buf_t wmi_buf;
15430 uint8_t *buf_ptr;
15431 uint16_t len;
15432 len = sizeof(wmi_roam_synch_complete_fixed_param);
15433
15434 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15435 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015436 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15437 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015438 }
15439 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15440 buf_ptr = (uint8_t *) cmd;
15441 WMITLV_SET_HDR(&cmd->tlv_header,
15442 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15443 WMITLV_GET_STRUCT_TLVLEN
15444 (wmi_roam_synch_complete_fixed_param));
15445 cmd->vdev_id = vdev_id;
15446 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15447 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015448 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015449 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015450 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015451 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015452 }
15453
Govind Singhb53420c2016-03-09 14:32:57 +053015454 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015455}
15456
15457/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015458 * send_fw_test_cmd_tlv() - send fw test command to fw.
15459 * @wmi_handle: wmi handle
15460 * @wmi_fwtest: fw test command
15461 *
15462 * This function sends fw test command to fw.
15463 *
15464 * Return: CDF STATUS
15465 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015466static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015467QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15468 struct set_fwtest_params *wmi_fwtest)
15469{
15470 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15471 wmi_buf_t wmi_buf;
15472 uint16_t len;
15473
15474 len = sizeof(*cmd);
15475
15476 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15477 if (!wmi_buf) {
15478 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15479 return QDF_STATUS_E_NOMEM;
15480 }
15481
15482 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15483 WMITLV_SET_HDR(&cmd->tlv_header,
15484 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15485 WMITLV_GET_STRUCT_TLVLEN(
15486 wmi_fwtest_set_param_cmd_fixed_param));
15487 cmd->param_id = wmi_fwtest->arg;
15488 cmd->param_value = wmi_fwtest->value;
15489
15490 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15491 WMI_FWTEST_CMDID)) {
15492 WMI_LOGP("%s: failed to send fw test command", __func__);
15493 qdf_nbuf_free(wmi_buf);
15494 return QDF_STATUS_E_FAILURE;
15495 }
15496
15497 return QDF_STATUS_SUCCESS;
15498}
15499
15500/**
Govind Singha4836fd2016-03-07 16:45:38 +053015501 * send_unit_test_cmd_tlv() - send unit test command to fw.
15502 * @wmi_handle: wmi handle
15503 * @wmi_utest: unit test command
15504 *
15505 * This function send unit test command to fw.
15506 *
15507 * Return: CDF STATUS
15508 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015509static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015510 struct wmi_unit_test_cmd *wmi_utest)
15511{
15512 wmi_unit_test_cmd_fixed_param *cmd;
15513 wmi_buf_t wmi_buf;
15514 uint8_t *buf_ptr;
15515 int i;
15516 uint16_t len, args_tlv_len;
15517 A_UINT32 *unit_test_cmd_args;
15518
15519 args_tlv_len =
15520 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
15521 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15522
15523 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15524 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015525 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15526 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015527 }
15528
15529 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15530 buf_ptr = (uint8_t *) cmd;
15531 WMITLV_SET_HDR(&cmd->tlv_header,
15532 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15533 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15534 cmd->vdev_id = wmi_utest->vdev_id;
15535 cmd->module_id = wmi_utest->module_id;
15536 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015537 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015538 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15539 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15540 (wmi_utest->num_args * sizeof(uint32_t)));
15541 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015542 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15543 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15544 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015545 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053015546 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
15547 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015548 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015549 }
15550 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15551 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015552 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015553 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015554 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015555 }
15556
Govind Singhb53420c2016-03-09 14:32:57 +053015557 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015558}
15559
15560/**
15561 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15562 * @wmi_handle: wma handle
15563 * @roaminvoke: roam invoke command
15564 *
15565 * Send roam invoke command to fw for fastreassoc.
15566 *
15567 * Return: CDF STATUS
15568 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015569static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015570 struct wmi_roam_invoke_cmd *roaminvoke,
15571 uint32_t ch_hz)
15572{
15573 wmi_roam_invoke_cmd_fixed_param *cmd;
15574 wmi_buf_t wmi_buf;
15575 u_int8_t *buf_ptr;
15576 u_int16_t len, args_tlv_len;
15577 A_UINT32 *channel_list;
15578 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015579 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015580
15581 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080015582 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
15583 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15584 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015585 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15586 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15587 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015588 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15589 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015590 }
15591
15592 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15593 buf_ptr = (u_int8_t *) cmd;
15594 WMITLV_SET_HDR(&cmd->tlv_header,
15595 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15596 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15597 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015598 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015599 if (roaminvoke->is_same_bssid)
15600 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15601 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015602
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015603 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015604 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015605 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15606 cmd->num_buf = 1;
15607 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015608 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015609 cmd->num_buf = 0;
15610 }
Naveen Rawat77797922017-01-20 17:00:07 -080015611
Govind Singha4836fd2016-03-07 16:45:38 +053015612 cmd->roam_ap_sel_mode = 0;
15613 cmd->roam_delay = 0;
15614 cmd->num_chan = 1;
15615 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015616
Govind Singha4836fd2016-03-07 16:45:38 +053015617 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15618 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15619 (sizeof(u_int32_t)));
15620 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
15621 *channel_list = ch_hz;
15622 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
15623 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15624 (sizeof(wmi_mac_addr)));
15625 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15626 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015627
15628 /* move to next tlv i.e. bcn_prb_buf_list */
15629 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15630
15631 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15632 sizeof(wmi_tlv_buf_len_param));
15633
15634 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15635 buf_len_tlv->buf_len = roaminvoke->frame_len;
15636
15637 /* move to next tlv i.e. bcn_prb_frm */
15638 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15639 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15640 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15641
15642 /* copy frame after the header */
15643 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15644 roaminvoke->frame_buf,
15645 roaminvoke->frame_len);
15646
15647 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
15648 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
15649 buf_ptr + WMI_TLV_HDR_SIZE,
15650 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015651 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15652 cmd->flags, cmd->roam_scan_mode,
15653 cmd->roam_ap_sel_mode, cmd->roam_delay,
15654 cmd->num_chan, cmd->num_bssid);
15655 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015656
Govind Singha4836fd2016-03-07 16:45:38 +053015657 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15658 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015659 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015660 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015661 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015662 }
15663
Govind Singhb53420c2016-03-09 14:32:57 +053015664 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015665}
15666
15667/**
15668 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15669 * @wmi_handle: wmi handle
15670 * @command: command
15671 * @vdev_id: vdev id
15672 *
15673 * This function set roam offload command to fw.
15674 *
15675 * Return: CDF status
15676 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015677static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015678 uint32_t command, uint32_t vdev_id)
15679{
Govind Singh67922e82016-04-01 16:48:57 +053015680 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015681 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15682 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015683 int len;
15684 uint8_t *buf_ptr;
15685
15686 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15687 buf = wmi_buf_alloc(wmi_handle, len);
15688 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015689 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15690 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015691 }
15692
15693 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15694
15695 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15696 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15697 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15698 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15699 cmd_fp->vdev_id = vdev_id;
15700 cmd_fp->command_arg = command;
15701
15702 status = wmi_unified_cmd_send(wmi_handle, buf,
15703 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015704 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015705 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015706 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015707 goto error;
15708 }
15709
Govind Singhb53420c2016-03-09 14:32:57 +053015710 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15711 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015712
15713error:
15714 wmi_buf_free(buf);
15715
Govind Singh67922e82016-04-01 16:48:57 +053015716 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015717}
15718
15719/**
15720 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15721 * @wmi_handle: wmi handle
15722 * @ap_profile_p: ap profile
15723 * @vdev_id: vdev id
15724 *
15725 * Send WMI_ROAM_AP_PROFILE to firmware
15726 *
15727 * Return: CDF status
15728 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015729static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015730 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015731{
Govind Singha4836fd2016-03-07 16:45:38 +053015732 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015733 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015734 int len;
15735 uint8_t *buf_ptr;
15736 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015737 wmi_roam_cnd_scoring_param *score_param;
15738 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015739
15740 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015741 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015742 buf = wmi_buf_alloc(wmi_handle, len);
15743 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015744 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15745 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015746 }
15747
15748 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15749 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15750 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15751 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15752 WMITLV_GET_STRUCT_TLVLEN
15753 (wmi_roam_ap_profile_fixed_param));
15754 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015755 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015756 roam_ap_profile_fp->id = 0;
15757 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15758
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015759 profile = (wmi_ap_profile *)buf_ptr;
15760 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015761 WMITLV_TAG_STRUC_wmi_ap_profile,
15762 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015763 profile->flags = ap_profile->profile.flags;
15764 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15765 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15766 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15767 profile->ssid.ssid_len);
15768 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15769 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15770 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15771 profile->rsn_mcastmgmtcipherset =
15772 ap_profile->profile.rsn_mcastmgmtcipherset;
15773 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15774
15775 WMI_LOGD("AP profile: flags %x rssi_threshold %d ssid:%.*s authmode %d uc cipher %d mc cipher %d mc mgmt cipher %d rssi abs thresh %d",
15776 profile->flags, profile->rssi_threshold,
15777 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15778 profile->rsn_authmode, profile->rsn_ucastcipherset,
15779 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15780 profile->rssi_abs_thresh);
15781
15782 buf_ptr += sizeof(wmi_ap_profile);
15783
15784 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15785 WMITLV_SET_HDR(&score_param->tlv_header,
15786 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15787 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15788 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15789 score_param->rssi_weightage_pcnt =
15790 ap_profile->param.rssi_weightage;
15791 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15792 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15793 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15794 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15795 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15796 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15797 score_param->esp_qbss_weightage_pcnt =
15798 ap_profile->param.esp_qbss_weightage;
15799 score_param->beamforming_weightage_pcnt =
15800 ap_profile->param.beamforming_weightage;
15801 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15802 score_param->oce_wan_weightage_pcnt =
15803 ap_profile->param.oce_wan_weightage;
15804
15805 WMI_LOGD("Score params weightage: disable_bitmap %x rssi %d ht %d vht %d he %d BW %d band %d NSS %d ESP %d BF %d PCL %d OCE WAN %d",
15806 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15807 score_param->ht_weightage_pcnt,
15808 score_param->vht_weightage_pcnt,
15809 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15810 score_param->band_weightage_pcnt,
15811 score_param->nss_weightage_pcnt,
15812 score_param->esp_qbss_weightage_pcnt,
15813 score_param->beamforming_weightage_pcnt,
15814 score_param->pcl_weightage_pcnt,
15815 score_param->oce_wan_weightage_pcnt);
15816
15817 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15818 score_param->band_scoring.score_pcnt =
15819 ap_profile->param.band_index_score;
15820 score_param->nss_scoring.score_pcnt =
15821 ap_profile->param.nss_index_score;
15822
15823 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15824 score_param->bw_scoring.score_pcnt,
15825 score_param->band_scoring.score_pcnt,
15826 score_param->nss_scoring.score_pcnt);
15827
15828 score_param->rssi_scoring.best_rssi_threshold =
15829 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15830 score_param->rssi_scoring.good_rssi_threshold =
15831 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15832 score_param->rssi_scoring.bad_rssi_threshold =
15833 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15834 score_param->rssi_scoring.good_rssi_pcnt =
15835 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15836 score_param->rssi_scoring.bad_rssi_pcnt =
15837 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15838 score_param->rssi_scoring.good_bucket_size =
15839 ap_profile->param.rssi_scoring.good_bucket_size;
15840 score_param->rssi_scoring.bad_bucket_size =
15841 ap_profile->param.rssi_scoring.bad_bucket_size;
15842 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15843 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15844
15845 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15846 score_param->rssi_scoring.best_rssi_threshold,
15847 score_param->rssi_scoring.good_rssi_threshold,
15848 score_param->rssi_scoring.bad_rssi_threshold,
15849 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15850 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15851 score_param->rssi_scoring.good_rssi_pcnt,
15852 score_param->rssi_scoring.bad_rssi_pcnt,
15853 score_param->rssi_scoring.good_bucket_size,
15854 score_param->rssi_scoring.bad_bucket_size);
15855
15856 score_param->esp_qbss_scoring.num_slot =
15857 ap_profile->param.esp_qbss_scoring.num_slot;
15858 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15859 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15860 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15861 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15862 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15863 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15864 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15865 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15866
15867 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15868 score_param->esp_qbss_scoring.num_slot,
15869 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15870 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15871 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15872 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15873
15874 score_param->oce_wan_scoring.num_slot =
15875 ap_profile->param.oce_wan_scoring.num_slot;
15876 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15877 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15878 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15879 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15880 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15881 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15882 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15883 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15884
15885 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15886 score_param->oce_wan_scoring.num_slot,
15887 score_param->oce_wan_scoring.score_pcnt3_to_0,
15888 score_param->oce_wan_scoring.score_pcnt7_to_4,
15889 score_param->oce_wan_scoring.score_pcnt11_to_8,
15890 score_param->oce_wan_scoring.score_pcnt15_to_12);
15891
Govind Singha4836fd2016-03-07 16:45:38 +053015892 status = wmi_unified_cmd_send(wmi_handle, buf,
15893 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015894 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015895 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015896 status);
Govind Singh67922e82016-04-01 16:48:57 +053015897 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015898 }
15899
Govind Singhb53420c2016-03-09 14:32:57 +053015900 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015901
Govind Singh67922e82016-04-01 16:48:57 +053015902 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015903}
15904
15905/**
15906 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15907 * @wmi_handle: wmi handle
15908 * @scan_period: scan period
15909 * @scan_age: scan age
15910 * @vdev_id: vdev id
15911 *
15912 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15913 *
15914 * Return: CDF status
15915 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015916static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015917 uint32_t scan_period,
15918 uint32_t scan_age,
15919 uint32_t vdev_id)
15920{
Govind Singh67922e82016-04-01 16:48:57 +053015921 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015922 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015923 int len;
15924 uint8_t *buf_ptr;
15925 wmi_roam_scan_period_fixed_param *scan_period_fp;
15926
15927 /* Send scan period values */
15928 len = sizeof(wmi_roam_scan_period_fixed_param);
15929 buf = wmi_buf_alloc(wmi_handle, len);
15930 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015931 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15932 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015933 }
15934
15935 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15936 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15937 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15938 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15939 WMITLV_GET_STRUCT_TLVLEN
15940 (wmi_roam_scan_period_fixed_param));
15941 /* fill in scan period values */
15942 scan_period_fp->vdev_id = vdev_id;
15943 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15944 scan_period_fp->roam_scan_age = scan_age;
15945
15946 status = wmi_unified_cmd_send(wmi_handle, buf,
15947 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015948 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015949 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015950 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015951 goto error;
15952 }
15953
Govind Singhb53420c2016-03-09 14:32:57 +053015954 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015955 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015956 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015957error:
15958 wmi_buf_free(buf);
15959
Govind Singh67922e82016-04-01 16:48:57 +053015960 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015961}
15962
15963/**
15964 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15965 * @wmi_handle: wmi handle
15966 * @chan_count: channel count
15967 * @chan_list: channel list
15968 * @list_type: list type
15969 * @vdev_id: vdev id
15970 *
15971 * Set roam offload channel list.
15972 *
15973 * Return: CDF status
15974 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015975static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015976 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015977 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015978 uint8_t list_type, uint32_t vdev_id)
15979{
Govind Singha4836fd2016-03-07 16:45:38 +053015980 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015981 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015982 int len, list_tlv_len;
15983 int i;
15984 uint8_t *buf_ptr;
15985 wmi_roam_chan_list_fixed_param *chan_list_fp;
15986 A_UINT32 *roam_chan_list_array;
15987
15988 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015989 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015990 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015991 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015992 }
15993 /* Channel list is a table of 2 TLV's */
15994 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
15995 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15996 buf = wmi_buf_alloc(wmi_handle, len);
15997 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015998 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15999 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016000 }
16001
16002 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16003 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
16004 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
16005 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
16006 WMITLV_GET_STRUCT_TLVLEN
16007 (wmi_roam_chan_list_fixed_param));
16008 chan_list_fp->vdev_id = vdev_id;
16009 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053016010 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053016011 /* external app is controlling channel list */
16012 chan_list_fp->chan_list_type =
16013 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
16014 } else {
16015 /* umac supplied occupied channel list in LFR */
16016 chan_list_fp->chan_list_type =
16017 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
16018 }
16019
16020 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
16021 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16022 (chan_list_fp->num_chan * sizeof(uint32_t)));
16023 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016024 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053016025 for (i = 0; ((i < chan_list_fp->num_chan) &&
16026 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
16027 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053016028 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053016029 }
16030
16031 status = wmi_unified_cmd_send(wmi_handle, buf,
16032 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053016033 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016034 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016035 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016036 goto error;
16037 }
16038
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016039 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053016040 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016041error:
16042 wmi_buf_free(buf);
16043
Govind Singh67922e82016-04-01 16:48:57 +053016044 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016045}
16046
16047/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016048 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
16049 * @wmi_handle: wmi handle
16050 * @req_buf: per roam config buffer
16051 *
16052 * Return: QDF status
16053 */
16054static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
16055 struct wmi_per_roam_config_req *req_buf)
16056{
16057 wmi_buf_t buf = NULL;
16058 QDF_STATUS status;
16059 int len;
16060 uint8_t *buf_ptr;
16061 wmi_roam_per_config_fixed_param *wmi_per_config;
16062
16063 len = sizeof(wmi_roam_per_config_fixed_param);
16064 buf = wmi_buf_alloc(wmi_handle, len);
16065 if (!buf) {
16066 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16067 return QDF_STATUS_E_NOMEM;
16068 }
16069
16070 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16071 wmi_per_config =
16072 (wmi_roam_per_config_fixed_param *) buf_ptr;
16073 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
16074 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
16075 WMITLV_GET_STRUCT_TLVLEN
16076 (wmi_roam_per_config_fixed_param));
16077
16078 /* fill in per roam config values */
16079 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016080
16081 wmi_per_config->enable = req_buf->per_config.enable;
16082 wmi_per_config->high_rate_thresh =
16083 (req_buf->per_config.tx_high_rate_thresh << 16) |
16084 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
16085 wmi_per_config->low_rate_thresh =
16086 (req_buf->per_config.tx_low_rate_thresh << 16) |
16087 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
16088 wmi_per_config->pkt_err_rate_thresh_pct =
16089 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
16090 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
16091 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053016092 wmi_per_config->pkt_err_rate_mon_time =
16093 (req_buf->per_config.tx_per_mon_time << 16) |
16094 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053016095 wmi_per_config->min_candidate_rssi =
16096 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016097
16098 /* Send per roam config parameters */
16099 status = wmi_unified_cmd_send(wmi_handle, buf,
16100 len, WMI_ROAM_PER_CONFIG_CMDID);
16101 if (QDF_IS_STATUS_ERROR(status)) {
16102 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
16103 status);
16104 wmi_buf_free(buf);
16105 return status;
16106 }
16107
16108 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
16109 req_buf->per_config.enable, req_buf->vdev_id);
16110 return QDF_STATUS_SUCCESS;
16111}
16112
16113/**
Govind Singha4836fd2016-03-07 16:45:38 +053016114 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
16115 * @wmi_handle: wmi handle
16116 * @rssi_change_thresh: RSSI Change threshold
16117 * @bcn_rssi_weight: beacon RSSI weight
16118 * @vdev_id: vdev id
16119 *
16120 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
16121 *
16122 * Return: CDF status
16123 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016124static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016125 uint32_t vdev_id,
16126 int32_t rssi_change_thresh,
16127 uint32_t bcn_rssi_weight,
16128 uint32_t hirssi_delay_btw_scans)
16129{
Govind Singha4836fd2016-03-07 16:45:38 +053016130 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016131 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016132 int len;
16133 uint8_t *buf_ptr;
16134 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
16135
16136 /* Send rssi change parameters */
16137 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
16138 buf = wmi_buf_alloc(wmi_handle, len);
16139 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016140 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16141 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016142 }
16143
16144 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16145 rssi_change_fp =
16146 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
16147 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
16148 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
16149 WMITLV_GET_STRUCT_TLVLEN
16150 (wmi_roam_scan_rssi_change_threshold_fixed_param));
16151 /* fill in rssi change threshold (hysteresis) values */
16152 rssi_change_fp->vdev_id = vdev_id;
16153 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
16154 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
16155 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
16156
16157 status = wmi_unified_cmd_send(wmi_handle, buf,
16158 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053016159 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016160 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016161 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016162 goto error;
16163 }
16164
Govind Singhb53420c2016-03-09 14:32:57 +053016165 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053016166 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053016167 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
16168 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016169error:
16170 wmi_buf_free(buf);
16171
Govind Singh67922e82016-04-01 16:48:57 +053016172 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016173}
16174
16175/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
16176 * @wmi_handle: wmi handle.
16177 * @cmd: size of command structure.
16178 * @per_entry_size: per entry size.
16179 *
16180 * This utility function calculates how many hotlist entries can
16181 * fit in one page.
16182 *
16183 * Return: number of entries
16184 */
16185static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
16186 size_t cmd_size,
16187 size_t per_entry_size)
16188{
16189 uint32_t avail_space = 0;
16190 int num_entries = 0;
16191 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
16192
16193 /* Calculate number of hotlist entries that can
16194 * be passed in wma message request.
16195 */
16196 avail_space = max_msg_len - cmd_size;
16197 num_entries = avail_space / per_entry_size;
16198 return num_entries;
16199}
16200
16201/**
16202 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
16203 * @wmi_handle: wmi handle
16204 * @photlist: hotlist command params
16205 * @buf_len: buffer length
16206 *
16207 * This function fills individual elements for hotlist request and
16208 * TLV for bssid entries
16209 *
16210 * Return: CDF Status.
16211 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016212static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016213 struct ext_scan_setbssi_hotlist_params *
16214 photlist, int *buf_len)
16215{
16216 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
16217 wmi_extscan_hotlist_entry *dest_hotlist;
16218 struct ap_threshold_params *src_ap = photlist->ap;
16219 wmi_buf_t buf;
16220 uint8_t *buf_ptr;
16221
16222 int j, index = 0;
16223 int cmd_len = 0;
16224 int num_entries;
16225 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016226 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053016227 int len = sizeof(*cmd);
16228
16229 len += WMI_TLV_HDR_SIZE;
16230 cmd_len = len;
16231
16232 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
16233 cmd_len,
16234 sizeof(*dest_hotlist));
16235 /* setbssid hotlist expects the bssid list
16236 * to be non zero value
16237 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016238 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080016239 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053016240 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053016241 }
16242
16243 /* Split the hot list entry pages and send multiple command
16244 * requests if the buffer reaches the maximum request size
16245 */
16246 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053016247 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053016248 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
16249 buf = wmi_buf_alloc(wmi_handle, len);
16250 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016251 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
16252 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016253 }
16254 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16255 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
16256 buf_ptr;
16257 WMITLV_SET_HDR(&cmd->tlv_header,
16258 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
16259 WMITLV_GET_STRUCT_TLVLEN
16260 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
16261
16262 /* Multiple requests are sent until the num_entries_in_page
16263 * matches the total_entries
16264 */
16265 cmd->request_id = photlist->requestId;
16266 cmd->vdev_id = photlist->sessionId;
16267 cmd->total_entries = numap;
16268 cmd->mode = 1;
16269 cmd->num_entries_in_page = min_entries;
16270 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
16271 cmd->first_entry_index = index;
16272
Govind Singhb53420c2016-03-09 14:32:57 +053016273 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016274 __func__, cmd->vdev_id, cmd->total_entries,
16275 cmd->num_entries_in_page,
16276 cmd->lost_ap_scan_count);
16277
16278 buf_ptr += sizeof(*cmd);
16279 WMITLV_SET_HDR(buf_ptr,
16280 WMITLV_TAG_ARRAY_STRUC,
16281 min_entries * sizeof(wmi_extscan_hotlist_entry));
16282 dest_hotlist = (wmi_extscan_hotlist_entry *)
16283 (buf_ptr + WMI_TLV_HDR_SIZE);
16284
16285 /* Populate bssid, channel info and rssi
16286 * for the bssid's that are sent as hotlists.
16287 */
16288 for (j = 0; j < min_entries; j++) {
16289 WMITLV_SET_HDR(dest_hotlist,
16290 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
16291 WMITLV_GET_STRUCT_TLVLEN
16292 (wmi_extscan_hotlist_entry));
16293
16294 dest_hotlist->min_rssi = src_ap->low;
16295 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
16296 &dest_hotlist->bssid);
16297
Govind Singhb53420c2016-03-09 14:32:57 +053016298 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016299 __func__, dest_hotlist->channel,
16300 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053016301 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053016302 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16303 __func__, dest_hotlist->bssid.mac_addr31to0,
16304 dest_hotlist->bssid.mac_addr47to32);
16305 dest_hotlist++;
16306 src_ap++;
16307 }
16308 buf_ptr += WMI_TLV_HDR_SIZE +
16309 (min_entries * sizeof(wmi_extscan_hotlist_entry));
16310
16311 if (wmi_unified_cmd_send(wmi_handle, buf, len,
16312 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016313 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016314 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053016315 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016316 }
16317 index = index + min_entries;
16318 num_entries = numap - min_entries;
16319 len = cmd_len;
16320 }
Govind Singhb53420c2016-03-09 14:32:57 +053016321 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016322}
16323
Govind Singhbca3b1b2016-05-02 17:59:24 +053016324/**
Dustin Brown4423f632017-01-13 15:24:07 -080016325 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
16326 * @wmi_handle: the WMI handle
16327 * @vdev_id: the Id of the vdev to apply the configuration to
16328 * @ucast_mode: the active BPF mode to configure for unicast packets
16329 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
16330 * packets
16331 *
16332 * Return: QDF status
16333 */
16334static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
16335 uint8_t vdev_id,
16336 enum wmi_host_active_bpf_mode ucast_mode,
16337 enum wmi_host_active_bpf_mode mcast_bcast_mode)
16338{
16339 const WMITLV_TAG_ID tag_id =
16340 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
16341 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
16342 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
16343 QDF_STATUS status;
16344 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
16345 wmi_buf_t buf;
16346
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016347 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080016348 vdev_id, ucast_mode, mcast_bcast_mode);
16349
16350 /* allocate command buffer */
16351 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
16352 if (!buf) {
16353 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
16354 return QDF_STATUS_E_NOMEM;
16355 }
16356
16357 /* set TLV header */
16358 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
16359 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
16360
16361 /* populate data */
16362 cmd->vdev_id = vdev_id;
16363 cmd->uc_mode = ucast_mode;
16364 cmd->mcbc_mode = mcast_bcast_mode;
16365
16366 /* send to FW */
16367 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
16368 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
16369 if (QDF_IS_STATUS_ERROR(status)) {
16370 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
16371 status);
16372 wmi_buf_free(buf);
16373 return status;
16374 }
16375
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016376 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080016377
16378 return QDF_STATUS_SUCCESS;
16379}
16380
16381/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053016382 * send_power_dbg_cmd_tlv() - send power debug commands
16383 * @wmi_handle: wmi handle
16384 * @param: wmi power debug parameter
16385 *
16386 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16387 *
16388 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16389 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016390static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16391 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016392{
16393 wmi_buf_t buf = NULL;
16394 QDF_STATUS status;
16395 int len, args_tlv_len;
16396 uint8_t *buf_ptr;
16397 uint8_t i;
16398 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16399 uint32_t *cmd_args;
16400
16401 /* Prepare and send power debug cmd parameters */
16402 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16403 len = sizeof(*cmd) + args_tlv_len;
16404 buf = wmi_buf_alloc(wmi_handle, len);
16405 if (!buf) {
16406 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16407 return QDF_STATUS_E_NOMEM;
16408 }
16409
16410 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16411 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16412 WMITLV_SET_HDR(&cmd->tlv_header,
16413 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16414 WMITLV_GET_STRUCT_TLVLEN
16415 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16416
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016417 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16418 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016419 cmd->module_id = param->module_id;
16420 cmd->num_args = param->num_args;
16421 buf_ptr += sizeof(*cmd);
16422 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16423 (param->num_args * sizeof(uint32_t)));
16424 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16425 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
16426 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
16427 cmd_args[i] = param->args[i];
16428 WMI_LOGI("%d,", param->args[i]);
16429 }
16430
16431 status = wmi_unified_cmd_send(wmi_handle, buf,
16432 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16433 if (QDF_IS_STATUS_ERROR(status)) {
16434 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16435 status);
16436 goto error;
16437 }
16438
16439 return QDF_STATUS_SUCCESS;
16440error:
16441 wmi_buf_free(buf);
16442
16443 return status;
16444}
16445
Govind Singhe7f2f342016-05-23 12:12:52 +053016446/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016447 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16448 * @wmi_handle: wmi handle
16449 * @param: wmi multiple vdev restart req param
16450 *
16451 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16452 *
16453 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16454 */
16455static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16456 wmi_unified_t wmi_handle,
16457 struct multiple_vdev_restart_params *param)
16458{
16459 wmi_buf_t buf;
16460 QDF_STATUS qdf_status;
16461 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16462 int i;
16463 uint8_t *buf_ptr;
16464 uint32_t *vdev_ids;
16465 wmi_channel *chan_info;
16466 struct channel_param *tchan_info;
16467 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16468
16469 len += sizeof(wmi_channel);
16470 if (param->num_vdevs)
16471 len += sizeof(uint32_t) * param->num_vdevs;
16472
16473 buf = wmi_buf_alloc(wmi_handle, len);
16474 if (!buf) {
16475 WMI_LOGE("Failed to allocate memory\n");
16476 qdf_status = QDF_STATUS_E_NOMEM;
16477 goto end;
16478 }
16479
16480 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16481 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16482 buf_ptr;
16483
16484 WMITLV_SET_HDR(&cmd->tlv_header,
16485 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16486 WMITLV_GET_STRUCT_TLVLEN
16487 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016488 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16489 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016490 cmd->requestor_id = param->requestor_id;
16491 cmd->disable_hw_ack = param->disable_hw_ack;
16492 cmd->cac_duration_ms = param->cac_duration_ms;
16493 cmd->num_vdevs = param->num_vdevs;
16494
16495 buf_ptr += sizeof(*cmd);
16496
16497 WMITLV_SET_HDR(buf_ptr,
16498 WMITLV_TAG_ARRAY_UINT32,
16499 sizeof(A_UINT32) * param->num_vdevs);
16500 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16501 for (i = 0; i < param->num_vdevs; i++) {
16502 vdev_ids[i] = param->vdev_ids[i];
16503 }
16504
16505 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
16506
16507 WMITLV_SET_HDR(buf_ptr,
16508 WMITLV_TAG_STRUC_wmi_channel,
16509 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016510 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016511 tchan_info = &(param->ch_param);
16512 chan_info->mhz = tchan_info->mhz;
16513 chan_info->band_center_freq1 = tchan_info->cfreq1;
16514 chan_info->band_center_freq2 = tchan_info->cfreq2;
16515 if (tchan_info->is_chan_passive)
16516 WMI_SET_CHANNEL_FLAG(chan_info,
16517 WMI_CHAN_FLAG_PASSIVE);
16518 if (tchan_info->allow_vht)
16519 WMI_SET_CHANNEL_FLAG(chan_info,
16520 WMI_CHAN_FLAG_ALLOW_VHT);
16521 else if (tchan_info->allow_ht)
16522 WMI_SET_CHANNEL_FLAG(chan_info,
16523 WMI_CHAN_FLAG_ALLOW_HT);
16524 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16525 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16526 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16527 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16528 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16529 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
16530
16531 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16532 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16533
16534 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16535 WMI_LOGE("%s: Failed to send\n", __func__);
16536 wmi_buf_free(buf);
16537 }
16538
16539end:
16540 return qdf_status;
16541}
16542
16543/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016544 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16545 * @wmi_handle: wmi handle
16546 * @pdev_id: pdev id
16547 *
16548 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16549 *
16550 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16551 */
16552static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16553 uint32_t pdev_id)
16554{
16555 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16556 wmi_buf_t buf;
16557 uint16_t len;
16558 QDF_STATUS ret;
16559
16560 len = sizeof(*cmd);
16561 buf = wmi_buf_alloc(wmi_handle, len);
16562
16563 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16564
16565 if (!buf) {
16566 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16567 return QDF_STATUS_E_NOMEM;
16568 }
16569
16570 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16571 wmi_buf_data(buf);
16572
16573 WMITLV_SET_HDR(&cmd->tlv_header,
16574 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16575 WMITLV_GET_STRUCT_TLVLEN(
16576 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16577
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016578 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016579 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16580 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16581 if (QDF_IS_STATUS_ERROR(ret)) {
16582 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16583 __func__, ret, pdev_id);
16584 wmi_buf_free(buf);
16585 return QDF_STATUS_E_FAILURE;
16586 }
16587
16588 return QDF_STATUS_SUCCESS;
16589}
16590
16591/**
16592 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16593 * @wmi_handle: wmi handle
16594 * @pdev_id: pdev id
16595 *
16596 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16597 *
16598 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16599 */
16600static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16601 uint32_t pdev_id)
16602{
16603 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16604 wmi_buf_t buf;
16605 uint16_t len;
16606 QDF_STATUS ret;
16607
16608 len = sizeof(*cmd);
16609 buf = wmi_buf_alloc(wmi_handle, len);
16610
16611 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16612
16613 if (!buf) {
16614 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16615 return QDF_STATUS_E_NOMEM;
16616 }
16617
16618 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16619 wmi_buf_data(buf);
16620
16621 WMITLV_SET_HDR(&cmd->tlv_header,
16622 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16623 WMITLV_GET_STRUCT_TLVLEN(
16624 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16625
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016626 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016627 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16628 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16629 if (QDF_IS_STATUS_ERROR(ret)) {
16630 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16631 __func__, ret, pdev_id);
16632 wmi_buf_free(buf);
16633 return QDF_STATUS_E_FAILURE;
16634 }
16635
16636 return QDF_STATUS_SUCCESS;
16637}
16638
16639/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016640 * init_cmd_send_tlv() - send initialization cmd to fw
16641 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016642 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016643 *
16644 * Return: QDF_STATUS_SUCCESS for success or error code
16645 */
16646static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016647 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016648{
16649 wmi_buf_t buf;
16650 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016651 uint8_t *buf_ptr;
16652 wmi_resource_config *resource_cfg;
16653 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016654 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016655 uint16_t idx;
16656 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016657 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016658
Kiran Venkatappa26117052016-12-23 19:58:54 +053016659 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16660 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016661 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016662
16663 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16664 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16665 WMI_TLV_HDR_SIZE +
16666 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16667
16668 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016669 if (!buf) {
16670 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16671 return QDF_STATUS_E_FAILURE;
16672 }
16673
16674 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16675 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16676 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16677
16678 host_mem_chunks = (wlan_host_memory_chunk *)
16679 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16680 + WMI_TLV_HDR_SIZE);
16681
16682 WMITLV_SET_HDR(&cmd->tlv_header,
16683 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16684 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16685
Kiran Venkatappa26117052016-12-23 19:58:54 +053016686 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016687 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16688 WMITLV_TAG_STRUC_wmi_resource_config,
16689 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16690
Kiran Venkatappa26117052016-12-23 19:58:54 +053016691 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016692 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16693 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16694 WMITLV_GET_STRUCT_TLVLEN
16695 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016696 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16697 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16698 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016699 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16700 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016701 idx, host_mem_chunks[idx].size,
16702 host_mem_chunks[idx].ptr);
16703 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016704 cmd->num_host_mem_chunks = param->num_mem_chunks;
16705 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16706
Govind Singhe7f2f342016-05-23 12:12:52 +053016707 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16708 WMITLV_TAG_ARRAY_STRUC,
16709 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016710 param->num_mem_chunks));
16711
16712 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016713 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016714
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016715 /* Fill fw_abi_vers */
16716 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016717
Abhishek Singh716c46c2016-05-04 16:24:07 +053016718 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16719 if (QDF_IS_STATUS_ERROR(ret)) {
16720 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16721 ret);
16722 wmi_buf_free(buf);
16723 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016724
Abhishek Singh716c46c2016-05-04 16:24:07 +053016725 return ret;
16726
Govind Singhe7f2f342016-05-23 12:12:52 +053016727}
16728
16729/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016730 * send_addba_send_cmd_tlv() - send addba send command to fw
16731 * @wmi_handle: wmi handle
16732 * @param: pointer to delba send params
16733 * @macaddr: peer mac address
16734 *
16735 * Send WMI_ADDBA_SEND_CMDID command to firmware
16736 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16737 */
16738static QDF_STATUS
16739send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16740 uint8_t macaddr[IEEE80211_ADDR_LEN],
16741 struct addba_send_params *param)
16742{
16743 wmi_addba_send_cmd_fixed_param *cmd;
16744 wmi_buf_t buf;
16745 uint16_t len;
16746 QDF_STATUS ret;
16747
16748 len = sizeof(*cmd);
16749
16750 buf = wmi_buf_alloc(wmi_handle, len);
16751 if (!buf) {
16752 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16753 return QDF_STATUS_E_NOMEM;
16754 }
16755
16756 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16757
16758 WMITLV_SET_HDR(&cmd->tlv_header,
16759 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16760 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16761
16762 cmd->vdev_id = param->vdev_id;
16763 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16764 cmd->tid = param->tidno;
16765 cmd->buffersize = param->buffersize;
16766
16767 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16768 if (QDF_IS_STATUS_ERROR(ret)) {
16769 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16770 wmi_buf_free(buf);
16771 return QDF_STATUS_E_FAILURE;
16772 }
16773
16774 return QDF_STATUS_SUCCESS;
16775}
16776
16777/**
16778 * send_delba_send_cmd_tlv() - send delba send command to fw
16779 * @wmi_handle: wmi handle
16780 * @param: pointer to delba send params
16781 * @macaddr: peer mac address
16782 *
16783 * Send WMI_DELBA_SEND_CMDID command to firmware
16784 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16785 */
16786static QDF_STATUS
16787send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16788 uint8_t macaddr[IEEE80211_ADDR_LEN],
16789 struct delba_send_params *param)
16790{
16791 wmi_delba_send_cmd_fixed_param *cmd;
16792 wmi_buf_t buf;
16793 uint16_t len;
16794 QDF_STATUS ret;
16795
16796 len = sizeof(*cmd);
16797
16798 buf = wmi_buf_alloc(wmi_handle, len);
16799 if (!buf) {
16800 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16801 return QDF_STATUS_E_NOMEM;
16802 }
16803
16804 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16805
16806 WMITLV_SET_HDR(&cmd->tlv_header,
16807 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16808 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16809
16810 cmd->vdev_id = param->vdev_id;
16811 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16812 cmd->tid = param->tidno;
16813 cmd->initiator = param->initiator;
16814 cmd->reasoncode = param->reasoncode;
16815
16816 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16817 if (QDF_IS_STATUS_ERROR(ret)) {
16818 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16819 wmi_buf_free(buf);
16820 return QDF_STATUS_E_FAILURE;
16821 }
16822
16823 return QDF_STATUS_SUCCESS;
16824}
16825
16826/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016827 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16828 * to fw
16829 * @wmi_handle: wmi handle
16830 * @param: pointer to addba clearresp params
16831 * @macaddr: peer mac address
16832 * Return: 0 for success or error code
16833 */
16834static QDF_STATUS
16835send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16836 uint8_t macaddr[IEEE80211_ADDR_LEN],
16837 struct addba_clearresponse_params *param)
16838{
16839 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16840 wmi_buf_t buf;
16841 uint16_t len;
16842 QDF_STATUS ret;
16843
16844 len = sizeof(*cmd);
16845
16846 buf = wmi_buf_alloc(wmi_handle, len);
16847 if (!buf) {
16848 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16849 return QDF_STATUS_E_FAILURE;
16850 }
16851 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16852
16853 WMITLV_SET_HDR(&cmd->tlv_header,
16854 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16855 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16856
16857 cmd->vdev_id = param->vdev_id;
16858 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16859
16860 ret = wmi_unified_cmd_send(wmi_handle,
16861 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16862 if (QDF_IS_STATUS_ERROR(ret)) {
16863 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16864 wmi_buf_free(buf);
16865 return QDF_STATUS_E_FAILURE;
16866 }
16867
16868 return QDF_STATUS_SUCCESS;
16869}
16870
16871/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016872 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16873 * @wmi_handle: wmi handle
16874 * @bcn_ctrl_param: pointer to bcn_offload_control param
16875 *
16876 * Return: QDF_STATUS_SUCCESS for success or error code
16877 */
16878static
16879QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16880 struct bcn_offload_control *bcn_ctrl_param)
16881{
16882 wmi_buf_t buf;
16883 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16884 QDF_STATUS ret;
16885 uint32_t len;
16886
16887 len = sizeof(*cmd);
16888
16889 buf = wmi_buf_alloc(wmi_handle, len);
16890 if (!buf) {
16891 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16892 return QDF_STATUS_E_FAILURE;
16893 }
16894
16895 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16896 WMITLV_SET_HDR(&cmd->tlv_header,
16897 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16898 WMITLV_GET_STRUCT_TLVLEN
16899 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16900 cmd->vdev_id = bcn_ctrl_param->vdev_id;
16901 if (bcn_ctrl_param->bcn_tx_enable)
16902 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16903 else
16904 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
16905
16906
16907 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16908 WMI_BCN_OFFLOAD_CTRL_CMDID);
16909
16910 if (QDF_IS_STATUS_ERROR(ret)) {
16911 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16912 ret);
16913 wmi_buf_free(buf);
16914 }
16915
16916 return ret;
16917}
16918
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016919#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16920static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16921 struct nan_datapath_initiator_req *ndp_req)
16922{
16923 uint16_t len;
16924 wmi_buf_t buf;
16925 uint8_t *tlv_ptr;
16926 QDF_STATUS status;
16927 wmi_channel *ch_tlv;
16928 wmi_ndp_initiator_req_fixed_param *cmd;
16929 uint32_t passphrase_len, service_name_len;
16930 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
16931
16932 /*
16933 * WMI command expects 4 byte alligned len:
16934 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16935 */
16936 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16937 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16938 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16939 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16940 service_name_len =
16941 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16942 /* allocated memory for fixed params as well as variable size data */
16943 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16944 + ndp_cfg_len + ndp_app_info_len + pmk_len
16945 + passphrase_len + service_name_len;
16946
16947 buf = wmi_buf_alloc(wmi_handle, len);
16948 if (!buf) {
16949 WMI_LOGE("wmi_buf_alloc failed");
16950 return QDF_STATUS_E_NOMEM;
16951 }
16952
16953 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16954 WMITLV_SET_HDR(&cmd->tlv_header,
16955 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16956 WMITLV_GET_STRUCT_TLVLEN(
16957 wmi_ndp_initiator_req_fixed_param));
16958 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16959 cmd->transaction_id = ndp_req->transaction_id;
16960 cmd->service_instance_id = ndp_req->service_instance_id;
16961 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16962 &cmd->peer_discovery_mac_addr);
16963
16964 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16965 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16966 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16967 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16968 cmd->nan_csid = ndp_req->ncs_sk_type;
16969 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16970 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16971
16972 ch_tlv = (wmi_channel *)&cmd[1];
16973 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16974 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16975 ch_tlv->mhz = ndp_req->channel;
16976 tlv_ptr = (uint8_t *)&ch_tlv[1];
16977
16978 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16979 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16980 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16981 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16982
16983 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16984 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16985 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
16986 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16987
16988 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16989 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
16990 cmd->nan_pmk_len);
16991 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16992
16993 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16994 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
16995 cmd->nan_passphrase_len);
16996 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16997
16998 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16999 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17000 ndp_req->service_name.service_name,
17001 cmd->nan_servicename_len);
17002 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17003
17004 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
17005 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
17006 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
17007 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
17008 cmd->peer_discovery_mac_addr.mac_addr31to0,
17009 cmd->peer_discovery_mac_addr.mac_addr47to32);
17010
17011 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
17012 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17013 ndp_req->ndp_config.ndp_cfg,
17014 ndp_req->ndp_config.ndp_cfg_len);
17015
17016 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
17017 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17018 ndp_req->ndp_info.ndp_app_info,
17019 ndp_req->ndp_info.ndp_app_info_len);
17020
17021 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17022 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17023 ndp_req->pmk.pmk, cmd->nan_pmk_len);
17024
17025 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17026 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17027 ndp_req->passphrase.passphrase,
17028 cmd->nan_passphrase_len);
17029
17030 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17031 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17032 ndp_req->service_name.service_name,
17033 cmd->nan_servicename_len);
17034
17035 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
17036 WMI_NDP_INITIATOR_REQ_CMDID);
17037
17038 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17039 WMI_NDP_INITIATOR_REQ_CMDID);
17040 if (QDF_IS_STATUS_ERROR(status)) {
17041 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
17042 wmi_buf_free(buf);
17043 }
17044
17045 return status;
17046}
17047
17048static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
17049 struct nan_datapath_responder_req *req)
17050{
17051 uint16_t len;
17052 wmi_buf_t buf;
17053 uint8_t *tlv_ptr;
17054 QDF_STATUS status;
17055 wmi_ndp_responder_req_fixed_param *cmd;
17056 uint32_t passphrase_len, service_name_len;
17057 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
17058
17059 vdev_id = wlan_vdev_get_id(req->vdev);
17060 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
17061 vdev_id, req->transaction_id,
17062 req->ndp_rsp,
17063 req->ndp_instance_id,
17064 req->ndp_info.ndp_app_info_len);
17065
17066 /*
17067 * WMI command expects 4 byte alligned len:
17068 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17069 */
17070 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
17071 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
17072 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
17073 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
17074 service_name_len =
17075 qdf_roundup(req->service_name.service_name_len, 4);
17076
17077 /* allocated memory for fixed params as well as variable size data */
17078 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
17079 + pmk_len + passphrase_len + service_name_len;
17080
17081 buf = wmi_buf_alloc(wmi_handle, len);
17082 if (!buf) {
17083 WMI_LOGE("wmi_buf_alloc failed");
17084 return QDF_STATUS_E_NOMEM;
17085 }
17086 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
17087 WMITLV_SET_HDR(&cmd->tlv_header,
17088 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
17089 WMITLV_GET_STRUCT_TLVLEN(
17090 wmi_ndp_responder_req_fixed_param));
17091 cmd->vdev_id = vdev_id;
17092 cmd->transaction_id = req->transaction_id;
17093 cmd->ndp_instance_id = req->ndp_instance_id;
17094 cmd->rsp_code = req->ndp_rsp;
17095 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
17096 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
17097 cmd->nan_pmk_len = req->pmk.pmk_len;
17098 cmd->nan_csid = req->ncs_sk_type;
17099 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
17100 cmd->nan_servicename_len = req->service_name.service_name_len;
17101
17102 tlv_ptr = (uint8_t *)&cmd[1];
17103 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17104 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17105 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17106
17107 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17108 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17109 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17110 req->ndp_info.ndp_app_info,
17111 req->ndp_info.ndp_app_info_len);
17112
17113 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17114 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17115 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
17116 cmd->nan_pmk_len);
17117
17118 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17119 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17120 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17121 req->passphrase.passphrase,
17122 cmd->nan_passphrase_len);
17123 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17124
17125 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17126 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17127 req->service_name.service_name,
17128 cmd->nan_servicename_len);
17129
17130 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17131
17132 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
17133 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
17134
17135 WMI_LOGD("ndp_config len: %d",
17136 req->ndp_config.ndp_cfg_len);
17137 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17138 req->ndp_config.ndp_cfg,
17139 req->ndp_config.ndp_cfg_len);
17140
17141 WMI_LOGD("ndp_app_info len: %d",
17142 req->ndp_info.ndp_app_info_len);
17143 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17144 req->ndp_info.ndp_app_info,
17145 req->ndp_info.ndp_app_info_len);
17146
17147 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17148 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17149 req->pmk.pmk, cmd->nan_pmk_len);
17150
17151 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17152 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17153 req->passphrase.passphrase,
17154 cmd->nan_passphrase_len);
17155
17156 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17157 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17158 req->service_name.service_name,
17159 cmd->nan_servicename_len);
17160
17161 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
17162 WMI_NDP_RESPONDER_REQ_CMDID);
17163 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17164 WMI_NDP_RESPONDER_REQ_CMDID);
17165 if (QDF_IS_STATUS_ERROR(status)) {
17166 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
17167 wmi_buf_free(buf);
17168 }
17169 return status;
17170}
17171
17172static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
17173 struct nan_datapath_end_req *req)
17174{
17175 uint16_t len;
17176 wmi_buf_t buf;
17177 QDF_STATUS status;
17178 uint32_t ndp_end_req_len, i;
17179 wmi_ndp_end_req *ndp_end_req_lst;
17180 wmi_ndp_end_req_fixed_param *cmd;
17181
17182 /* len of tlv following fixed param */
17183 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
17184 /* above comes out to 4 byte alligned already, no need of padding */
17185 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
17186 buf = wmi_buf_alloc(wmi_handle, len);
17187 if (!buf) {
17188 WMI_LOGE("Malloc failed");
17189 return QDF_STATUS_E_NOMEM;
17190 }
17191
17192 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
17193 WMITLV_SET_HDR(&cmd->tlv_header,
17194 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
17195 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
17196
17197 cmd->transaction_id = req->transaction_id;
17198
17199 /* set tlv pointer to end of fixed param */
17200 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
17201 ndp_end_req_len);
17202
17203 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
17204 WMI_TLV_HDR_SIZE);
17205 for (i = 0; i < req->num_ndp_instances; i++) {
17206 WMITLV_SET_HDR(&ndp_end_req_lst[i],
17207 WMITLV_TAG_ARRAY_FIXED_STRUC,
17208 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
17209
17210 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
17211 }
17212
17213 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
17214 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17215 WMI_NDP_END_REQ_CMDID);
17216 if (QDF_IS_STATUS_ERROR(status)) {
17217 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
17218 wmi_buf_free(buf);
17219 }
17220
17221 return status;
17222}
17223
17224static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
17225 uint8_t *data, struct nan_datapath_initiator_rsp **rsp)
17226{
17227 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
17228 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
17229
17230 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
17231 fixed_params = event->fixed_param;
17232
17233 *rsp = qdf_mem_malloc(sizeof(**rsp));
17234 if (!(*rsp)) {
17235 WMI_LOGE("malloc failed");
17236 return QDF_STATUS_E_NOMEM;
17237 }
17238
17239 (*rsp)->vdev =
17240 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17241 fixed_params->vdev_id,
17242 WLAN_NAN_ID);
17243 if (!(*rsp)->vdev) {
17244 WMI_LOGE("vdev is null");
17245 qdf_mem_free(*rsp);
17246 return QDF_STATUS_E_INVAL;
17247 }
17248
17249 (*rsp)->transaction_id = fixed_params->transaction_id;
17250 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17251 (*rsp)->status = fixed_params->rsp_status;
17252 (*rsp)->reason = fixed_params->reason_code;
17253
17254 return QDF_STATUS_SUCCESS;
17255}
17256
17257static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
17258 uint8_t *data, struct nan_datapath_indication_event **rsp)
17259{
17260 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
17261 wmi_ndp_indication_event_fixed_param *fixed_params;
17262
17263 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
17264 fixed_params =
17265 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
17266
17267 *rsp = qdf_mem_malloc(sizeof(**rsp));
17268 if (!(*rsp)) {
17269 WMI_LOGE("malloc failed");
17270 return QDF_STATUS_E_NOMEM;
17271 }
17272
17273 (*rsp)->vdev =
17274 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17275 fixed_params->vdev_id,
17276 WLAN_NAN_ID);
17277 if (!(*rsp)->vdev) {
17278 WMI_LOGE("vdev is null");
17279 qdf_mem_free(*rsp);
17280 return QDF_STATUS_E_INVAL;
17281 }
17282 (*rsp)->service_instance_id = fixed_params->service_instance_id;
17283 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17284 (*rsp)->role = fixed_params->self_ndp_role;
17285 (*rsp)->policy = fixed_params->accept_policy;
17286
17287 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17288 (*rsp)->peer_mac_addr.bytes);
17289 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
17290 (*rsp)->peer_discovery_mac_addr.bytes);
17291
17292 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
17293 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
17294 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
17295 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
17296 fixed_params->service_instance_id,
17297 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
17298 fixed_params->accept_policy,
17299 fixed_params->nan_csid, fixed_params->nan_scid_len,
17300 (*rsp)->peer_mac_addr.bytes,
17301 (*rsp)->peer_discovery_mac_addr.bytes);
17302
17303 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17304 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17305 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17306
17307 WMI_LOGD("ndp_app_info - %d bytes",
17308 fixed_params->ndp_app_info_len);
17309 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17310 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17311
17312 (*rsp)->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
17313 (*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17314 (*rsp)->ncs_sk_type = fixed_params->nan_csid;
17315 (*rsp)->scid.scid_len = fixed_params->nan_scid_len;
17316 qdf_mem_copy((*rsp)->ndp_config.ndp_cfg, event->ndp_cfg,
17317 (*rsp)->ndp_config.ndp_cfg_len);
17318 qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
17319 (*rsp)->ndp_info.ndp_app_info_len);
17320 qdf_mem_copy((*rsp)->scid.scid, event->ndp_scid, (*rsp)->scid.scid_len);
17321 WMI_LOGD("scid hex dump:");
17322 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17323 (*rsp)->scid.scid, (*rsp)->scid.scid_len);
17324
17325 return QDF_STATUS_SUCCESS;
17326}
17327
17328static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
17329 uint8_t *data, struct nan_datapath_confirm_event **rsp)
17330{
17331 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
17332 wmi_ndp_confirm_event_fixed_param *fixed_params;
17333
17334 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
17335 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
17336 WMI_LOGD("WMI_NDP_CONFIRM_EVENTID(0x%X) recieved. vdev %d, ndp_instance %d, rsp_code %d, reason_code: %d, num_active_ndps_on_peer: %d",
17337 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
17338 fixed_params->ndp_instance_id, fixed_params->rsp_code,
17339 fixed_params->reason_code,
17340 fixed_params->num_active_ndps_on_peer);
17341 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17342 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17343 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17344
17345 WMI_LOGD("ndp_app_info - %d bytes",
17346 fixed_params->ndp_app_info_len);
17347 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17348 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17349
17350 *rsp = qdf_mem_malloc(sizeof(**rsp));
17351 if (!(*rsp)) {
17352 WMI_LOGE("malloc failed");
17353 return QDF_STATUS_E_NOMEM;
17354 }
17355
17356 (*rsp)->vdev =
17357 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17358 fixed_params->vdev_id,
17359 WLAN_NAN_ID);
17360 if (!(*rsp)->vdev) {
17361 WMI_LOGE("vdev is null");
17362 qdf_mem_free(*rsp);
17363 return QDF_STATUS_E_INVAL;
17364 }
17365 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17366 (*rsp)->rsp_code = fixed_params->rsp_code;
17367 (*rsp)->reason_code = fixed_params->reason_code;
17368 (*rsp)->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
17369 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17370 (*rsp)->peer_ndi_mac_addr.bytes);
17371 (*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17372 qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
17373 (*rsp)->ndp_info.ndp_app_info_len);
17374
17375 return QDF_STATUS_SUCCESS;
17376}
17377
17378static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
17379 uint8_t *data, struct nan_datapath_responder_rsp **rsp)
17380{
17381 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17382 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17383
17384 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17385 fixed_params = event->fixed_param;
17386
17387 WMI_LOGD("WMI_NDP_RESPONDER_RSP_EVENTID(0x%X) received. vdev_id: %d, peer_mac_addr: %pM,transaction_id: %d, status_code %d, reason_code: %d, create_peer: %d",
17388 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
17389 (*rsp)->peer_mac_addr.bytes, (*rsp)->transaction_id,
17390 (*rsp)->status, (*rsp)->reason, (*rsp)->create_peer);
17391
17392 *rsp = qdf_mem_malloc(sizeof(**rsp));
17393 if (!(*rsp)) {
17394 WMI_LOGE("malloc failed");
17395 return QDF_STATUS_E_NOMEM;
17396 }
17397
17398 (*rsp)->vdev =
17399 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17400 fixed_params->vdev_id,
17401 WLAN_NAN_ID);
17402 if (!(*rsp)->vdev) {
17403 WMI_LOGE("vdev is null");
17404 qdf_mem_free(*rsp);
17405 return QDF_STATUS_E_INVAL;
17406 }
17407 (*rsp)->transaction_id = fixed_params->transaction_id;
17408 (*rsp)->reason = fixed_params->reason_code;
17409 (*rsp)->status = fixed_params->rsp_status;
17410 (*rsp)->create_peer = fixed_params->create_peer;
17411 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17412 (*rsp)->peer_mac_addr.bytes);
17413
17414 return QDF_STATUS_SUCCESS;
17415}
17416
17417static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
17418 uint8_t *data, struct nan_datapath_end_rsp_event **rsp)
17419{
17420 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17421 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17422
17423 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17424 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
17425 WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) recieved. transaction_id: %d, rsp_status: %d, reason_code: %d",
17426 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17427 fixed_params->rsp_status, fixed_params->reason_code);
17428
17429 *rsp = qdf_mem_malloc(sizeof(**rsp));
17430 if (!(*rsp)) {
17431 WMI_LOGE("malloc failed");
17432 return QDF_STATUS_E_NOMEM;
17433 }
17434
17435 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17436 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17437 if (!(*rsp)->vdev) {
17438 WMI_LOGE("vdev is null");
17439 qdf_mem_free(*rsp);
17440 return QDF_STATUS_E_INVAL;
17441 }
17442 (*rsp)->transaction_id = fixed_params->transaction_id;
17443 (*rsp)->reason = fixed_params->reason_code;
17444 (*rsp)->status = fixed_params->rsp_status;
17445
17446 return QDF_STATUS_SUCCESS;
17447}
17448
17449static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17450 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17451{
17452 uint32_t i, buf_size;
17453 wmi_ndp_end_indication *ind;
17454 struct qdf_mac_addr peer_addr;
17455 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17456
17457 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17458 ind = event->ndp_end_indication_list;
17459
17460 if (event->num_ndp_end_indication_list == 0) {
17461 WMI_LOGE("Error: Event ignored, 0 ndp instances");
17462 return -EINVAL;
17463 }
17464
17465 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17466 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17467 if (!(*rsp)->vdev) {
17468 WMI_LOGE("vdev is null");
17469 qdf_mem_free(*rsp);
17470 return QDF_STATUS_E_INVAL;
17471 }
17472
17473 WMI_LOGD("number of ndp instances = %d",
17474 event->num_ndp_end_indication_list);
17475 buf_size = sizeof(*rsp) + event->num_ndp_end_indication_list *
17476 sizeof((*rsp)->ndp_map[0]);
17477 *rsp = qdf_mem_malloc(buf_size);
17478 if (!(*rsp)) {
17479 WMI_LOGE("Failed to allocate memory");
17480 return -ENOMEM;
17481 }
17482
17483 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17484 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17485 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17486 peer_addr.bytes);
17487 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17488 i, ind[i].type, ind[i].reason_code,
17489 ind[i].ndp_instance_id,
17490 ind[i].num_active_ndps_on_peer);
17491 /* Add each instance entry to the list */
17492 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17493 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17494 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17495 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17496 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17497 ind[i].num_active_ndps_on_peer;
17498 (*rsp)->ndp_map[i].type = ind[i].type;
17499 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17500 }
17501
17502 return QDF_STATUS_SUCCESS;
17503}
17504#endif
17505
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017506/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017507 * save_service_bitmap_tlv() - save service bitmap
17508 * @wmi_handle: wmi handle
17509 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017510 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017511 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017512 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017513 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017514static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017515QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017516 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017517{
17518 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017519 struct wmi_soc *soc = wmi_handle->soc;
17520
Govind Singhe7f2f342016-05-23 12:12:52 +053017521 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17522
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017523 /* If it is already allocated, use that buffer. This can happen
17524 * during target stop/start scenarios where host allocation is skipped.
17525 */
17526 if (!soc->wmi_service_bitmap) {
17527 soc->wmi_service_bitmap =
17528 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17529 if (!soc->wmi_service_bitmap) {
17530 WMI_LOGE("Failed memory allocation for service bitmap");
17531 return QDF_STATUS_E_NOMEM;
17532 }
17533 }
17534
17535 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017536 param_buf->wmi_service_bitmap,
17537 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017538
17539 if (bitmap_buf)
17540 qdf_mem_copy(bitmap_buf,
17541 param_buf->wmi_service_bitmap,
17542 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017543
17544 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017545}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017546
17547/**
17548 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17549 * @wmi_handle: wmi handle
17550 * @param evt_buf: pointer to event buffer
17551 * @param bitmap_buf: bitmap buffer, for converged legacy support
17552 *
17553 * Return: QDF_STATUS
17554 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017555static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017556QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017557 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017558{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017559 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17560 wmi_service_available_event_fixed_param *ev;
17561 struct wmi_soc *soc = wmi_handle->soc;
17562
17563 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17564
17565 ev = param_buf->fixed_param;
17566
17567 /* If it is already allocated, use that buffer. This can happen
17568 * during target stop/start scenarios where host allocation is skipped.
17569 */
17570 if (!soc->wmi_ext_service_bitmap) {
17571 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17572 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17573 if (!soc->wmi_ext_service_bitmap) {
17574 WMI_LOGE("Failed memory allocation for service bitmap");
17575 return QDF_STATUS_E_NOMEM;
17576 }
17577 }
17578
17579 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17580 ev->wmi_service_segment_bitmap,
17581 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017582
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017583 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17584 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17585 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17586
Rajeev Kumar77901472017-02-12 02:12:17 -080017587 if (bitmap_buf)
17588 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017589 soc->wmi_ext_service_bitmap,
17590 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017591
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017592 return QDF_STATUS_SUCCESS;
17593}
Govind Singhe7f2f342016-05-23 12:12:52 +053017594/**
17595 * is_service_enabled_tlv() - Check if service enabled
17596 * @param wmi_handle: wmi handle
17597 * @param service_id: service identifier
17598 *
17599 * Return: 1 enabled, 0 disabled
17600 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053017601#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053017602static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17603 uint32_t service_id)
17604{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017605 struct wmi_soc *soc = wmi_handle->soc;
17606
17607 if (!soc->wmi_service_bitmap) {
17608 WMI_LOGE("WMI service bit map is not saved yet\n");
17609 return false;
17610 }
17611
17612 /* if WMI_EXTENDED_SERVICE_AVAILABLE was received with extended bitmap,
17613 * use WMI_SERVICE_EXT_ENABLE to check the services.
17614 */
17615 if (soc->wmi_ext_service_bitmap)
17616 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17617 soc->wmi_ext_service_bitmap,
17618 service_id);
17619
17620 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17621 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017622}
17623#else
17624static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17625 uint32_t service_id)
17626{
17627 return false;
17628}
17629#endif
17630
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017631static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17632 struct wlan_psoc_target_capability_info *cap)
17633{
17634 /* except LDPC all flags are common betwen legacy and here
17635 * also IBFEER is not defined for TLV
17636 */
17637 cap->ht_cap_info |= ev_target_cap & (
17638 WMI_HT_CAP_ENABLED
17639 | WMI_HT_CAP_HT20_SGI
17640 | WMI_HT_CAP_DYNAMIC_SMPS
17641 | WMI_HT_CAP_TX_STBC
17642 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17643 | WMI_HT_CAP_RX_STBC
17644 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17645 | WMI_HT_CAP_LDPC
17646 | WMI_HT_CAP_L_SIG_TXOP_PROT
17647 | WMI_HT_CAP_MPDU_DENSITY
17648 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17649 | WMI_HT_CAP_HT40_SGI);
17650 if (ev_target_cap & WMI_HT_CAP_LDPC)
17651 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17652 WMI_HOST_HT_CAP_TX_LDPC;
17653}
Govind Singhe7f2f342016-05-23 12:12:52 +053017654/**
17655 * extract_service_ready_tlv() - extract service ready event
17656 * @wmi_handle: wmi handle
17657 * @param evt_buf: pointer to received event buffer
17658 * @param cap: pointer to hold target capability information extracted from even
17659 *
17660 * Return: QDF_STATUS_SUCCESS for success or error code
17661 */
17662static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017663 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017664{
17665 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17666 wmi_service_ready_event_fixed_param *ev;
17667
17668
17669 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17670
17671 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17672 if (!ev) {
17673 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17674 return QDF_STATUS_E_FAILURE;
17675 }
17676
17677 cap->phy_capability = ev->phy_capability;
17678 cap->max_frag_entry = ev->max_frag_entry;
17679 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017680 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017681 cap->vht_cap_info = ev->vht_cap_info;
17682 cap->vht_supp_mcs = ev->vht_supp_mcs;
17683 cap->hw_min_tx_power = ev->hw_min_tx_power;
17684 cap->hw_max_tx_power = ev->hw_max_tx_power;
17685 cap->sys_cap_info = ev->sys_cap_info;
17686 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17687 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17688 cap->max_num_scan_channels = ev->max_num_scan_channels;
17689 cap->max_supported_macs = ev->max_supported_macs;
17690 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17691 cap->txrx_chainmask = ev->txrx_chainmask;
17692 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17693 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017694 cap->fw_version = ev->fw_build_vers;
17695 /* fw_version_1 is not available in TLV. */
17696 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017697
17698 return QDF_STATUS_SUCCESS;
17699}
17700
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017701/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17702 * to host internal WMI_HOST_REGDMN_MODE values.
17703 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17704 * host currently. Add this in the future if required.
17705 * 11AX (Phase II) : 11ax related values are not currently
17706 * advertised separately by FW. As part of phase II regulatory bring-up,
17707 * finalize the advertisement mechanism.
17708 * @target_wireless_mode: target wireless mode received in message
17709 *
17710 * Return: returns the host internal wireless mode.
17711 */
17712static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17713{
17714
17715 uint32_t wireless_modes = 0;
17716
17717 if (target_wireless_mode & REGDMN_MODE_11A)
17718 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17719
17720 if (target_wireless_mode & REGDMN_MODE_TURBO)
17721 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17722
17723 if (target_wireless_mode & REGDMN_MODE_11B)
17724 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17725
17726 if (target_wireless_mode & REGDMN_MODE_PUREG)
17727 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17728
17729 if (target_wireless_mode & REGDMN_MODE_11G)
17730 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17731
17732 if (target_wireless_mode & REGDMN_MODE_108G)
17733 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17734
17735 if (target_wireless_mode & REGDMN_MODE_108A)
17736 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17737
17738 if (target_wireless_mode & REGDMN_MODE_XR)
17739 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17740
17741 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17742 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17743
17744 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17745 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17746
17747 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17748 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17749
17750 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17751 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17752
17753 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17754 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17755
17756 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17757 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17758
17759 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17760 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17761
17762 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17763 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17764
17765 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17766 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17767
17768 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17769 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17770
17771 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17772 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17773
17774 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17775 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17776
17777 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17778 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17779
17780 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17781 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17782
17783 return wireless_modes;
17784}
17785
Govind Singhe7f2f342016-05-23 12:12:52 +053017786/**
17787 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17788 * @wmi_handle: wmi handle
17789 * @param evt_buf: Pointer to event buffer
17790 * @param cap: pointer to hold HAL reg capabilities
17791 *
17792 * Return: QDF_STATUS_SUCCESS for success or error code
17793 */
17794static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017795 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017796{
17797 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17798
17799 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17800
17801 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17802 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017803 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017804
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017805 cap->wireless_modes = convert_wireless_modes_tlv(
17806 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017807
Govind Singhe7f2f342016-05-23 12:12:52 +053017808 return QDF_STATUS_SUCCESS;
17809}
17810
17811/**
17812 * extract_host_mem_req_tlv() - Extract host memory request event
17813 * @wmi_handle: wmi handle
17814 * @param evt_buf: pointer to event buffer
17815 * @param num_entries: pointer to hold number of entries requested
17816 *
17817 * Return: Number of entries requested
17818 */
17819static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17820 void *evt_buf, uint8_t *num_entries)
17821{
17822 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17823 wmi_service_ready_event_fixed_param *ev;
17824
17825 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17826
17827 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17828 if (!ev) {
17829 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17830 return NULL;
17831 }
17832
17833 *num_entries = ev->num_mem_reqs;
17834
17835 return (host_mem_req *)param_buf->mem_reqs;
17836}
17837
17838/**
17839 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17840 * ready function
17841 * @wmi_handle: wmi handle
17842 * @param evt_buf: pointer to event buffer
17843 *
17844 * Return: QDF_STATUS_SUCCESS for success or error code
17845 */
17846static QDF_STATUS
17847save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17848{
17849 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17850 wmi_service_ready_event_fixed_param *ev;
17851
17852
17853 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17854
17855 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17856 if (!ev) {
17857 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17858 return QDF_STATUS_E_FAILURE;
17859 }
17860
17861 /*Save fw version from service ready message */
17862 /*This will be used while sending INIT message */
17863 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17864 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017865
Govind Singhe7f2f342016-05-23 12:12:52 +053017866 return QDF_STATUS_SUCCESS;
17867}
17868
17869/**
17870 * ready_extract_init_status_tlv() - Extract init status from ready event
17871 * @wmi_handle: wmi handle
17872 * @param evt_buf: Pointer to event buffer
17873 *
17874 * Return: ready status
17875 */
17876static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17877 void *evt_buf)
17878{
17879 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17880 wmi_ready_event_fixed_param *ev = NULL;
17881
Govind Singhe7f2f342016-05-23 12:12:52 +053017882 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17883 ev = param_buf->fixed_param;
17884
17885 qdf_print("%s:%d\n", __func__, ev->status);
17886
17887 return ev->status;
17888}
17889
17890/**
17891 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17892 * @wmi_handle: wmi handle
17893 * @param evt_buf: pointer to event buffer
17894 * @param macaddr: Pointer to hold MAC address
17895 *
17896 * Return: QDF_STATUS_SUCCESS for success or error code
17897 */
17898static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17899 void *evt_buf, uint8_t *macaddr)
17900{
17901 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17902 wmi_ready_event_fixed_param *ev = NULL;
17903
17904
17905 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17906 ev = param_buf->fixed_param;
17907
17908 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17909
17910 return QDF_STATUS_SUCCESS;
17911}
17912
17913/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017914 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17915 * @wmi_handle: wmi handle
17916 * @param evt_buf: pointer to event buffer
17917 * @param macaddr: Pointer to hold number of MAC addresses
17918 *
17919 * Return: Pointer to addr list
17920 */
17921static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17922 void *evt_buf, uint8_t *num_mac)
17923{
17924 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17925 wmi_ready_event_fixed_param *ev = NULL;
17926
17927 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17928 ev = param_buf->fixed_param;
17929
17930 *num_mac = ev->num_extra_mac_addr;
17931
17932 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17933}
17934
17935/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017936 * extract_ready_params_tlv() - Extract data from ready event apart from
17937 * status, macaddr and version.
17938 * @wmi_handle: Pointer to WMI handle.
17939 * @evt_buf: Pointer to Ready event buffer.
17940 * @ev_param: Pointer to host defined struct to copy the data from event.
17941 *
17942 * Return: QDF_STATUS_SUCCESS on success.
17943 */
17944static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17945 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17946{
17947 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17948 wmi_ready_event_fixed_param *ev = NULL;
17949
17950 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17951 ev = param_buf->fixed_param;
17952
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017953 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017954 ev_param->num_dscp_table = ev->num_dscp_table;
17955 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17956 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017957 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017958 /* Agile_cap in ready event is not supported in TLV target */
17959 ev_param->agile_capability = false;
17960
17961 return QDF_STATUS_SUCCESS;
17962}
17963
17964/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017965 * extract_dbglog_data_len_tlv() - extract debuglog data length
17966 * @wmi_handle: wmi handle
17967 * @param evt_buf: pointer to event buffer
17968 *
17969 * Return: length
17970 */
17971static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017972 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017973{
17974 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17975
17976 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17977
17978 *len = param_buf->num_bufp;
17979
17980 return param_buf->bufp;
17981}
17982
17983/**
17984 * extract_vdev_start_resp_tlv() - extract vdev start response
17985 * @wmi_handle: wmi handle
17986 * @param evt_buf: pointer to event buffer
17987 * @param vdev_rsp: Pointer to hold vdev response
17988 *
17989 * Return: QDF_STATUS_SUCCESS for success or error code
17990 */
17991static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17992 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17993{
17994 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17995 wmi_vdev_start_response_event_fixed_param *ev;
17996
17997 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17998 if (!param_buf) {
17999 qdf_print("Invalid start response event buffer\n");
18000 return QDF_STATUS_E_INVAL;
18001 }
18002
18003 ev = param_buf->fixed_param;
18004 if (!ev) {
18005 qdf_print("Invalid start response event buffer\n");
18006 return QDF_STATUS_E_INVAL;
18007 }
18008
18009 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
18010
18011 vdev_rsp->vdev_id = ev->vdev_id;
18012 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018013 switch (ev->resp_type) {
18014 case WMI_VDEV_START_RESP_EVENT:
18015 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
18016 break;
18017 case WMI_VDEV_RESTART_RESP_EVENT:
18018 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
18019 break;
18020 default:
18021 qdf_print("Invalid start response event buffer\n");
18022 break;
18023 };
Govind Singhe7f2f342016-05-23 12:12:52 +053018024 vdev_rsp->status = ev->status;
18025 vdev_rsp->chain_mask = ev->chain_mask;
18026 vdev_rsp->smps_mode = ev->smps_mode;
18027 vdev_rsp->mac_id = ev->mac_id;
18028 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
18029 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
18030
18031 return QDF_STATUS_SUCCESS;
18032}
18033
18034/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053018035 * extract_vdev_delete_resp_tlv() - extract vdev delete response
18036 * @wmi_handle: wmi handle
18037 * @param evt_buf: pointer to event buffer
18038 * @param delete_rsp: Pointer to hold vdev delete response
18039 *
18040 * Return: QDF_STATUS_SUCCESS for success or error code
18041 */
18042static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
18043 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
18044{
18045 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
18046 wmi_vdev_delete_resp_event_fixed_param *ev;
18047
18048 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
18049 if (!param_buf) {
18050 WMI_LOGE("Invalid vdev delete response event buffer\n");
18051 return QDF_STATUS_E_INVAL;
18052 }
18053
18054 ev = param_buf->fixed_param;
18055 if (!ev) {
18056 WMI_LOGE("Invalid vdev delete response event\n");
18057 return QDF_STATUS_E_INVAL;
18058 }
18059
18060 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
18061 delete_rsp->vdev_id = ev->vdev_id;
18062
18063 return QDF_STATUS_SUCCESS;
18064}
18065
18066
18067/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018068 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053018069 * @wmi_handle: wmi handle
18070 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018071 * @param num_vdevs: Pointer to hold num vdev
18072 *
18073 * Return: QDF_STATUS_SUCCESS for success or error code
18074 */
18075static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18076 void *evt_buf, uint32_t *num_vdevs)
18077{
18078 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18079 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
18080 uint32_t vdev_map;
18081
18082 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
18083 if (!param_buf) {
18084 qdf_print("Invalid tbtt update ext event buffer\n");
18085 return QDF_STATUS_E_INVAL;
18086 }
18087 tbtt_offset_event = param_buf->fixed_param;
18088 vdev_map = tbtt_offset_event->vdev_map;
18089 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18090
18091 return QDF_STATUS_SUCCESS;
18092}
18093
18094/**
18095 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
18096 * @wmi_handle: wmi handle
18097 * @param evt_buf: pointer to event buffer
18098 * @param num_vdevs: Pointer to hold num vdev
18099 *
18100 * Return: QDF_STATUS_SUCCESS for success or error code
18101 */
18102static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18103 void *evt_buf, uint32_t *num_vdevs)
18104{
18105 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18106 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
18107
18108 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18109 if (!param_buf) {
18110 qdf_print("Invalid tbtt update ext event buffer\n");
18111 return QDF_STATUS_E_INVAL;
18112 }
18113 tbtt_offset_ext_event = param_buf->fixed_param;
18114
18115 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
18116
18117 return QDF_STATUS_SUCCESS;
18118}
18119
18120/**
18121 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
18122 * @wmi_handle: wmi handle
18123 * @param evt_buf: pointer to event buffer
18124 * @param idx: Index refering to a vdev
18125 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053018126 *
18127 * Return: QDF_STATUS_SUCCESS for success or error code
18128 */
18129static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018130 void *evt_buf, uint8_t idx,
18131 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018132{
18133 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18134 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018135 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018136
18137 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
18138 if (!param_buf) {
18139 qdf_print("Invalid tbtt update event buffer\n");
18140 return QDF_STATUS_E_INVAL;
18141 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018142
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018143 tbtt_offset_event = param_buf->fixed_param;
18144 vdev_map = tbtt_offset_event->vdev_map;
18145 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
18146 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
18147 return QDF_STATUS_E_INVAL;
18148 tbtt_param->tbttoffset =
18149 param_buf->tbttoffset_list[tbtt_param->vdev_id];
18150
18151 return QDF_STATUS_SUCCESS;
18152}
18153
18154/**
18155 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
18156 * @wmi_handle: wmi handle
18157 * @param evt_buf: pointer to event buffer
18158 * @param idx: Index refering to a vdev
18159 * @param tbtt_param: Pointer to tbttoffset event param
18160 *
18161 * Return: QDF_STATUS_SUCCESS for success or error code
18162 */
18163static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
18164 void *evt_buf, uint8_t idx,
18165 struct tbttoffset_params *tbtt_param)
18166{
18167 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18168 wmi_tbtt_offset_info *tbtt_offset_info;
18169
18170 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18171 if (!param_buf) {
18172 qdf_print("Invalid tbtt update event buffer\n");
18173 return QDF_STATUS_E_INVAL;
18174 }
18175 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
18176
18177 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
18178 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053018179
18180 return QDF_STATUS_SUCCESS;
18181}
18182
18183/**
18184 * extract_mgmt_rx_params_tlv() - extract management rx params from event
18185 * @wmi_handle: wmi handle
18186 * @param evt_buf: pointer to event buffer
18187 * @param hdr: Pointer to hold header
18188 * @param bufp: Pointer to hold pointer to rx param buffer
18189 *
18190 * Return: QDF_STATUS_SUCCESS for success or error code
18191 */
18192static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053018193 void *evt_buf, struct mgmt_rx_event_params *hdr,
18194 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053018195{
18196 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
18197 wmi_mgmt_rx_hdr *ev_hdr = NULL;
18198
18199 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
18200 if (!param_tlvs) {
18201 WMI_LOGE("Get NULL point message from FW");
18202 return QDF_STATUS_E_INVAL;
18203 }
18204
18205 ev_hdr = param_tlvs->hdr;
18206 if (!hdr) {
18207 WMI_LOGE("Rx event is NULL");
18208 return QDF_STATUS_E_INVAL;
18209 }
18210
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018211 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18212 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018213
18214 hdr->channel = ev_hdr->channel;
18215 hdr->snr = ev_hdr->snr;
18216 hdr->rate = ev_hdr->rate;
18217 hdr->phy_mode = ev_hdr->phy_mode;
18218 hdr->buf_len = ev_hdr->buf_len;
18219 hdr->status = ev_hdr->status;
18220 hdr->flags = ev_hdr->flags;
18221 hdr->rssi = ev_hdr->rssi;
18222 hdr->tsf_delta = ev_hdr->tsf_delta;
18223 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
18224
18225 *bufp = param_tlvs->bufp;
18226
18227 return QDF_STATUS_SUCCESS;
18228}
18229
18230/**
18231 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
18232 * @wmi_handle: wmi handle
18233 * @param evt_buf: pointer to event buffer
18234 * @param vdev_id: Pointer to hold vdev identifier
18235 *
18236 * Return: QDF_STATUS_SUCCESS for success or error code
18237 */
18238static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
18239 void *evt_buf, uint32_t *vdev_id)
18240{
18241 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
18242 wmi_vdev_stopped_event_fixed_param *resp_event;
18243
18244 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
18245 if (!param_buf) {
18246 WMI_LOGE("Invalid event buffer");
18247 return QDF_STATUS_E_INVAL;
18248 }
18249 resp_event = param_buf->fixed_param;
18250 *vdev_id = resp_event->vdev_id;
18251
18252 return QDF_STATUS_SUCCESS;
18253}
18254
18255/**
18256 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
18257 * @wmi_handle: wmi handle
18258 * @param evt_buf: pointer to event buffer
18259 * @param param: Pointer to hold roam param
18260 *
18261 * Return: QDF_STATUS_SUCCESS for success or error code
18262 */
18263static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
18264 void *evt_buf, wmi_host_roam_event *param)
18265{
18266 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18267 wmi_roam_event_fixed_param *evt;
18268
18269 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18270 if (!param_buf) {
18271 WMI_LOGE("Invalid roam event buffer");
18272 return QDF_STATUS_E_INVAL;
18273 }
18274
18275 evt = param_buf->fixed_param;
18276 qdf_mem_zero(param, sizeof(*param));
18277
18278 param->vdev_id = evt->vdev_id;
18279 param->reason = evt->reason;
18280 param->rssi = evt->rssi;
18281
18282 return QDF_STATUS_SUCCESS;
18283}
18284
18285/**
18286 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18287 * @wmi_handle: wmi handle
18288 * @param evt_buf: pointer to event buffer
18289 * @param param: Pointer to hold vdev scan param
18290 *
18291 * Return: QDF_STATUS_SUCCESS for success or error code
18292 */
18293static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018294 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018295{
18296 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18297 wmi_scan_event_fixed_param *evt = NULL;
18298
18299 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18300 evt = param_buf->fixed_param;
18301
18302 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018303
Govind Singhe7f2f342016-05-23 12:12:52 +053018304 switch (evt->event) {
18305 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018306 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018307 break;
18308 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018309 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018310 break;
18311 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018312 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018313 break;
18314 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018315 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018316 break;
18317 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018318 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018319 break;
18320 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018321 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018322 break;
18323 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018324 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018325 break;
18326 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018327 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018328 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018329 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018330 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018331 break;
18332 case WMI_SCAN_EVENT_MAX:
18333 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018334 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018335 break;
18336 };
18337
18338 switch (evt->reason) {
18339 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018340 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018341 break;
18342 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018343 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018344 break;
18345 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018346 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018347 break;
18348 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018349 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018350 break;
18351 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018352 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018353 break;
18354 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018355 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018356 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018357 case WMI_SCAN_REASON_SUSPENDED:
18358 param->reason = SCAN_REASON_SUSPENDED;
18359 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018360 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018361 param->reason = SCAN_REASON_MAX;
18362 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018363 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018364 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018365 break;
18366 };
18367
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018368 param->chan_freq = evt->channel_freq;
18369 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018370 param->scan_id = evt->scan_id;
18371 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018372 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018373
18374 return QDF_STATUS_SUCCESS;
18375}
18376
Frank Liu3d5e9992017-03-15 17:51:43 +080018377#ifdef CONVERGED_TDLS_ENABLE
18378/**
18379 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18380 * @wmi_handle: wmi handle
18381 * @param evt_buf: pointer to event buffer
18382 * @param param: Pointer to hold vdev tdls param
18383 *
18384 * Return: QDF_STATUS_SUCCESS for success or error code
18385 */
18386static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18387 void *evt_buf, struct tdls_event_info *param)
18388{
18389 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18390 wmi_tdls_peer_event_fixed_param *evt;
18391
18392 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18393 if (!param_buf) {
18394 WMI_LOGE("%s: NULL param_buf", __func__);
18395 return QDF_STATUS_E_NULL_VALUE;
18396 }
18397
18398 evt = param_buf->fixed_param;
18399
18400 qdf_mem_zero(param, sizeof(*param));
18401
18402 param->vdev_id = evt->vdev_id;
18403 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18404 param->peermac.bytes);
18405 switch (evt->peer_status) {
18406 case WMI_TDLS_SHOULD_DISCOVER:
18407 param->message_type = TDLS_SHOULD_DISCOVER;
18408 break;
18409 case WMI_TDLS_SHOULD_TEARDOWN:
18410 param->message_type = TDLS_SHOULD_TEARDOWN;
18411 break;
18412 case WMI_TDLS_PEER_DISCONNECTED:
18413 param->message_type = TDLS_PEER_DISCONNECTED;
18414 break;
18415 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18416 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18417 break;
18418 default:
18419 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18420 __func__, evt->peer_status);
18421 return QDF_STATUS_E_INVAL;
18422 };
18423
18424 switch (evt->peer_reason) {
18425 case WMI_TDLS_TEARDOWN_REASON_TX:
18426 param->peer_reason = TDLS_TEARDOWN_TX;
18427 break;
18428 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18429 param->peer_reason = TDLS_TEARDOWN_RSSI;
18430 break;
18431 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18432 param->peer_reason = TDLS_TEARDOWN_SCAN;
18433 break;
18434 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18435 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18436 break;
18437 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18438 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18439 break;
18440 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18441 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18442 break;
18443 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18444 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18445 break;
18446 case WMI_TDLS_ENTER_BUF_STA:
18447 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18448 break;
18449 case WMI_TDLS_EXIT_BUF_STA:
18450 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18451 break;
18452 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18453 param->peer_reason = TDLS_ENTER_BT_BUSY;
18454 break;
18455 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18456 param->peer_reason = TDLS_EXIT_BT_BUSY;
18457 break;
18458 case WMI_TDLS_SCAN_STARTED_EVENT:
18459 param->peer_reason = TDLS_SCAN_STARTED;
18460 break;
18461 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18462 param->peer_reason = TDLS_SCAN_COMPLETED;
18463 break;
18464
18465 default:
18466 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18467 __func__, evt->peer_reason, evt->peer_status);
18468 return QDF_STATUS_E_INVAL;
18469 };
18470
18471 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18472 __func__, param->peermac.bytes, param->message_type,
18473 param->peer_reason, param->vdev_id);
18474
18475 return QDF_STATUS_SUCCESS;
18476}
18477#endif
18478
Govind Singhe7f2f342016-05-23 12:12:52 +053018479/**
18480 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18481 * @wmi_handle: wmi handle
18482 * @param evt_buf: pointer to event buffer
18483 * @param param: Pointer to hold MGMT TX completion params
18484 *
18485 * Return: QDF_STATUS_SUCCESS for success or error code
18486 */
18487static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18488 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18489{
18490 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18491 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18492
18493 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18494 evt_buf;
18495 if (!param_buf) {
18496 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18497 return QDF_STATUS_E_INVAL;
18498 }
18499 cmpl_params = param_buf->fixed_param;
18500
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018501 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18502 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018503 param->desc_id = cmpl_params->desc_id;
18504 param->status = cmpl_params->status;
18505
18506 return QDF_STATUS_SUCCESS;
18507}
18508
18509/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018510 * extract_offchan_data_tx_compl_param_tlv() -
18511 * extract Offchan data tx completion event params
18512 * @wmi_handle: wmi handle
18513 * @param evt_buf: pointer to event buffer
18514 * @param param: Pointer to hold offchan data TX completion params
18515 *
18516 * Return: QDF_STATUS_SUCCESS for success or error code
18517 */
18518static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18519 wmi_unified_t wmi_handle, void *evt_buf,
18520 struct wmi_host_offchan_data_tx_compl_event *param)
18521{
18522 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18523 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18524
18525 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18526 evt_buf;
18527 if (!param_buf) {
18528 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18529 return QDF_STATUS_E_INVAL;
18530 }
18531 cmpl_params = param_buf->fixed_param;
18532
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018533 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18534 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018535 param->desc_id = cmpl_params->desc_id;
18536 param->status = cmpl_params->status;
18537
18538 return QDF_STATUS_SUCCESS;
18539}
18540
18541/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018542 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18543 * status tlv
18544 * @wmi_handle: wmi handle
18545 * @param evt_buf: pointer to event buffer
18546 * @param param: Pointer to hold csa switch count status event param
18547 *
18548 * Return: QDF_STATUS_SUCCESS for success or error code
18549 */
18550static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18551 wmi_unified_t wmi_handle,
18552 void *evt_buf,
18553 struct pdev_csa_switch_count_status *param)
18554{
18555 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18556 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18557
18558 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18559 evt_buf;
18560 if (!param_buf) {
18561 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18562 return QDF_STATUS_E_INVAL;
18563 }
18564
18565 csa_status = param_buf->fixed_param;
18566
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018567 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18568 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018569 param->current_switch_count = csa_status->current_switch_count;
18570 param->num_vdevs = csa_status->num_vdevs;
18571 param->vdev_ids = param_buf->vdev_ids;
18572
18573 return QDF_STATUS_SUCCESS;
18574}
18575
18576/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018577 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018578 * @wmi_handle: wmi handle
18579 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018580 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018581 *
18582 * Return: QDF_STATUS_SUCCESS for success or error code
18583 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018584static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18585 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018586{
18587 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18588 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018589 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018590
18591 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18592 if (!param_buf) {
18593 WMI_LOGE("Invalid swba event buffer");
18594 return QDF_STATUS_E_INVAL;
18595 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018596
Govind Singhe7f2f342016-05-23 12:12:52 +053018597 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018598 *num_vdevs = swba_event->num_vdevs;
18599 if (!(*num_vdevs)) {
18600 vdev_map = swba_event->vdev_map;
18601 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18602 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018603
18604 return QDF_STATUS_SUCCESS;
18605}
18606
18607/**
18608 * extract_swba_tim_info_tlv() - extract swba tim info from event
18609 * @wmi_handle: wmi handle
18610 * @param evt_buf: pointer to event buffer
18611 * @param idx: Index to bcn info
18612 * @param tim_info: Pointer to hold tim info
18613 *
18614 * Return: QDF_STATUS_SUCCESS for success or error code
18615 */
18616static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18617 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18618{
18619 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18620 wmi_tim_info *tim_info_ev;
18621
18622 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18623 if (!param_buf) {
18624 WMI_LOGE("Invalid swba event buffer");
18625 return QDF_STATUS_E_INVAL;
18626 }
18627
18628 tim_info_ev = &param_buf->tim_info[idx];
18629
18630 tim_info->tim_len = tim_info_ev->tim_len;
18631 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18632 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18633 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18634 tim_info->tim_changed = tim_info_ev->tim_changed;
18635 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018636 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018637
18638 return QDF_STATUS_SUCCESS;
18639}
18640
18641/**
18642 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18643 * @wmi_handle: wmi handle
18644 * @param evt_buf: pointer to event buffer
18645 * @param idx: Index to bcn info
18646 * @param p2p_desc: Pointer to hold p2p NoA info
18647 *
18648 * Return: QDF_STATUS_SUCCESS for success or error code
18649 */
18650static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18651 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18652{
18653 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18654 wmi_p2p_noa_info *p2p_noa_info;
18655 uint8_t i = 0;
18656
18657 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18658 if (!param_buf) {
18659 WMI_LOGE("Invalid swba event buffer");
18660 return QDF_STATUS_E_INVAL;
18661 }
18662
18663 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18664
18665 p2p_desc->modified = false;
18666 p2p_desc->num_descriptors = 0;
18667 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18668 p2p_desc->modified = true;
18669 p2p_desc->index =
18670 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18671 p2p_desc->oppPS =
18672 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18673 p2p_desc->ctwindow =
18674 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18675 p2p_desc->num_descriptors =
18676 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18677 (p2p_noa_info);
18678 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18679 p2p_desc->noa_descriptors[i].type_count =
18680 (uint8_t) p2p_noa_info->noa_descriptors[i].
18681 type_count;
18682 p2p_desc->noa_descriptors[i].duration =
18683 p2p_noa_info->noa_descriptors[i].duration;
18684 p2p_desc->noa_descriptors[i].interval =
18685 p2p_noa_info->noa_descriptors[i].interval;
18686 p2p_desc->noa_descriptors[i].start_time =
18687 p2p_noa_info->noa_descriptors[i].start_time;
18688 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018689 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018690 }
18691
18692 return QDF_STATUS_SUCCESS;
18693}
18694
Wu Gaocd3a8512017-03-13 20:17:34 +080018695#ifdef CONVERGED_P2P_ENABLE
18696/**
18697 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18698 * @wmi_handle: wmi handle
18699 * @param evt_buf: pointer to event buffer
18700 * @param param: Pointer to hold p2p noa info
18701 *
18702 * Return: QDF_STATUS_SUCCESS for success or error code
18703 */
18704static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18705 wmi_unified_t wmi_handle, void *evt_buf,
18706 struct p2p_noa_info *param)
18707{
18708 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18709 wmi_p2p_noa_event_fixed_param *fixed_param;
18710 uint8_t i;
18711 wmi_p2p_noa_info *wmi_noa_info;
18712 uint8_t *buf_ptr;
18713 uint32_t descriptors;
18714
18715 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18716 if (!param_tlvs) {
18717 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18718 return QDF_STATUS_E_INVAL;
18719 }
18720
18721 if (!param) {
18722 WMI_LOGE("noa information param is null");
18723 return QDF_STATUS_E_INVAL;
18724 }
18725
18726 fixed_param = param_tlvs->fixed_param;
18727 buf_ptr = (uint8_t *) fixed_param;
18728 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18729 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18730
18731 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18732 WMI_LOGE("%s: noa attr is not modified", __func__);
18733 return QDF_STATUS_E_INVAL;
18734 }
18735
18736 param->vdev_id = fixed_param->vdev_id;
18737 param->index =
18738 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18739 param->opps_ps =
18740 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18741 param->ct_window =
18742 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18743 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18744 param->num_desc = (uint8_t) descriptors;
18745
18746 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18747 param->index, param->opps_ps, param->ct_window,
18748 param->num_desc);
18749 for (i = 0; i < param->num_desc; i++) {
18750 param->noa_desc[i].type_count =
18751 (uint8_t) wmi_noa_info->noa_descriptors[i].
18752 type_count;
18753 param->noa_desc[i].duration =
18754 wmi_noa_info->noa_descriptors[i].duration;
18755 param->noa_desc[i].interval =
18756 wmi_noa_info->noa_descriptors[i].interval;
18757 param->noa_desc[i].start_time =
18758 wmi_noa_info->noa_descriptors[i].start_time;
18759 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18760 __func__, i, param->noa_desc[i].type_count,
18761 param->noa_desc[i].duration,
18762 param->noa_desc[i].interval,
18763 param->noa_desc[i].start_time);
18764 }
18765
18766 return QDF_STATUS_SUCCESS;
18767}
18768
18769/**
18770 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18771 * information from event
18772 * @wmi_handle: wmi handle
18773 * @param evt_buf: pointer to event buffer
18774 * @param param: Pointer to hold p2p lo stop event information
18775 *
18776 * Return: QDF_STATUS_SUCCESS for success or error code
18777 */
18778static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18779 wmi_unified_t wmi_handle, void *evt_buf,
18780 struct p2p_lo_event *param)
18781{
18782 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18783 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18784
18785 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18786 evt_buf;
18787 if (!param_tlvs) {
18788 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18789 return QDF_STATUS_E_INVAL;
18790 }
18791
18792 if (!param) {
18793 WMI_LOGE("lo stop event param is null");
18794 return QDF_STATUS_E_INVAL;
18795 }
18796
18797 lo_param = param_tlvs->fixed_param;
18798 param->vdev_id = lo_param->vdev_id;
18799 param->reason_code = lo_param->reason;
18800 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18801 param->vdev_id, param->reason_code);
18802
18803 return QDF_STATUS_SUCCESS;
18804}
18805#endif /* End of CONVERGED_P2P_ENABLE */
18806
Govind Singhe7f2f342016-05-23 12:12:52 +053018807/**
18808 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18809 * @wmi_handle: wmi handle
18810 * @param evt_buf: pointer to event buffer
18811 * @param ev: Pointer to hold peer param
18812 *
18813 * Return: QDF_STATUS_SUCCESS for success or error code
18814 */
18815static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18816 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18817{
18818 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18819 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18820
18821 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18822 kickout_event = param_buf->fixed_param;
18823
18824 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18825 ev->peer_macaddr);
18826
18827 ev->reason = kickout_event->reason;
18828 ev->rssi = kickout_event->rssi;
18829
18830 return QDF_STATUS_SUCCESS;
18831}
18832
18833/**
18834 * extract_all_stats_counts_tlv() - extract all stats count from event
18835 * @wmi_handle: wmi handle
18836 * @param evt_buf: pointer to event buffer
18837 * @param stats_param: Pointer to hold stats count
18838 *
18839 * Return: QDF_STATUS_SUCCESS for success or error code
18840 */
18841static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18842 void *evt_buf, wmi_host_stats_event *stats_param)
18843{
18844 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18845 wmi_stats_event_fixed_param *ev;
18846
18847 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18848
18849 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18850 if (!ev) {
18851 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
18852 return QDF_STATUS_E_FAILURE;
18853 }
18854
18855 switch (ev->stats_id) {
18856 case WMI_REQUEST_PEER_STAT:
18857 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18858 break;
18859
18860 case WMI_REQUEST_AP_STAT:
18861 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18862 break;
18863
18864 case WMI_REQUEST_PDEV_STAT:
18865 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18866 break;
18867
18868 case WMI_REQUEST_VDEV_STAT:
18869 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18870 break;
18871
18872 case WMI_REQUEST_BCNFLT_STAT:
18873 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18874 break;
18875
18876 case WMI_REQUEST_VDEV_RATE_STAT:
18877 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18878 break;
18879
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018880 case WMI_REQUEST_BCN_STAT:
18881 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18882 break;
18883
Govind Singhe7f2f342016-05-23 12:12:52 +053018884 default:
18885 stats_param->stats_id = 0;
18886 break;
18887
18888 }
18889
18890 stats_param->num_pdev_stats = ev->num_pdev_stats;
18891 stats_param->num_pdev_ext_stats = 0;
18892 stats_param->num_vdev_stats = ev->num_vdev_stats;
18893 stats_param->num_peer_stats = ev->num_peer_stats;
18894 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18895 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018896 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018897 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18898 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018899
18900 return QDF_STATUS_SUCCESS;
18901}
18902
18903/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018904 * extract_pdev_tx_stats() - extract pdev tx stats from event
18905 */
18906static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18907{
18908 /* Tx Stats */
18909 tx->comp_queued = tx_stats->comp_queued;
18910 tx->comp_delivered = tx_stats->comp_delivered;
18911 tx->msdu_enqued = tx_stats->msdu_enqued;
18912 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18913 tx->wmm_drop = tx_stats->wmm_drop;
18914 tx->local_enqued = tx_stats->local_enqued;
18915 tx->local_freed = tx_stats->local_freed;
18916 tx->hw_queued = tx_stats->hw_queued;
18917 tx->hw_reaped = tx_stats->hw_reaped;
18918 tx->underrun = tx_stats->underrun;
18919 tx->tx_abort = tx_stats->tx_abort;
18920 tx->mpdus_requed = tx_stats->mpdus_requed;
18921 tx->data_rc = tx_stats->data_rc;
18922 tx->self_triggers = tx_stats->self_triggers;
18923 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18924 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18925 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18926 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18927 tx->pdev_resets = tx_stats->pdev_resets;
18928 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18929 tx->phy_underrun = tx_stats->phy_underrun;
18930 tx->txop_ovf = tx_stats->txop_ovf;
18931
18932 return;
18933}
18934
18935
18936/**
18937 * extract_pdev_rx_stats() - extract pdev rx stats from event
18938 */
18939static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18940{
18941 /* Rx Stats */
18942 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18943 rx->status_rcvd = rx_stats->status_rcvd;
18944 rx->r0_frags = rx_stats->r0_frags;
18945 rx->r1_frags = rx_stats->r1_frags;
18946 rx->r2_frags = rx_stats->r2_frags;
18947 /* Only TLV */
18948 rx->r3_frags = 0;
18949 rx->htt_msdus = rx_stats->htt_msdus;
18950 rx->htt_mpdus = rx_stats->htt_mpdus;
18951 rx->loc_msdus = rx_stats->loc_msdus;
18952 rx->loc_mpdus = rx_stats->loc_mpdus;
18953 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18954 rx->phy_errs = rx_stats->phy_errs;
18955 rx->phy_err_drop = rx_stats->phy_err_drop;
18956 rx->mpdu_errs = rx_stats->mpdu_errs;
18957
18958 return;
18959}
18960
18961/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018962 * extract_pdev_stats_tlv() - extract pdev stats from event
18963 * @wmi_handle: wmi handle
18964 * @param evt_buf: pointer to event buffer
18965 * @param index: Index into pdev stats
18966 * @param pdev_stats: Pointer to hold pdev stats
18967 *
18968 * Return: QDF_STATUS_SUCCESS for success or error code
18969 */
18970static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18971 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18972{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018973 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18974 wmi_stats_event_fixed_param *ev_param;
18975 uint8_t *data;
18976
18977 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18978 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18979
18980 data = param_buf->data;
18981
18982 if (index < ev_param->num_pdev_stats) {
18983 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18984 (index * sizeof(wmi_pdev_stats)));
18985
18986 pdev_stats->chan_nf = ev->chan_nf;
18987 pdev_stats->tx_frame_count = ev->tx_frame_count;
18988 pdev_stats->rx_frame_count = ev->rx_frame_count;
18989 pdev_stats->rx_clear_count = ev->rx_clear_count;
18990 pdev_stats->cycle_count = ev->cycle_count;
18991 pdev_stats->phy_err_count = ev->phy_err_count;
18992 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
18993
18994 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
18995 &(ev->pdev_stats.tx));
18996 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
18997 &(ev->pdev_stats.rx));
18998 }
18999
Govind Singhe7f2f342016-05-23 12:12:52 +053019000 return QDF_STATUS_SUCCESS;
19001}
19002
19003/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070019004 * extract_unit_test_tlv() - extract unit test data
19005 * @wmi_handle: wmi handle
19006 * @param evt_buf: pointer to event buffer
19007 * @param unit_test: pointer to hold unit test data
19008 * @param maxspace: Amount of space in evt_buf
19009 *
19010 * Return: QDF_STATUS_SUCCESS for success or error code
19011 */
19012static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
19013 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
19014{
19015 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
19016 wmi_unit_test_event_fixed_param *ev_param;
19017 uint32_t num_bufp;
19018 uint32_t copy_size;
19019 uint8_t *bufp;
19020
19021 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
19022 ev_param = param_buf->fixed_param;
19023 bufp = param_buf->bufp;
19024 num_bufp = param_buf->num_bufp;
19025 unit_test->vdev_id = ev_param->vdev_id;
19026 unit_test->module_id = ev_param->module_id;
19027 unit_test->diag_token = ev_param->diag_token;
19028 unit_test->flag = ev_param->flag;
19029 unit_test->payload_len = ev_param->payload_len;
19030 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
19031 ev_param->vdev_id,
19032 ev_param->module_id,
19033 ev_param->diag_token,
19034 ev_param->flag);
19035 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
19036 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
19037 bufp, num_bufp);
19038 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
19039 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
19040 unit_test->buffer_len = copy_size;
19041
19042 return QDF_STATUS_SUCCESS;
19043}
19044
19045/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019046 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
19047 * @wmi_handle: wmi handle
19048 * @param evt_buf: pointer to event buffer
19049 * @param index: Index into extended pdev stats
19050 * @param pdev_ext_stats: Pointer to hold extended pdev stats
19051 *
19052 * Return: QDF_STATUS_SUCCESS for success or error code
19053 */
19054static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
19055 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
19056{
19057 return QDF_STATUS_SUCCESS;
19058}
19059
19060/**
19061 * extract_vdev_stats_tlv() - extract vdev stats from event
19062 * @wmi_handle: wmi handle
19063 * @param evt_buf: pointer to event buffer
19064 * @param index: Index into vdev stats
19065 * @param vdev_stats: Pointer to hold vdev stats
19066 *
19067 * Return: QDF_STATUS_SUCCESS for success or error code
19068 */
19069static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
19070 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
19071{
19072 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19073 wmi_stats_event_fixed_param *ev_param;
19074 uint8_t *data;
19075
19076 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19077 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19078 data = (uint8_t *) param_buf->data;
19079
19080 if (index < ev_param->num_vdev_stats) {
19081 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
19082 ((ev_param->num_pdev_stats) *
19083 sizeof(wmi_pdev_stats)) +
19084 (index * sizeof(wmi_vdev_stats)));
19085
19086 vdev_stats->vdev_id = ev->vdev_id;
19087 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
19088 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
19089
19090 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
19091 sizeof(ev->tx_frm_cnt));
19092 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
19093 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
19094 ev->multiple_retry_cnt,
19095 sizeof(ev->multiple_retry_cnt));
19096 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
19097 sizeof(ev->fail_cnt));
19098 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
19099 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
19100 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
19101 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
19102 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
19103 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
19104 sizeof(ev->tx_rate_history));
19105 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
19106 sizeof(ev->bcn_rssi_history));
19107
19108 }
19109
19110 return QDF_STATUS_SUCCESS;
19111}
19112
19113/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019114 * extract_bcn_stats_tlv() - extract bcn stats from event
19115 * @wmi_handle: wmi handle
19116 * @param evt_buf: pointer to event buffer
19117 * @param index: Index into vdev stats
19118 * @param bcn_stats: Pointer to hold bcn stats
19119 *
19120 * Return: QDF_STATUS_SUCCESS for success or error code
19121 */
19122static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
19123 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
19124{
19125 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19126 wmi_stats_event_fixed_param *ev_param;
19127 uint8_t *data;
19128
19129 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19130 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19131 data = (uint8_t *) param_buf->data;
19132
19133 if (index < ev_param->num_bcn_stats) {
19134 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
19135 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19136 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19137 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19138 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
19139 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
19140 (index * sizeof(wmi_bcn_stats)));
19141
19142 bcn_stats->vdev_id = ev->vdev_id;
19143 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
19144 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
19145 }
19146
19147 return QDF_STATUS_SUCCESS;
19148}
19149
19150/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019151 * extract_peer_stats_tlv() - extract peer stats from event
19152 * @wmi_handle: wmi handle
19153 * @param evt_buf: pointer to event buffer
19154 * @param index: Index into peer stats
19155 * @param peer_stats: Pointer to hold peer stats
19156 *
19157 * Return: QDF_STATUS_SUCCESS for success or error code
19158 */
19159static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19160 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19161{
19162 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19163 wmi_stats_event_fixed_param *ev_param;
19164 uint8_t *data;
19165
19166 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19167 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19168 data = (uint8_t *) param_buf->data;
19169
19170 if (index < ev_param->num_peer_stats) {
19171 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19172 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19173 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19174 (index * sizeof(wmi_peer_stats)));
19175
19176 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19177
19178 OS_MEMCPY(&(peer_stats->peer_macaddr),
19179 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19180
19181 peer_stats->peer_rssi = ev->peer_rssi;
19182 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19183 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19184 }
19185
19186 return QDF_STATUS_SUCCESS;
19187}
19188
19189/**
19190 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19191 * @wmi_handle: wmi handle
19192 * @param evt_buf: pointer to event buffer
19193 * @param index: Index into bcn fault stats
19194 * @param bcnflt_stats: Pointer to hold bcn fault stats
19195 *
19196 * Return: QDF_STATUS_SUCCESS for success or error code
19197 */
19198static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19199 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19200{
19201 return QDF_STATUS_SUCCESS;
19202}
19203
19204/**
19205 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19206 * @wmi_handle: wmi handle
19207 * @param evt_buf: pointer to event buffer
19208 * @param index: Index into extended peer stats
19209 * @param peer_extd_stats: Pointer to hold extended peer stats
19210 *
19211 * Return: QDF_STATUS_SUCCESS for success or error code
19212 */
19213static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19214 void *evt_buf, uint32_t index,
19215 wmi_host_peer_extd_stats *peer_extd_stats)
19216{
19217 return QDF_STATUS_SUCCESS;
19218}
19219
19220/**
19221 * extract_chan_stats_tlv() - extract chan stats from event
19222 * @wmi_handle: wmi handle
19223 * @param evt_buf: pointer to event buffer
19224 * @param index: Index into chan stats
19225 * @param vdev_extd_stats: Pointer to hold chan stats
19226 *
19227 * Return: QDF_STATUS_SUCCESS for success or error code
19228 */
19229static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19230 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19231{
19232 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19233 wmi_stats_event_fixed_param *ev_param;
19234 uint8_t *data;
19235
19236 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19237 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19238 data = (uint8_t *) param_buf->data;
19239
19240 if (index < ev_param->num_chan_stats) {
19241 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19242 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19243 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19244 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19245 (index * sizeof(wmi_chan_stats)));
19246
19247
19248 /* Non-TLV doesnt have num_chan_stats */
19249 chan_stats->chan_mhz = ev->chan_mhz;
19250 chan_stats->sampling_period_us = ev->sampling_period_us;
19251 chan_stats->rx_clear_count = ev->rx_clear_count;
19252 chan_stats->tx_duration_us = ev->tx_duration_us;
19253 chan_stats->rx_duration_us = ev->rx_duration_us;
19254 }
19255
19256 return QDF_STATUS_SUCCESS;
19257}
19258
19259/**
19260 * extract_profile_ctx_tlv() - extract profile context from event
19261 * @wmi_handle: wmi handle
19262 * @param evt_buf: pointer to event buffer
19263 * @idx: profile stats index to extract
19264 * @param profile_ctx: Pointer to hold profile context
19265 *
19266 * Return: QDF_STATUS_SUCCESS for success or error code
19267 */
19268static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19269 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19270{
19271 return QDF_STATUS_SUCCESS;
19272}
19273
19274/**
19275 * extract_profile_data_tlv() - extract profile data from event
19276 * @wmi_handle: wmi handle
19277 * @param evt_buf: pointer to event buffer
19278 * @param profile_data: Pointer to hold profile data
19279 *
19280 * Return: QDF_STATUS_SUCCESS for success or error code
19281 */
19282static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19283 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19284{
19285
19286 return QDF_STATUS_SUCCESS;
19287}
19288
19289/**
19290 * extract_chan_info_event_tlv() - extract chan information from event
19291 * @wmi_handle: wmi handle
19292 * @param evt_buf: pointer to event buffer
19293 * @param chan_info: Pointer to hold chan information
19294 *
19295 * Return: QDF_STATUS_SUCCESS for success or error code
19296 */
19297static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19298 void *evt_buf, wmi_host_chan_info_event *chan_info)
19299{
19300 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19301 wmi_chan_info_event_fixed_param *ev;
19302
19303 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19304
19305 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19306 if (!ev) {
19307 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19308 return QDF_STATUS_E_FAILURE;
19309 }
19310
19311 chan_info->err_code = ev->err_code;
19312 chan_info->freq = ev->freq;
19313 chan_info->cmd_flags = ev->cmd_flags;
19314 chan_info->noise_floor = ev->noise_floor;
19315 chan_info->rx_clear_count = ev->rx_clear_count;
19316 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019317 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19318 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019319 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19320 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19321 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019322 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19323 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19324 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19325 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19326 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19327 chan_info->rx_frame_count = ev->rx_frame_count;
19328 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19329 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019330
19331 return QDF_STATUS_SUCCESS;
19332}
19333
19334/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019335 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19336 * @wmi_handle: WMI handle
19337 * @param evt_buf: Pointer to event buffer
19338 * @param param: Pointer to hold data
19339 *
19340 * Return : QDF_STATUS_SUCCESS for success or error code
19341 */
19342static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19343 uint8_t *evt_buf,
19344 struct wmi_host_pdev_utf_event *event)
19345{
19346 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019347 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019348
19349 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19350 event->data = param_buf->data;
19351 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019352 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019353 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019354 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019355 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019356
19357 return QDF_STATUS_SUCCESS;
19358}
Govind Singhe7f2f342016-05-23 12:12:52 +053019359
Kiran Venkatappa06520822016-08-10 23:55:40 +053019360/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019361 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19362 * @wmi_handle: wmi handle
19363 * @param evt_buf: pointer to event buffer
19364 * @param param: Pointer to hold evt buf
19365 *
19366 * Return: QDF_STATUS_SUCCESS for success or error code
19367 */
19368static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19369 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19370{
19371 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19372 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19373 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19374 uint8_t i = 0, j = 0;
19375
19376 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19377 if (!param_buf)
19378 return QDF_STATUS_E_INVAL;
19379
19380 hw_caps = param_buf->soc_hw_mode_caps;
19381 if (!hw_caps)
19382 return QDF_STATUS_E_INVAL;
19383
19384 if (!hw_caps->num_chainmask_tables)
19385 return QDF_STATUS_E_INVAL;
19386
19387 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19388
19389 if (chainmask_caps == NULL)
19390 return QDF_STATUS_E_INVAL;
19391
19392 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19393
19394 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19395 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19396
19397 chainmask_table[i].cap_list[j].chainmask =
19398 chainmask_caps->chainmask;
19399
19400 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19401 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19402
19403 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19404 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19405
19406 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19407 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19408
19409 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19410 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19411
19412 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19413 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19414
19415 chainmask_table[i].cap_list[j].chain_mask_2G =
19416 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19417
19418 chainmask_table[i].cap_list[j].chain_mask_5G =
19419 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19420
19421 chainmask_table[i].cap_list[j].chain_mask_tx =
19422 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19423
19424 chainmask_table[i].cap_list[j].chain_mask_rx =
19425 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19426
19427 chainmask_table[i].cap_list[j].supports_aDFS =
19428 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19429
19430 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19431 chainmask_caps->supported_flags,
19432 chainmask_caps->chainmask
19433 );
19434 chainmask_caps++;
19435 }
19436 }
19437
19438 return QDF_STATUS_SUCCESS;
19439}
19440
19441/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019442 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19443 * from event
19444 * @wmi_handle: wmi handle
19445 * @param evt_buf: pointer to event buffer
19446 * @param param: Pointer to hold evt buf
19447 *
19448 * Return: QDF_STATUS_SUCCESS for success or error code
19449 */
19450static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019451 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019452{
19453 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19454 wmi_service_ready_ext_event_fixed_param *ev;
19455 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19456 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019457 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19458 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019459
19460 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19461 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019462 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019463
19464 ev = param_buf->fixed_param;
19465 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019466 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019467
19468 /* Move this to host based bitmap */
19469 param->default_conc_scan_config_bits =
19470 ev->default_conc_scan_config_bits;
19471 param->default_fw_config_bits = ev->default_fw_config_bits;
19472 param->he_cap_info = ev->he_cap_info;
19473 param->mpdu_density = ev->mpdu_density;
19474 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019475 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019476 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019477 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19478
19479 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019480 if (hw_caps)
19481 param->num_hw_modes = hw_caps->num_hw_modes;
19482 else
19483 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019484
19485 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019486 if (reg_caps)
19487 param->num_phy = reg_caps->num_phy;
19488 else
19489 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019490
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019491 if (hw_caps) {
19492 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19493 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19494 } else
19495 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019496
19497 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19498
19499 if (chain_mask_combo == NULL)
19500 return QDF_STATUS_SUCCESS;
19501
19502 qdf_print("Dumping chain mask combo data\n");
19503
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019504 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019505
19506 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19507 chain_mask_combo->chainmask_table_id,
19508 chain_mask_combo->num_valid_chainmask
19509 );
19510
19511 param->chainmask_table[i].table_id =
19512 chain_mask_combo->chainmask_table_id;
19513 param->chainmask_table[i].num_valid_chainmasks =
19514 chain_mask_combo->num_valid_chainmask;
19515 chain_mask_combo++;
19516 }
19517 qdf_print("chain mask combo end\n");
19518
Kiran Venkatappa06520822016-08-10 23:55:40 +053019519 return QDF_STATUS_SUCCESS;
19520}
19521
19522/**
19523 * extract_hw_mode_cap_service_ready_ext_tlv() -
19524 * extract HW mode cap from service ready event
19525 * @wmi_handle: wmi handle
19526 * @param evt_buf: pointer to event buffer
19527 * @param param: Pointer to hold evt buf
19528 * @param hw_mode_idx: hw mode idx should be less than num_mode
19529 *
19530 * Return: QDF_STATUS_SUCCESS for success or error code
19531 */
19532static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19533 wmi_unified_t wmi_handle,
19534 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019535 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019536{
19537 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19538 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19539
19540 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19541 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019542 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019543
19544 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019545 if (!hw_caps)
19546 return QDF_STATUS_E_INVAL;
19547
Kiran Venkatappa06520822016-08-10 23:55:40 +053019548 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019549 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019550
19551 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19552 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19553
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019554 param->hw_mode_config_type =
19555 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19556
Kiran Venkatappa06520822016-08-10 23:55:40 +053019557 return QDF_STATUS_SUCCESS;
19558}
19559
19560/**
19561 * extract_mac_phy_cap_service_ready_ext_tlv() -
19562 * extract MAC phy cap from service ready event
19563 * @wmi_handle: wmi handle
19564 * @param evt_buf: pointer to event buffer
19565 * @param param: Pointer to hold evt buf
19566 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019567 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019568 *
19569 * Return: QDF_STATUS_SUCCESS for success or error code
19570 */
19571static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19572 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019573 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019574 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019575{
19576 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019577 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019578 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19579 uint32_t phy_map;
19580 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019581
19582 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19583 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019584 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019585
19586 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019587 if (!hw_caps)
19588 return QDF_STATUS_E_INVAL;
19589
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019590 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19591 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19592 break;
19593
19594 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19595 while (phy_map) {
19596 phy_map >>= 1;
19597 phy_idx++;
19598 }
19599 }
19600
19601 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019602 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019603
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019604 phy_idx += phy_id;
19605 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019606 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019607
19608 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019609
19610 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019611 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19612 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019613 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019614 param->supports_11b =
19615 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19616 param->supports_11g =
19617 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19618 param->supports_11a =
19619 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19620 param->supports_11n =
19621 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19622 param->supports_11ac =
19623 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19624 param->supports_11ax =
19625 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019626
19627 param->supported_bands = mac_phy_caps->supported_bands;
19628 param->ampdu_density = mac_phy_caps->ampdu_density;
19629 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19630 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19631 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19632 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19633 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19634 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19635 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19636 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19637 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19638 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19639 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19640 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19641 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19642 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19643 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19644 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019645 qdf_mem_copy(&param->he_cap_phy_info_2G,
19646 &mac_phy_caps->he_cap_phy_info_2G,
19647 sizeof(param->he_cap_phy_info_2G));
19648 qdf_mem_copy(&param->he_cap_phy_info_5G,
19649 &mac_phy_caps->he_cap_phy_info_5G,
19650 sizeof(param->he_cap_phy_info_5G));
19651 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19652 sizeof(param->he_ppet2G));
19653 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19654 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019655 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019656
19657 return QDF_STATUS_SUCCESS;
19658}
19659
19660/**
19661 * extract_reg_cap_service_ready_ext_tlv() -
19662 * extract REG cap from service ready event
19663 * @wmi_handle: wmi handle
19664 * @param evt_buf: pointer to event buffer
19665 * @param param: Pointer to hold evt buf
19666 * @param phy_idx: phy idx should be less than num_mode
19667 *
19668 * Return: QDF_STATUS_SUCCESS for success or error code
19669 */
19670static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19671 wmi_unified_t wmi_handle,
19672 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019673 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019674{
19675 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19676 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19677 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19678
19679 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19680 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019681 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019682
19683 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019684 if (!reg_caps)
19685 return QDF_STATUS_E_INVAL;
19686
Kiran Venkatappa06520822016-08-10 23:55:40 +053019687 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019688 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019689
19690 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19691
19692 param->phy_id = ext_reg_cap->phy_id;
19693 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19694 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19695 param->regcap1 = ext_reg_cap->regcap1;
19696 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019697 param->wireless_modes = convert_wireless_modes_tlv(
19698 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019699 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19700 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19701 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19702 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19703
19704 return QDF_STATUS_SUCCESS;
19705}
19706
Sathish Kumarf396c722017-11-17 17:30:41 +053019707static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19708 wmi_unified_t wmi_handle,
19709 uint8_t *event, uint8_t idx,
19710 struct wlan_psoc_host_dbr_ring_caps *param)
19711{
19712 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19713 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19714
19715 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19716 if (!param_buf)
19717 return QDF_STATUS_E_INVAL;
19718
19719 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19720
19721 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19722 dbr_ring_caps->pdev_id);
19723 param->mod_id = dbr_ring_caps->mod_id;
19724 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19725 param->min_buf_size = dbr_ring_caps->min_buf_size;
19726 param->min_buf_align = dbr_ring_caps->min_buf_align;
19727
19728 return QDF_STATUS_SUCCESS;
19729}
19730
19731static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19732 uint8_t *event, struct direct_buf_rx_rsp *param)
19733{
19734 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19735 wmi_dma_buf_release_fixed_param *ev;
19736
19737 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19738 if (!param_buf)
19739 return QDF_STATUS_E_INVAL;
19740
19741 ev = param_buf->fixed_param;
19742 if (!ev)
19743 return QDF_STATUS_E_INVAL;
19744
19745 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19746 ev->pdev_id);
19747 param->mod_id = ev->mod_id;
19748 param->num_buf_release_entry = ev->num_buf_release_entry;
19749 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19750 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19751
19752 return QDF_STATUS_SUCCESS;
19753}
19754
19755static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19756 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19757{
19758 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19759 wmi_dma_buf_release_entry *entry;
19760
19761 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19762 if (!param_buf)
19763 return QDF_STATUS_E_INVAL;
19764
19765 entry = &param_buf->entries[idx];
19766
19767 if (!entry) {
19768 WMI_LOGE("%s: Entry is NULL\n", __func__);
19769 return QDF_STATUS_E_FAILURE;
19770 }
19771
19772 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19773
19774 param->paddr_lo = entry->paddr_lo;
19775 param->paddr_hi = entry->paddr_hi;
19776
19777 return QDF_STATUS_SUCCESS;
19778}
19779
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019780/**
19781 * extract_dcs_interference_type_tlv() - extract dcs interference type
19782 * from event
19783 * @wmi_handle: wmi handle
19784 * @param evt_buf: pointer to event buffer
19785 * @param param: Pointer to hold dcs interference param
19786 *
19787 * Return: 0 for success or error code
19788 */
19789static QDF_STATUS extract_dcs_interference_type_tlv(
19790 wmi_unified_t wmi_handle,
19791 void *evt_buf, struct wmi_host_dcs_interference_param *param)
19792{
19793 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19794
19795 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19796 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019797 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019798
19799 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019800 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19801 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019802
19803 return QDF_STATUS_SUCCESS;
19804}
19805
19806/*
19807 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
19808 * @wmi_handle: wmi handle
19809 * @param evt_buf: pointer to event buffer
19810 * @param cw_int: Pointer to hold cw interference
19811 *
19812 * Return: 0 for success or error code
19813 */
19814static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
19815 void *evt_buf,
19816 wmi_host_ath_dcs_cw_int *cw_int)
19817{
19818 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19819 wlan_dcs_cw_int *ev;
19820
19821 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19822 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019823 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019824
19825 ev = param_buf->cw_int;
19826
19827 cw_int->channel = ev->channel;
19828
19829 return QDF_STATUS_SUCCESS;
19830}
19831
19832/**
19833 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
19834 * @wmi_handle: wmi handle
19835 * @param evt_buf: pointer to event buffer
19836 * @param wlan_stat: Pointer to hold wlan stats
19837 *
19838 * Return: 0 for success or error code
19839 */
19840static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
19841 void *evt_buf,
19842 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
19843{
19844 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19845 wlan_dcs_im_tgt_stats_t *ev;
19846
19847 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19848 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019849 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019850
19851 ev = param_buf->wlan_stat;
19852 wlan_stat->reg_tsf32 = ev->reg_tsf32;
19853 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
19854 wlan_stat->tx_waste_time = ev->tx_waste_time;
19855 wlan_stat->rx_time = ev->rx_time;
19856 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
19857 wlan_stat->mib_stats.listen_time = ev->listen_time;
19858 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
19859 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
19860 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
19861 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
19862 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
19863 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
19864 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
19865 wlan_stat->chan_nf = ev->chan_nf;
19866 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19867
19868 return QDF_STATUS_SUCCESS;
19869}
19870
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019871/**
19872 * extract_thermal_stats_tlv() - extract thermal stats from event
19873 * @wmi_handle: wmi handle
19874 * @param evt_buf: Pointer to event buffer
19875 * @param temp: Pointer to hold extracted temperature
19876 * @param level: Pointer to hold extracted level
19877 *
19878 * Return: 0 for success or error code
19879 */
19880static QDF_STATUS
19881extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
19882 void *evt_buf, uint32_t *temp,
19883 uint32_t *level, uint32_t *pdev_id)
19884{
19885 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19886 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
19887
19888 param_buf =
19889 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19890 if (!param_buf)
19891 return QDF_STATUS_E_INVAL;
19892
19893 tt_stats_event = param_buf->fixed_param;
19894
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019895 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19896 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019897 *temp = tt_stats_event->temp;
19898 *level = tt_stats_event->level;
19899
19900 return QDF_STATUS_SUCCESS;
19901}
19902
19903/**
19904 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19905 * @wmi_handle: wmi handle
19906 * @param evt_buf: pointer to event buffer
19907 * @param idx: Index to level stats
19908 * @param levelcount: Pointer to hold levelcount
19909 * @param dccount: Pointer to hold dccount
19910 *
19911 * Return: 0 for success or error code
19912 */
19913static QDF_STATUS
19914extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19915 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19916 uint32_t *dccount)
19917{
19918 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19919 wmi_therm_throt_level_stats_info *tt_level_info;
19920
19921 param_buf =
19922 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19923 if (!param_buf)
19924 return QDF_STATUS_E_INVAL;
19925
19926 tt_level_info = param_buf->therm_throt_level_stats_info;
19927
19928 if (idx < THERMAL_LEVELS) {
19929 *levelcount = tt_level_info[idx].level_count;
19930 *dccount = tt_level_info[idx].dc_count;
19931 return QDF_STATUS_SUCCESS;
19932 }
19933
19934 return QDF_STATUS_E_FAILURE;
19935}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019936#ifdef BIG_ENDIAN_HOST
19937/**
19938 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19939 * @param data_len - data length
19940 * @param data - pointer to data
19941 *
19942 * Return: QDF_STATUS - success or error status
19943 */
19944static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19945{
19946 uint8_t *data_aligned = NULL;
19947 int c;
19948 unsigned char *data_unaligned;
19949
19950 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19951 FIPS_ALIGN));
19952 /* Assigning unaligned space to copy the data */
19953 /* Checking if kmalloc does succesful allocation */
19954 if (data_unaligned == NULL)
19955 return QDF_STATUS_E_FAILURE;
19956
19957 /* Checking if space is alligned */
19958 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19959 /* align the data space */
19960 data_aligned =
19961 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19962 } else {
19963 data_aligned = (u_int8_t *)data_unaligned;
19964 }
19965
19966 /* memset and copy content from data to data aligned */
19967 OS_MEMSET(data_aligned, 0, data_len);
19968 OS_MEMCPY(data_aligned, data, data_len);
19969 /* Endianness to LE */
19970 for (c = 0; c < data_len/4; c++) {
19971 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019972 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019973 }
19974
19975 /* Copy content to event->data */
19976 OS_MEMCPY(data, data_aligned, data_len);
19977
19978 /* clean up allocated space */
19979 qdf_mem_free(data_unaligned);
19980 data_aligned = NULL;
19981 data_unaligned = NULL;
19982
19983 /*************************************************************/
19984
19985 return QDF_STATUS_SUCCESS;
19986}
19987#else
19988/**
19989 * fips_conv_data_be() - DUMMY for LE platform
19990 *
19991 * Return: QDF_STATUS - success
19992 */
19993static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19994{
19995 return QDF_STATUS_SUCCESS;
19996}
19997#endif
19998
19999/**
20000 * extract_fips_event_data_tlv() - extract fips event data
20001 * @wmi_handle: wmi handle
20002 * @param evt_buf: pointer to event buffer
20003 * @param param: pointer FIPS event params
20004 *
20005 * Return: 0 for success or error code
20006 */
20007static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
20008 void *evt_buf, struct wmi_host_fips_event_param *param)
20009{
20010 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
20011 wmi_pdev_fips_event_fixed_param *event;
20012
20013 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
20014 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
20015
20016 if (fips_conv_data_be(event->data_len, param_buf->data) !=
20017 QDF_STATUS_SUCCESS)
20018 return QDF_STATUS_E_FAILURE;
20019
20020 param->data = (uint32_t *)param_buf->data;
20021 param->data_len = event->data_len;
20022 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020023 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20024 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020025
20026 return QDF_STATUS_SUCCESS;
20027}
20028
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020029/*
20030 * extract_peer_delete_response_event_tlv() - extract peer delete response event
20031 * @wmi_handle: wmi handle
20032 * @param evt_buf: pointer to event buffer
20033 * @param vdev_id: Pointer to hold vdev_id
20034 * @param mac_addr: Pointer to hold peer mac address
20035 *
20036 * Return: QDF_STATUS_SUCCESS for success or error code
20037 */
20038static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
20039 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
20040{
20041 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
20042 wmi_peer_delete_resp_event_fixed_param *ev;
20043
20044 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
20045
20046 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
20047 if (!ev) {
20048 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
20049 return QDF_STATUS_E_FAILURE;
20050 }
20051
20052 param->vdev_id = ev->vdev_id;
20053 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
20054 &param->mac_address.bytes[0]);
20055
20056 return QDF_STATUS_SUCCESS;
20057}
20058
Govind Singhecf03cd2016-05-12 12:45:51 +053020059static bool is_management_record_tlv(uint32_t cmd_id)
20060{
jiad36c94d22018-01-22 15:37:03 +080020061 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
20062 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
20063 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053020064 return true;
jiad36c94d22018-01-22 15:37:03 +080020065 }
Govind Singhe7f2f342016-05-23 12:12:52 +053020066
Govind Singhecf03cd2016-05-12 12:45:51 +053020067 return false;
20068}
20069
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020070static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20071{
20072 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
20073
20074 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
20075
20076 switch (set_cmd->param_id) {
20077 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
20078 case WMI_VDEV_PARAM_DTIM_POLICY:
20079 return HTC_TX_PACKET_TAG_AUTO_PM;
20080 default:
20081 break;
20082 }
20083
20084 return 0;
20085}
20086
20087static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20088{
20089 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20090
20091 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20092
20093 switch (ps_cmd->param) {
20094 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20095 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20096 case WMI_STA_PS_ENABLE_QPOWER:
20097 return HTC_TX_PACKET_TAG_AUTO_PM;
20098 default:
20099 break;
20100 }
20101
20102 return 0;
20103}
20104
20105static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20106 uint32_t cmd_id)
20107{
20108 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20109 return 0;
20110
20111 switch (cmd_id) {
20112 case WMI_VDEV_SET_PARAM_CMDID:
20113 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20114 case WMI_STA_POWERSAVE_PARAM_CMDID:
20115 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20116 default:
20117 break;
20118 }
20119
20120 return 0;
20121}
20122
20123static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20124{
20125 uint16_t tag = 0;
20126
20127 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20128 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20129 __func__);
20130 return tag;
20131 }
20132
20133 if (wmi_handle->tag_crash_inject)
20134 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20135
20136 wmi_handle->tag_crash_inject = false;
20137 return tag;
20138}
20139
20140/**
20141 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20142 * @wmi_handle: WMI handle
20143 * @buf: WMI buffer
20144 * @cmd_id: WMI command Id
20145 *
20146 * Return htc_tx_tag
20147 */
20148static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20149 wmi_buf_t buf,
20150 uint32_t cmd_id)
20151{
20152 uint16_t htc_tx_tag = 0;
20153
20154 switch (cmd_id) {
20155 case WMI_WOW_ENABLE_CMDID:
20156 case WMI_PDEV_SUSPEND_CMDID:
20157 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20158 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20159 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20160 case WMI_PDEV_RESUME_CMDID:
20161 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20162 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20163#ifdef FEATURE_WLAN_D0WOW
20164 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20165#endif
20166 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20167 break;
20168 case WMI_FORCE_FW_HANG_CMDID:
20169 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20170 break;
20171 case WMI_VDEV_SET_PARAM_CMDID:
20172 case WMI_STA_POWERSAVE_PARAM_CMDID:
20173 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20174 default:
20175 break;
20176 }
20177
20178 return htc_tx_tag;
20179}
20180
Sathish Kumard3ab1002017-02-07 17:10:59 +053020181/**
20182 * extract_channel_hopping_event_tlv() - extract channel hopping param
20183 * from event
20184 * @wmi_handle: wmi handle
20185 * @param evt_buf: pointer to event buffer
20186 * @param ch_hopping: Pointer to hold channel hopping param
20187 *
20188 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20189 */
20190static QDF_STATUS extract_channel_hopping_event_tlv(
20191 wmi_unified_t wmi_handle, void *evt_buf,
20192 wmi_host_pdev_channel_hopping_event *ch_hopping)
20193{
20194 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20195 wmi_pdev_channel_hopping_event_fixed_param *event;
20196
20197 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20198 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20199 param_buf->fixed_param;
20200
20201 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20202 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020203 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20204 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020205
20206 return QDF_STATUS_SUCCESS;
20207}
20208
20209/**
20210 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20211 * @wmi_handle: wmi handle
20212 * @param evt_buf: pointer to event buffer
20213 * @param param: Pointer to hold tpc param
20214 *
20215 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20216 */
20217static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20218 void *evt_buf,
20219 wmi_host_pdev_tpc_event *param)
20220{
20221 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20222 wmi_pdev_tpc_event_fixed_param *event;
20223
20224 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20225 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20226
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020227 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20228 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020229 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20230
20231 return QDF_STATUS_SUCCESS;
20232}
20233
20234
20235#ifdef BIG_ENDIAN_HOST
20236/**
20237 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20238 * @param data_len - data length
20239 * @param data - pointer to data
20240 *
20241 * Return: QDF_STATUS - success or error status
20242 */
20243static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20244{
20245 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020246 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020247 /* Skip swapping the first word */
20248 datap += sizeof(uint32_t);
20249 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20250 i++, datap += sizeof(uint32_t)) {
20251 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20252 }
20253
20254 return QDF_STATUS_SUCCESS;
20255}
20256#else
20257/**
20258 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20259 * @param data_len - data length
20260 * @param data - pointer to data
20261 *
20262 * Return: QDF_STATUS - success or error status
20263 */
20264static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20265{
20266 return QDF_STATUS_SUCCESS;
20267}
20268#endif
20269
20270/**
20271 * extract_wds_addr_event_tlv() - extract wds address from event
20272 * @wmi_handle: wmi handle
20273 * @param evt_buf: pointer to event buffer
20274 * @param wds_ev: Pointer to hold wds address
20275 *
20276 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20277 */
20278static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20279 void *evt_buf,
20280 uint16_t len, wds_addr_event_t *wds_ev)
20281{
20282 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20283 wmi_wds_addr_event_fixed_param *ev;
20284 int i;
20285
20286 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20287 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20288
20289 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20290 return QDF_STATUS_E_FAILURE;
20291
20292 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20293 sizeof(wds_ev->event_type));
20294 for (i = 0; i < 4; i++) {
20295 wds_ev->peer_mac[i] =
20296 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20297 wds_ev->dest_mac[i] =
20298 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20299 }
20300 for (i = 0; i < 2; i++) {
20301 wds_ev->peer_mac[4+i] =
20302 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20303 wds_ev->dest_mac[4+i] =
20304 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20305 }
20306 return QDF_STATUS_SUCCESS;
20307}
20308
20309/**
20310 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20311 * from event
20312 * @wmi_handle: wmi handle
20313 * @param evt_buf: pointer to event buffer
20314 * @param ev: Pointer to hold peer param and ps state
20315 *
20316 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20317 */
20318static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20319 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20320{
20321 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20322 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20323
20324 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20325 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20326 param_buf->fixed_param;
20327
20328 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20329 ev->peer_ps_state = event->peer_ps_state;
20330
20331 return QDF_STATUS_SUCCESS;
20332}
20333
20334/**
20335 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20336 * @wmi_handle: wmi handle
20337 * @param evt_buf: pointer to event buffer
20338 * @param inst_rssi_resp: Pointer to hold inst rssi response
20339 *
20340 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20341 */
20342static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20343 wmi_unified_t wmi_handle, void *evt_buf,
20344 wmi_host_inst_stats_resp *inst_rssi_resp)
20345{
20346 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20347 wmi_inst_rssi_stats_resp_fixed_param *event;
20348
20349 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20350 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20351
20352 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20353 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20354 inst_rssi_resp->iRSSI = event->iRSSI;
20355
20356 return QDF_STATUS_SUCCESS;
20357}
20358
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020359static struct cur_reg_rule
20360*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20361 wmi_regulatory_rule_struct *wmi_reg_rule)
20362{
20363 struct cur_reg_rule *reg_rule_ptr;
20364 uint32_t count;
20365
20366 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20367
20368 if (NULL == reg_rule_ptr) {
20369 WMI_LOGE("memory allocation failure");
20370 return NULL;
20371 }
20372
20373 for (count = 0; count < num_reg_rules; count++) {
20374 reg_rule_ptr[count].start_freq =
20375 WMI_REG_RULE_START_FREQ_GET(
20376 wmi_reg_rule[count].freq_info);
20377 reg_rule_ptr[count].end_freq =
20378 WMI_REG_RULE_END_FREQ_GET(
20379 wmi_reg_rule[count].freq_info);
20380 reg_rule_ptr[count].max_bw =
20381 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020382 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020383 reg_rule_ptr[count].reg_power =
20384 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020385 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020386 reg_rule_ptr[count].ant_gain =
20387 WMI_REG_RULE_ANTENNA_GAIN_GET(
20388 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020389 reg_rule_ptr[count].flags =
20390 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020391 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020392 }
20393
20394 return reg_rule_ptr;
20395}
20396
20397static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20398 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20399 struct cur_regulatory_info *reg_info, uint32_t len)
20400{
20401 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20402 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20403 wmi_regulatory_rule_struct *wmi_reg_rule;
20404 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20405
20406 WMI_LOGD("processing regulatory channel list");
20407
20408 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20409 if (!param_buf) {
20410 WMI_LOGE("invalid channel list event buf");
20411 return QDF_STATUS_E_FAILURE;
20412 }
20413
20414 chan_list_event_hdr = param_buf->fixed_param;
20415
20416 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20417 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20418 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020419 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020420 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20421 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020422 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020423 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020424 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020425 reg_info->ctry_code = chan_list_event_hdr->country_id;
20426 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20427 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20428 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20429 else if (chan_list_event_hdr->status_code ==
20430 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20431 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20432 else if (chan_list_event_hdr->status_code ==
20433 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20434 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20435 else if (chan_list_event_hdr->status_code ==
20436 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20437 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20438 else if (chan_list_event_hdr->status_code ==
20439 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20440 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20441 else if (chan_list_event_hdr->status_code ==
20442 WMI_REG_SET_CC_STATUS_FAIL)
20443 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20444
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020445 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20446 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20447 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20448 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20449
20450 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20451 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20452
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020453 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20454 __func__, reg_info->alpha2, reg_info->dfs_region,
20455 reg_info->min_bw_2g, reg_info->max_bw_2g,
20456 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020457
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020458 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20459 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020460 wmi_reg_rule =
20461 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20462 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20463 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020464 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20465 wmi_reg_rule);
20466 wmi_reg_rule += num_2g_reg_rules;
20467
20468 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20469 wmi_reg_rule);
20470
20471 WMI_LOGD("processed regulatory channel list");
20472
20473 return QDF_STATUS_SUCCESS;
20474}
20475
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020476static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20477 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20478 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20479{
20480 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20481 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20482
20483 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20484 if (!param_buf) {
20485 WMI_LOGE("invalid 11d country event buf");
20486 return QDF_STATUS_E_FAILURE;
20487 }
20488
20489 reg_11d_country_event = param_buf->fixed_param;
20490
20491 qdf_mem_copy(reg_11d_country->alpha2,
20492 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20493
20494 WMI_LOGD("processed 11d country event, new cc %s",
20495 reg_11d_country->alpha2);
20496
20497 return QDF_STATUS_SUCCESS;
20498}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020499
20500static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20501 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20502 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20503{
20504 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20505 wmi_avoid_freq_range_desc *afr_desc;
20506 uint32_t num_freq_ranges, freq_range_idx;
20507 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20508 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20509
20510 if (!param_buf) {
20511 WMI_LOGE("Invalid channel avoid event buffer");
20512 return QDF_STATUS_E_INVAL;
20513 }
20514
20515 afr_fixed_param = param_buf->fixed_param;
20516 if (!afr_fixed_param) {
20517 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20518 return QDF_STATUS_E_INVAL;
20519 }
20520
20521 if (!ch_avoid_ind) {
20522 WMI_LOGE("Invalid channel avoid indication buffer");
20523 return QDF_STATUS_E_INVAL;
20524 }
20525 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20526 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20527 afr_fixed_param->num_freq_ranges;
20528
20529 WMI_LOGD("Channel avoid event received with %d ranges",
20530 num_freq_ranges);
20531
20532 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20533 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20534 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20535 freq_range_idx++) {
20536 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20537 afr_desc->start_freq;
20538 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20539 afr_desc->end_freq;
20540 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20541 freq_range_idx, afr_desc->tlv_header,
20542 afr_desc->start_freq, afr_desc->end_freq);
20543 afr_desc++;
20544 }
20545
20546 return QDF_STATUS_SUCCESS;
20547}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020548#ifdef DFS_COMPONENT_ENABLE
20549/**
20550 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20551 * @wmi_handle: wma handle
20552 * @evt_buf: event buffer
20553 * @vdev_id: vdev id
20554 * @len: length of buffer
20555 *
20556 * Return: 0 for success or error code
20557 */
20558static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20559 uint8_t *evt_buf,
20560 uint32_t *vdev_id,
20561 uint32_t len)
20562{
20563 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20564 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20565
20566 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20567 if (!param_tlvs) {
20568 WMI_LOGE("invalid cac complete event buf");
20569 return QDF_STATUS_E_FAILURE;
20570 }
20571
20572 cac_event = param_tlvs->fixed_param;
20573 *vdev_id = cac_event->vdev_id;
20574 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20575
20576 return QDF_STATUS_SUCCESS;
20577}
20578
20579/**
20580 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20581 * @wmi_handle: wma handle
20582 * @evt_buf: event buffer
20583 * @radar_found: radar found event info
20584 * @len: length of buffer
20585 *
20586 * Return: 0 for success or error code
20587 */
20588static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20589 wmi_unified_t wmi_handle,
20590 uint8_t *evt_buf,
20591 struct radar_found_info *radar_found,
20592 uint32_t len)
20593{
20594 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20595 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20596
20597 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20598 if (!param_tlv) {
20599 WMI_LOGE("invalid radar detection event buf");
20600 return QDF_STATUS_E_FAILURE;
20601 }
20602
20603 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020604 radar_found->pdev_id = wmi_handle->ops->
20605 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020606 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020607 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020608 radar_found->chan_width = radar_event->chan_width;
20609 radar_found->detector_id = radar_event->detector_id;
20610 radar_found->segment_id = radar_event->segment_id;
20611 radar_found->timestamp = radar_event->timestamp;
20612 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020613 radar_found->freq_offset = radar_event->freq_offset;
20614 radar_found->sidx = radar_event->sidx;
20615
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020616 WMI_LOGI("processed radar found event pdev %d,"
20617 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20618 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20619 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20620 "is_chirp %d,detection mode %d\n",
20621 radar_event->pdev_id, radar_event->pdev_id,
20622 radar_event->timestamp, radar_event->chan_freq,
20623 radar_event->chan_width, radar_event->detector_id,
20624 radar_event->freq_offset, radar_event->segment_id,
20625 radar_event->sidx, radar_event->is_chirp,
20626 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020627
20628 return QDF_STATUS_SUCCESS;
20629}
20630#endif
20631
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020632/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020633 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20634 * @wmi_handle: wmi handle
20635 * @get_rcpi_param: rcpi params
20636 *
20637 * Return: QDF status
20638 */
20639static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20640 struct rcpi_req *get_rcpi_param)
20641{
20642 wmi_buf_t buf;
20643 wmi_request_rcpi_cmd_fixed_param *cmd;
20644 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
20645
20646 buf = wmi_buf_alloc(wmi_handle, len);
20647 if (!buf) {
20648 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
20649 return QDF_STATUS_E_NOMEM;
20650 }
20651
20652 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
20653 WMITLV_SET_HDR(&cmd->tlv_header,
20654 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
20655 WMITLV_GET_STRUCT_TLVLEN
20656 (wmi_request_rcpi_cmd_fixed_param));
20657
20658 cmd->vdev_id = get_rcpi_param->vdev_id;
20659 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
20660 &cmd->peer_macaddr);
20661 cmd->measurement_type = get_rcpi_param->measurement_type;
20662 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
20663 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20664 WMI_REQUEST_RCPI_CMDID)) {
20665
20666 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
20667 __func__);
20668 wmi_buf_free(buf);
20669 return QDF_STATUS_E_FAILURE;
20670 }
20671
20672 return QDF_STATUS_SUCCESS;
20673}
20674
20675/**
20676 * extract_rcpi_response_event_tlv() - Extract RCPI event params
20677 * @wmi_handle: wmi handle
20678 * @evt_buf: pointer to event buffer
20679 * @res: pointer to hold rcpi response from firmware
20680 *
20681 * Return: QDF_STATUS_SUCCESS for successful event parse
20682 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
20683 */
20684static QDF_STATUS
20685extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
20686 void *evt_buf, struct rcpi_res *res)
20687{
20688 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
20689 wmi_update_rcpi_event_fixed_param *event;
20690
20691 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
20692 if (!param_buf) {
20693 WMI_LOGE(FL("Invalid rcpi event"));
20694 return QDF_STATUS_E_INVAL;
20695 }
20696
20697 event = param_buf->fixed_param;
20698 res->vdev_id = event->vdev_id;
20699 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
20700
20701 switch (event->measurement_type) {
20702
20703 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20704 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20705 break;
20706
20707 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
20708 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
20709 break;
20710
20711 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20712 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20713 break;
20714
20715 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
20716 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
20717 break;
20718
20719 default:
20720 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
20721 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
20722 return QDF_STATUS_E_FAILURE;
20723 }
20724
20725 if (event->status)
20726 return QDF_STATUS_E_FAILURE;
20727 else
20728 return QDF_STATUS_SUCCESS;
20729}
20730
20731/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020732 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
20733 * host to target defines. For legacy there is not conversion
20734 * required. Just return pdev_id as it is.
20735 * @param pdev_id: host pdev_id to be converted.
20736 * Return: target pdev_id after conversion.
20737 */
20738static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
20739 uint32_t pdev_id)
20740{
20741 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
20742 return WMI_PDEV_ID_SOC;
20743
20744 /*No conversion required*/
20745 return pdev_id;
20746}
20747
20748/**
20749 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
20750 * target to host defines. For legacy there is not conversion
20751 * required. Just return pdev_id as it is.
20752 * @param pdev_id: target pdev_id to be converted.
20753 * Return: host pdev_id after conversion.
20754 */
20755static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
20756 uint32_t pdev_id)
20757{
20758 /*No conversion required*/
20759 return pdev_id;
20760}
20761
20762/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020763 * send_set_country_cmd_tlv() - WMI scan channel list function
20764 * @param wmi_handle : handle to WMI.
20765 * @param param : pointer to hold scan channel list parameter
20766 *
20767 * Return: 0 on success and -ve on failure.
20768 */
20769static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
20770 struct set_country *params)
20771{
20772 wmi_buf_t buf;
20773 QDF_STATUS qdf_status;
20774 wmi_set_current_country_cmd_fixed_param *cmd;
20775 uint16_t len = sizeof(*cmd);
20776
20777 buf = wmi_buf_alloc(wmi_handle, len);
20778 if (!buf) {
20779 WMI_LOGE("Failed to allocate memory");
20780 qdf_status = QDF_STATUS_E_NOMEM;
20781 goto end;
20782 }
20783
20784 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
20785 WMITLV_SET_HDR(&cmd->tlv_header,
20786 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
20787 WMITLV_GET_STRUCT_TLVLEN
20788 (wmi_set_current_country_cmd_fixed_param));
20789
20790 WMI_LOGD("setting cuurnet country to %s", params->country);
20791
20792 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
20793
20794 cmd->pdev_id = params->pdev_id;
20795
20796 qdf_status = wmi_unified_cmd_send(wmi_handle,
20797 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
20798
20799 if (QDF_IS_STATUS_ERROR(qdf_status)) {
20800 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
20801 wmi_buf_free(buf);
20802 }
20803
20804end:
20805 return qdf_status;
20806}
20807
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020808#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
20809 WMI_SET_BITS(alpha, 0, 8, val0); \
20810 WMI_SET_BITS(alpha, 8, 8, val1); \
20811 WMI_SET_BITS(alpha, 16, 8, val2); \
20812 } while (0)
20813
20814static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
20815 uint8_t pdev_id, struct cc_regdmn_s *rd)
20816{
20817 wmi_set_init_country_cmd_fixed_param *cmd;
20818 uint16_t len;
20819 wmi_buf_t buf;
20820 int ret;
20821
20822 len = sizeof(wmi_set_init_country_cmd_fixed_param);
20823 buf = wmi_buf_alloc(wmi_handle, len);
20824 if (!buf) {
20825 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
20826 return QDF_STATUS_E_NOMEM;
20827 }
20828 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
20829 WMITLV_SET_HDR(&cmd->tlv_header,
20830 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
20831 WMITLV_GET_STRUCT_TLVLEN
20832 (wmi_set_init_country_cmd_fixed_param));
20833
20834 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
20835
20836 if (rd->flags == CC_IS_SET) {
20837 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
20838 cmd->country_code.country_id = rd->cc.country_code;
20839 } else if (rd->flags == ALPHA_IS_SET) {
20840 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
20841 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
20842 rd->cc.alpha[0],
20843 rd->cc.alpha[1],
20844 rd->cc.alpha[2]);
20845 } else if (rd->flags == REGDMN_IS_SET) {
20846 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
20847 cmd->country_code.domain_code = rd->cc.regdmn_id;
20848 }
20849
20850 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
20851 WMI_SET_INIT_COUNTRY_CMDID);
20852 if (ret) {
20853 WMI_LOGE("Failed to config wow wakeup event");
20854 wmi_buf_free(buf);
20855 return QDF_STATUS_E_FAILURE;
20856 }
20857
20858 return QDF_STATUS_SUCCESS;
20859}
20860
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020861/**
20862 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
20863 * configuration params
20864 * @wmi_handle: wmi handler
20865 * @limit_off_chan_param: pointer to wmi_off_chan_param
20866 *
20867 * Return: 0 for success and non zero for failure
20868 */
20869static
20870QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
20871 struct wmi_limit_off_chan_param *limit_off_chan_param)
20872{
20873 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
20874 wmi_buf_t buf;
20875 uint32_t len = sizeof(*cmd);
20876 int err;
20877
20878 buf = wmi_buf_alloc(wmi_handle, len);
20879 if (!buf) {
20880 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
20881 __func__);
20882 return QDF_STATUS_E_NOMEM;
20883 }
20884
20885 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
20886
20887 WMITLV_SET_HDR(&cmd->tlv_header,
20888 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
20889 WMITLV_GET_STRUCT_TLVLEN(
20890 wmi_vdev_limit_offchan_cmd_fixed_param));
20891
20892 cmd->vdev_id = limit_off_chan_param->vdev_id;
20893
20894 cmd->flags &= 0;
20895 if (limit_off_chan_param->status)
20896 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20897 if (limit_off_chan_param->skip_dfs_chans)
20898 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20899
20900 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20901 cmd->rest_time = limit_off_chan_param->rest_time;
20902
20903 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20904 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20905 cmd->rest_time);
20906
20907 err = wmi_unified_cmd_send(wmi_handle, buf,
20908 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20909 if (QDF_IS_STATUS_ERROR(err)) {
20910 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20911 wmi_buf_free(buf);
20912 return QDF_STATUS_E_FAILURE;
20913 }
20914
20915 return QDF_STATUS_SUCCESS;
20916}
20917
Anurag Chouhan97f00422017-09-11 14:56:30 +053020918/**
20919 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20920 * @wmi_handle: wmi handler
20921 * @req_buf: set arp stats request buffer
20922 *
20923 * Return: 0 for success and non zero for failure
20924 */
20925static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20926 struct set_arp_stats *req_buf)
20927{
20928 wmi_buf_t buf = NULL;
20929 QDF_STATUS status;
20930 int len;
20931 uint8_t *buf_ptr;
20932 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20933
20934 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
20935 buf = wmi_buf_alloc(wmi_handle, len);
20936 if (!buf) {
20937 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20938 return QDF_STATUS_E_NOMEM;
20939 }
20940
20941 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20942 wmi_set_arp =
20943 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
20944 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
20945 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
20946 WMITLV_GET_STRUCT_TLVLEN
20947 (wmi_vdev_set_arp_stats_cmd_fixed_param));
20948
20949 /* fill in per roam config values */
20950 wmi_set_arp->vdev_id = req_buf->vdev_id;
20951
20952 wmi_set_arp->set_clr = req_buf->flag;
20953 wmi_set_arp->pkt_type = req_buf->pkt_type;
20954 wmi_set_arp->ipv4 = req_buf->ip_addr;
20955
20956 /* Send per roam config parameters */
20957 status = wmi_unified_cmd_send(wmi_handle, buf,
20958 len, WMI_VDEV_SET_ARP_STAT_CMDID);
20959 if (QDF_IS_STATUS_ERROR(status)) {
20960 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
20961 status);
20962 goto error;
20963 }
20964
20965 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
20966 req_buf->flag, req_buf->vdev_id);
20967 return QDF_STATUS_SUCCESS;
20968error:
20969 wmi_buf_free(buf);
20970
20971 return status;
20972}
20973
20974/**
20975 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
20976 * @wmi_handle: wmi handler
20977 * @req_buf: get arp stats request buffer
20978 *
20979 * Return: 0 for success and non zero for failure
20980 */
20981static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20982 struct get_arp_stats *req_buf)
20983{
20984 wmi_buf_t buf = NULL;
20985 QDF_STATUS status;
20986 int len;
20987 uint8_t *buf_ptr;
20988 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
20989
20990 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
20991 buf = wmi_buf_alloc(wmi_handle, len);
20992 if (!buf) {
20993 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20994 return QDF_STATUS_E_NOMEM;
20995 }
20996
20997 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20998 get_arp_stats =
20999 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21000 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21001 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21002 WMITLV_GET_STRUCT_TLVLEN
21003 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21004
21005 /* fill in arp stats req cmd values */
21006 get_arp_stats->vdev_id = req_buf->vdev_id;
21007
21008 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21009 /* Send per roam config parameters */
21010 status = wmi_unified_cmd_send(wmi_handle, buf,
21011 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21012 if (QDF_IS_STATUS_ERROR(status)) {
21013 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21014 status);
21015 goto error;
21016 }
21017
21018 return QDF_STATUS_SUCCESS;
21019error:
21020 wmi_buf_free(buf);
21021
21022 return status;
21023}
21024
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021025/**
21026 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21027 * @wmi_handle: wmi handler
21028 * @pmk_info: pointer to PMK cache entry
21029 * @vdev_id: vdev id
21030 *
21031 * Return: 0 for success and non zero for failure
21032 */
21033static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21034 struct wmi_unified_pmk_cache *pmk_info)
21035{
21036 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21037 wmi_buf_t buf;
21038 QDF_STATUS status;
21039 uint8_t *buf_ptr;
21040 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021041 uint32_t len = sizeof(*cmd);
21042
21043 if (pmk_info->pmk_len)
21044 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021045
21046 buf = wmi_buf_alloc(wmi_handle, len);
21047 if (!buf) {
21048 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21049 __func__);
21050 return QDF_STATUS_E_NOMEM;
21051 }
21052
21053 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21054 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21055
21056 WMITLV_SET_HDR(&cmd->tlv_header,
21057 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21058 WMITLV_GET_STRUCT_TLVLEN(
21059 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21060
21061 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021062
21063 /* If pmk_info->pmk_len is 0, this is a flush request */
21064 if (!pmk_info->pmk_len) {
21065 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21066 cmd->num_cache = 0;
21067 goto send_cmd;
21068 }
21069
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021070 cmd->num_cache = 1;
21071 buf_ptr += sizeof(*cmd);
21072
21073 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21074 sizeof(*pmksa));
21075 buf_ptr += WMI_TLV_HDR_SIZE;
21076
21077 pmksa = (wmi_pmk_cache *)buf_ptr;
21078 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21079 WMITLV_GET_STRUCT_TLVLEN
21080 (wmi_pmk_cache));
21081 pmksa->pmk_len = pmk_info->pmk_len;
21082 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21083 pmksa->pmkid_len = pmk_info->pmkid_len;
21084 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21085 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21086 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21087 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21088 pmksa->ssid.ssid_len);
21089 pmksa->cache_id = pmk_info->cache_id;
21090 pmksa->cat_flag = pmk_info->cat_flag;
21091 pmksa->action_flag = pmk_info->action_flag;
21092
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021093send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021094 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21095 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21096 if (status != QDF_STATUS_SUCCESS) {
21097 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21098 __func__, status);
21099 wmi_buf_free(buf);
21100 }
21101
21102 return status;
21103}
21104
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021105/**
21106 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21107 * @wmi_handle: wmi handle
21108 * @param: reserved param
21109 *
21110 * Return: 0 for success or error code
21111 */
21112static QDF_STATUS
21113send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21114 uint32_t param)
21115{
21116 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21117 wmi_buf_t buf;
21118 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21119
21120 buf = wmi_buf_alloc(wmi_handle, len);
21121 if (!buf) {
21122 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21123 return QDF_STATUS_E_FAILURE;
21124 }
21125 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21126 WMITLV_SET_HDR(&cmd->tlv_header,
21127 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21128 WMITLV_GET_STRUCT_TLVLEN
21129 (wmi_pdev_check_cal_version_cmd_fixed_param));
21130 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21131 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21132 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21133 wmi_buf_free(buf);
21134 return QDF_STATUS_E_FAILURE;
21135 }
21136
21137 return QDF_STATUS_SUCCESS;
21138}
21139
21140/**
21141 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21142 * @wmi_handle: wmi handle
21143 * @param evt_buf: pointer to event buffer
21144 * @param param: Pointer to hold peer caldata version data
21145 *
21146 * Return: 0 for success or error code
21147 */
21148static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21149 wmi_unified_t wmi_handle,
21150 void *evt_buf,
21151 wmi_host_pdev_check_cal_version_event *param)
21152{
21153 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21154 wmi_pdev_check_cal_version_event_fixed_param *event;
21155
21156 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21157 if (!param_tlvs) {
21158 WMI_LOGE("invalid cal version event buf");
21159 return QDF_STATUS_E_FAILURE;
21160 }
21161 event = param_tlvs->fixed_param;
21162 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21163 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21164 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21165 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21166
21167 param->software_cal_version = event->software_cal_version;
21168 param->board_cal_version = event->board_cal_version;
21169 param->cal_ok = event->cal_status;
21170
21171 return QDF_STATUS_SUCCESS;
21172}
21173
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021174/*
21175 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21176 * @wmi_handle: wmi handle
21177 * @params: pointer to wmi_btm_config
21178 *
21179 * Return: QDF_STATUS
21180 */
21181static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21182 struct wmi_btm_config *params)
21183{
21184
21185 wmi_btm_config_fixed_param *cmd;
21186 wmi_buf_t buf;
21187 uint32_t len;
21188
21189 len = sizeof(*cmd);
21190 buf = wmi_buf_alloc(wmi_handle, len);
21191 if (!buf) {
21192 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21193 return QDF_STATUS_E_NOMEM;
21194 }
21195
21196 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21197 WMITLV_SET_HDR(&cmd->tlv_header,
21198 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21199 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21200 cmd->vdev_id = params->vdev_id;
21201 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021202 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21203 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21204 cmd->stick_time_seconds = params->btm_sticky_time;
21205
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021206 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21207 WMI_ROAM_BTM_CONFIG_CMDID)) {
21208 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21209 __func__);
21210 wmi_buf_free(buf);
21211 return QDF_STATUS_E_FAILURE;
21212 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021213
21214 return QDF_STATUS_SUCCESS;
21215}
21216
21217/**
21218 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21219 * configurations to firmware.
21220 * @wmi_handle: wmi handle
21221 * @obss_cfg_param: obss detection configurations
21222 *
21223 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21224 *
21225 * Return: QDF_STATUS
21226 */
21227static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21228 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21229{
21230 wmi_buf_t buf;
21231 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21232 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21233
21234 buf = wmi_buf_alloc(wmi_handle, len);
21235 if (!buf) {
21236 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21237 return QDF_STATUS_E_NOMEM;
21238 }
21239
21240 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21241 WMITLV_SET_HDR(&cmd->tlv_header,
21242 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21243 WMITLV_GET_STRUCT_TLVLEN
21244 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21245
21246 cmd->vdev_id = obss_cfg_param->vdev_id;
21247 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21248 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21249 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21250 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21251 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21252 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21253 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21254 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
21255 WMI_LOGD("Sending WMI_SAP_OBSS_DETECTION_CFG_CMDID vdev_id:%d",
21256 cmd->vdev_id);
21257
21258 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21259 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21260 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21261 wmi_buf_free(buf);
21262 return QDF_STATUS_E_FAILURE;
21263 }
21264
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021265 return QDF_STATUS_SUCCESS;
21266}
21267
Arif Hussain33d98502018-01-12 13:15:04 -080021268/**
21269 * extract_obss_detection_info_tlv() - Extract obss detection info
21270 * received from firmware.
21271 * @evt_buf: pointer to event buffer
21272 * @obss_detection: Pointer to hold obss detection info
21273 *
21274 * Return: QDF_STATUS
21275 */
21276static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21277 struct wmi_obss_detect_info
21278 *obss_detection)
21279{
21280 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21281 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21282
21283 if (!obss_detection) {
21284 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21285 return QDF_STATUS_E_INVAL;
21286 }
21287
21288 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21289 if (!param_buf) {
21290 WMI_LOGE("%s: Invalid evt_buf", __func__);
21291 return QDF_STATUS_E_INVAL;
21292 }
21293
21294 fix_param = param_buf->fixed_param;
21295 obss_detection->vdev_id = fix_param->vdev_id;
21296 obss_detection->matched_detection_masks =
21297 fix_param->matched_detection_masks;
21298 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21299 &obss_detection->matched_bssid_addr[0]);
21300 switch (fix_param->reason) {
21301 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21302 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21303 break;
21304 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21305 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21306 break;
21307 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21308 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21309 break;
21310 default:
21311 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21312 return QDF_STATUS_E_INVAL;
21313 }
21314
21315 return QDF_STATUS_SUCCESS;
21316}
21317
Govind Singh5eb51532016-03-09 11:34:12 +053021318struct wmi_ops tlv_ops = {
21319 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
21320 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
21321 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053021322 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
21323 .send_hidden_ssid_vdev_restart_cmd =
21324 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021325 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
21326 .send_peer_param_cmd = send_peer_param_cmd_tlv,
21327 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021328 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021329 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021330 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070021331 .send_peer_rx_reorder_queue_setup_cmd =
21332 send_peer_rx_reorder_queue_setup_cmd_tlv,
21333 .send_peer_rx_reorder_queue_remove_cmd =
21334 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053021335 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
21336 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
21337 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021338 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
21339 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
21340 .send_suspend_cmd = send_suspend_cmd_tlv,
21341 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080021342#ifdef FEATURE_WLAN_D0WOW
21343 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
21344 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
21345#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021346 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
21347 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
21348 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
21349 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
21350 .send_dbglog_cmd = send_dbglog_cmd_tlv,
21351 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
21352 .send_stats_request_cmd = send_stats_request_cmd_tlv,
21353 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070021354 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021355 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021356 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021357 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
21358 .send_scan_start_cmd = send_scan_start_cmd_tlv,
21359 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
21360 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021361 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021362 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021363 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
21364 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021365 .send_set_sta_uapsd_auto_trig_cmd =
21366 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021367 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
21368 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
21369 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080021370#ifdef CONVERGED_P2P_ENABLE
21371 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
21372 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
21373#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053021374 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
21375 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053021376 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
21377 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
21378 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
21379 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
21380 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
21381 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
21382 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021383 .send_ocb_start_timing_advert_cmd =
21384 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053021385 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
21386 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
21387 .send_set_mcc_channel_time_latency_cmd =
21388 send_set_mcc_channel_time_latency_cmd_tlv,
21389 .send_set_mcc_channel_time_quota_cmd =
21390 send_set_mcc_channel_time_quota_cmd_tlv,
21391 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
21392 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053021393 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021394 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
21395 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
21396 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021397 .send_probe_rsp_tmpl_send_cmd =
21398 send_probe_rsp_tmpl_send_cmd_tlv,
21399 .send_p2p_go_set_beacon_ie_cmd =
21400 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053021401 .send_setup_install_key_cmd =
21402 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021403 .send_set_gateway_params_cmd =
21404 send_set_gateway_params_cmd_tlv,
21405 .send_set_rssi_monitoring_cmd =
21406 send_set_rssi_monitoring_cmd_tlv,
21407 .send_scan_probe_setoui_cmd =
21408 send_scan_probe_setoui_cmd_tlv,
21409 .send_reset_passpoint_network_list_cmd =
21410 send_reset_passpoint_network_list_cmd_tlv,
21411 .send_set_passpoint_network_list_cmd =
21412 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021413 .send_roam_scan_offload_rssi_thresh_cmd =
21414 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070021415 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021416 .send_roam_scan_filter_cmd =
21417 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021418 .send_set_epno_network_list_cmd =
21419 send_set_epno_network_list_cmd_tlv,
21420 .send_ipa_offload_control_cmd =
21421 send_ipa_offload_control_cmd_tlv,
21422 .send_extscan_get_capabilities_cmd =
21423 send_extscan_get_capabilities_cmd_tlv,
21424 .send_extscan_get_cached_results_cmd =
21425 send_extscan_get_cached_results_cmd_tlv,
21426 .send_extscan_stop_change_monitor_cmd =
21427 send_extscan_stop_change_monitor_cmd_tlv,
21428 .send_extscan_start_change_monitor_cmd =
21429 send_extscan_start_change_monitor_cmd_tlv,
21430 .send_extscan_stop_hotlist_monitor_cmd =
21431 send_extscan_stop_hotlist_monitor_cmd_tlv,
21432 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
21433 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
21434 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
21435 .send_plm_start_cmd = send_plm_start_cmd_tlv,
21436 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
21437 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070021438 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021439 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
21440 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
21441 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
21442 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053021443 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021444 .send_snr_request_cmd = send_snr_request_cmd_tlv,
21445 .send_snr_cmd = send_snr_cmd_tlv,
21446 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021447#ifdef WLAN_PMO_ENABLE
21448 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
21449 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
21450 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
21451 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053021452 .send_multiple_add_clear_mcbc_filter_cmd =
21453 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070021454 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021455 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
21456 .send_process_gtk_offload_getinfo_cmd =
21457 send_process_gtk_offload_getinfo_cmd_tlv,
21458 .send_enable_enhance_multicast_offload_cmd =
21459 send_enable_enhance_multicast_offload_tlv,
21460 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
21461#ifdef FEATURE_WLAN_RA_FILTERING
21462 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
21463#endif
21464 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021465 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
21466 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021467 .send_lphb_config_tcp_pkt_filter_cmd =
21468 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021469 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
21470 .send_lphb_config_udp_pkt_filter_cmd =
21471 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053021472 .send_enable_disable_packet_filter_cmd =
21473 send_enable_disable_packet_filter_cmd_tlv,
21474 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021475#endif /* End of WLAN_PMO_ENABLE */
21476#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053021477 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
21478 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021479 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021480 .send_roam_scan_offload_mode_cmd =
21481 send_roam_scan_offload_mode_cmd_tlv,
21482 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
21483 .send_roam_scan_offload_ap_profile_cmd =
21484 send_roam_scan_offload_ap_profile_cmd_tlv,
21485#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053021486#ifdef WLAN_SUPPORT_GREEN_AP
21487 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
21488 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
21489#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053021490 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
21491 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021492 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080021493 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021494 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070021495#ifdef WLAN_FEATURE_CIF_CFR
21496 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
21497#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053021498 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021499 .send_dfs_phyerr_filter_offload_en_cmd =
21500 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021501 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
21502 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
21503 .send_del_ts_cmd = send_del_ts_cmd_tlv,
21504 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
21505 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021506 .send_process_add_periodic_tx_ptrn_cmd =
21507 send_process_add_periodic_tx_ptrn_cmd_tlv,
21508 .send_process_del_periodic_tx_ptrn_cmd =
21509 send_process_del_periodic_tx_ptrn_cmd_tlv,
21510 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
21511 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
21512 .send_set_app_type2_params_in_fw_cmd =
21513 send_set_app_type2_params_in_fw_cmd_tlv,
21514 .send_set_auto_shutdown_timer_cmd =
21515 send_set_auto_shutdown_timer_cmd_tlv,
21516 .send_nan_req_cmd = send_nan_req_cmd_tlv,
21517 .send_process_dhcpserver_offload_cmd =
21518 send_process_dhcpserver_offload_cmd_tlv,
21519 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
21520 .send_process_ch_avoid_update_cmd =
21521 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053021522 .send_pdev_set_regdomain_cmd =
21523 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021524 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
21525 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
21526 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
21527 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021528 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053021529 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021530 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053021531 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053021532 .send_set_base_macaddr_indicate_cmd =
21533 send_set_base_macaddr_indicate_cmd_tlv,
21534 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
21535 .send_enable_specific_fw_logs_cmd =
21536 send_enable_specific_fw_logs_cmd_tlv,
21537 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053021538 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053021539 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053021540 .send_pdev_set_dual_mac_config_cmd =
21541 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053021542 .send_app_type1_params_in_fw_cmd =
21543 send_app_type1_params_in_fw_cmd_tlv,
21544 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
21545 .send_process_roam_synch_complete_cmd =
21546 send_process_roam_synch_complete_cmd_tlv,
21547 .send_unit_test_cmd = send_unit_test_cmd_tlv,
21548 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
21549 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053021550 .send_roam_scan_offload_scan_period_cmd =
21551 send_roam_scan_offload_scan_period_cmd_tlv,
21552 .send_roam_scan_offload_chan_list_cmd =
21553 send_roam_scan_offload_chan_list_cmd_tlv,
21554 .send_roam_scan_offload_rssi_change_cmd =
21555 send_roam_scan_offload_rssi_change_cmd_tlv,
21556 .send_get_buf_extscan_hotlist_cmd =
21557 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080021558 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053021559 .send_adapt_dwelltime_params_cmd =
21560 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053021561 .send_dbs_scan_sel_params_cmd =
21562 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021563 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053021564 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
21565 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
21566 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
21567 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
21568 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
21569 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053021570 .send_vdev_set_custom_aggr_size_cmd =
21571 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053021572 .send_vdev_set_qdepth_thresh_cmd =
21573 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053021574 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
21575 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
21576 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053021577 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
21578 .send_smart_ant_set_training_info_cmd =
21579 send_smart_ant_set_training_info_cmd_tlv,
21580 .send_smart_ant_set_node_config_cmd =
21581 send_smart_ant_set_node_config_cmd_tlv,
21582 .send_set_atf_cmd = send_set_atf_cmd_tlv,
21583 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
21584 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053021585 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
21586 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
21587 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
21588 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053021589 .send_periodic_chan_stats_config_cmd =
21590 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053021591 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
21592 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
21593 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053021594 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
21595 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
21596 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
21597 .send_vdev_spectral_configure_cmd =
21598 send_vdev_spectral_configure_cmd_tlv,
21599 .send_vdev_spectral_enable_cmd =
21600 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053021601 .send_thermal_mitigation_param_cmd =
21602 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053021603 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
21604 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053021605 .send_process_update_edca_param_cmd =
21606 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053021607 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021608 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053021609 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080021610 .send_addba_send_cmd = send_addba_send_cmd_tlv,
21611 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080021612 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021613 .get_target_cap_from_service_ready = extract_service_ready_tlv,
21614 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
21615 .extract_host_mem_req = extract_host_mem_req_tlv,
21616 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053021617 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021618 .is_service_enabled = is_service_enabled_tlv,
21619 .save_fw_version = save_fw_version_in_service_ready_tlv,
21620 .ready_extract_init_status = ready_extract_init_status_tlv,
21621 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070021622 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053021623 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021624 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
21625 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053021626 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021627 .extract_tbttoffset_update_params =
21628 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053021629 .extract_ext_tbttoffset_update_params =
21630 extract_ext_tbttoffset_update_params_tlv,
21631 .extract_tbttoffset_num_vdevs =
21632 extract_tbttoffset_num_vdevs_tlv,
21633 .extract_ext_tbttoffset_num_vdevs =
21634 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021635 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
21636 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
21637 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
21638 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080021639#ifdef CONVERGED_TDLS_ENABLE
21640 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
21641#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053021642 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053021643 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021644 .extract_swba_tim_info = extract_swba_tim_info_tlv,
21645 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080021646#ifdef CONVERGED_P2P_ENABLE
21647 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
21648 .extract_p2p_lo_stop_ev_param =
21649 extract_p2p_lo_stop_ev_param_tlv,
21650#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021651 .extract_offchan_data_tx_compl_param =
21652 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021653 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
21654 .extract_all_stats_count = extract_all_stats_counts_tlv,
21655 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070021656 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021657 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
21658 .extract_vdev_stats = extract_vdev_stats_tlv,
21659 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053021660 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021661 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
21662 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
21663 .extract_chan_stats = extract_chan_stats_tlv,
21664 .extract_profile_ctx = extract_profile_ctx_tlv,
21665 .extract_profile_data = extract_profile_data_tlv,
21666 .extract_chan_info_event = extract_chan_info_event_tlv,
21667 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053021668 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053021669#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053021670 .send_encrypt_decrypt_send_cmd =
21671 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053021672 .extract_encrypt_decrypt_resp_event =
21673 extract_encrypt_decrypt_resp_event_tlv,
21674#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080021675 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080021676 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
21677 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053021678 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053021679 .send_multiple_vdev_restart_req_cmd =
21680 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053021681 .extract_service_ready_ext = extract_service_ready_ext_tlv,
21682 .extract_hw_mode_cap_service_ready_ext =
21683 extract_hw_mode_cap_service_ready_ext_tlv,
21684 .extract_mac_phy_cap_service_ready_ext =
21685 extract_mac_phy_cap_service_ready_ext_tlv,
21686 .extract_reg_cap_service_ready_ext =
21687 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053021688 .extract_dbr_ring_cap_service_ready_ext =
21689 extract_dbr_ring_cap_service_ready_ext_tlv,
21690 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
21691 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053021692 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053021693 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053021694 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
21695 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
21696 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053021697 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053021698 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053021699 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021700 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053021701 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053021702 .extract_pdev_csa_switch_count_status =
21703 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053021704 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
21705 .extract_wds_addr_event = extract_wds_addr_event_tlv,
21706 .extract_peer_sta_ps_statechange_ev =
21707 extract_peer_sta_ps_statechange_ev_tlv,
21708 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053021709 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080021710 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
21711 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053021712 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053021713 extract_reg_chan_list_update_event_tlv,
21714 .extract_chainmask_tables =
21715 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053021716 .extract_thermal_stats = extract_thermal_stats_tlv,
21717 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021718 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
21719 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021720#ifdef DFS_COMPONENT_ENABLE
21721 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
21722 .extract_dfs_radar_detection_event =
21723 extract_dfs_radar_detection_event_tlv,
21724#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021725 .convert_pdev_id_host_to_target =
21726 convert_host_pdev_id_to_target_pdev_id_legacy,
21727 .convert_pdev_id_target_to_host =
21728 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070021729
21730 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
21731 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
21732 .extract_reg_11d_new_country_event =
21733 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021734 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021735 .send_limit_off_chan_cmd =
21736 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070021737 .extract_reg_ch_avoid_event =
21738 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021739 .send_pdev_caldata_version_check_cmd =
21740 send_pdev_caldata_version_check_cmd_tlv,
21741 .extract_pdev_caldata_version_check_ev_param =
21742 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053021743 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
21744 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021745 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
21746#if defined(WLAN_FEATURE_FILS_SK)
21747 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
21748#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070021749 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080021750#ifdef WLAN_FEATURE_NAN_CONVERGENCE
21751 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
21752 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
21753 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
21754 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
21755 .extract_ndp_ind = extract_ndp_ind_tlv,
21756 .extract_ndp_confirm = extract_ndp_confirm_tlv,
21757 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
21758 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
21759 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
21760#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021761 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080021762 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080021763 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053021764#ifdef WLAN_SUPPORT_FILS
21765 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
21766 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
21767 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
21768#endif /* WLAN_SUPPORT_FILS */
Govind Singh5eb51532016-03-09 11:34:12 +053021769};
21770
Govind Singhe7f2f342016-05-23 12:12:52 +053021771/**
21772 * populate_tlv_event_id() - populates wmi event ids
21773 *
21774 * @param event_ids: Pointer to hold event ids
21775 * Return: None
21776 */
21777static void populate_tlv_events_id(uint32_t *event_ids)
21778{
21779 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
21780 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
21781 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
21782 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
21783 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
21784 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
21785 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
21786 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
21787 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
21788 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
21789 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
21790 event_ids[wmi_service_ready_ext_event_id] =
21791 WMI_SERVICE_READY_EXT_EVENTID;
21792 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
21793 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
21794 event_ids[wmi_vdev_install_key_complete_event_id] =
21795 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
21796 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
21797 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
21798
21799 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
21800 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
21801 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
21802 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
21803 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
21804 event_ids[wmi_peer_estimated_linkspeed_event_id] =
21805 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
21806 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053021807 event_ids[wmi_peer_delete_response_event_id] =
21808 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021809 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
21810 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
21811 event_ids[wmi_tbttoffset_update_event_id] =
21812 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053021813 event_ids[wmi_ext_tbttoffset_update_event_id] =
21814 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021815 event_ids[wmi_offload_bcn_tx_status_event_id] =
21816 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
21817 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
21818 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
21819 event_ids[wmi_mgmt_tx_completion_event_id] =
21820 WMI_MGMT_TX_COMPLETION_EVENTID;
21821
21822 event_ids[wmi_tx_delba_complete_event_id] =
21823 WMI_TX_DELBA_COMPLETE_EVENTID;
21824 event_ids[wmi_tx_addba_complete_event_id] =
21825 WMI_TX_ADDBA_COMPLETE_EVENTID;
21826 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
21827
21828 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
21829
21830 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
21831 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
21832
21833 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053021834 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021835
21836 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
21837
21838 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080021839 event_ids[wmi_p2p_lo_stop_event_id] =
21840 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021841 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
21842 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080021843 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053021844 WMI_D0_WOW_DISABLE_ACK_EVENTID;
21845 event_ids[wmi_wow_initial_wakeup_event_id] =
21846 WMI_WOW_INITIAL_WAKEUP_EVENTID;
21847
21848 event_ids[wmi_rtt_meas_report_event_id] =
21849 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
21850 event_ids[wmi_tsf_meas_report_event_id] =
21851 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
21852 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
21853 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
21854 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
21855 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
21856 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021857 event_ids[wmi_diag_event_id_log_supported_event_id] =
21858 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
21859 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
21860 event_ids[wmi_nlo_scan_complete_event_id] =
21861 WMI_NLO_SCAN_COMPLETE_EVENTID;
21862 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
21863 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
21864
21865 event_ids[wmi_gtk_offload_status_event_id] =
21866 WMI_GTK_OFFLOAD_STATUS_EVENTID;
21867 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
21868 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
21869 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
21870
21871 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
21872
21873 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
21874
21875 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
21876 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
21877 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
21878 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
21879 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
21880 event_ids[wmi_wlan_profile_data_event_id] =
21881 WMI_WLAN_PROFILE_DATA_EVENTID;
21882 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
21883 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
21884 event_ids[wmi_vdev_get_keepalive_event_id] =
21885 WMI_VDEV_GET_KEEPALIVE_EVENTID;
21886 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
21887
21888 event_ids[wmi_diag_container_event_id] =
21889 WMI_DIAG_DATA_CONTAINER_EVENTID;
21890
21891 event_ids[wmi_host_auto_shutdown_event_id] =
21892 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
21893
21894 event_ids[wmi_update_whal_mib_stats_event_id] =
21895 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
21896
21897 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
21898 event_ids[wmi_update_vdev_rate_stats_event_id] =
21899 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
21900
21901 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070021902 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021903
21904 /** Set OCB Sched Response, deprecated */
21905 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
21906
21907 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
21908 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
21909 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
21910
21911 /* GPIO Event */
21912 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
21913 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
21914
21915 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
21916 event_ids[wmi_rfkill_state_change_event_id] =
21917 WMI_RFKILL_STATE_CHANGE_EVENTID;
21918
21919 /* TDLS Event */
21920 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
21921
21922 event_ids[wmi_batch_scan_enabled_event_id] =
21923 WMI_BATCH_SCAN_ENABLED_EVENTID;
21924 event_ids[wmi_batch_scan_result_event_id] =
21925 WMI_BATCH_SCAN_RESULT_EVENTID;
21926 /* OEM Event */
21927 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
21928 event_ids[wmi_oem_meas_report_event_id] =
21929 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
21930 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
21931
21932 /* NAN Event */
21933 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
21934
21935 /* LPI Event */
21936 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
21937 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
21938 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
21939
21940 /* ExtScan events */
21941 event_ids[wmi_extscan_start_stop_event_id] =
21942 WMI_EXTSCAN_START_STOP_EVENTID;
21943 event_ids[wmi_extscan_operation_event_id] =
21944 WMI_EXTSCAN_OPERATION_EVENTID;
21945 event_ids[wmi_extscan_table_usage_event_id] =
21946 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
21947 event_ids[wmi_extscan_cached_results_event_id] =
21948 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
21949 event_ids[wmi_extscan_wlan_change_results_event_id] =
21950 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
21951 event_ids[wmi_extscan_hotlist_match_event_id] =
21952 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
21953 event_ids[wmi_extscan_capabilities_event_id] =
21954 WMI_EXTSCAN_CAPABILITIES_EVENTID;
21955 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
21956 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
21957
21958 /* mDNS offload events */
21959 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
21960
21961 /* SAP Authentication offload events */
21962 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
21963 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
21964
21965 /** Out-of-context-of-bss (OCB) events */
21966 event_ids[wmi_ocb_set_config_resp_event_id] =
21967 WMI_OCB_SET_CONFIG_RESP_EVENTID;
21968 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
21969 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
21970 event_ids[wmi_dcc_get_stats_resp_event_id] =
21971 WMI_DCC_GET_STATS_RESP_EVENTID;
21972 event_ids[wmi_dcc_update_ndl_resp_event_id] =
21973 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
21974 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
21975 /* System-On-Chip events */
21976 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
21977 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
21978 event_ids[wmi_soc_hw_mode_transition_event_id] =
21979 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
21980 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
21981 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053021982 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053021983 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
21984 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053021985 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053021986 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
21987 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
21988 event_ids[wmi_peer_sta_ps_statechg_event_id] =
21989 WMI_PEER_STA_PS_STATECHG_EVENTID;
21990 event_ids[wmi_pdev_channel_hopping_event_id] =
21991 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021992 event_ids[wmi_offchan_data_tx_completion_event] =
21993 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021994 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
21995 event_ids[wmi_dfs_radar_detection_event_id] =
21996 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053021997 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070021998 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053021999 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022000 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022001 event_ids[wmi_service_available_event_id] =
22002 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022003 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022004 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022005 /* NDP events */
22006 event_ids[wmi_ndp_initiator_rsp_event_id] =
22007 WMI_NDP_INITIATOR_RSP_EVENTID;
22008 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22009 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22010 event_ids[wmi_ndp_responder_rsp_event_id] =
22011 WMI_NDP_RESPONDER_RSP_EVENTID;
22012 event_ids[wmi_ndp_end_indication_event_id] =
22013 WMI_NDP_END_INDICATION_EVENTID;
22014 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
22015
22016 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22017 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22018 event_ids[wmi_pdev_chip_power_stats_event_id] =
22019 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22020 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22021 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22022 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
22023 event_ids[wmi_bpf_capability_info_event_id] =
22024 WMI_BPF_CAPABILIY_INFO_EVENTID;
22025 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22026 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22027 event_ids[wmi_report_rx_aggr_failure_event_id] =
22028 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22029 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22030 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22031 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22032 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22033 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22034 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22035 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22036 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22037 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22038 event_ids[wmi_coex_bt_activity_event_id] =
22039 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22040 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22041 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22042 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22043 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22044 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022045 event_ids[wmi_dma_buf_release_event_id] =
22046 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022047 event_ids[wmi_sap_obss_detection_report_event_id] =
22048 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022049 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022050 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022051}
22052
Soumya Bhat488092d2017-03-22 14:41:01 +053022053#ifndef CONFIG_MCL
22054/**
22055 * populate_tlv_service() - populates wmi services
22056 *
22057 * @param wmi_service: Pointer to hold wmi_service
22058 * Return: None
22059 */
22060static void populate_tlv_service(uint32_t *wmi_service)
22061{
22062 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022063 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022064 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22065 wmi_service[wmi_service_roam_scan_offload] =
22066 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22067 wmi_service[wmi_service_bcn_miss_offload] =
22068 WMI_SERVICE_BCN_MISS_OFFLOAD;
22069 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22070 wmi_service[wmi_service_sta_advanced_pwrsave] =
22071 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22072 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22073 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22074 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22075 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22076 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22077 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22078 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22079 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22080 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22081 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22082 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22083 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22084 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22085 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22086 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22087 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22088 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22089 wmi_service[wmi_service_packet_power_save] =
22090 WMI_SERVICE_PACKET_POWER_SAVE;
22091 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22092 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22093 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22094 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22095 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22096 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22097 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22098 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22099 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22100 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22101 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22102 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22103 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22104 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22105 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22106 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22107 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
22108 wmi_service[wmi_service_mcc_bcn_interval_change] =
22109 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
22110 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
22111 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
22112 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
22113 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
22114 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
22115 wmi_service[wmi_service_lte_ant_share_support] =
22116 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
22117 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
22118 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
22119 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
22120 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
22121 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
22122 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
22123 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
22124 wmi_service[wmi_service_bcn_txrate_override] =
22125 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
22126 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
22127 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
22128 wmi_service[wmi_service_estimate_linkspeed] =
22129 WMI_SERVICE_ESTIMATE_LINKSPEED;
22130 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
22131 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
22132 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
22133 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
22134 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
22135 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
22136 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
22137 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
22138 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
22139 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
22140 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
22141 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
22142 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
22143 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
22144 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
22145 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
22146 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
22147 wmi_service[wmi_service_sap_auth_offload] =
22148 WMI_SERVICE_SAP_AUTH_OFFLOAD;
22149 wmi_service[wmi_service_dual_band_simultaneous_support] =
22150 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
22151 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
22152 wmi_service[wmi_service_ap_arpns_offload] =
22153 WMI_SERVICE_AP_ARPNS_OFFLOAD;
22154 wmi_service[wmi_service_per_band_chainmask_support] =
22155 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
22156 wmi_service[wmi_service_packet_filter_offload] =
22157 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
22158 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
22159 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
22160 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
22161 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
22162 wmi_service[wmi_service_multiple_vdev_restart] =
22163 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
22164
22165 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
22166 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
22167 wmi_service[wmi_service_smart_antenna_sw_support] =
22168 WMI_SERVICE_UNAVAILABLE;
22169 wmi_service[wmi_service_smart_antenna_hw_support] =
22170 WMI_SERVICE_UNAVAILABLE;
22171 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053022172 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022173 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053022174 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
22175 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
22176 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
22177 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
22178 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
22179 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
22180 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
22181 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053022182 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
22183 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
22184 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022185 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022186 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
22187 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
22188 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
22189 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
22190 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
22191 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022192 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
22193 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
22194 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
22195 wmi_service[wmi_service_unified_wow_capability] =
22196 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
22197 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
22198 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
22199 wmi_service[wmi_service_sync_delete_cmds] =
22200 WMI_SERVICE_SYNC_DELETE_CMDS;
22201 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
22202 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
22203 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
22204 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
22205 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
22206 wmi_service[wmi_service_deprecated_replace] =
22207 WMI_SERVICE_DEPRECATED_REPLACE;
22208 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
22209 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
22210 wmi_service[wmi_service_enhanced_mcast_filter] =
22211 WMI_SERVICE_ENHANCED_MCAST_FILTER;
22212 wmi_service[wmi_service_half_rate_quarter_rate_support] =
22213 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
22214 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
22215 wmi_service[wmi_service_p2p_listen_offload_support] =
22216 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
22217 wmi_service[wmi_service_mark_first_wakeup_packet] =
22218 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
22219 wmi_service[wmi_service_multiple_mcast_filter_set] =
22220 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
22221 wmi_service[wmi_service_host_managed_rx_reorder] =
22222 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
22223 wmi_service[wmi_service_flash_rdwr_support] =
22224 WMI_SERVICE_FLASH_RDWR_SUPPORT;
22225 wmi_service[wmi_service_wlan_stats_report] =
22226 WMI_SERVICE_WLAN_STATS_REPORT;
22227 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
22228 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
22229 wmi_service[wmi_service_dfs_phyerr_offload] =
22230 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
22231 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
22232 wmi_service[wmi_service_fw_mem_dump_support] =
22233 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
22234 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
22235 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
22236 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
22237 wmi_service[wmi_service_hw_data_filtering] =
22238 WMI_SERVICE_HW_DATA_FILTERING;
22239 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
22240 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053022241 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053022242 wmi_service[wmi_service_extended_nss_support] =
22243 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053022244 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022245 wmi_service[wmi_service_bcn_offload_start_stop_support] =
22246 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053022247 wmi_service[wmi_service_offchan_data_tid_support] =
22248 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053022249 wmi_service[wmi_service_support_dma] =
22250 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Soumya Bhat488092d2017-03-22 14:41:01 +053022251}
22252
Govind Singhe7f2f342016-05-23 12:12:52 +053022253/**
22254 * populate_pdev_param_tlv() - populates pdev params
22255 *
22256 * @param pdev_param: Pointer to hold pdev params
22257 * Return: None
22258 */
22259static void populate_pdev_param_tlv(uint32_t *pdev_param)
22260{
22261 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
22262 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
22263 pdev_param[wmi_pdev_param_txpower_limit2g] =
22264 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
22265 pdev_param[wmi_pdev_param_txpower_limit5g] =
22266 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
22267 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
22268 pdev_param[wmi_pdev_param_beacon_gen_mode] =
22269 WMI_PDEV_PARAM_BEACON_GEN_MODE;
22270 pdev_param[wmi_pdev_param_beacon_tx_mode] =
22271 WMI_PDEV_PARAM_BEACON_TX_MODE;
22272 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
22273 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
22274 pdev_param[wmi_pdev_param_protection_mode] =
22275 WMI_PDEV_PARAM_PROTECTION_MODE;
22276 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
22277 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
22278 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
22279 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
22280 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
22281 pdev_param[wmi_pdev_param_sta_kickout_th] =
22282 WMI_PDEV_PARAM_STA_KICKOUT_TH;
22283 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
22284 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
22285 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
22286 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
22287 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
22288 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
22289 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
22290 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
22291 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
22292 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
22293 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
22294 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
22295 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
22296 pdev_param[wmi_pdev_param_ltr_sleep_override] =
22297 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
22298 pdev_param[wmi_pdev_param_ltr_rx_override] =
22299 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
22300 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
22301 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
22302 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
22303 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
22304 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
22305 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
22306 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
22307 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
22308 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
22309 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
22310 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
22311 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
22312 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
22313 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
22314 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
22315 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
22316 pdev_param[wmi_pdev_param_peer_stats_update_period] =
22317 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
22318 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
22319 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
22320 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
22321 pdev_param[wmi_pdev_param_arp_ac_override] =
22322 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
22323 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
22324 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
22325 pdev_param[wmi_pdev_param_ani_poll_period] =
22326 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
22327 pdev_param[wmi_pdev_param_ani_listen_period] =
22328 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
22329 pdev_param[wmi_pdev_param_ani_ofdm_level] =
22330 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
22331 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
22332 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
22333 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
22334 pdev_param[wmi_pdev_param_idle_ps_config] =
22335 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
22336 pdev_param[wmi_pdev_param_power_gating_sleep] =
22337 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
22338 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
22339 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
22340 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
22341 pdev_param[wmi_pdev_param_hw_rfkill_config] =
22342 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
22343 pdev_param[wmi_pdev_param_low_power_rf_enable] =
22344 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
22345 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
22346 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
22347 pdev_param[wmi_pdev_param_power_collapse_enable] =
22348 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
22349 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
22350 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
22351 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
22352 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
22353 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
22354 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
22355 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
22356 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
22357 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
22358 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
22359 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
22360 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
22361 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
22362 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
22363 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
22364 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
22365 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
22366 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
22367 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
22368 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
22369 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
22370 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
22371 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
22372 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
22373 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
22374 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
22375 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
22376 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
22377 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
22378 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
22379 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
22380 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
22381 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
22382 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
22383 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
22384 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
22385 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
22386 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
22387 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
22388 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
22389 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
22390 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
22391 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
22392 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022393 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
22394 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
22395 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053022396 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
22397 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022398 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053022399 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022400 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
22401 pdev_param[wmi_pdev_param_proxy_sta_mode] =
22402 WMI_PDEV_PARAM_PROXY_STA_MODE;
22403 pdev_param[wmi_pdev_param_mu_group_policy] =
22404 WMI_PDEV_PARAM_MU_GROUP_POLICY;
22405 pdev_param[wmi_pdev_param_noise_detection] =
22406 WMI_PDEV_PARAM_NOISE_DETECTION;
22407 pdev_param[wmi_pdev_param_noise_threshold] =
22408 WMI_PDEV_PARAM_NOISE_THRESHOLD;
22409 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
22410 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
22411 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022412 pdev_param[wmi_pdev_param_atf_strict_sch] =
22413 WMI_PDEV_PARAM_ATF_STRICT_SCH;
22414 pdev_param[wmi_pdev_param_atf_sched_duration] =
22415 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022416 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
22417 pdev_param[wmi_pdev_param_sensitivity_level] =
22418 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
22419 pdev_param[wmi_pdev_param_signed_txpower_2g] =
22420 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
22421 pdev_param[wmi_pdev_param_signed_txpower_5g] =
22422 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070022423 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
22424 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
22425 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
22426 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022427 pdev_param[wmi_pdev_param_cca_threshold] =
22428 WMI_PDEV_PARAM_CCA_THRESHOLD;
22429 pdev_param[wmi_pdev_param_rts_fixed_rate] =
22430 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053022431 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022432 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
22433 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
22434 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
22435 pdev_param[wmi_pdev_param_arp_srcaddr] =
22436 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
22437 pdev_param[wmi_pdev_param_arp_dstaddr] =
22438 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
22439 pdev_param[wmi_pdev_param_txpower_decr_db] =
22440 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053022441 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
22442 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022443 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
22444 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053022445 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022446 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022447 pdev_param[wmi_pdev_param_cust_txpower_scale] =
22448 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022449 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
22450 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053022451 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
22452 WMI_UNAVAILABLE_PARAM;
22453 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
22454 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022455 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
22456 pdev_param[wmi_pdev_param_block_interbss] =
22457 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053022458 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022459 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
22460 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
22461 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022462 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022463 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053022464 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
22465 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022466 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053022467 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
22468 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053022469 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
22470 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
22471 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
22472 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
22473 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
22474 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
22475 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
22476 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
22477 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
22478 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
22479 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
22480 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
22481 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
22482 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
22483 pdev_param[wmi_pdev_param_fast_channel_reset] =
22484 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
22485 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022486 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053022487}
22488
22489/**
22490 * populate_vdev_param_tlv() - populates vdev params
22491 *
22492 * @param vdev_param: Pointer to hold vdev params
22493 * Return: None
22494 */
22495static void populate_vdev_param_tlv(uint32_t *vdev_param)
22496{
22497 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
22498 vdev_param[wmi_vdev_param_fragmentation_threshold] =
22499 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
22500 vdev_param[wmi_vdev_param_beacon_interval] =
22501 WMI_VDEV_PARAM_BEACON_INTERVAL;
22502 vdev_param[wmi_vdev_param_listen_interval] =
22503 WMI_VDEV_PARAM_LISTEN_INTERVAL;
22504 vdev_param[wmi_vdev_param_multicast_rate] =
22505 WMI_VDEV_PARAM_MULTICAST_RATE;
22506 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
22507 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
22508 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
22509 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
22510 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
22511 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
22512 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
22513 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
22514 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
22515 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
22516 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
22517 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
22518 vdev_param[wmi_vdev_param_bmiss_count_max] =
22519 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
22520 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
22521 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
22522 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
22523 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
22524 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
22525 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
22526 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
22527 vdev_param[wmi_vdev_param_disable_htprotection] =
22528 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
22529 vdev_param[wmi_vdev_param_sta_quickkickout] =
22530 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
22531 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
22532 vdev_param[wmi_vdev_param_protection_mode] =
22533 WMI_VDEV_PARAM_PROTECTION_MODE;
22534 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
22535 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
22536 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
22537 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
22538 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
22539 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
22540 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
22541 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
22542 vdev_param[wmi_vdev_param_bcast_data_rate] =
22543 WMI_VDEV_PARAM_BCAST_DATA_RATE;
22544 vdev_param[wmi_vdev_param_mcast_data_rate] =
22545 WMI_VDEV_PARAM_MCAST_DATA_RATE;
22546 vdev_param[wmi_vdev_param_mcast_indicate] =
22547 WMI_VDEV_PARAM_MCAST_INDICATE;
22548 vdev_param[wmi_vdev_param_dhcp_indicate] =
22549 WMI_VDEV_PARAM_DHCP_INDICATE;
22550 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
22551 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
22552 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
22553 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
22554 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
22555 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
22556 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
22557 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
22558 vdev_param[wmi_vdev_param_ap_enable_nawds] =
22559 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
22560 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
22561 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
22562 vdev_param[wmi_vdev_param_packet_powersave] =
22563 WMI_VDEV_PARAM_PACKET_POWERSAVE;
22564 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
22565 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
22566 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
22567 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
22568 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
22569 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
22570 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
22571 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
22572 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
22573 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
22574 vdev_param[wmi_vdev_param_early_rx_slop_step] =
22575 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
22576 vdev_param[wmi_vdev_param_early_rx_init_slop] =
22577 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
22578 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
22579 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
22580 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
22581 vdev_param[wmi_vdev_param_snr_num_for_cal] =
22582 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
22583 vdev_param[wmi_vdev_param_roam_fw_offload] =
22584 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
22585 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
22586 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
22587 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
22588 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
22589 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
22590 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
22591 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
22592 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
22593 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
22594 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
22595 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
22596 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
22597 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
22598 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
22599 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
22600 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
22601 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
22602 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
22603 vdev_param[wmi_vdev_param_inactivity_cnt] =
22604 WMI_VDEV_PARAM_INACTIVITY_CNT;
22605 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
22606 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
22607 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
22608 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
22609 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
22610 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
22611 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
22612 vdev_param[wmi_vdev_param_rx_leak_window] =
22613 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
22614 vdev_param[wmi_vdev_param_stats_avg_factor] =
22615 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
22616 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
22617 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
22618 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
22619 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
22620 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
22621 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053022622 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
22623 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053022624 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080022625 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
22626 vdev_param[wmi_vdev_param_he_range_ext_enable] =
22627 WMI_VDEV_PARAM_HE_RANGE_EXT;
22628 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
22629 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070022630 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053022631 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
22632 vdev_param[wmi_vdev_param_dtim_enable_cts] =
22633 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
22634 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
22635 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
22636 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
22637 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053022638 vdev_param[wmi_vdev_param_mcast2ucast_set] =
22639 WMI_VDEV_PARAM_MCAST2UCAST_SET;
22640 vdev_param[wmi_vdev_param_rc_num_retries] =
22641 WMI_VDEV_PARAM_RC_NUM_RETRIES;
22642 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
22643 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
22644 vdev_param[wmi_vdev_param_rts_fixed_rate] =
22645 WMI_VDEV_PARAM_RTS_FIXED_RATE;
22646 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
22647 vdev_param[wmi_vdev_param_vht80_ratemask] =
22648 WMI_VDEV_PARAM_VHT80_RATEMASK;
22649 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
22650 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
22651 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika88e11832017-09-18 15:59:34 -070022652 vdev_param[wmi_vdev_param_set_he_ltf] = WMI_VDEV_PARAM_HE_LTF;
Sathish Kumar6011c742017-11-08 14:49:58 +053022653 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
22654 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Govind Singhe7f2f342016-05-23 12:12:52 +053022655}
22656#endif
22657
Govind Singh5eb51532016-03-09 11:34:12 +053022658/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022659 * populate_target_defines_tlv() - Populate target defines and params
22660 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053022661 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053022662 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053022663 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053022664#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022665static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053022666{
Govind Singhe7f2f342016-05-23 12:12:52 +053022667 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053022668 populate_pdev_param_tlv(wmi_handle->pdev_param);
22669 populate_vdev_param_tlv(wmi_handle->vdev_param);
22670}
22671#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022672static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
22673{ }
22674#endif
22675
22676/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022677 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
22678 * host to target defines.
22679 * @param pdev_id: host pdev_id to be converted.
22680 * Return: target pdev_id after conversion.
22681 */
22682static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
22683{
22684 switch (pdev_id) {
22685 case WMI_HOST_PDEV_ID_SOC:
22686 return WMI_PDEV_ID_SOC;
22687 case WMI_HOST_PDEV_ID_0:
22688 return WMI_PDEV_ID_1ST;
22689 case WMI_HOST_PDEV_ID_1:
22690 return WMI_PDEV_ID_2ND;
22691 case WMI_HOST_PDEV_ID_2:
22692 return WMI_PDEV_ID_3RD;
22693 }
22694
22695 QDF_ASSERT(0);
22696
22697 return WMI_PDEV_ID_SOC;
22698}
22699
22700/**
22701 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
22702 * target to host defines.
22703 * @param pdev_id: target pdev_id to be converted.
22704 * Return: host pdev_id after conversion.
22705 */
22706static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
22707{
22708 switch (pdev_id) {
22709 case WMI_PDEV_ID_SOC:
22710 return WMI_HOST_PDEV_ID_SOC;
22711 case WMI_PDEV_ID_1ST:
22712 return WMI_HOST_PDEV_ID_0;
22713 case WMI_PDEV_ID_2ND:
22714 return WMI_HOST_PDEV_ID_1;
22715 case WMI_PDEV_ID_3RD:
22716 return WMI_HOST_PDEV_ID_2;
22717 }
22718
22719 QDF_ASSERT(0);
22720
22721 return WMI_HOST_PDEV_ID_SOC;
22722}
22723
22724/**
22725 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
22726 *
22727 * Return None.
22728 */
22729void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
22730{
22731 wmi_handle->ops->convert_pdev_id_host_to_target =
22732 convert_host_pdev_id_to_target_pdev_id;
22733 wmi_handle->ops->convert_pdev_id_target_to_host =
22734 convert_target_pdev_id_to_host_pdev_id;
22735}
22736/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022737 * wmi_tlv_attach() - Attach TLV APIs
22738 *
22739 * Return: None
22740 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053022741void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053022742{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053022743 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053022744#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053022745 /* Skip saving WMI_CMD_HDR and TLV HDR */
22746 wmi_handle->log_info.buf_offset_command = 8;
22747 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053022748 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053022749#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053022750 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022751 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053022752}